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
53cee3d2
Commit
53cee3d2
authored
Sep 6, 2019
by
David Seus
Browse files
Options
Downloads
Patches
Plain Diff
add _init_simulation_output method and rewrite output dictionary
parent
c6e26f7c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
LDDsimulation/LDDsimulation.py
+26
-19
26 additions, 19 deletions
LDDsimulation/LDDsimulation.py
LDDsimulation/domainPatch.py
+1
-0
1 addition, 0 deletions
LDDsimulation/domainPatch.py
with
27 additions
and
19 deletions
LDDsimulation/LDDsimulation.py
+
26
−
19
View file @
53cee3d2
...
...
@@ -302,6 +302,7 @@ class LDDsimulation(object):
# solution case.
self
.
_init_exact_solution_expression
()
self
.
_init_DirichletBC_dictionary
()
self
.
_init_simulation_output
()
if
self
.
exact_solution
and
self
.
write2file
[
'
solutions
'
]:
df
.
info
(
colored
(
"
writing exact solution for all time steps to xdmf files ...
"
,
"
yellow
"
))
self
.
write_exact_solution_to_xdmf
()
...
...
@@ -343,18 +344,7 @@ class LDDsimulation(object):
df
.
info
(
colored
(
"
Start time stepping
"
,
"
green
"
))
# write initial values to file.
self
.
timestep_num
=
int
(
1
)
# set up spacetime_errornorm dictionaries.
self
.
spacetime_errornorm
=
dict
()
for
subdom_ind
,
subdomain
in
self
.
subdomain
.
items
():
self
.
spacetime_errornorm
.
update
({
subdom_ind
:
dict
()})
for
phase
in
subdomain
.
has_phases
:
self
.
spacetime_errornorm
[
subdom_ind
].
update
({
phase
:
dict
()})
self
.
spacetime_errornorm
[
subdom_ind
][
phase
].
update
(
{
# keys mean the norm in time. We use L2 in space
'
Linf
'
:
0.0
,
'
L1
'
:
0.0
,
'
L2
'
:
0.0
}
)
# note that at this point of the code self.t = self.starttime as set in
# the beginning.
while
self
.
timestep_num
<=
self
.
number_of_timesteps
:
...
...
@@ -395,10 +385,10 @@ class LDDsimulation(object):
pa_exact
.
t
=
self
.
t
norm_pa_exact
=
df
.
norm
(
pa_exact
,
norm_type
=
'
L2
'
,
mesh
=
subdomain
.
mesh
)
error_calculated
=
df
.
errornorm
(
pa_exact
,
subdomain
.
pressure
[
phase
],
'
L2
'
,
degree_rise
=
6
)
self
.
spacetime_errornorm
[
subdom_ind
][
phase
][
'
L1
'
]
+=
self
.
timestep_size
*
self
.
spacetime_errornorm
[
subdom_ind
][
phase
][
'
L1
'
]
self
.
spacetime_errornorm
[
subdom_ind
][
phase
][
'
L2
'
]
+=
self
.
timestep_size
*
self
.
spacetime_errornorm
[
subdom_ind
][
phase
][
'
L2
'
]
**
2
if
error_calculated
>
self
.
spacetime_errornorm
[
subdom_ind
][
phase
][
'
Linf
'
]:
self
.
spacetime_errornorm
[
subdom_ind
][
phase
][
'
Linf
'
]
=
error_calculated
self
.
output
[
subdom_ind
][
'
errornorm
'
][
phase
][
'
L1
'
]
+=
self
.
timestep_size
*
self
.
output
[
subdom_ind
][
'
errornorm
'
][
phase
][
'
L1
'
]
self
.
output
[
subdom_ind
][
'
errornorm
'
][
phase
][
'
L2
'
]
+=
self
.
timestep_size
*
self
.
output
[
subdom_ind
][
'
errornorm
'
][
phase
][
'
L2
'
]
**
2
if
error_calculated
>
self
.
output
[
subdom_ind
][
'
errornorm
'
][
phase
][
'
Linf
'
]:
self
.
output
[
subdom_ind
][
'
errornorm
'
][
phase
][
'
Linf
'
]
=
error_calculated
if
norm_pa_exact
>
self
.
tol
:
relative_L2_errornorm
.
update
(
...
...
@@ -437,7 +427,7 @@ class LDDsimulation(object):
)
self
.
timestep_num
+=
1
self
.
spacetime_errornorm
[
subdom_ind
][
phase
][
'
L2
'
]
=
np
.
sqrt
(
self
.
spacetime_errornorm
[
subdom_ind
][
phase
][
'
L2
'
])
self
.
output
[
subdom_ind
][
'
errornorm
'
][
phase
][
'
L2
'
]
=
np
.
sqrt
(
self
.
output
[
subdom_ind
][
'
errornorm
'
][
phase
][
'
L2
'
])
print
(
"
LDD simulation use case: {}
"
.
format
(
self
.
use_case
))
df
.
info
(
"
Finished calculation
"
)
...
...
@@ -455,7 +445,7 @@ class LDDsimulation(object):
# df.info(colored("start post processing calculations ...\n", "yellow"))
# self.post_processing()
# df.info(colored("finished post processing calculations \nAll right. I'm Done.", "green"))
return
self
.
spacetime_errornorm
return
self
.
output
def
LDDsolver
(
self
,
time
:
float
=
None
,
#
debug
:
bool
=
False
,
#
...
...
@@ -759,7 +749,7 @@ class LDDsimulation(object):
for
subdom_ind
,
subdomain
in
self
.
subdomain
.
items
():
tau
=
subdomain
.
timestep_size
L
=
subdomain
.
L
h
=
subdomain
.
mesh
.
hmax
()
h
=
subdomain
.
mesh
_size
if
subdomain
.
isRichards
:
Lam
=
subdomain
.
lambda_param
[
'
wetting
'
]
name1
=
"
subdomain
"
+
"
{}
"
.
format
(
subdom_ind
)
...
...
@@ -1488,3 +1478,20 @@ class LDDsimulation(object):
self
.
endtime
=
self
.
number_of_timesteps
*
self
.
timestep_size
# time_interval = [starttime, Tmax]
print
(
f
"
The simulation interval is [
{
self
.
starttime
}
,
{
self
.
endtime
}
]
"
)
def
_init_simulation_output
(
self
):
"""
set up dictionary for simulation output
"""
self
.
output
=
dict
()
for
subdom_ind
,
subdomain
in
self
.
subdomain
.
items
():
self
.
output
.
update
({
subdom_ind
:
dict
()})
self
.
output
[
subdom_ind
].
update
({
'
mesh_size
'
:
subdomain
.
mesh_size
})
self
.
output
[
subdom_ind
].
update
({
'
errornorm
'
:
dict
()})
for
phase
in
subdomain
.
has_phases
:
self
.
output
[
subdom_ind
][
'
errornorm
'
].
update
({
phase
:
dict
()})
self
.
output
[
subdom_ind
][
'
errornorm
'
][
phase
].
update
(
{
# keys mean the norm in time. We use L2 in space
'
Linf
'
:
0.0
,
'
L1
'
:
0.0
,
'
L2
'
:
0.0
}
)
This diff is collapsed.
Click to expand it.
LDDsimulation/domainPatch.py
+
1
−
0
View file @
53cee3d2
...
...
@@ -149,6 +149,7 @@ class DomainPatch(df.SubDomain):
self
.
subdomain_index
=
subdomain_index
self
.
isRichards
=
isRichards
self
.
mesh
=
mesh
self
.
mesh_size
=
self
.
mesh
.
hmax
()
self
.
porosity
=
porosity
self
.
viscosity
=
viscosity
self
.
outer_boundary_def_points
=
outer_boundary_def_points
...
...
...
...
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
sign in
to comment