Hi Everyone,
I want to refine the mesh in the solid domain of the fluid structure interaction problem. For that, I am using a refine() function and a boolean mesh function. However, I believe I am losing markers, and I need to use adapt() because my relative and absolute residuals have become nan. But I’m not sure how or where to use adapt(). Please help me figure out how to locally refine it.
from dolfin import *
from ufl import indices, Jacobian, Min
from mshr import *
# Parameters defining domain geometry:
SOLID_LEFT = 0.45
SOLID_RIGHT = 0.55
SOLID_TOP = 0.5
OMEGA_H = 0.75
OMEGA_W = 1.0
# Define the mshr geometrical primitives for this domain:
r_Omega = Rectangle(Point(0,0),Point(OMEGA_W,OMEGA_H))
r_Omega_s = Rectangle(Point(SOLID_LEFT,0),
Point(SOLID_RIGHT,SOLID_TOP))
SOLID_FLAG = 1
r_Omega.set_subdomain(SOLID_FLAG,r_Omega_s)
# Define subdomains for use in boundary condition definitions:
class Walls(SubDomain):
def inside(self, x, on_boundary):
return (on_boundary
and ((x[1] < DOLFIN_EPS)
or (x[1] > (OMEGA_H - DOLFIN_EPS))))
class Inflow(SubDomain):
def inside(self, x, on_boundary):
return (on_boundary and (x[0] < DOLFIN_EPS))
class Outflow(SubDomain):
def inside(self, x, on_boundary):
return (on_boundary and (x[0] > (OMEGA_W - DOLFIN_EPS)))
class SolidDomainClosure(SubDomain):
def inside(self, x, on_boundary):
return (x[0] > SOLID_LEFT - DOLFIN_EPS
and x[0] < SOLID_RIGHT + DOLFIN_EPS
and x[1] < SOLID_TOP + DOLFIN_EPS)
mesh = generate_mesh(r_Omega, 70)
d = mesh.geometry().dim()
DomainToRefine= CompiledSubDomain("x[0] > 0.45 - DOLFIN_EPS and x[0] < 0.55 + DOLFIN_EPS and x[1] < 0.5 + DOLFIN_EPS")
r_markers = MeshFunction("bool", mesh, d, False)
DomainToRefine.mark(r_markers, True)
refinedMesh = refine(mesh,r_markers)
mesh=refinedMesh
markers = MeshFunction('size_t', mesh, d, mesh.domains())
bdry_markers = MeshFunction('size_t', mesh, d-1,0)
OUTFLOW_FLAG = 2
Outflow().mark(bdry_markers,OUTFLOW_FLAG)
dx = dx(metadata={'quadrature_degree': 2},
subdomain_data=markers)
ds = ds(metadata={'quadrature_degree': 2},
subdomain_data=bdry_markers)
cell = mesh.ufl_cell()
Ve = VectorElement("CG", cell, 1)
Qe = FiniteElement("CG", cell, 1)
VQe = MixedElement((Ve,Qe))
W = FunctionSpace(mesh,VQe)
V = FunctionSpace(mesh,Ve)