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
9d3d817d
Commit
9d3d817d
authored
Mar 14, 2019
by
David Seus
Browse files
Options
Downloads
Patches
Plain Diff
update Interface.write_dofs() and Interface.read_dofs()
parent
5ca414d7
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
RR-2-patch-test.py
+15
-6
15 additions, 6 deletions
RR-2-patch-test.py
domainPatch.py
+112
-27
112 additions, 27 deletions
domainPatch.py
with
127 additions
and
33 deletions
RR-2-patch-test.py
+
15
−
6
View file @
9d3d817d
...
@@ -271,15 +271,21 @@ print("vertices of subdomain1: \n", coordinates1)
...
@@ -271,15 +271,21 @@ print("vertices of subdomain1: \n", coordinates1)
# dom1_interface_coordinates = interface[0].coordinates(subdomain_boundary_marker1, 1, print_coordinates = True)
# dom1_interface_coordinates = interface[0].coordinates(subdomain_boundary_marker1, 1, print_coordinates = True)
dom1_interface_def_points
=
interface
[
0
].
_vertex_indices
(
subdomain_boundary_marker1
,
1
,
print_vertex_indices
=
True
)
dom1_interface_def_points
=
interface
[
0
].
_vertex_indices
(
subdomain_boundary_marker1
,
1
,
print_vertex_indices
=
True
)
interface
[
0
].
write_dofs
(
f
e
m_function
=
f1test
,
#
interface
[
0
].
write_dofs
(
f
ro
m_function
=
f1test
,
#
interface_dofs
=
dofs_on_interface1
,
#
interface_dofs
=
dofs_on_interface1
,
#
dof_to_vert_map
=
dom1_d2v
,
#
dof_to_vert_map
=
dom1_d2v
,
#
local_to_parent_vertex_map
=
dom1_parent_vertex_indices
)
local_to_parent_vertex_map
=
dom1_parent_vertex_indices
,
#
phase
=
'
wetting
'
,
#
pressure
=
True
,
#
subdomain_ind
=
1
)
interface
[
0
].
read_dofs
(
fem
_function
=
f2test
,
#
interface
[
0
].
read_dofs
(
to
_function
=
f2test
,
#
interface_dofs
=
dofs_on_interface2
,
#
interface_dofs
=
dofs_on_interface2
,
#
dof_to_vert_map
=
dom2_d2v
,
#
dof_to_vert_map
=
dom2_d2v
,
#
local_to_parent_vertex_map
=
dom2_parent_vertex_indices
)
local_to_parent_vertex_map
=
dom2_parent_vertex_indices
,
#
phase
=
'
wetting
'
,
#
pressure
=
True
,
#
subdomain_ind
=
1
)
i
=
0
i
=
0
for
x
in
coordinates2
:
for
x
in
coordinates2
:
...
@@ -365,10 +371,13 @@ for iterations in range(1):
...
@@ -365,10 +371,13 @@ for iterations in range(1):
df
.
solve
(
A1
,
U1
,
b1
)
df
.
solve
(
A1
,
U1
,
b1
)
print
(
'
solution:
\n
'
,
U1
)
print
(
'
solution:
\n
'
,
U1
)
p1_i
.
vector
()[:]
=
U1
p1_i
.
vector
()[:]
=
U1
interface
[
0
].
write_dofs
(
f
e
m_function
=
p1_i
,
#
interface
[
0
].
write_dofs
(
f
ro
m_function
=
p1_i
,
#
interface_dofs
=
dofs_on_interface1
,
#
interface_dofs
=
dofs_on_interface1
,
#
dof_to_vert_map
=
dom1_d2v
,
#
dof_to_vert_map
=
dom1_d2v
,
#
local_to_parent_vertex_map
=
dom1_parent_vertex_indices
)
local_to_parent_vertex_map
=
dom1_parent_vertex_indices
,
#
phase
=
'
wetting
'
,
#
pressure
=
True
,
#
subdomain_ind
=
1
)
#
#
# Save mesh to file
# Save mesh to file
df
.
File
(
'
./test_domain_layered_soil.xml.gz
'
)
<<
mesh_subdomain
[
0
]
df
.
File
(
'
./test_domain_layered_soil.xml.gz
'
)
<<
mesh_subdomain
[
0
]
...
...
This diff is collapsed.
Click to expand it.
domainPatch.py
+
112
−
27
View file @
9d3d817d
...
@@ -596,22 +596,42 @@ class Interface(BoundaryPart):
...
@@ -596,22 +596,42 @@ class Interface(BoundaryPart):
self
.
gl_values
[
subdom_ind
][
phase
].
update
({
vert_ind
:
0.0
})
self
.
gl_values
[
subdom_ind
][
phase
].
update
({
vert_ind
:
0.0
})
self
.
gl_values_prev
[
subdom_ind
][
phase
].
update
({
vert_ind
:
0.0
})
self
.
gl_values_prev
[
subdom_ind
][
phase
].
update
({
vert_ind
:
0.0
})
def
write_dofs
(
self
,
f
e
m_function
:
df
.
Function
,
#
def
write_dofs
(
self
,
f
ro
m_function
:
df
.
Function
,
#
interface_dofs
:
np
.
array
,
#
interface_dofs
:
np
.
array
,
#
dof_to_vert_map
:
np
.
array
,
#
dof_to_vert_map
:
np
.
array
,
#
local_to_parent_vertex_map
:
np
.
array
)
->
None
:
local_to_parent_vertex_map
:
np
.
array
,
#
"""
write dofs of fem_function with indices interface_dofs to self.pressure_values
phase
:
str
,
#
subdomain_ind
:
int
,
#
Write the degrees of freedom of the function fem_function with indices
pressure
:
bool
=
False
,
#
interface_dofs, i.e. the dofs of the interface, to the dictionary of the
gl
:
bool
=
False
,
#
interface self.pressure_values.
previous_iter
:
bool
=
False
,
#
)
->
None
:
"""
write dofs of from_function with indices interface_dofs to self.pressure_values
Write the degrees of freedom of the function from_function with indices
interface_dofs, i.e. the dofs of the interface, to one of the dictionaries
of the interface
self.pressure_values[subdomain_ind][phase], (if pressure == True)
self.pressure_values_prev[subdomain_ind][phase], (if previous_iter == True)
self.gl_values[subdomain_ind][phase], (if gl == True)
self.gl_values_prev[subdomain_ind][phase] (if previous_iter == True)
# Parameters
# Parameters
f
e
m_function:
#type: df.Function, function to save the dofs to
f
ro
m_function: #type: df.Function, function to save the dofs to
interface_dofs: #type: np.array, index array of dofs to be saved
interface_dofs: #type: np.array, index array of dofs to be saved
dof_to_vert_map: #type: np.array, dof to vert map of the function
dof_to_vert_map: #type: np.array, dof to vert map of the function
space on the submesh.
space on the submesh.
local_to_parent_vertex_map: #type: np.array,
local_to_parent_vertex_map: #type: np.array,
phase #type: str is either
'
wetting
'
or
'
nonwetting
'
and determins
the dict to be written to.
subdomain_ind #type: int subdomain index
pressure #type: bool determins wether pressure
values are being written or not
gl #type: bool determins wether gl
values are being written or not
previous_iter #type: bool determins wether a previous
iterate is being written or not
"""
"""
if
self
.
pressure_values
==
None
:
if
self
.
pressure_values
==
None
:
raise
RuntimeError
(
"
self.pressure_values not initiated. You forgot to
\
raise
RuntimeError
(
"
self.pressure_values not initiated. You forgot to
\
...
@@ -619,33 +639,74 @@ class Interface(BoundaryPart):
...
@@ -619,33 +639,74 @@ class Interface(BoundaryPart):
parent
=
local_to_parent_vertex_map
parent
=
local_to_parent_vertex_map
d2v
=
dof_to_vert_map
d2v
=
dof_to_vert_map
# chose where to write the dofs to
if
pressure
:
if
not
previous_iter
:
for
dof_index
in
interface_dofs
:
for
dof_index
in
interface_dofs
:
# f
e
m_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# f
ro
m_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
self
.
pressure_values
.
update
({
parent
[
d2v
[
dof_index
]]:
fem_function
.
vector
()[
dof_index
]})
self
.
pressure_values
[
subdomain_ind
][
phase
].
update
({
parent
[
d2v
[
dof_index
]]:
from_function
.
vector
()[
dof_index
]})
print
(
"
have written pressure interface values
\n
"
,
self
.
pressure_values
[
subdomain_ind
][
phase
])
print
(
"
interface values
\n
"
,
self
.
pressure_values
)
else
:
for
dof_index
in
interface_dofs
:
# from_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
self
.
pressure_values_prev
[
subdomain_ind
][
phase
].
update
({
parent
[
d2v
[
dof_index
]]:
from_function
.
vector
()[
dof_index
]})
print
(
"
have written previous pressure interface values
\n
"
,
self
.
pressure_values_prev
[
subdomain_ind
][
phase
])
if
gl
:
if
not
previous_iter
:
for
dof_index
in
interface_dofs
:
# from_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
self
.
gl_values
[
subdomain_ind
][
phase
].
update
({
parent
[
d2v
[
dof_index
]]:
from_function
.
vector
()[
dof_index
]})
print
(
"
have written gl interface values
\n
"
,
self
.
gl_values
[
subdomain_ind
][
phase
])
else
:
for
dof_index
in
interface_dofs
:
# from_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
self
.
gl_values_prev
[
subdomain_ind
][
phase
].
update
({
parent
[
d2v
[
dof_index
]]:
from_function
.
vector
()[
dof_index
]})
print
(
"
have written previous gl interface values
\n
"
,
self
.
gl_values_prev
[
subdomain_ind
][
phase
])
def
read_dofs
(
self
,
fem
_function
:
df
.
Function
,
#
def
read_dofs
(
self
,
to
_function
:
df
.
Function
,
#
interface_dofs
:
np
.
array
,
#
interface_dofs
:
np
.
array
,
#
dof_to_vert_map
:
np
.
array
,
#
dof_to_vert_map
:
np
.
array
,
#
local_to_parent_vertex_map
:
np
.
array
)
->
None
:
local_to_parent_vertex_map
:
np
.
array
,
#
"""
read dofs off self.pressure_values and overwrite the dofs of fem_function
phase
:
str
,
#
subdomain_ind
:
int
,
#
pressure
:
bool
=
False
,
#
gl
:
bool
=
False
,
#
previous_iter
:
bool
=
False
,
#
)
->
None
:
"""
read dofs off self.pressure_values and overwrite the dofs of from_function
with indices interface_dofs
with indices interface_dofs
Read the degrees of freedom of the interface self.pressure_values and
Read the degrees of freedom of one of the dictionaries of the interface
overwrite the dofs of the function fem_function with indices
self.pressure_values[subdomain_ind][phase], (if pressure == True)
self.pressure_values_prev[subdomain_ind][phase], (if previous_iter == True)
self.gl_values[subdomain_ind][phase], (if gl == True)
self.gl_values_prev[subdomain_ind][phase] (if previous_iter == True)
and overwrite the dofs of the function to_function with indices
interface_dofs, i.e. update the interface dofs of the function.
interface_dofs, i.e. update the interface dofs of the function.
.
.
# Parameters
# Parameters
fem
_function: #type: df.Function, function to overwrite the
to
_function: #type: df.Function, function to overwrite the
dofs of.
dofs of.
interface_dofs: #type: np.array, index array of interface
interface_dofs: #type: np.array, index array of interface
dofs of f
e
m_function
dofs of f
ro
m_function
dof_to_vert_map: #type: np.array, dof to vert map of the function
dof_to_vert_map: #type: np.array, dof to vert map of the function
space on the submesh.
space on the submesh.
local_to_parent_vertex_map: #type: np.array,
local_to_parent_vertex_map: #type: np.array,
phase #type: str is either
'
wetting
'
or
'
nonwetting
'
and determins
the dict to be read of.
subdomain_ind #type: int subdomain index
pressure #type: bool determins wether pressure
values are being read or not
gl #type: bool determins wether gl
values are being read or not
previous_iter #type: bool determins wether a previous
iterate is being read or not
"""
"""
if
self
.
pressure_values
==
None
:
if
self
.
pressure_values
==
None
:
raise
RuntimeError
(
"
self.pressure_values not initiated. You forgot to
\
raise
RuntimeError
(
"
self.pressure_values not initiated. You forgot to
\
...
@@ -653,12 +714,36 @@ class Interface(BoundaryPart):
...
@@ -653,12 +714,36 @@ class Interface(BoundaryPart):
parent
=
local_to_parent_vertex_map
parent
=
local_to_parent_vertex_map
d2v
=
dof_to_vert_map
d2v
=
dof_to_vert_map
if
pressure
:
if
not
previous_iter
:
for
dof_index
in
interface_dofs
:
for
dof_index
in
interface_dofs
:
# f
e
m_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# f
ro
m_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
fem_function
.
vector
()[
dof_index
]
=
self
.
pressure_values
[
parent
[
d2v
[
dof_index
]]]
to_function
.
vector
()[
dof_index
]
=
self
.
pressure_values
[
subdomain_ind
][
phase
][
parent
[
d2v
[
dof_index
]]]
print
(
"
read pressure interface values
\n
"
,
self
.
pressure_values
[
subdomain_ind
][
phase
])
print
(
"
overwritten function
\n
"
,
fem_function
.
vector
()[:])
print
(
"
wrote these dofs to function
\n
"
,
to_function
.
vector
()[:])
else
:
for
dof_index
in
interface_dofs
:
# from_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
to_function
.
vector
()[
dof_index
]
=
self
.
pressure_values_prev
[
subdomain_ind
][
phase
][
parent
[
d2v
[
dof_index
]]]
print
(
"
read previous pressure interface values
\n
"
,
self
.
pressure_values_prev
[
subdomain_ind
][
phase
])
print
(
"
wrote these dofs to function
\n
"
,
to_function
.
vector
()[:])
if
gl
:
if
not
previous_iter
:
for
dof_index
in
interface_dofs
:
# from_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
to_function
.
vector
()[
dof_index
]
=
self
.
gl_values
[
subdomain_ind
][
phase
][
parent
[
d2v
[
dof_index
]]]
print
(
"
read gl interface values
\n
"
,
self
.
gl_values
[
subdomain_ind
][
phase
])
print
(
"
wrote these dofs to function
\n
"
,
to_function
.
vector
()[:])
else
:
for
dof_index
in
interface_dofs
:
# from_function.vector() is orderd by dof and not by vertex numbering of the mesh.
# parent needs a mesh vertex index of the submesh, therefore d2v is needed.
to_function
.
vector
()[
dof_index
]
=
self
.
gl_values_prev
[
subdomain_ind
][
phase
][
parent
[
d2v
[
dof_index
]]]
print
(
"
read gl interface values
\n
"
,
self
.
gl_values_prev
[
subdomain_ind
][
phase
])
print
(
"
wrote these dofs to function
\n
"
,
to_function
.
vector
()[:])
#### Private Methods ####
#### Private Methods ####
...
...
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