Usage of mmg3d does not work like in doc

Hello,
I tried to use mmg3d to adapt some 3d mesh. However, it seems that the examples in the documentation pdf are not up to date. I use version 4.7 of FreeFEM.

I tried to use the command

Th3 = mmg3d(Th,options=opt);
with opt being an int[int] of size 6 as shown in the documentation.

However FreeFem gives an error that there is no option “options”. I see “opt” as an option, but it does not work. Can you please give an example of usage of mmg3d inside FreeFEM? Thank you.

Best regards,
Beniamin

You can do the following:

$ git clone -b develop https://github.com/FreeFem/FreeFem-sources
$ cd FreeFem-sources
$ git grep "load \"mmg\""
examples/3d/Laplace-Adapt-aniso-3d.edp:load "mmg"
examples/3d/Sphere-Isocahedron.edp:load "mmg"
examples/3dSurf/Pinocchio.edp:load "mmg"
examples/hpddm/laplace-adapt-3d-PETSc.edp:load "mmg"
examples/hpddm/transfer.edp:load "mmg"

You can look at any of these examples to see how to use Mmg.

1 Like

Thank you for the answer. I was able to adapt one of the examples to what I am doing.

Hello,

In the souce code it appears that :

basicAC_F0::name_and_type mmg3d_Op::name_param = {
{“metric”, &typeid(KN< double > *)}, // 0
{“displacement”, &typeid(E_Array)}, // 1
{“displVect”, &typeid(KN_< double >)}, // 2
{“opt”, &typeid(string *)}, // 3
{“Mb”, &typeid(long)} // 4
};

  • Memory usage is controled with “Mb”
  • Options are defined using “opt” string

Does anybody know the options in the string ?

Best regards.

Hello,

In the souce code it appears that :

basicAC_F0::name_and_type mmg3d_Op::name_param = {
{“metric”, &typeid(KN< double > *)}, // 0
{“displacement”, &typeid(E_Array)}, // 1
{“displVect”, &typeid(KN_< double >)}, // 2
{“opt”, &typeid(string *)}, // 3
{“Mb”, &typeid(long)} // 4
};

  • Memory usage is controled with “Mb”
  • Options are defined using “opt” string

Does anybody know the options in the string ?

As Prof. Pierre suggested, you should use the new “mmg” module (~v5.5.2) instead of the old “mmg3d-v4.0” module (~v4.0). These parameters you mentioned exist in mmg3d-v4.0 (which is an old version Mmg in 3d). If you just want to understand what these old parameters mean, you can refer to P168 in FreeFEM tutorial https://doc.freefem.org/pdf/FreeFEM-documentation.pdf.

Hi,
I use the latest version of freefem (4.9), it includes mmg3d 4.0. Do you know where to find dll file of mmg 5.5.2 (cause the mmg website only offer exe) ?

I use the latest version of freefem (4.9), it includes mmg3d 4.0. Do you know where to find dll file of mmg 5.5.2 (cause the mmg website only offer exe) ?

In FreeFem-sources/plugin/seq/mmg.cpp

That’s the source code… not sure to understand.

mmg.so is the dll file, which is generated by mmg.cpp. If you want to refer to all parameters added, you also can see mmg.cpp.

Sorry, i made a confusion, i believed that mmg.dll was for 2d and mmg3d for 3d… now it’s fine, mmg.dll contains both 2d and 3d !
Thanks.

Yes, the new version Mmg include mmgs and mmg3d

I try to use mmg3d for mesh adaption using mshmet first (to get the metric from a scalar solution) but i’m not really sure.
Did you ever used mmg for 3d mesh refinement ?

I try to use mmg3d for mesh adaption using mshmet first (to get the metric from a scalar solution) but i’m not really sure.

Right, using “Mshmet + Mmg” if you use the default metric instead of the metric constructed by yourself.

Did you ever used mmg for 3d mesh refinement ?

Yes, I used them to do mesh adaptation

