Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jigyasa Watwani
/
growth-pattern-control
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0a761893
authored
Apr 18, 2022
by
Jigyasa Watwani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed vform -- no imex for v
parent
cb568e30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
30 deletions
no_c_fixed_bdry_fenics.py
no_c_fixed_bdry_fenics.py
View file @
0a761893
...
@@ -13,8 +13,8 @@ class Growth(object):
...
@@ -13,8 +13,8 @@ class Growth(object):
# create mesh, mixed element and function space
# create mesh, mixed element and function space
self
.
mesh
=
df
.
IntervalMesh
(
self
.
resolution
,
0.0
,
2.0
*
np
.
pi
*
self
.
system_size_by_2PI
)
self
.
mesh
=
df
.
IntervalMesh
(
self
.
resolution
,
0.0
,
2.0
*
np
.
pi
*
self
.
system_size_by_2PI
)
conc
_element
=
df
.
FiniteElement
(
'P'
,
self
.
mesh
.
ufl_cell
(),
1
)
scalar
_element
=
df
.
FiniteElement
(
'P'
,
self
.
mesh
.
ufl_cell
(),
1
)
mixed_element
=
df
.
MixedElement
([
conc_element
,
conc_element
,
conc
_element
])
# u, v, rho
mixed_element
=
df
.
MixedElement
([
scalar_element
,
scalar_element
,
scalar
_element
])
# u, v, rho
# define function space with this mixed element
# define function space with this mixed element
self
.
function_space
=
df
.
FunctionSpace
(
self
.
mesh
,
mixed_element
)
self
.
function_space
=
df
.
FunctionSpace
(
self
.
mesh
,
mixed_element
)
...
@@ -32,8 +32,14 @@ class Growth(object):
...
@@ -32,8 +32,14 @@ class Growth(object):
def
advection
(
self
,
conc
,
vel
,
tconc
):
def
advection
(
self
,
conc
,
vel
,
tconc
):
return
(
df
.
inner
((
vel
*
conc
)
.
dx
(
0
),
tconc
))
return
(
df
.
inner
((
vel
*
conc
)
.
dx
(
0
),
tconc
))
def
active_stress
(
self
,
rho
,
tv
):
def
active_stress
(
self
,
rho
):
return
self
.
lamda
*
df
.
inner
((
rho
/
(
rho
+
self
.
saturation_rho
))
.
dx
(
0
),
tv
)
return
self
.
lamda
*
rho
/
(
rho
+
self
.
saturation_rho
)
def
passive_stress
(
self
,
u
,
v
):
return
(
self
.
elasticity
*
u
.
dx
(
0
)
+
self
.
viscosity
*
v
.
dx
(
0
))
def
stress
(
self
,
u
,
v
,
rho
):
return
(
self
.
passive_stress
(
u
,
v
)
+
self
.
active_stress
(
rho
))
def
reaction_rho
(
self
,
rho
,
trho
):
def
reaction_rho
(
self
,
rho
,
trho
):
return
self
.
turnover_rho
*
df
.
inner
(
rho
-
self
.
average_rho
,
trho
)
return
self
.
turnover_rho
*
df
.
inner
(
rho
-
self
.
average_rho
,
trho
)
...
@@ -46,16 +52,15 @@ class Growth(object):
...
@@ -46,16 +52,15 @@ class Growth(object):
u0
=
df
.
interpolate
(
u0
,
self
.
function_space
.
sub
(
0
)
.
collapse
())
u0
=
df
.
interpolate
(
u0
,
self
.
function_space
.
sub
(
0
)
.
collapse
())
rho0
=
df
.
interpolate
(
rho0
,
self
.
function_space
.
sub
(
2
)
.
collapse
())
rho0
=
df
.
interpolate
(
rho0
,
self
.
function_space
.
sub
(
2
)
.
collapse
())
v0_function_space
=
df
.
FunctionSpace
(
self
.
mesh
,
'P'
,
1
)
v0_function_space
=
self
.
function_space
.
sub
(
1
)
.
collapse
(
)
v0
=
df
.
Function
(
v0_function_space
)
v0
=
df
.
Function
(
v0_function_space
)
tv0
=
df
.
TestFunction
(
v0_function_space
)
tv0
=
df
.
TestFunction
(
v0_function_space
)
v0form
=
(
df
.
inner
(
v0
,
tv0
)
v0form
=
(
self
.
friction
*
df
.
inner
(
v0
,
tv0
)
+
self
.
elasticity
*
df
.
inner
(
u0
.
dx
(
0
),
tv0
.
dx
(
0
))
+
df
.
inner
(
self
.
stress
(
u0
,
v0
,
rho0
),
tv0
.
dx
(
0
))
+
self
.
viscosity
*
df
.
inner
(
v0
.
dx
(
0
),
tv0
.
dx
(
0
))
-
self
.
lamda
*
df
.
inner
((
rho0
/
(
rho0
+
self
.
saturation_rho
))
.
dx
(
0
),
tv0
)
)
*
df
.
dx
)
*
df
.
dx
bcv0
=
df
.
DirichletBC
(
v0_function_space
,
df
.
Constant
(
0.0
),
'on_boundary'
)
bcv0
=
df
.
DirichletBC
(
v0_function_space
,
df
.
Constant
(
0.0
),
'on_boundary'
)
df
.
solve
(
v0form
==
0
,
v0
,
bcv0
)
df
.
solve
(
v0form
==
0
,
v0
,
bcv0
)
df
.
assign
(
self
.
f0
,
[
u0
,
v0
,
rho0
])
df
.
assign
(
self
.
f0
,
[
u0
,
v0
,
rho0
])
self
.
fminus1
.
assign
(
self
.
f0
)
self
.
fminus1
.
assign
(
self
.
f0
)
...
@@ -71,19 +76,9 @@ class Growth(object):
...
@@ -71,19 +76,9 @@ class Growth(object):
-
3
/
8
*
df
.
inner
(
v0
,
tu
)
-
3
/
8
*
df
.
inner
(
v0
,
tu
)
-
1
/
16
*
df
.
inner
(
vminus1
,
tu
)
-
1
/
16
*
df
.
inner
(
vminus1
,
tu
)
)
)
vform
=
(
df
.
inner
(
v
,
tv
)
vform
=
(
self
.
friction
*
df
.
inner
(
v
,
tv
)
+
9
/
16
*
self
.
elasticity
*
df
.
inner
(
u
.
dx
(
0
),
tv
.
dx
(
0
))
+
df
.
inner
(
self
.
stress
(
u
,
v
,
rho
),
tv
.
dx
(
0
))
+
3
/
8
*
self
.
elasticity
*
df
.
inner
(
u0
.
dx
(
0
),
tv
.
dx
(
0
))
)
+
1
/
16
*
self
.
elasticity
*
df
.
inner
(
uminus1
.
dx
(
0
),
tv
.
dx
(
0
))
-
9
/
16
*
self
.
active_stress
(
rho0
,
tv
)
-
3
/
8
*
self
.
active_stress
(
rhominus1
,
tv
)
-
1
/
16
*
self
.
active_stress
(
rhominus1
,
tv
)
+
9
/
16
*
self
.
viscosity
*
df
.
inner
(
v
.
dx
(
0
),
tv
.
dx
(
0
))
+
3
/
8
*
self
.
viscosity
*
df
.
inner
(
v0
.
dx
(
0
),
tv
.
dx
(
0
))
+
1
/
16
*
self
.
viscosity
*
df
.
inner
(
vminus1
.
dx
(
0
),
tv
.
dx
(
0
))
)
rhoform
=
(
df
.
inner
((
rho
-
rho0
)
/
self
.
timestep
,
trho
)
rhoform
=
(
df
.
inner
((
rho
-
rho0
)
/
self
.
timestep
,
trho
)
+
3
/
2
*
self
.
advection
(
rho0
,
v
,
trho
)
+
3
/
2
*
self
.
advection
(
rho0
,
v
,
trho
)
...
@@ -104,7 +99,7 @@ class Growth(object):
...
@@ -104,7 +99,7 @@ class Growth(object):
self
.
setup_initial_conditions
(
u0
,
rho0
)
self
.
setup_initial_conditions
(
u0
,
rho0
)
self
.
setup_weak_forms
()
self
.
setup_weak_forms
()
u
,
v
,
rho
=
self
.
f0
.
split
(
deepcopy
=
True
)
u
,
v
,
rho
=
self
.
f0
.
split
(
deepcopy
=
True
)
u_array
[
0
]
=
u
.
compute_vertex_values
(
self
.
mesh
)
u_array
[
0
]
=
u
.
compute_vertex_values
(
self
.
mesh
)
v_array
[
0
]
=
v
.
compute_vertex_values
(
self
.
mesh
)
v_array
[
0
]
=
v
.
compute_vertex_values
(
self
.
mesh
)
rho_array
[
0
]
=
rho
.
compute_vertex_values
(
self
.
mesh
)
rho_array
[
0
]
=
rho
.
compute_vertex_values
(
self
.
mesh
)
...
@@ -120,23 +115,18 @@ class Growth(object):
...
@@ -120,23 +115,18 @@ class Growth(object):
return
(
u_array
,
v_array
,
rho_array
)
return
(
u_array
,
v_array
,
rho_array
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
dolfin
as
df
import
json
import
json
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
from
matplotlib.widgets
import
Slider
from
matplotlib.widgets
import
Slider
with
open
(
'growth_parameters.json'
)
as
jsonFile
:
with
open
(
'growth_parameters.json'
)
as
jsonFile
:
params
=
json
.
load
(
jsonFile
)
params
=
json
.
load
(
jsonFile
)
assert
(
params
[
'dimension'
]
==
1
)
g
=
Growth
(
params
)
g
=
Growth
(
params
)
u0
=
df
.
Expression
(
'sin(x[0])'
,
degree
=
1
)
u0
=
df
.
Expression
(
'sin(x[0])'
,
degree
=
1
)
u0
=
df
.
interpolate
(
u0
,
g
.
function_space
.
sub
(
0
)
.
collapse
())
rho0
=
df
.
Expression
(
'cos(x[0])+cos(x[0]/2)'
,
degree
=
1
)
rho0
=
df
.
Expression
(
'rho0 + 0.1 * (cos(x[0])+cos(x[0]/2))'
,
rho0
=
g
.
average_rho
,
degree
=
1
)
rho0
=
df
.
interpolate
(
rho0
,
g
.
function_space
.
sub
(
2
)
.
collapse
())
(
u
,
v
,
rho
)
=
g
.
solve
(
u0
,
rho0
)
(
u
,
v
,
rho
)
=
g
.
solve
(
u0
,
rho0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment