MMG3DLS: slow performance


Hi all,

I’m using this version of MMG3D: 5.3.13 (Oct. 2, 2018).
I briefly summarize what I need.
I have a 3D model composed by a cylinder in which the base is the terrain profile. The diameter of the cylinder is 600 m.

After a first refinement of the mesh with MMG (MMG3DLIB) I get a model in which the elements with minimum dimension are positioned near the terrain (lower part of the volume) and the elements with maximum dimension are positioned in the upper part of the volume (far off the terrain).

This model has 1195066 of tetrahedron and 330325 of nodes.

After that, I need to insert the geometry of the buildings on the terrain (within the volume). The geometries of the buildings are simple parallelepipeds.
Among other things, I set the value of hausdorff (0.01), maximum size (1.0) and minimum size (0.5).

I started to insert only one building (2.0 x 2.0 x 10.0 m) and, after almost 2 hours, the analysis was blocked at “- PHASE 1: ISOSURFACE DISCRETIZATION” and in particular in “** ISOSURFACE EXTRACTION”.
This is the output:

MODULE MMG3D: 5.3.13 (Oct. 2, 2018)



– MESH QUALITY 1195066
BEST 0.999308 AVRG. 0.497243 WRST. 0.001434 (412002)
HISTOGRAMM: 96.18 % > 0.12
49.43 % > 0.5
0.8 < Q < 1.0 119787 10.02 %
0.6 < Q < 0.8 294134 24.61 %
0.4 < Q < 0.6 355318 29.73 %
0.2 < Q < 0.4 300821 25.17 %
0.0 < Q < 0.2 125006 10.46 %

I tried to read the code to understand the reason for this block and noticed that a lot of time is lost here:

Which is called by:

 _MMG3D_mmg3d2 (in /src/mmg3d/mmg3d2.c)
     _MMG3D_snpval_ls (in /src/mmg3d/mmg3d2.c)
       MMG3D_hashTetra (in /src/mmg3d/hash_3d.c)
          _MMG5_paktet (in /src/mmg3d/hash_3d.c)

Any idea what may be the cause of this slow performance?

Also, reading the code, there are some things I don’t understand what they contain; such as “info.imprim”.
Where can I find information about it?



Hi Nicola,

Welcome on this forum.

I am not sure of what happens. I have 2 guesses :

  • the arrays allocated by Mmg are too large (so we spend lot of time travelling empty cells) : it is a hard task to find a good balance between the number of call to reallocation operators and the number of empty cells in the arrays…
  • cache misses (maybe we need to renumber tetra / nodes to increase the locality).

Is it possible to send me your mesh and solution?

Best Regards,



Hello Algiane,
at this link, there are the .mesh and .sol files:

Changing some parameters, the metric is as in the images (we have a view inside the domain).

…and, after less than 2 hours, the situation is depicted in the following picture:

I need to do an iterative process; after this step, I need to insert the other buildings one at a time.
The problem is the hight executive time for calculating these results.

Thank you very much.

Best Regards,


Hi Nicola,

I think that the version of Mmg that you use is bugged (sorry). Is it better if you download the v5.4.00?
(on my laptop, it takes less than 16 minutes in debug mode and 9 minutes in release mode).

If you want to speed a little the step of adaptation, maybe you can try to give local parameters to Mmg (more especially, I think that you can release the hausdorff parameter on the “bounding box” triangles of reference 0 and keep the default hausdorff on the discretized isovalue (triangles of ref 10)).

For your question about the mesh->info.imprim field : it stores the verbosity level (that you can tune using the -v command line argument or the MMG3D_IPARAM_verbose keyword using the API).

Best regards,