Local insertion of new vertices?

Hi there,
I’m relatively new to MMG, but already managed to get some very good results re-meshing sub-domains with Level set functions. However, for my work the set up seems a bit complicated and I’m hoping to improve it.
My current set-up takes an input mesh, then (1) re-meshes it in MMG using a fixed size (hsiz) which is then sampled with an implicit function. (2) That mesh is then cut at an iso-value (I do this in VTK as I need to preserve boundaries and labels (text strings) which works better within the current setup). (3) The result from (2) is then optimized in MMG to obtain the final result with all sub-domains preserved correctly. I repeat the process for multiple sub-domains and the results are really good.

However, in my field (geology), area extents can be 100’s of meter or even kilometres, whereas the domain to model can be 10’s of centimetres up to a few metres. This means step (1) needs to sample at a very fine resolution across the whole space to be able to construct the isosurface correctly.

My question is if in step (1) I can locally insert only new vertices into the existing mesh close to the zero crossing of the level set function instead of using the -hsiz option? This could save a lot or memory, and potentially processing time.

BTW, I’m using the library so advice that shows how to do it using the API are much appreciated.

Many thanks in advance,
Hilco

Hi Hilco,

To impose a non-uniform mesh size, you will have to provide an input size map to Mmg, i.e. to give the wanted edge size at each mesh node.

A very easy way to do that may be to impose the wanted size (lets call it h) at the nodes that are at a distance less than \epsilon of your level-set and to impose the maximal wanted edge size h_{max} elsewhere. Just note that your input mesh must have a reasonable size (not too coarse) and that it may be needed to iterate very few times to capture accurately enough the level-set.

In term of implementation, it gives something like this (C-code):

 /** Allocation of the size map structure (metric) at size $np$ (point number)*/
 if ( MMG3D_Set_solSize(mmgMesh,mmgSol,MMG5_Vertex,np,MMG5_Scalar) != 1 ) {
    exit(EXIT_FAILURE);
  }

  /** For each node, impose the wanted size (h near the level-set, hmax elsewhere)*/
  for(k=1 ; k<=np ; ++k) {
    double x,y,z,hloc;
    if ( MMG3D_GetByIdx_vertex(mmgMesh,x,y,z,NULL,NULL,NULL,k) !=1 ) {
      exit(EXIT_FAILURE);
    }
    if ( signed_distance(x,y,z) < epsilon ) {
      hloc = h;
    }
    else {
      hloc = hmax;
    }  
    if ( MMG3D_Set_scalarSol(mmgSol,hloc,k) != 1 ) exit(EXIT_FAILURE);
  }

  /** Mesh adaptation */
  ier = MMG3D_mmg3dlib(mmgMesh,mmgSol);

  if ( ier == MMG5_STRONGFAILURE ) {
    fprintf(stdout,"BAD ENDING OF MMG3DLIB: UNABLE TO SAVE MESH\n");
    return(ier);
  } else if ( ier == MMG5_LOWFAILURE ) {
    fprintf(stdout,"BAD ENDING OF MMG3DLIB\n");
  }

I hope that it will help!

Best Regards,
Algiane

Hi Algiane,

Many thanks for your answer. I’ll give this a go. I think it might work, but I think the iterative refinement could be a bit slow?
I was hoping that there was a Delaunay type vertex insert function that would re-distribute the tetrahedra with new points? That way I could sub-sample large tetrahedra based on the implicit function. Since there exists the ‘MMG3D_IPARAM_noinsert’ option, I thought maybe there was a way to manually insert new points.
Anyway, your answer might provide a solution and I will let you know how I get on.

Kind regards,
Hilco

Hi Hilco,

We don’t provide the possibility to call directly the insertion function (in Mmg it is not allowed to insert nodes anywhere, it is only possible in the middle of the edges).
I understand your concern about the sub-sampling and the need of a fast adaptation on the level-set: Can’t you use VTK to manually insert given vertices?

Best Regards,

Hi Algiane,

Many thanks for your response. I have tried your previous solution and that works for now. It is already faster than the -hsiz option using 2 iterations to get enough resolution.
I will likely resort to VTK for localized insertion. It does not, however, have the option to do Delaunay tesselation starting from an existing grid. But that can be adjusted :). I just hoped for a ready solution in MMG. No worries. Thanks again for your time!

Kind regards,
Hilco