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

fix domainPatch.write_pressure_to_interfaces()

parent 02032034
No related branches found
No related tags found
No related merge requests found
...@@ -328,6 +328,27 @@ class LDDsimulation(object): ...@@ -328,6 +328,27 @@ 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):
""" set initial values
"""
for num, subdomain in self.subdomain.items():
mesh = subdomain.mesh
V = subdomain.function_space
# p0 contains both pw_0 and pnw_0 for subdomain[num]
p0 = self.initial_conditions[num]
if subdomain.isRichards:
# note that the default interpolation degree is 2
pw0 = df.Expression(p0['wetting'], domain = mesh, degree = interpolation_degree)
subdomain.pressure_prev_iter = {'wetting' : df.interpolate(pw0, V['wetting'])}
subdomain.pressure_prev_timestep = {'wetting' : df.interpolate(pw0, V['wetting'])}
else:
pw0 = df.Expression(p0['wetting'], domain = mesh, degree = interpolation_degree)
pnw0 = df.Expression(p0['nonwetting'], domain = mesh, degree = interpolation_degree)
subdomain.pressure_prev_iter = {'wetting' : df.interpolate(pw0, V['wetting']),#
'nonwetting' : df.interpolate(pnw0, V['nonwetting'])}
subdomain.pressure_prev_timestep = {'wetting' : df.interpolate(pw0, V['wetting']),#
'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
""" """
......
...@@ -125,6 +125,13 @@ initial_condition = { ...@@ -125,6 +125,13 @@ initial_condition = {
2: {'wetting': '-x[1]*x[1]'} 2: {'wetting': '-x[1]*x[1]'}
} }
exact_solution = {
1: {'wetting': '1.0 - (1.0 + t*t)*(1.0 + x[0]*x[0] + x[1]*x[1])'},#
2: {'wetting': '1.0 - (1.0 + t*t)*(1.0 + x[1]*x[1])'}
}
dirichletBC = exact_solution
# def saturation(pressure, subdomain_index): # def saturation(pressure, subdomain_index):
# # inverse capillary pressure-saturation-relationship # # inverse capillary pressure-saturation-relationship
# return df.conditional(pressure < 0, 1/((1 - pressure)**(1/(subdomain_index + 1))), 1) # return df.conditional(pressure < 0, 1/((1 - pressure)**(1/(subdomain_index + 1))), 1)
......
...@@ -139,7 +139,7 @@ class DomainPatch(df.SubDomain): ...@@ -139,7 +139,7 @@ class DomainPatch(df.SubDomain):
### Class variables set by methods ### Class variables set by methods
# dictionary holding the dof indices corresponding to an interface of # dictionary holding the dof indices corresponding to an interface of
# given interface. see self._calc_dof_indices_of_interfaces() # given interface. see self._calc_dof_indices_of_interfaces()
self.dof_indices_of_interface = dict() self._dof_indices_of_interface = dict()
# measures are set by self._init_measures() # measures are set by self._init_measures()
self.iteration_number = 0 self.iteration_number = 0
self.dx = None self.dx = None
...@@ -165,7 +165,7 @@ class DomainPatch(df.SubDomain): ...@@ -165,7 +165,7 @@ class DomainPatch(df.SubDomain):
def write_pressure_to_interfaces(self): def write_pressure_to_interfaces(self):
""" save the interface values of self.pressure to all neighbouring interfaces""" """ save the interface values of self.pressure to all neighbouring interfaces"""
if self.isRichards: if self.isRichards:
for ind in has_interface: for ind in self.has_interface:
interface[ind].write_dofs(from_function = self.pressure['wetting'], # interface[ind].write_dofs(from_function = self.pressure['wetting'], #
interface_dofs = self._dof_indices_of_interface[ind]['wetting'],# interface_dofs = self._dof_indices_of_interface[ind]['wetting'],#
dof_to_vert_map = self.dof2vertex['wetting'],# dof_to_vert_map = self.dof2vertex['wetting'],#
...@@ -173,7 +173,7 @@ class DomainPatch(df.SubDomain): ...@@ -173,7 +173,7 @@ class DomainPatch(df.SubDomain):
phase = 'wetting',# phase = 'wetting',#
subdomain_ind = self.subdomain_index) subdomain_ind = self.subdomain_index)
else: else:
for ind in has_interface: for ind in self.has_interface:
for phase in ['wetting', 'nonwetting']: for phase in ['wetting', 'nonwetting']:
interface[ind].write_dofs(from_function = self.pressure[phase], # interface[ind].write_dofs(from_function = self.pressure[phase], #
interface_dofs = self._dof_indices_of_interface[ind][phase],# interface_dofs = self._dof_indices_of_interface[ind][phase],#
...@@ -311,7 +311,7 @@ class DomainPatch(df.SubDomain): ...@@ -311,7 +311,7 @@ class DomainPatch(df.SubDomain):
""" calculate dof indices of each interface """ """ calculate dof indices of each interface """
V = self.function_space V = self.function_space
marker = self.boundary_marker marker = self.boundary_marker
for ind in has_interface: for ind in self.has_interface:
self._dof_indices_of_interface.update(# self._dof_indices_of_interface.update(#
{ind: dict()} {ind: dict()}
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment