# Adaptmesh bamg error

**URL:** https://community.freefem.org/t/adaptmesh-bamg-error/773
**Category:** General Discussion
**Created:** [January 28, 2021, 2:12pm UTC](https://community.freefem.org/t/adaptmesh-bamg-error/773 "2021-01-28T14:12:13Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mrbenson](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mrbenson](https://community.freefem.org/u/mrbenson)
#### Post date: [January 28, 2021, 2:12pm UTC](https://community.freefem.org/t/adaptmesh-bamg-error/773/1 "2021-01-28T14:12:13Z")

</div>

Hello,

I get sometimes a fatal error in the mesh generator using adaptmesh with the following option  
iso=false, nbvx = 1e6, maxsubdiv=5  
Is there an adaptmesh option for pervent this ?

Best regards.

number of required edges : 0  
2938 Problem: insert point 2926([116177873,193304108],[-6.45389,4.95713]{3.52903e-07,1.96232e-07,[0.996706,0.0810952]})3171 tcvj = 0x7fffc490 0  
([116177832,193304081],[-6.45389,4.95713]{3.4564e-07,2.37417e-07,[0.999816,0.0192053]})([116178067,193304220],[-6.45389,4.95713]{2.24982e-07,1.94815e-07,[0.516705,-0.856164]})  
([116177832,193304081],[-6.45389,4.95713]{3.4564e-07,2.37417e-07,[0.999816,0.0192053]})([116178067,193304220],[-6.45389,4.95713]{2.24982e-07,1.94815e-07,[0.516705,-0.856164]})  
Fatal error in the mesh generator 1001  
current line = 73  
Meshing error: Bamg  
number : 1001,  
Meshing error: Bamg  
number : 1001,  
err code 5 , mpirank 0

---

<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: [January 28, 2021, 4:35pm UTC](https://community.freefem.org/t/adaptmesh-bamg-error/773/2 "2021-01-28T16:35:03Z")

</div>

Yes, and no, you want to build a to fine mesh  
one way is to bound hmin= parameter of adapdmesh

---

<div class="post-metadata">

### Author: ![mrbenson](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mrbenson](https://community.freefem.org/u/mrbenson)
#### Post date: [January 28, 2021, 5:49pm UTC](https://community.freefem.org/t/adaptmesh-bamg-error/773/3 "2021-01-28T17:49:07Z")

</div>

1 - hmin does the job !  
In the source code the default value of hmin is Th.MinimalHmin(), i can’t see where hmin is really updated.  
2 - Is that expected adaptmesh works with 3d mesh ?  
Best regards.

---

<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: [January 29, 2021, 4:04pm UTC](https://community.freefem.org/t/adaptmesh-bamg-error/773/4 "2021-01-29T16:04:55Z")

</div>

THe minimal Th.MinimalHmin() is a real min of the algorithm, I think is a bad  
idea to change.

the place is

bamglib/Mesh2.h: Real8 MinimalHmin( ) const { return 2.0 / coefIcoor; }  
bamglib/Mesh2.h: Real8 MinimalHmin( ) { return 2.0 / coefIcoor; }  
you can change 2. in 10.

for the 3d can you can use mmg pluggin . They is an example in [FreeFem-sources/Laplace-Adapt-aniso-3d.edp at master · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/master/examples/3d/Laplace-Adapt-aniso-3d.edp)

---

<div class="post-metadata">

### Author: ![mrbenson](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mrbenson](https://community.freefem.org/u/mrbenson)
#### Post date: [January 30, 2021, 11:24am UTC](https://community.freefem.org/t/adaptmesh-bamg-error/773/5 "2021-01-30T11:24:06Z")

</div>

Thanks, that makes hmin very clear.

Does mmg compatible with 2d mesh ? Is there an exemple ?

---

<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: [January 31, 2021, 2:51pm UTC](https://community.freefem.org/t/adaptmesh-bamg-error/773/6 "2021-01-31T14:51:17Z")

</div>

Sorry no example, but is simple to build a 2d example from the 3d example.

---

<div class="post-metadata">

### Author: ![mrbenson](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mrbenson](https://community.freefem.org/u/mrbenson)
#### Post date: [February 1, 2021, 11:41am UTC](https://community.freefem.org/t/adaptmesh-bamg-error/773/7 "2021-02-01T11:41:41Z")

</div>

mmg seems not to work with 2d mesh.

---

<div class="post-metadata">

### Author: ![LucasPa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/lucaspa/32/347_2.png) [@LucasPa](https://community.freefem.org/u/LucasPa)
#### Post date: [November 16, 2021, 9:52am UTC](https://community.freefem.org/t/adaptmesh-bamg-error/773/8 "2021-11-16T09:52:15Z")

</div>

Hi mrbenson,

I found a tutorial at [http://annabellecollin.perso.math.cnrs.fr/TPS/TP\_0.pdf](http://annabellecollin.perso.math.cnrs.fr/TPS/TP_0.pdf) (it’s in French sorry). You can download the file at [http://annabellecollin.perso.math.cnrs.fr/TPS/Code\_TP0.zip](http://annabellecollin.perso.math.cnrs.fr/TPS/Code_TP0.zip). Basically it works the following way:

1.In the folder Mesh/:

> g++ -std=c++11 -o run main.cc # compile the gmsh to FreeFem converter  
> ./run Lmesh-2D.mesh # run the converter to create the file freefem-Lmesh-2D.mesh

1. In the main directory:

> FreeFem++ adaptLPoisson.edp

And then

> mmg2d freefem-Lmesh-2D.mesh -sol freefem-Lmesh-2D.sol -out freefem-Lmesh-2D.mesh

Best,

Lucas
