Hello everybody,
I have a problem. I defined my geometry and mesh in gmsh.
SetFactory("OpenCASCADE");
L = 2;
R = 0.2;
r = 0.1;
Box(1) = {-L/2,-L/2,-L/2,L,L,L}; //tag=1
//+
Torus(2) = {0, 0, 0, R, r, Pi}; //tag=2
//+
Torus(3) = {0, 0, 0, R, r, Pi}; //tag=3
//+
Rotate {{1, 0, 0}, {0, 0, 0}, Pi/2}{
Volume{2};
}
//+
Rotate {{1, 0, 0}, {0, 0, 0}, -Pi/2}{
Volume{3};
}
Physical Volume(1) = {2, 3}; //Torus
//+
Physical Volume(2) = {1}; //surrounding
//+
Physical Surface(3) = {13, 16}; //internal boundary
//+
Physical Surface(4) = {1, 2, 3, 4, 5, 6}; //external boundary
Mesh 3;
But when I look at the integrals, the integral over the internal boundarie is 0.
What is the reason for this?
from fenics import*
import meshio
# Konvertiere Mesh zu XDMF für die Benutzung in FEniCS
msh = meshio.read("torus.msh")
tet_data = msh.cell_data_dict["gmsh:physical"]["tetra"]
tri_data = msh.cell_data_dict["gmsh:physical"]["triangle"]
meshio.write("mesht.xdmf",
meshio.Mesh(points=msh.points,
cells={"tetra": msh.cells_dict["tetra"]}
)
)
meshio.write("randt.xdmf",
meshio.Mesh(points=msh.points,
cells={"triangle": msh.cells_dict["triangle"]},
cell_data={"bnd_marker": [msh.cell_data_dict["gmsh:physical"]["triangle"]]}
)
)
meshio.write("gebiett.xdmf",
meshio.Mesh(
points=msh.points,
cells={"tetra": msh.cells_dict["tetra"]},
cell_data={"dom_marker": [msh.get_cell_data("gmsh:physical", "tetra")]}
)
)
mesh = Mesh()
with XDMFFile("mesht.xdmf") as mshfile:
mshfile.read(mesh)
mft = MeshFunction('size_t', mesh, mesh.topology().dim(), 0)
with XDMFFile("gebiett.xdmf") as domfile:
domfile.read(mft)
File("mft.pvd") << mft
dx = Measure('dx', domain=mesh, subdomain_data=mft)
submesh_torus = SubMesh(mesh, mft, 1)
submesh_OT = SubMesh(mesh, mft, 2)
mvc = MeshValueCollection("size_t", mesh, mesh.topology().dim()-1)
with XDMFFile("randt.xdmf") as bndfile:
bndfile.read(mvc, "bnd_marker")
mff = MeshFunction('size_t', mesh, mvc)
for i in range(mff.size()):
if mff[i] not in (3, 4):
mff[i] = 0
File("mff.pvd") << mff
dS = Measure('dS', domain=mesh, subdomain_data=mff) # internal facets
ds = Measure("ds", domain=mesh, subdomain_data=mff) #external facets
print(assemble(Constant(1)*dx))
print(assemble(Constant(1)*dx(1)))
print(assemble(Constant(1)*dx(2)))
print(assemble(Constant(1)*ds(4)))
print(assemble(Constant(1)*dS(3)))
8.031561967647798
0.03156196764777432
8.000000000000007
23.999999999999968
0.0
I have oriented myself on this Mesh, Submesh , Torus, Boundary - #3 by conpierce8 but the outputs of “mesht”, “randt” and “gebiett” were different from the xdmf files created there if you ignore the “refinement” of the mesh.
left my mesht right mesh
left my gebiett right domains
left my randt right boundaries
But why? Can someone please have a look and give me a tip to fix it?
Thank you and best regards,
noya