Hi @Sean_Breckling,
I believe the issue is the physical groups and the default behavior of Gmsh when physical groups are defined:
Since you have defined a physical group of surfaces, but not of volumes, your volume elements are not being exported. Hence the error when you try to define a tetrahedron finite element, since your mesh contains only triangles. To fix this, you can add Physical Volume(1) = {1,2};
to the end of your .geo file.
To convert the mesh, you can use the meshio
Python package (note: not the meshio-convert
script). Copy the following to a .py file (e.g. convert_mesh.py
) and run using python convert_mesh.py
:
import meshio
mesh_name = "mesh"
msh = meshio.read(mesh_name+".msh")
tet_data = msh.cell_data_dict["gmsh:physical"]["tetra"]
meshio.write(mesh_name+".xdmf",
meshio.Mesh(points=msh.points,
cells={"tetra": msh.cells_dict["tetra"]},
cell_data={"dom_marker": [tet_data]}
)
)
tri_data = msh.cell_data_dict["gmsh:physical"]["triangle"]
meshio.write(mesh_name+"_surf.xdmf",
meshio.Mesh(points=msh.points,
cells={"triangle": msh.cells_dict["triangle"]},
cell_data={"bnd_marker": [tri_data]}
)
)
This will give you two files, one containing the domain markers and one containing the surface markers. To read the mesh, use
from fenics import *
mesh = Mesh()
with XDMFFile("mesh.xdmf") as file:
file.read(mesh)
P.S. There’s a birthday cake emoji appearing beside your username today. Happy birthday!