pygmsh icon indicating copy to clipboard operation
pygmsh copied to clipboard

Export mesh with geometry included

Open nicola-sorace opened this issue 3 years ago • 4 comments

Hello,

So I'm wanting to use pygmsh for generation of a mesh to use in OpenFOAM. This line is able to export a gmsh mesh:

mesh.write('case.msh', 'gmsh22')

However, it looks like only the actual mesh objects are exported with this, not the geometry. This is a problem because the physical names I assigned to surfaces don't seem to make it through. I can export the geometry with this line:

geom.save_geometry('case.geo_unrolled')

Which produces a file I can open in the gmsh GUI, and generating a mesh in there works great. However, the extra step of running gmsh is annoying. Is there a way of exporting to a msh file in pygmsh with the geometry included?

Possibly related to #264

nicola-sorace avatar May 10 '21 16:05 nicola-sorace

Probably related to one of the gmsh bugs in meshio. I don't think anyone takes much interested in the legacy gmsh format 2.2 anymore, so you'll probably have to PR this yourself.

nschloe avatar May 10 '21 16:05 nschloe

@nschloe ok, I've looked at the meshio code a bit and it looks like the issue is that the cell_data dictionary is not being populated in the mesh object before writing, only the cell_sets. Does this make sense / is it normal? I'm guessing maybe the cell_sets needs to be converted to cell_data somewhere?

nicola-sorace avatar May 10 '21 18:05 nicola-sorace

Or the gmsh writer needs to be modified to understand the cell sets. Not sure which now.

nschloe avatar May 11 '21 06:05 nschloe

Hi, I also confirm that cell_data dictionary is not being populated, which is also a problem for the msh-to-xdmf converters for use in Fenics (which is my intention). Did you find any solution or is there any work around on this issue? Thanks

raptistasos avatar May 31 '21 09:05 raptistasos