Output sol file with metric info from input mesh file

Hi,

I am a new mmg user and wish to do anisotropic adaptive mesh refinement using your library. I would like to do the following:

  1. obtain the metric information on mesh nodes for an existing mesh,
  2. rescale the eigenvalues of the metric at each node
  3. use this to generate a new mesh

My question is: Can mmg do step 1) for me ( through the API), or do I need to do this part myself? I noticed mmg creates a sol file for me when I give it a mesh, but this only has scalar data.

Thanks,
Mike

Dear Mike,

You can use Mmg to create an anisotropic metric associated to your mesh nodes.

However, the metric given by Mmg corresponds to its target metric when you don’t provide an input metric. Which means that this metric doesn’t correspond to your initial edge sizes: it tries to unrefine the mesh with respect to the asked geometric approximation (driven by the hausdorff parameter, -hausd option), the minimal and maximal edge sizes imposed by the user (-hmin and -hmax options) and the authorized gradation (-hgrad option).

To get the Mmg’s anisotropic size map you must:

  • say to Mmg that you just want to analyse your mesh and to compute the associated target metric.
    This can be done by running Mmg with the MMG3D_IPARAM_noinsert, MMG3D_IPARAM_nomove and MMG3D_IPARAM_noswap options setted to 1 (-noinsert -nomove -noswap in command line):
     MMG3D_Set_iparameter(mmgMesh,mmgSol,MMG3D_IPARAM_noinsert,1);
     MMG3D_Set_iparameter(mmgMesh,mmgSol,MMG3D_IPARAM_nomove,1);
     MMG3D_Set_iparameter(mmgMesh,mmgSol,MMG3D_IPARAM_noswap,1);
  • ask Mmg to perform anisotropic metric computations:
    • with the -A argument in command line;
    • by specifying that your input solution structure contains tensors at nodes if you call the library:
        if (!MMG3D_Set_solSize(mmgMesh,mmgSol,MMG5_Vertex,0,MMG5_Tensor))
           exit(EXIT_FAILURE);
  • run the Mmg library: ier = MMG3D_mmg3dlib(mmgMesh,mmgSol);

  • get the metric values at nodes:

    for (i=0; i<nvertices; ++i )
      if ( MMG3D_Get_tensorSol(mmgSol,&m11,&m12,&m13,&m22,&m23,&m33) != 1)
         exit(EXIT_FAILURE);

Note that providing a metric is not the aim of Mmg, thus, you may have some troubles. In particular:

  • Mmg uses two metric values at “ridges nodes” (non singular nodes over ridges). This metrics are associated to the surfaces that creates the sharp angle. We can only save one metric per node, thus, Mmg will arbitrary choose one of this two metrics to give it back to the user.

I hope that it will help you.

Best regards,

Algiane

Thanks Algiane! Your reply was very helpful.

Best regards,
Mike