Closed r-maas closed 6 years ago
Unfortunately, there appears to be no publically available Medit specification so the implementation is always a bit incomplete. Anyways, vertex
should go in. Can you add it and let me know if this solves your problems? (Perhaps there are more cell types.) I'll then add it to meshio as well.
There's a specification in appendix 7.2.1 to
It doesn't cover all usages though; e.g. for two-dimensional meshes, FreeFem++ wants 'Dimension 2' and only two coordinates per vertex.
Adding: 'vertex': ('Vertex',1)
to the dictionary medit_from_meshio
did solve my problem. I should say adding 'Vertex',1 was just the first thing I tried and not based on a reference manual or something. In the geometry I tried this on there were no other cell types at this point.
Hmm, then using this .mesh file in a subsequent sfepy FEM simulation did give problems. It seems the mesh reader of sfepy has some trouble with the added data in the .mesh file:
sfepy: skipping unknown entity: ['Vertex']
With the 'vertex' added the .mesh file contained first a list of vertices, then a list of vertex, then a list of triangles. It seems to me the minimal information a mesh should have is just the list of vertices and triangles. So I'm not sure what the 'vertex' list adds.
So I'm not sure what the 'vertex' list adds.
Some meshes define not only triangles, quads and such, but also empty cells and cells that only contain one vertex. This can be useful for arranging vertices like cell sets as regions or so. Gmsh does that, for example, so when you're translating a gmsh file to medit, it tries to convert vertex cells as well.
Given the fact that sfepy
doesn't know Vertex
, I've now just skipped vertex cells in medit writes (and and some other cells as well). Grab 1.11.4 and check it out.
Thanks for the explanation on the vertex list, that makes sense.
The .mesh that is saved by medit after running Gmsh contains a lot of cells. Sfepy runs on volumetric meshes so all I am interested in are the vertices and tetrahedra, but after saving the .mesh file it also contains a list of edges and triangles, which Sfepy does not expect and complains about.
So looking again through my flow, I should just filter the cells I get after generating the geometry with pygmsh, and make sure I only add the tetrahedra to the cell dictionary before saving. I tried this and that works well. This would also avoid the previous key error of 'vertex'.
I generated a 3D geometry with pygmsh (by extruding a surface). Next I am trying to save it as a .mesh file, I get an error in medit_io.py because the geometry also has a "vertex" key. Should I do something different with my geometry or should this key be included in the list "medit_from_meshio"?
https://github.com/nschloe/meshio/blob/3d9c2bb54cde3b9bcaae403a63b63b3483e35fd4/meshio/medit_io.py#L116