Workflow for FEniCS

Hi all,

I would like to know if anyone has any experience or pointers on how to use Cubit to mesh a geometry, tag subdomains and use it in a FEniCS script.

I was unsuccessful with meshio so far and was curious to know if someone tried to do something similar.

Thanks in advance!

Hi @remdelaportemathurin

That’s the troublesome part. I am not quite sure which mesh types fenics supports yet. I only know of their native XDMF format and that there should be a reader for gmsh .msh files. But Cubit doesn’t support any of those.

There are 3 options:
• use a converter like meshio to convert a mesh from lets say abaqus to dolfin
• if you are aware of the right syntax, you can write yourself an exporter with the cubit sdk
• code a new reader for fenics to import other mesh formats

Meshio works well, but even better is the code GitHub - jorgensd/mesh_converter: A mesh converter from EXODUS 2 to XDMF. This converts blocks and sidesets to meshtags. Export from cubit as an exodus mesh, and then convert to xdmf format using mesh_converter. The dolfinx lines to import the mesh and meshtags are:

from dolfinx import io
from mpi4py import MPI

with io.XDMFFile(MPI.COMM_WORLD, ‘mesh_file.xdmf’, ‘r’) as file:
msh = file.read_mesh(name=‘Mesh’)
block_data = file.read_meshtags(msh, name=‘Mesh’)