Difference in mesh format between 2D and 3D

Hi,

I’m using a C++ library that is built on top of FreeFem source code. When importing meshes from files, it requires the format generated by e.g. the following FreeFem code snippet:

mesh Th square(5,5);
savemesh(Th, “Th.msh”);

This is fine in 2D. However, the corresponding thing is not possible to do in 3D. The following code generates an error message:

load “msh3”
mesh3 Th = cube(5, 5, 5);
savemesh(Th, “cube.msh”);

since FreeFEM cannot save 3D meshes to the .msh format. Instead it is only possible to save it to a .mesh file, but I don’t know how to convert this file into the format .msh. Also, running savemesh to generate a .msh file doesn’t seem to generate a file on the Version 2 ASCII format from .gmsh as has been mentioned.

My question is: how can I save a 3d mesh into the same format as the format that is generated by 2D mesh generation in FreeFEM, i.e.

mesh Th square(5,5);
savemesh(Th, “Th.msh”);

?

To day no, sorry I am lazy.

1 Like