# Mmg3d does not work in Ubuntu 20.04 but works in Mac and Windows

**URL:** <https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432>\
**Category:** General Discussion\
**Created:** [May 5, 2023, 9:50am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432 "2023-05-05T09:50:11Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![YAOH](https://avatars.discourse-cdn.com/v4/letter/y/ea5d25/32.png) [@YAOH](https://community.freefem.org/u/YAOH)\
**Post date:** [May 5, 2023, 9:50am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/1 "2023-05-05T09:50:11Z")

</div>

Dear all,

I did mesh adaption by mmg3d, the same code has different results on different PCs. In windows with FreeFem v4.10 and Mac with v4.12,  
the mesh can be adapted, be refined near the edge (y==0);  
but in Ubuntu 20.04 with ff v4.12, the mmg3d did not change the mesh.  
One of my colleague also checked in his Linux with v4.12, the mesh was not changed.

The following is my simple example:

```auto
load "msh3"
load "medit"
load "aniso"
load "mmg"
load "mshmet"
include "cube.idp"

int[int] Nxyz=[10,10,3];
real [int,int] Bxyz=[[0.,0.06],[0.,0.06],[0.,0.0015]];
int [int,int] Lxyz=[[1,1],[2,2],[2,2]];
mesh3 Th=Cube(Nxyz,Bxyz,Lxyz);
fespace Ph6(Th,[P1,P1,P1,P1,P1,P1]);
Ph6 [m11,m21,m22,m31,m32,m33];

real errh,hmax,hmin,adaptratio;
errh = 1e-3; hmax = 0.01; hmin =1e-7 ;adaptratio = 1.5;
real epsilon = 0.002; 

fespace Ph(Th,P1);
Ph p = -(2*tanh(y/(epsilon))-1);
real[int] hmetric(6*Th.nv);

hmetric=mshmet(Th,p,normalization=1,aniso=1,nbregul=1,hmax=hmax,hmin=hmin,err=errh);
boundaniso(6,hmetric,40);
m11[]=hmetric;

mesh3 Th3=mmg3d(Th,mem=10000,metric=m11[],hmax = hmax,hmin = hmin);
medit("init",Th);
medit("after",Th3);

```

Thanks!  
Y.H.  
[Examplemmg.edp](https://community.freefem.org/uploads/short-url/3zy8T3z6ZzR8JjJgb0d7senh8nN.edp) (728 Bytes)

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [May 5, 2023, 9:56am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/2 "2023-05-05T09:56:42Z")

</div>

Can you include it as an attachment? The copy/paste has been corrupting files  
for me ( Ubuntu 15 or so lol ).

---

<div class="post-metadata">

**Author:** ![YAOH](https://avatars.discourse-cdn.com/v4/letter/y/ea5d25/32.png) [@YAOH](https://community.freefem.org/u/YAOH)\
**Post date:** [May 5, 2023, 10:42am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/4 "2023-05-05T10:42:17Z")

</div>

I upload an attachement of this example.

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [May 5, 2023, 10:55am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/5 "2023-05-05T10:55:45Z")

</div>

![forum9](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/6725be6c9fded68ac7edb35c9b8cacac51b39fa4.jpeg)

---

<div class="post-metadata">

**Author:** ![YAOH](https://avatars.discourse-cdn.com/v4/letter/y/ea5d25/32.png) [@YAOH](https://community.freefem.org/u/YAOH)\
**Post date:** [May 5, 2023, 11:16am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/6 "2023-05-05T11:16:27Z")

</div>

![after](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/1/1cf35cf4810d226883d01bfdd37d56c39ba31ad4.png)

In Windows, the 2nd image is adapted like that.

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [May 5, 2023, 11:35am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/7 "2023-05-05T11:35:31Z")

</div>

```auto
 cat /proc/version
Linux version 4.15.0-142-generic (buildd@lgw01-amd64-039) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)) #146~16.04.1-Ubuntu SMP Tue Apr 13 09:27:15 UTC 2021
marchywka@happy:/home/documents/cpp/proj/freefem/play$ FreeFem++ 
FreeFem++ - version 4.12 (Sun Jan 22 17:51:12 EST 2023 - git no git) 64bits
License: LGPL 3+ (https://www.gnu.org/licenses/lgpl-3.0.en.html)

```

```auto
`ldd `which FreeFem++`
	linux-vdso.so.1 => (0x00007fff155a6000)
	libumfpack.so.5 => /home/ubuntu/dev/freefem/install2/ff-petsc/r/lib/libumfpack.so.5 (0x00007f8fec4b4000)
	libcholmod.so.3 => /home/ubuntu/dev/freefem/install2/ff-petsc/r/lib/libcholmod.so.3 (0x00007f8fec1a9000)
	liblapack.so.3 => /usr/lib/liblapack.so.3 (0x00007f8feb9b1000)
	libblas.so.3 => /usr/lib/libblas.so.3 (0x00007f8feb773000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8feb56f000)
	libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007f8feb244000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8feaf3b000)
	libhdf5_serial.so.10 => /usr/lib/x86_64-linux-gnu/libhdf5_serial.so.10 (0x00007f8feaa9d000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8fea880000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8fea4fe000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8fea2e8000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8fe9f1e000)
	libamd.so.2 => /home/ubuntu/dev/freefem/install2/ff-petsc/r/lib/libamd.so.2 (0x00007f8fe9d14000)
	libsuitesparseconfig.so.5 => /home/ubuntu/dev/freefem/install2/ff-petsc/r/lib/libsuitesparseconfig.so.5 (0x00007f8fe9b11000)
	libcolamd.so.2 => /home/ubuntu/dev/freefem/install2/ff-petsc/r/lib/libcolamd.so.2 (0x00007f8fe9909000)
	libccolamd.so.2 => /home/ubuntu/dev/freefem/install2/ff-petsc/r/lib/libccolamd.so.2 (0x00007f8fe96fc000)
	libcamd.so.2 => /home/ubuntu/dev/freefem/install2/ff-petsc/r/lib/libcamd.so.2 (0x00007f8fe94f0000)
	libmetis.so => /home/ubuntu/dev/freefem/install2/ff-petsc/r/lib/libmetis.so (0x00007f8fe927e000)
	libatlas.so.3 => /usr/lib/libatlas.so.3 (0x00007f8fe8ce0000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f8fec77c000)
	libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f8fe8aa1000)
	libsz.so.2 => /usr/lib/x86_64-linux-gnu/libsz.so.2 (0x00007f8fe889e000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f8fe8684000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f8fe847c000)
	libaec.so.0 => /usr/lib/x86_64-linux-gnu/libaec.so.0 (0x00007f8fe8274000)
`

```

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 5, 2023, 11:48am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/8 "2023-05-05T11:48:30Z")

</div>

Here is what I get with Linux. You should consider trying out the `develop` branch with the latest available PETSc (which will get you the latest available Mmg).

 ![Screenshot 2023-05-05 at 1.46.35 PM](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/4/4cc83c3b8bd2ae4b2af888dce9010ac2d41e457a.jpeg)

---

<div class="post-metadata">

**Author:** ![YAOH](https://avatars.discourse-cdn.com/v4/letter/y/ea5d25/32.png) [@YAOH](https://community.freefem.org/u/YAOH)\
**Post date:** [May 5, 2023, 12:53pm UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/9 "2023-05-05T12:53:52Z")

</div>

In Windows, the mmg version is 5.5.2 ,  
and in Linux with mmg 5.6.0, is it the latest ?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 5, 2023, 12:57pm UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/10 "2023-05-05T12:57:13Z")

</div>

Not at all. This is what you’ll get with a proper installation (on both Linux/macOS/Windows).

```auto
$ FreeFem-sources-linux/src/nw/FreeFem++ Examplemmg.edp -v 0 -nw

  ## Warning: MMG5_memOption_memSet: asking for 10000 MB of memory when only 3966 available.

  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   MODULE MMG3D: 5.7.1 (Dec. 20, 2022)
  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
     git branch: HEAD
     git commit: 9bd0023fe5f4a7de55d2959dd8dd4bf5d6929a36
     git date: 2022-12-22 08:56:26 +0100
[...]

```

---

<div class="post-metadata">

**Author:** ![spacelab](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@spacelab](https://community.freefem.org/u/spacelab)\
**Post date:** [September 8, 2025, 10:09am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/11 "2025-09-08T10:09:21Z")

</div>

Same here. mmg example Pinnochio Works well in my windows but not in mu ubuntu. in ubuntu i get

”\*\*\* buffer overflow detected \*\*\*: terminated

Unexpected error: \*\*\* potential lack of memory.” Requesting if someone has any solution.

I use : FreeFem++ - version 4.15. and the pinnochio code is

”load “medit”

load “mmg”

int nn = 15;

mesh3 Th3=cube(nn,2\*nn,nn,[x,2\*y,z]);

func head = sqrt((x-0.5)^2+(y-0.5)^2+(z-0.5)^2)-0.3;

func ear1 = sqrt((x-0.3)^2+(y-0.5)^2+0.5\*(z-0.8)^2)-0.1;

func ear2 = sqrt((x-0.7)^2+(y-0.5)^2+0.5\*(z-0.8)^2)-0.1;

func nose = sqrt((x-0.5)^2+0.006\*(y-0.9)^2+(z-0.5)^2)-0.03;

fespace Uh(Th3,P1);

Uh Pinocchio = min(min(min(head,ear1),ear2),nose);

Th3 = mmg3d(Th3,metric=Pinocchio,iso=1,ls=0,hausd=0.008,hgrad=2.3,verbose=10,mem=1000);// 1 G de ram ..

Th3 = buildBdMesh(Th3);

//medit(“Th3”,Th3);

meshS ThS = Th3.Gamma;

ThS = trunc(ThS,region==10);

ThS = mmgs(ThS,hausd=0.004,hgrad=2.3);

medit(“Pinocchio”,ThS);”

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [September 8, 2025, 4:16pm UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/12 "2025-09-08T16:16:47Z")

</div>

We cannot copy/paste your code.

---

<div class="post-metadata">

**Author:** ![spacelab](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@spacelab](https://community.freefem.org/u/spacelab)\
**Post date:** [September 9, 2025, 6:46am UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/13 "2025-09-09T06:46:42Z")

</div>

Hi prj, Greetings. This is the same code given in

```auto
> examples/3dSurf/Pinocchio.edp.

```

code works well in my windows but not in my Ubuntu 24.04

```auto
> load "medit"
> 
> load "mmg"
> 
> int nn = 15;
> 
> mesh3 Th3=cube(nn,2*nn,nn,[x,2*y,z]);
> 
> func head = sqrt((x-0.5)^2+(y-0.5)^2+(z-0.5)^2)-0.3;
> 
> func ear1 = sqrt((x-0.3)^2+(y-0.5)^2+0.5*(z-0.8)^2)-0.1;
> 
> func ear2 = sqrt((x-0.7)^2+(y-0.5)^2+0.5*(z-0.8)^2)-0.1;
> 
> func nose = sqrt((x-0.5)^2+0.006*(y-0.9)^2+(z-0.5)^2)-0.03;
> 
> fespace Uh(Th3,P1);
> 
> Uh Pinocchio = min(min(min(head,ear1),ear2),nose);
> 
> Th3 = mmg3d(Th3,metric=Pinocchio[],iso=1,ls=0,hausd=0.008,hgrad=2.3,verbose=10,mem=1000);// 1 G de ram ..
> 
> Th3 = buildBdMesh(Th3);
> 
> medit("Th3",Th3);
> 
> meshS ThS = Th3.Gamma;
> 
> ThS = trunc(ThS,region==10);
> 
> ThS = mmgs(ThS,hausd=0.004,hgrad=2.3);
> 
> medit("Pinocchio",ThS);

```

when i reduce "int nn = 5; " it works. But for anything greater than 5 it fails with the below error,

```auto
> -- Cube nv=7936 nt=40500 nbe=4500 kind= 6
> -- FESpace: Nb of Nodes 7936 Nb of DoF 7936
> MAXIMUM MEMORY AUTHORIZED (MB) 1000
> MMG3D_NPMAX 612706
> MMG3D_NTMAX 1214040
> MMG3D_NEMAX 3669120
> 
> ## Warning: MMG3D_skipIso: skip of all entites with 10 reference.
> ## Warning: we will overflow the memory asked with "-m" option during Scotch call.
> 
> -- MMG3DLS: INPUT DATA
> Deleted iso triangles: 0
> -- INPUT DATA COMPLETED. 0.000s
> 
> -- PHASE 1 : ISOSURFACE DISCRETIZATION
> 
> -- MESH QUALITY 40500
> BEST 0.657267 AVRG. 0.657267 WRST. 0.657267 (10189)
> HISTOGRAMM: 100.00 % > 0.12
> 100.00 % > 0.5
> 0.6 < Q < 0.8 40500 100.00 %
> ** ISOSURFACE EXTRACTION 
> ** SETTING STRUCTURE
> ** SETTING STRUCTURE
> 1846 splitted
> -- PHASE 1 COMPLETED. 0.053s
> 
> -- PHASE 2 : ANALYSIS
> 
> ** SURFACE ANALYSIS
> ** SETTING STRUCTURE
> ** SETTING TOPOLOGY
> Connected component: 2, genus: -1, reoriented: 0
> Edges: 10362, tagged: 240, ridges: 0, required: 0, refs: 240
> 296 ridges, 240 edges added
> 52 corners, 44 singular points detected
> ** DEFINING GEOMETRY
> 3152 normals, 254 tangents updated (0 failed)
> ** UPDATING TOPOLOGY AT NON-MANIFOLD POINTS
> 0 required edges added
> 0 corner and 0 required vertices added
> -- PHASE 2 COMPLETED. 0.030s
> 
> -- PHASE 3 : MESH IMPROVEMENT
> -- RENUMBERING. 
> ***buffer overflow detected*** : terminated
> 
> Unexpected error: *** potential lack of memory.

```

i have enough RAM available in the system

```
total used free shared buff/cache available
Mem: 15Gi 3.6Gi 9.5Gi 582Mi 3.0Gi 11Gi
Swap: 8.0Gi 0B 8.0Gi
```

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [September 9, 2025, 1:18pm UTC](https://community.freefem.org/t/mmg3d-does-not-work-in-ubuntu-20-04-but-works-in-mac-and-windows/2432/14 "2025-09-09T13:18:57Z")

</div>

What’s your Mmg version? I’m using the `develop` branch on FreeFEM, and I have no issue on either macOS or Linux.
