Mesh a surface defined by a levelset

Dear MMG team,

I 'd like to cut 3D domains to perform different post processing. For example I 'd like a surface mesh that corresponds to a cut of the domain at a constant radius. Is it possible to do this with mmg?
Thank you very much.

Best regards

Xavier

Dear Xavier,

Thanks for using Mmg.

To cut a domain at a constant radius, you just need to provide the value of the level-set function at your mesh nodes.

Being:

  • (x,y,z) the coordinates at a mesh node P,
  • (cx,cy,cz) the coordinates of the sphere center,
  • r the sphere radius,

the value of level-set function at P is computed as:
f_p = sqrt( (x-cx)^2 + (y-cy)^2 + (z-cz)^2 ) - r

To provide the discrete values of the level-set you must use a solution file at the medit format (file with .sol extension).

Here is an example of solution file for a mesh with 4 nodes (the given solution is 0.5 for all nodes):

MeshVersionFormatted 2

Dimension
3

SolAtVertices
4
1 1
0.5
0.5
0.5
0.5

End

After the SolAtVertices keyword, you must give:

  • The number of nodes (the same as in your mesh file).
  • Then the line 1 1 gives the number of solutions at each node (for now, we only handle one solution at a node) and the type of each solution (scalar=1, vector=2, tensor=3).
  • Last, you can provide the solution at each node.

To end, you can run Mmg as explained here.

I hope this will help you.

Best regards,

Algiane.

Dear Algiane,

Thank you for your answer. If I understand correctly, this procedure builds a volume mesh for the inside of the levelset. I could get the surface mesh from this volume mesh, but in my case the levelset is not closed. I believe it is why in my case mms_ls fails. Is it correct?

An example of the meshes I’d like to do is:

For now, I compute the mesh (and interpolate the backgroud mesh metric on these surface meshes) for each cut using vtk, and then run mmgs_lib to refine/adapt.

Best regards,

Xavier

Dear Xavier,

Sorry for the response time (I was in holidays).

Our procedure build 2 volume meshes: one for the inside of the level-set and one for the outside. Then you can recover the surface mesh by deleting the volume elements.

Mmg should success to discretize an open level-set but your case is tricky: what happens when mmg_ls fails? Is there an error message?

Regards,

Algiane

Dear Algiane,

I use the library, and I set iso = 1 and ls = 0.5. The is the message I get is

– MMG3d, Release 5.1.1 (Dec 4, 2015)
Copyright © IMB-LJLL, 2004-
Aug 1 2016 15:25:30

– MMG3DLS: INPUT DATA
– INPUT DATA COMPLETED. 0.000s

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
MODULE MMG3D: IMB-LJLL : 5.1.1 (Dec 4, 2015)
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

– PHASE 1 : ANALYSIS

– MESH QUALITY 119880
BEST 0.999211 AVRG. 0.693878 WRST. 0.176603 (67132)
– PHASE 1 COMPLETED. 2.273s

– PHASE 2 : ISOTROPIC MESHING
*** Topological problem: non manifold surface at point 1398

Non orientable implicit surface. Exit program.

 NUMBER OF VERTICES      35414   CORNERS      468
 NUMBER OF EDGES          2298   RIDGES      2133
 NUMBER OF TRIANGLES     54068
 NUMBER OF ELEMENTS     127202

The mesh & solution are available here:
https://drive.google.com/open?id=0Bw6L_PG_JiMkNGJ3LU5SU0dEWXc
https://drive.google.com/open?id=0Bw6L_PG_JiMkbDl2RThjLXhNUjQ

Best regards,

Xavier

Dear Xavier,

The possibility to specify the level-set value is not implemented in the release 5.1 of Mmg. Thus it is always the 0 value of the level-set that is discretized.
I am sorry because it is really not clear (I will comment the corresponding part of the API to avoid futher errors).

In your case, the 0 value of the level-set leads to discretize a non-manifold surface and this case is not yet developed (which means that in fact we can not discretize the complex surface that you have shown in your previous example).

If you want, the develop branch of Mmg allows to specify the level-set value that should be discretized (but this branch is unstable). It works for the provided mesh and solution.

Best Regards,

Algiane

Dear Xavier,

The discretization of a specific level-set value is now available in the stable version of Mmg (release 5.2).
I close this topic.

Best regards,

Algiane