Closed r-maas closed 7 years ago
Neither pygmsh nor meshio have explicit support for 2D meshes. Perhaps that'll be something to add? I've never come across a case where a zeroed-out third dimension would be a problem. For this, I'll have to check which mesh formats actually support 2D meshed. I assume there won't be many.
Ok well if it's not a feature it's not a bug! So I'll close this issue.
Sfepy gave an error when I tried to load a .mesh file with Dimension 3 for a 2D finite element problem. I'll check how the mesh is read in.
Feel free to reopen if this continues to be a problem for you.
The specification of the MEDIT format by Frey (2001, §7.2.1, p. 33) only allows Dimension 3
. That does seem slightly odd: if so, why bother with the line? But that's my reading.
Another program (besides SfePy reported by @r-maas above) FreeFem++ wants its MEDIT .mesh files for two-dimensional problems to have:
Dimension 2
andVertices
Since Gmsh always thinks in three dimensions and writes MEDIT files with Dimension 3
, I wrote a small 3to2.awk
script which I include in my Make/Shake pipelines between (Py)Gmsh and FreeFem++. It's available at https://bitbucket.org/gdmcbain/freefem and has also been posted numerous times to the freefempp and Gmsh mailing lists; e.g.:
Hi Nico,
Thanks for creating such useful tools as pygmsh and meshio. I have been using them for a few days now, and it has been a big help. I did run into a small problem when I tried to create a 2D mesh. I understand that gmsh requires 3D points, and the "dim" variable in the generate_mesh function here is passed correctly to gmsh. However, if I save the output geometry as a .mesh file, it always seems to list "Dimension 3" regardless of "dim".
If I first manually adapt the array containing the points and then save the mesh meshio does correctly store it as "Dimension 2":
However, this doesn't seem very elegant. Am I doing something wrong, or is there maybe a better way of ensuring that a 2D mesh is saved with the correct value for the Dimension?
Best regards, Ruben