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
73807ab0
Commit
73807ab0
authored
May 31, 2019
by
David Seus
Browse files
Options
Downloads
Patches
Plain Diff
implement general _normal_vector_norms_for_common_dofs with linear combinations of normal vectors
parent
bde6886a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
LDDsimulation/domainPatch.py
+35
-7
35 additions, 7 deletions
LDDsimulation/domainPatch.py
with
35 additions
and
7 deletions
LDDsimulation/domainPatch.py
+
35
−
7
View file @
73807ab0
...
@@ -391,7 +391,7 @@ class DomainPatch(df.SubDomain):
...
@@ -391,7 +391,7 @@ class DomainPatch(df.SubDomain):
return
form_and_rhs
return
form_and_rhs
def
calc_gl0_term
(
self
,
debug
:
bool
=
Fals
e
)
->
None
:
# tp.Dict[str, fl.Form]
def
calc_gl0_term
(
self
,
debug
:
bool
=
Tru
e
)
->
None
:
# tp.Dict[str, fl.Form]
"""
calculate the gl0 terms for all interfaces of the subdomain.
"""
calculate the gl0 terms for all interfaces of the subdomain.
assemble the gl0 terms for all interfaces of the subdomain and save them
assemble the gl0 terms for all interfaces of the subdomain and save them
...
@@ -503,15 +503,21 @@ class DomainPatch(df.SubDomain):
...
@@ -503,15 +503,21 @@ class DomainPatch(df.SubDomain):
# since we are looping over the interfaces we correct each dof
# since we are looping over the interfaces we correct each dof
# that is common with another interfaces with the corresponding
# that is common with another interfaces with the corresponding
# factor norm(n_1 + 1_2).
# factor norm(n_1 + 1_2).
# We take the mean of the pressure on both interfaces, so
# we multiply these by 1/2
if
dofs_in_common_with_other_interfaces
[
phase
].
size
!=
0
:
if
dofs_in_common_with_other_interfaces
[
phase
].
size
!=
0
:
if
debug
:
if
debug
:
print
(
f
"
the following dofs (phase =
{
phase
}
) of interface
{
interf_ind
}
are in common with
\n
"
,
print
(
f
"
the following dofs (phase =
{
phase
}
) of interface
{
interf_ind
}
are in common with
\n
"
,
f
"
other interfaces:
{
dofs_in_common_with_other_interfaces
[
phase
]
}
"
)
f
"
other interfaces:
{
dofs_in_common_with_other_interfaces
[
phase
]
}
"
)
for
common_dof
in
dofs_in_common_with_other_interfaces
[
phase
]:
for
common_dof
in
dofs_in_common_with_other_interfaces
[
phase
]:
n_norm
=
self
.
_normal_vector_norms_for_common_dofs
[
interf_ind
][
phase
][
common_dof
]
# from the standpoint of the subdomain we are currently on,
# from the standpoint of the subdomain we are currently on,
# each dof can belong maximally to two interfaces.
# each dof can belong maximally to two interfaces.
# because we have not
# because we have not
gl0_assembled
[
common_dof
]
=
0.5
*
gl0_assembled
[
common_dof
]
neumann_flux_assembled
[
common_dof
]
=
neumann_flux_assembled
[
common_dof
]
/
n_norm
robin_pressure_assembled
[
common_dof
]
=
robin_pressure_assembled
[
common_dof
]
/
2
gl0_assembled
=
neumann_flux_assembled
-
robin_pressure_assembled
# now, add the just assembled and corrected term to the Global
# now, add the just assembled and corrected term to the Global
# gli_assembled_tmp vector
# gli_assembled_tmp vector
gli_assembled_tmp
[
phase
]
+=
gl0_assembled
gli_assembled_tmp
[
phase
]
+=
gl0_assembled
...
@@ -652,12 +658,16 @@ class DomainPatch(df.SubDomain):
...
@@ -652,12 +658,16 @@ class DomainPatch(df.SubDomain):
phi_a
=
self
.
testfunction
[
phase
]
phi_a
=
self
.
testfunction
[
phase
]
gli_pressure_part
=
df
.
assemble
(
-
2
*
dt
*
Lambda
[
phase
]
*
pa_prev
*
phi_a
*
ds
)
gli_pressure_part
=
df
.
assemble
(
-
2
*
dt
*
Lambda
[
phase
]
*
pa_prev
*
phi_a
*
ds
)
gli_pressure_part_array
=
gli_pressure_part
.
get_local
()
gli_pressure_part_array
=
gli_pressure_part
.
get_local
()
gli
=
gli_pressure_part_array
-
gli_prev_of_neighbour
# check if there are shared dofs with another interface.
# check if there are shared dofs with another interface.
if
dofs_in_common_with_other_interfaces
[
phase
].
size
!=
0
:
if
dofs_in_common_with_other_interfaces
[
phase
].
size
!=
0
:
for
common_dof
in
dofs_in_common_with_other_interfaces
[
phase
]:
for
common_dof
in
dofs_in_common_with_other_interfaces
[
phase
]:
# n_norm = self._normal_vector_norms_for_common_dofs[ind][phase][common_dof]
gli_prev_of_neighbour
[
common_dof
]
=
gli_prev_of_neighbour
[
common_dof
]
/
2
# see previous case.
# see previous case.
gli
[
common_dof
]
=
0.5
*
gli
[
common_dof
]
gli_pressure_part_array
[
common_dof
]
=
0.5
*
gli_pressure_part_array
[
common_dof
]
gli
=
gli_pressure_part_array
-
gli_prev_of_neighbour
# now, add the just assembled and corrected term to the Global
# now, add the just assembled and corrected term to the Global
# gli_assembled_tmp vector
# gli_assembled_tmp vector
gli_assembled_tmp
[
phase
]
+=
gli
gli_assembled_tmp
[
phase
]
+=
gli
...
@@ -897,6 +907,7 @@ class DomainPatch(df.SubDomain):
...
@@ -897,6 +907,7 @@ class DomainPatch(df.SubDomain):
interfaces. This is used by the functions calc_gli_term and calc_gl0_term
interfaces. This is used by the functions calc_gli_term and calc_gl0_term
"""
"""
self
.
_normal_vector_norms_for_common_dofs
=
dict
()
self
.
_normal_vector_norms_for_common_dofs
=
dict
()
self
.
mesh
.
init
(
0
)
for
interface_ind
in
self
.
has_interface
:
for
interface_ind
in
self
.
has_interface
:
# if one phase has common dofs to two interfaces, the both phases
# if one phase has common dofs to two interfaces, the both phases
# have, so it suffices to check for the wetting phase as it is always
# have, so it suffices to check for the wetting phase as it is always
...
@@ -908,10 +919,27 @@ class DomainPatch(df.SubDomain):
...
@@ -908,10 +919,27 @@ class DomainPatch(df.SubDomain):
{
phase
:
dict
()}
{
phase
:
dict
()}
)
)
for
dof
in
self
.
_interface_has_common_dof_indices
[
interface_ind
][
phase
]:
for
dof
in
self
.
_interface_has_common_dof_indices
[
interface_ind
][
phase
]:
# at the moment we only determine this correctly if the patch
common_vertex_index
=
self
.
dof2vertex
[
phase
][
dof
]
# is rectangular and parallel to the x and y axis.
for
index
,
vertex
in
enumerate
(
df
.
vertices
(
self
.
mesh
)):
if
index
==
common_vertex_index
:
common_vertex
=
vertex
# print(f"\non subdomain{self.subdomain_index}, interface{interface_ind} and phase {phase}")
# print(f"vertex_{index} = {vertex.point()[:]}, type(vertex) = {type(vertex)}")
linear_combination_of_normals
=
np
.
zeros
(
np
.
size
(
vertex
.
point
()[:]),
dtype
=
float
)
# normals = []
# print(f"common_vertex = {common_vertex}",
# f"common_vertex_index = {common_vertex_index}")
for
facet_containing_vertex
in
df
.
facets
(
common_vertex
):
#df.cells(common_vertex):
if
facet_containing_vertex
.
exterior
():
# normals.append(facet_containing_vertex.normal()[:])
# print(f"type(facet_normal) = {type(facet_containing_vertex.normal()[:])}")
linear_combination_of_normals
+=
facet_containing_vertex
.
normal
()[:]
# print(f"normals of common_vertex: {common_vertex} are ", normals)
# print(f"linear combination is: {linear_combination_of_normals[:]}.")
# print(f"with length {np.linalg.norm(linear_combination_of_normals, ord=2, axis=None)}. For comparison, np.sqrt(2) = {np.sqrt(2)}.")
self
.
_normal_vector_norms_for_common_dofs
[
interface_ind
][
phase
].
update
(
self
.
_normal_vector_norms_for_common_dofs
[
interface_ind
][
phase
].
update
(
{
dof
:
np
.
sqrt
(
2
)}
{
dof
:
np
.
linalg
.
norm
(
linear_combination_of_normals
)}
)
)
...
...
...
...
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