Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LDD-for-two-phase-flow-systems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Seus
LDD-for-two-phase-flow-systems
Commits
e74e500a
Commit
e74e500a
authored
Mar 21, 2019
by
David Seus
Browse files
Options
Downloads
Patches
Plain Diff
add set_DirichletBC() method
parent
17f3c1bb
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
LDDsimulation.py
+26
-14
26 additions, 14 deletions
LDDsimulation.py
with
26 additions
and
14 deletions
LDDsimulation.py
+
26
−
14
View file @
e74e500a
...
@@ -86,6 +86,8 @@ class LDDsimulation(object):
...
@@ -86,6 +86,8 @@ class LDDsimulation(object):
self
.
_parameters_set
=
False
self
.
_parameters_set
=
False
# dictionary of objects of class DomainPatch initialised by self._init_subdomains()
# dictionary of objects of class DomainPatch initialised by self._init_subdomains()
self
.
subdomain
=
dict
()
self
.
subdomain
=
dict
()
# dictionary to store the dirichletBC in.
self
.
outerBC
=
dict
()
def
set_parameters
(
self
,
#
def
set_parameters
(
self
,
#
output_dir
:
str
,
#
output_dir
:
str
,
#
...
@@ -103,7 +105,8 @@ class LDDsimulation(object):
...
@@ -103,7 +105,8 @@ class LDDsimulation(object):
saturation
:
tp
.
Dict
[
int
,
tp
.
Callable
[...,
None
]],
#
saturation
:
tp
.
Dict
[
int
,
tp
.
Callable
[...,
None
]],
#
timestep
:
tp
.
Dict
[
int
,
float
],
#
timestep
:
tp
.
Dict
[
int
,
float
],
#
sources
:
tp
.
Dict
[
int
,
tp
.
Dict
[
str
,
str
]],
#
sources
:
tp
.
Dict
[
int
,
tp
.
Dict
[
str
,
str
]],
#
initial_conditions
:
tp
.
Dict
[
int
,
tp
.
Dict
[
str
,
str
]]
initial_conditions
:
tp
.
Dict
[
int
,
tp
.
Dict
[
str
,
str
]],
#
outer_dirichletBC
:
tp
.
Dict
[
int
,
tp
.
Dict
[
str
,
str
]],
#
)
->
None
:
)
->
None
:
"""
set parameters of an instance of class LDDsimulation
"""
"""
set parameters of an instance of class LDDsimulation
"""
...
@@ -122,6 +125,7 @@ class LDDsimulation(object):
...
@@ -122,6 +125,7 @@ class LDDsimulation(object):
self
.
timestep
=
timestep
self
.
timestep
=
timestep
self
.
sources
=
sources
self
.
sources
=
sources
self
.
initial_conditions
=
initial_conditions
self
.
initial_conditions
=
initial_conditions
self
.
outer_dirichletBC
=
outer_dirichletBC
self
.
_parameters_set
=
True
self
.
_parameters_set
=
True
def
initialise
(
self
)
->
None
:
def
initialise
(
self
)
->
None
:
...
@@ -136,6 +140,8 @@ class LDDsimulation(object):
...
@@ -136,6 +140,8 @@ class LDDsimulation(object):
self
.
_init_subdomains
()
self
.
_init_subdomains
()
self
.
_init_initial_values
()
self
.
_init_initial_values
()
self
.
_eval_sources
()
self
.
_eval_sources
()
# init Dirichlet Boundary values for the first time
self
.
set_DirichletBC
(
time
=
0
,
first_init
=
True
)
## Private methods
## Private methods
def
_init_meshes_and_markers
(
self
,
subdomain_def_points
:
tp
.
List
[
tp
.
List
[
df
.
Point
]]
=
None
,
#
def
_init_meshes_and_markers
(
self
,
subdomain_def_points
:
tp
.
List
[
tp
.
List
[
df
.
Point
]]
=
None
,
#
...
@@ -328,26 +334,32 @@ class LDDsimulation(object):
...
@@ -328,26 +334,32 @@ class LDDsimulation(object):
subdomain
.
pressure_prev_timestep
=
{
'
wetting
'
:
df
.
interpolate
(
pw0
,
V
[
'
wetting
'
]),
#
subdomain
.
pressure_prev_timestep
=
{
'
wetting
'
:
df
.
interpolate
(
pw0
,
V
[
'
wetting
'
]),
#
'
nonwetting
'
:
df
.
interpolate
(
pnw0
,
V
[
'
nonwetting
'
])}
'
nonwetting
'
:
df
.
interpolate
(
pnw0
,
V
[
'
nonwetting
'
])}
def
_init_DirichletBC
(
self
,
interpolation_degree
:
int
=
2
):
def
set_DirichletBC
(
self
,
interpolation_degree
:
int
=
2
,
#
"""
set initial values
time
:
float
=
0
,
#
# exact_solution: bool = False,#
first_init
:
bool
=
False
):
"""
set dirichlet boundary values at time time.
"""
"""
for
num
,
subdomain
in
self
.
subdomain
.
items
():
for
num
,
subdomain
in
self
.
subdomain
.
items
():
mesh
=
subdomain
.
mesh
mesh
=
subdomain
.
mesh
V
=
subdomain
.
function_space
V
=
subdomain
.
function_space
# p0 contains both pw_0 and pnw_0 for subdomain[num]
# if first_init==True we have not initialised the dictionary
p0
=
self
.
initial_conditions
[
num
]
if
first_init
:
self
.
outerBC
.
update
({
num
:
dict
()})
pDC
=
self
.
outer_dirichletBC
[
num
]
boundary_marker
=
subdomain
.
boundary_marker
if
subdomain
.
isRichards
:
if
subdomain
.
isRichards
:
# note that the default interpolation degree is 2
# note that the default interpolation degree is 2
pw0
=
df
.
Expression
(
p0
[
'
wetting
'
],
domain
=
mesh
,
degree
=
interpolation_degree
)
pDCw
=
df
.
Expression
(
pDC
[
'
wetting
'
],
domain
=
mesh
,
degree
=
interpolation_degree
,
t
=
time
)
subdomain
.
pressure_prev_iter
=
{
'
wetting
'
:
df
.
interpolate
(
pw0
,
V
[
'
wetting
'
])}
self
.
outerBC
[
num
].
update
({
'
wetting
'
:
df
.
DirichletBC
(
V
[
'
wetting
'
],
pDCw
,
boundary_marker
,
0
)})
subdomain
.
pressure_prev_timestep
=
{
'
wetting
'
:
df
.
interpolate
(
pw0
,
V
[
'
wetting
'
])}
else
:
else
:
pw
0
=
df
.
Expression
(
p
0
[
'
wetting
'
],
domain
=
mesh
,
degree
=
interpolation_degree
)
p
DC
w
=
df
.
Expression
(
p
DC
[
'
wetting
'
],
domain
=
mesh
,
degree
=
interpolation_degree
,
t
=
time
)
pnw
0
=
df
.
Expression
(
p
0
[
'
nonwetting
'
],
domain
=
mesh
,
degree
=
interpolation_degree
)
p
DC
nw
=
df
.
Expression
(
p
DC
[
'
nonwetting
'
],
domain
=
mesh
,
degree
=
interpolation_degree
,
t
=
time
)
s
ubdomain
.
pressure_prev_iter
=
{
'
wetting
'
:
df
.
interpolate
(
pw0
,
V
[
'
wetting
'
]),
#
s
elf
.
outerBC
[
num
].
update
(
#
'
non
wetting
'
:
df
.
interpolate
(
pnw0
,
V
[
'
nonwetting
'
])}
{
'
wetting
'
:
df
.
DirichletBC
(
V
[
'
wetting
'
],
pDCw
,
boundary_marker
,
0
)},
#
subdomain
.
pressure_prev_timestep
=
{
'
wetting
'
:
df
.
interpolate
(
pw0
,
V
[
'
wetting
'
])
,
#
{
'
non
wetting
'
:
df
.
DirichletBC
(
V
[
'
nonwetting
'
],
pDCnw
,
boundary_marker
,
0
)}
,
#
'
nonwetting
'
:
df
.
interpolate
(
pnw0
,
V
[
'
nonwetting
'
])}
)
def
_eval_sources
(
self
,
interpolation_degree
:
int
=
2
,
time
:
float
=
0
):
def
_eval_sources
(
self
,
interpolation_degree
:
int
=
2
,
time
:
float
=
0
):
"""
evaluate time dependent source terms or initialise them if time == 0
"""
evaluate time dependent source terms or initialise them if time == 0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment