Periodic BC with mmg3d

Hello,

I think that :

  • mmg3d does not deal with periodic BC
  • mmg3d new version remesh the boundary
  • mmg3d old version do not remesh the boundary

so how to mix between the old version mmg3d and the newest one ?
what I need is that mmg3d keep untouch two boundary of a cube and remesh all other boundary

Thanks in advance

Hello,

  1. You’re right, we don’t deal with periodic BC;
  2. yes;
  3. yes!

You can use the -nosurf option of Mmg-5 to remesh your volume mesh untouching your boundary (Mmg-4 like behaviour).

Regards,

Algiane

Ok,
Is there is any possibility to use -nosurf with boundary label ?
i.e. I want to remesh 4 surfaces (of label 0,2,4,5) of a cube and keep untouched two surfaces (of label 1,3), how it’s possible to do this?

Sincerely,
GS

Using the mmg parameters it is not possible (however, I think that it can be useful so I add it to my todo list) but you can use required entities to keep some boundaries untouched.

A short example:
I suppose that you work in 2D and want to preserve 3 boundary edges, the bdy edges of index 4, 100 and 32.

  • in library mode, you can call the MMG2D_Set_requiredEdge function on the edges that will be required:

    • MMG2D_Set_requiredEdge( mesh, 4);
      MMG2D_Set_requiredEdge( mesh, 100);
      MMG2D_Set_requiredEdge( mesh, 32);
  • In command line, you can add to your input mesh file the RequiredEdges field followed by the number of required edges, then the list of the index of the edges to mark as required:

    • RequiredEdges 3
      4
      100
      32

In 3D, you have equivalent functionnalities using the MMG3D_Set_requiredTriangle API function and the RequiredTriangles field in the input mesh file.

Regards,

Algiane

ok,
inside the mesh file, I have the infos about the triangles belonging to the boundary with there boundary label :

Triangles
96
11 1 16 4
1 11 12 1
2 1 12 1
1 2 7 5
6 7 17 3
6 1 7 5
17 16 6 3
1 6 16 4
2 12 13 1

so I can extract in a file the triangles belonging to boundary label 1 for exemple
but how to use the last file in a command line using “MMG3D_Set_requiredTriangle” and “RequiredTriangles”?

Thanks in advance

GS

Hi,

I have written a little C program (4.6 KB)
that:

  1. read a mesh file (the mesh name must be given as the first argument of the program);
  2. for each triangle, get the triangle reference;
  3. if the reference is 1, mark the triangle as required;
  4. save the mesh file (the output file name must be given as second argument of the program).

It uses the mmg3d library and its API functions so to build it:
gcc main.c -I$PATH_TO_MMG_INCLUDE_DIR/ -L$PATH_TO_MMG_LIBRARY_DIR -lmmg3d

And to run it :
./a.out input.mesh outputfile.mesh

If you open the òutput.meshfile, you can see that now you have aRequiredTriangles`field.

Of course, it is easier to do similar thing with a bash script but this program shows how to use the Mmg API and how to manipulate meshes with its library.

Moreover, if you don’t have to play with the Mmg arguments, you can add a call to the MMG3D_mmg3dlib function (API function to call the mesh adaptation module) and adapt your mesh in one command.

Regards,

Algiane


now, thanks to your script and FreeFem++ I can do parallel + PBC + adapt3D, see attached,
for info after compiling the C program with gcc, I include to my script inside FreeFem++, these following line :
savemesh(Th,“Th.mesh”);
savesol(“Th.sol”,Th, [m11,m21,m22,m31,m32,m33]);
exec("./a.out Th.mesh ThReqTri.mesh");
exec("~/mmg/build/bin/mmg3d_O3 ThReqTri.mesh -out Tho.mesh -sol Th.sol -hmin “+hmin+” -hmax “+hmax+” -hgrad 2.3 -v 0");

thanks for your help and good luck for the parallel adaptation in 3D :wink:

Sincerly
GS

Hi,

Beautiful result!
Thank you for the info on how to use the script with freefem++.

Regards,

Algiane