# Difference in mesh format between 2D and 3D

**URL:** https://community.freefem.org/t/difference-in-mesh-format-between-2d-and-3d/3019
**Category:** General Discussion
**Created:** [March 7, 2024, 10:40am UTC](https://community.freefem.org/t/difference-in-mesh-format-between-2d-and-3d/3019 "2024-03-07T10:40:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![smyrback](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@smyrback](https://community.freefem.org/u/smyrback)
#### Post date: [March 7, 2024, 10:40am UTC](https://community.freefem.org/t/difference-in-mesh-format-between-2d-and-3d/3019/1 "2024-03-07T10:40:27Z")

</div>

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”);

?

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [March 11, 2024, 8:50pm UTC](https://community.freefem.org/t/difference-in-mesh-format-between-2d-and-3d/3019/2 "2024-03-11T20:50:24Z")

</div>

To day no, sorry I am lazy.