I have an error during mmg 3d for a classic laplacian equation on an anisotropic mesh

h = mshmet(Th, u, normalization=true); // u is the initial solution
Th = mmg3d(Th, metric=h, mem=1000,hmin=1e-3, hmax=1e-1);

– PHASE 2 : ISOTROPIC MESHING
Assertion failed: MG_GET(pxt1->ori,voyq ), file C:/builds/workspace/deployEXE/3rdparty/ff-petsc/petsc-3.15.0/fr/externalpackages/git.mmg/src/mmg3d/colver_3d.c, line 1131
Unexpected error: *** potential lack of memory.

How to use mm3g for anisotropic meshes ?

How to use mm3g for anisotropic meshes ?

As Prof. Pierre (prj) suggested before, you can refer to the following examples to study how to use it.

examples/3d/Laplace-Adapt-aniso-3d.edp:load “mmg”
examples/3d/Sphere-Isocahedron.edp:load “mmg”
examples/3dSurf/Pinocchio.edp:load “mmg”
examples/hpddm/laplace-adapt-3d-PETSc.edp:load “mmg”
examples/hpddm/transfer.edp:load “mmg”

Yes that very good examples, i do the same.
When i activate aniso in mshmet, the metric is very strange, but with aniso=0 the metric looks better.
I want a final anisotropic mesh, so i guess i must set aniso=true ? (as you see, my initial mesh is highly anisotropic, it contains thin layers)

Moreover mmg3d doesn’t work whatever aniso.

Here my very basic script with a .sol file

Can you have a look ? Thank you for your help.

adapt.zip (192.9 KB)

Here the modified edp script with a finer mesh. The script crash when performing mmg3d.

adapt3d.zip (184.2 KB)

Yes that very good examples, i do the same.
When i activate aniso in mshmet, the metric is very strange, but with aniso=0 the metric looks better.
I want a final anisotropic mesh, so i guess i must set aniso=true ? (as you see, my initial mesh is highly anisotropic, it contains thin layers)

Moreover mmg3d doesn’t work whatever aniso.

Here my very basic script with a .sol file

Can you have a look ? Thank you for your help.

I captured two errors:

  1. hmet in your temp.edp is in P1, but it should be in [P1, P1, P1, P1, P1, P1]
  2. I’m not sure that loading your temp.mesh is right (there seems to be a problem in your temp.mesh or loading ‘temp.mesh’). For the temp.mesh and its loading, I don’t know.

Hello,

Thanks yo for your answer.

This two blocks are different ?

fespace Mh(Th,[P1, P1, P1, P1, P1, P1]);
Mh [m11,m21,m22,m31,m32,m33];
real[int] met = mshmet(Th, u, hmin=1e-3,hmax=0.2, err=errm, aniso=1);
m11 = met;

fespace Mh(Th,P1);
Mh m11;
real[int] met = mshmet(Th, u, hmin=1e-3,hmax=0.2, err=errm, aniso=1);
m11 = met;

the scalar field m11 looks very strange for a metric…

Concerning the mesh :
readmesh3 with the medit file temp.mesh indicates one warning

— Warning manifold obj nb:432 adj 446 of dim =2

The mesh comes from a brep file that i mesh with gmsh and export it as medit file. You can find file the brep file here.
I tried to use gmsh mesh file (gmshload3, no warning when loading), mmg3d doesn’t crash but it’s still running (more than 15min, then i stopped) with some worrying warnings…

Warning: MMG5_elementWeight: at least 1 negative or null density.
Warning: MMG5_movbdyregpt_ani: unable to compute optimal position for at least 1 point.

Sorry for disturbing you.

Best regards.

This two blocks are different ?

The second code block is wrong, and please note that met obtained by Mshmet describe the metric at each vertice in the mesh (It’s a flatten vector). Checking if m11[].n equals met.n before doing m11[] = met;, you can also find the wrong from this point.

Sorry, I don’t know about loading and exporting of Gmsh grids and the gmshload3 module