Here is the problem. I have a geometry imported from gmsh. There are 4 subdomains. Let’s call them mesh1, mesh2, mesh3 and mesh4. After importing the mesh, I define my boundary and surface markers. Then I use the surface markers to create a compiled subdomain of mesh2 + mesh3 + mesh4. The problem is creating surface and boundary measures for the compiled subdomain using surface and boundary markers of the parent mesh.
The geometry looks like
# Importing mesh from gmsh and defining surface and boundary markers
msh = meshio.read("mesh.msh")
triangle_mesh = create_mesh(msh, "triangle", True)
line_mesh = create_mesh(msh, "line", True)
meshio.write("mesh.xdmf", triangle_mesh)
meshio.write("mf.xdmf", line_mesh)
from dolfin import *
mesh = Mesh()
mvc = MeshValueCollection("size_t", mesh, mesh.topology().dim())
with XDMFFile("mesh.xdmf") as infile:
infile.read(mesh)
infile.read(mvc, "name_to_read")
cf = cpp.mesh.MeshFunctionSizet(mesh, mvc)
mvc = MeshValueCollection("size_t", mesh, mesh.topology().dim()-1)
with XDMFFile("mf.xdmf") as infile:
infile.read(mvc, "name_to_read")
mf = cpp.mesh.MeshFunctionSizet(mesh, mvc)
# Compiling subdomains
combined_subdomains = MeshFunction("size_t", mesh, mesh.topology().dim(), 0)
combined_subdomains.array()[cf.array()==5] = 1
combined_subdomains.array()[cf.array()==6] = 1
combined_subdomains.array()[cf.array()==7] = 1
mesh_ima = SubMesh(mesh, combined_subdomains, 1)
# Defining measures for the compiled subdomain
mvc_ima = MeshValueCollection("size_t", mesh_ima, mesh_ima.topology().dim())
with XDMFFile("mesh.xdmf") as infile:
infile.read(mesh_ima)
infile.read(mvc_ima, "name_to_read")
cf_ima = cpp.mesh.MeshFunctionSizet(mesh_ima, mvc_ima)
mvc_ima = MeshValueCollection("size_t", mesh_ima, mesh_ima.topology().dim()-1)
with XDMFFile("mf.xdmf") as infile:
infile.read(mvc_ima, "name_to_read")
mf_ima = cpp.mesh.MeshFunctionSizet(mesh_ima, mvc_ima)
ds_custom = Measure("dS", domain=mesh_ima, subdomain_data=mf_ima)
dx_custom = Measure("dx", domain=mesh_ima, subdomain_data=cf_ima)
I believe that in ds_custom and dx_custom, the domain and subdomain data are for the compiled subdomain, but that seems not to be the case. So is there anything wrong in creating dx_custom and ds_custom?
Let me know if you need any other information.