# Problem import 3d mesh from gmsh

**URL:** <https://community.freefem.org/t/problem-import-3d-mesh-from-gmsh/256>\
**Category:** General Discussion\
**Created:** [February 18, 2020, 12:45pm UTC](https://community.freefem.org/t/problem-import-3d-mesh-from-gmsh/256 "2020-02-18T12:45:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Unam](https://avatars.discourse-cdn.com/v4/letter/u/ecae2f/32.png) [@Unam](https://community.freefem.org/u/Unam)\
**Post date:** [February 18, 2020, 12:45pm UTC](https://community.freefem.org/t/problem-import-3d-mesh-from-gmsh/256/1 "2020-02-18T12:45:07Z")

</div>

Hi,  
I’m trying to import a 3d mesh from gmsh to Freefem++ in order to simulate an object. The problem is that Freefem++ give me this :

$ FreeFem++ real\_3d.eps  
– FreeFem++ v4.5 (Tue Feb 11 17:02:48 CET 2020 - git v4.5-18-gcf799e13)  
Load: lg\_fem lg\_mesh lg\_mesh3 eigenvalue  
1 : load “gmsh”  
2 :  
3 : mesh3 Th2 = gmshload3(“real\_3d.msh”);  
4 :  
5 : plot(Th2,wait=1);  
6 : sizestack + 1024 =1248 ( 224 )

**Element of type 3 is not considered in Freefem++**

Here are my files : real\_3d.geo :  
nb=10;

Point(1) = {0, 0, 0};  
Point(2) = {0, 0.5, 0};  
Point(3) = {1, 0.5, 0};  
Point(4) = {4, 0.5, 0};  
Point(5) = {5, 0.5, 0};  
Point(6) = {5, 0, 0};

Point(7) = {1, 0.5, 0};  
Point(8) = {4, 0.5, 0};  
Point(9) = {5, 1.5, 0};  
Point(10) = {3.5, 1.5, 0};  
Point(11) = {1.5, 1.5, 0};  
Point(12) = {0,1.5,0};

Point(13) = {0, 1.5, 0};  
Point(14) = {1.5,1.5,0};  
Point(15) = {3.5, 1.5, 0};  
Point(16) = {5, 1.5, 0};  
Point(17) = {5, 2, 0};  
Point(18) = {0, 2, 0};

Line(30) = {1,2};  
Line(31) = {2,3};  
Line(32) = {3,4};  
Line(33) = {4,5};  
Line(34) = {5,6};  
Line(35) = {6,1};

Line(36) = {2,3};  
Line(37)= {3,7};  
Line(38) = {7,8};  
Line(39) = {8,4};  
Line(40) = {4,5};  
Line(41) = {5,9};  
Line(42) = {9,10};  
Line(43) = {10,11};  
Line(44) = {11,12};  
Line(45) = {12,2};

Line(46) = {13,14};  
Line(47) = {14,11};  
Line(48) = {11,10};  
Line(49) = {10,15};  
Line(50) = {15,16};  
Line(51) = {16,17};  
Line(52) = {17,18};  
Line(53) = {18,13};

Line Loop(60) = {30,31,32,33,34,35};  
Line Loop(61) = {36,37,38,39,40,41,42,43,44,45};  
Line Loop(62) = {46,47,48,49,50,51,52,53};

Plane Surface(63) = {60};  
Plane Surface(64) = {61};  
Plane Surface(65) = {62};

surfaceVector[] = Extrude {0, 0, 1} {  
Surface{63};  
Layers{2};  
Recombine;  
};  
surfaceVector[] = Extrude {0, 0, 1} {  
Surface{64};  
Layers{2};  
Recombine;  
};  
surfaceVector[] = Extrude {0, 0, 1} {  
Surface{65};  
Layers{2};  
Recombine;  
};

AND real\_3d.eps :

load “gmsh”

mesh3 Th2 = gmshload3(“real\_3d.msh”);

plot(Th2,wait=1);

---

<div class="post-metadata">

**Author:** ![gdmcbain](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/gdmcbain/32/37_2.png) [@gdmcbain](https://community.freefem.org/u/gdmcbain)\
**Post date:** [February 18, 2020, 10:54pm UTC](https://community.freefem.org/t/problem-import-3d-mesh-from-gmsh/256/2 "2020-02-18T22:54:01Z")

</div>

FreeFEM doesn’t support quadrilateral or hexahedral elements, only simplicial elements (triangles and tetrahedra). Gmsh can generate purely triangular and tetrahedral meshes and indeed will do so by default. Here, just omit the ‘Recombine’ commands which recombine tetrahedra into hexahedra.

Also, when generating a mesh with Gmsh, I’d highly recommend defining a Physical Volume for the domain (or multiple for multiple subdomains, called regions in FreeFEM) and a Physical Surface for the boundary (or multiple for mixed boundary value problems: inlet, outlet, wall, &c.). See [http://gmsh.info/dev/doc/texinfo/gmsh.html#Elementary-entities-vs-physical-groups](http://gmsh.info/dev/doc/texinfo/gmsh.html#Elementary-entities-vs-physical-groups). When defining these physical groups, Gmsh saves only those to the MSH file rather than everything which is often superfluous; also, the physical group tags are accessible from within FreeFEM if required for multiple subdomains or boundary-patches.

---

<div class="post-metadata">

**Author:** ![Unam](https://avatars.discourse-cdn.com/v4/letter/u/ecae2f/32.png) [@Unam](https://community.freefem.org/u/Unam)\
**Post date:** [February 19, 2020, 7:41am UTC](https://community.freefem.org/t/problem-import-3d-mesh-from-gmsh/256/3 "2020-02-19T07:41:46Z")

</div>

OK  
Thanks for the help
