Importing mesh from Comsol to FEnics, what is the best way?

Hello. I am looking for some straightforward way of importing a 2D triangle mesh from Comsol to Fenics. I tried to find some convenient way but failed so far. One option I currently see is to export the mesh from Comsol as a list of coordinates of vertices and list of triangles (as triplets of triangle indexes) and somehow construct a fenics friendly format from this data.

The question is how to do this in most elegant way? Or is there some more straightforward way? I’d be grateful for any tip on how to approach the problem.

I would suggest using meshio to convert your mesh to xdmf which is one of the formats dolfin supports. See for instance section 2 of: Mesh generation and conversion with GMSH and PYGMSH | Jørgen S. Dokken which shows how to convert msh files to XDMF.

1 Like

Thanks! The linked page with examples pretty much solves it for me. :slight_smile: