Skip to content
Snippets Groups Projects
Commit 3a7fc0d5 authored by David Seus's avatar David Seus
Browse files

add init_boundary_markers, add support for rel perm as callable object

parent 4b6ac188
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,9 @@ Assumed is the use of python 3.6 ...@@ -17,7 +17,9 @@ Assumed is the use of python 3.6
import dolfin as df import dolfin as df
import mshr import mshr
import numpy as np import numpy as np
# import domainPatch as dp
import typing as tp import typing as tp
# Interface = tp.NewType('Interface', tp.any)
#import domainPatch as domainPatch #import domainPatch as domainPatch
...@@ -48,6 +50,9 @@ class DomainPatch(df.SubDomain): ...@@ -48,6 +50,9 @@ class DomainPatch(df.SubDomain):
present (isRichards == False) viscosity[1] is present (isRichards == False) viscosity[1] is
assumed to be the viscosity of the non-wetting phase. assumed to be the viscosity of the non-wetting phase.
interfaces: #type tp.List[dp.Interface] List of Interface class
objects from the LDDsimulation
class.
has_interface #type tp.List[int]: list of indices (w.r.t. the global has_interface #type tp.List[int]: list of indices (w.r.t. the global
numbering of interfaces in numbering of interfaces in
LDDsimulation.interfaces) indicating LDDsimulation.interfaces) indicating
...@@ -69,25 +74,31 @@ class DomainPatch(df.SubDomain): ...@@ -69,25 +74,31 @@ class DomainPatch(df.SubDomain):
## Public Variables ## Public Variables
self.isRichards #type bool set by input, see above isRichards #type bool set by input, see above
self.mesh #type df.Mesh set by input, see above mesh #type df.Mesh set by input, see above
self.porosity #type float set by input, see above porosity #type float set by input, see above
self.viscosity #type tp.List[float] set by input, see above viscosity #type tp.List[float] set by input, see above
self.has_interface #type tp.List[int] set by input, see above interfaces: #type tp.List[dp.Interface] set by input, see above
self.L #type tp.List[float] set by input, see above has_interface #type tp.List[int] set by input, see above
self.lambda_param #type tp.List[float] set by input, see above L #type tp.List[float] set by input, see above
self.function_space #type tp.Dict[str: df.Function] function space lambda_param #type tp.List[float] set by input, see above
function_space #type tp.Dict[str: df.Function] function space
used for wetting used for wetting
and nonwetting and nonwetting
pressures. This is pressures. This is
set by set by
self._init_function_space() self._init_function_space()
parent_mesh_index #type np.array parent vertex map of the submesh.
boundary_marker #type df.MeshFunction marker function to mark all
boundaries of the subdomain.
The marker value marking
interface i with global index
has_interface[i] will be
has_interface[i] aswell.
## Public Methods ## Public Methods
""" """
# default class variable values
tol: float = df.DOLFIN_EPS
### constructor ### constructor
def __init__(self, # def __init__(self, #
...@@ -95,9 +106,12 @@ class DomainPatch(df.SubDomain): ...@@ -95,9 +106,12 @@ class DomainPatch(df.SubDomain):
mesh: df.Mesh,# mesh: df.Mesh,#
porosity: float,# porosity: float,#
viscosity: tp.List[float],# viscosity: tp.List[float],#
# tp.List[Interface] doesn't work, because it hasen't been defined yet.
interfaces: tp.List[object],#
has_interface: tp.List[int],# has_interface: tp.List[int],#
L: tp.List[float],# L: tp.List[float],#
lambda_param: tp.List[float],# lambda_param: tp.List[float],#
relative_permeability: tp.Callable[...,None]#
): ):
# because we declare our own __init__ method for the derived class BoundaryPart, # because we declare our own __init__ method for the derived class BoundaryPart,
# we overwrite the __init__-method of the parent class df.SubDomain. However, # we overwrite the __init__-method of the parent class df.SubDomain. However,
...@@ -109,11 +123,15 @@ class DomainPatch(df.SubDomain): ...@@ -109,11 +123,15 @@ class DomainPatch(df.SubDomain):
self.mesh = mesh self.mesh = mesh
self.porosity = porosity self.porosity = porosity
self.viscosity = viscosity self.viscosity = viscosity
self.interface = interfaces
self.has_interface = has_interface self.has_interface = has_interface
self.L = L self.L = L
self.lambda_param = lambda_param self.lambda_param = lambda_param
self.relative_permeability = relative_permeability
self._init_function_space() self._init_function_space()
self._init_dof_and_vertex_maps()
self._init_boundary_markers()
# END constructor # END constructor
...@@ -124,7 +142,8 @@ class DomainPatch(df.SubDomain): ...@@ -124,7 +142,8 @@ class DomainPatch(df.SubDomain):
""" create function space for solution and trial functions """ create function space for solution and trial functions
Note that P1 FEM is hard coded here, as it is assumed in other methods Note that P1 FEM is hard coded here, as it is assumed in other methods
aswell. aswell. This method sets the class variable
self.function_space
""" """
if self.isRichards: if self.isRichards:
self.function_space = {'wetting': df.FunctionSpace(self.mesh, 'P', 1)} self.function_space = {'wetting': df.FunctionSpace(self.mesh, 'P', 1)}
...@@ -133,6 +152,47 @@ class DomainPatch(df.SubDomain): ...@@ -133,6 +152,47 @@ class DomainPatch(df.SubDomain):
'wetting' : df.FunctionSpace(self.mesh, 'P', 1),# 'wetting' : df.FunctionSpace(self.mesh, 'P', 1),#
'nonwetting' : df.FunctionSpace(self.mesh, 'P', 1)# 'nonwetting' : df.FunctionSpace(self.mesh, 'P', 1)#
} }
def _init_dof_and_vertex_maps(self) -> None:
""" calculate dof maps and the vertex to parent map.
This method sets the class Variables
self.parent_mesh_index
self.dof2vertex
self.vertex2dof
"""
mesh_data = self.mesh.data()
self.parent_mesh_index = mesh_data.array('parent_vertex_indices',0)
if self.isRichards:
self.dof2vertex = {#
'wetting' :df.dof_to_vertex_map(self.function_space['wetting'])#
}
self.vertex2dof = {#
'wetting' :df.vertex_to_dof_map(self.function_space['wetting'])#
}
else:
self.dof2vertex = {#
'wetting' :df.dof_to_vertex_map(self.function_space['wetting']),#
'nonwetting':df.dof_to_vertex_map(self.function_space['nonwetting'])#
}
self.vertex2dof = {#
'wetting' :df.vertex_to_dof_map(self.function_space['wetting']),#
'nonwetting':df.vertex_to_dof_map(self.function_space['nonwetting'])#
}
def _init_boundary_markers(self) -> None:
""" define boundary markers
This method sets the class Variables
self.boundary_marker
"""
self.boundary_marker = df.MeshFunction('size_t', self.mesh, self.mesh.topology().dim()-1)
self.boundary_marker.set_all(0)
for glob_index in self.has_interface:
# each interface gets marked with the global interface index.
self.interface[glob_index].mark(self.boundary_marker, glob_index)
# END is_Richards # END is_Richards
# END OF CLASS DomainPatch # END OF CLASS DomainPatch
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment