Mesh generation with MMG2D ignoring edge table

Hi Algiane,

thank you for your help. I also think there is a problem with mmg2d since I tried to first remesh the given domain boundaries to avoid small edges. I set a constant resolution for edges equals to 1m and the smallest edge is now 0.25m et the biggest 1.13m. I have the same problem with this new input mesh.

Best regards,

Pierre

Hi Pierre,

I just push (in develop branch) some modifications in mmg2d to correct your bug (it was due to the epsilon machine management).

There is still 2 epsilon values that are maybe too large in Mmg but as your test case seems to work, I prefer not changing it.

Let me know if you encounter other similar problems.

Regards,

Algiane

Hi Algiane,

I have tried the develop branch for 2d mesh generation. As you mentioned, it works well with the mesh I had given (“input_boundary.mesh”) using exe.

I have done a new test calling mesh generation functions form the lib. In this case, there is still the “unexpected edge table” message. There is something interesting: in my code, I save the input mesh used in MMG2D_mmg2dmesh(…) : ok_with_exe.mesh (29.9 KB)

I tried to use this mesh with the exe (./mmg2d_O3d -hmax 1 ok_with_exe.mesh out.mesh). Everything is ok.
But using the lib function
MMG2D_mmg2dmesh(…) it does not work.

Do you think I do something wrong in the initialization of mesh data?

The function I used before running mesh generation are (in this order):

MMG2D_Init_mesh(… );
MMG2D_Set_meshSize( … );
MMG2D_Set_vertex( … ); and MMG2D_Set_requiredVertex( …); for each vertex
MMG2D_Set_edge(… ); and MMG2D_Set_requiredEdge( … ); for each edge
MMG2D_Set_solSize( … );
MMG2D_Set_scalarSol(… ); for each vertex
MMG2D_saveMesh(…);

Thank you for the help

Pierre

Hi Pierre,

  1. When you run your test case in command line, do you use a metric too?

  2. This test case is hard because it is very close to the machine epsilon. Maybe you are loosing the double precision somewhere. I have check the library call, it seems to work. (I haven’t use the set_vertex function, I have used the loadMesh one). If you call the saveMesh function after the mesh setters and then the loadMesh function and the library, does it works?

Regards,

Algiane

Hi Algiane,

thanks for answering.
For your first question, I do not use a metric pour le test case in command line. Maybe the difference comes from that point.

I will do the test you mention in #2, and I will come back to you. Is there a way to impose the double precision?

Best regards,
Pierre

Hi,

I have made 2 tests: saving the metric in a .sol file et using both .mesh and .sol in the command line: no problem.
I tried to saveMesh and then to loadMesh, there is a crash (seg fault) when loading (in file inout_2d.c line 96).

EDIT: I was forgetting to init the new mesh object before loading. There is no more crash but the edge table is still ignored. How to set (and test) double precision?

Best regards,
Pierre

In which language is your code? In C, you must use the “double” declaration, in fortran the REAL(KIND=8) one…

I am not sure but you can :

  • compare the mesh that you have saved and that crashes with the mesh that works. If the nodes have the same order you can check their precisions (the number of digits on which they are identical). Or you can do the same thing with a debugger in your code.

  • it reminds me that your problem may still be due to Mmg : if your nodes (or edges) are ordered differently between the mesh that works and the mesh that crashes, the process of mesh generation may fall on another bug…

Regards

  • i

The language of my code is C++. I think it is ok for double precision.

I use the same .mesh for exe and lib (see “ok_with_exe.mesh” in post #11). It crashes only using the lib.

Here is a snap of the code I use.

    MMG5_pMesh mmg_mesh_reload_ptr = nil;
    MMG5_pSol mmgSol = nil;
    MMG2D_Init_mesh( MMG5_ARG_start,
    MMG5_ARG_ppMesh, &mmg_mesh_reload_ptr, MMG5_ARG_ppMet, &mmgSol,
    MMG5_ARG_end );
    MMG2D_loadMesh( mmg_mesh_reload_ptr, "/tmp/ok_with_exe.mesh" );

    MMG2D_Set_solSize( mmg_mesh_reload_ptr, mmgSol, MMG5_Vertex,
        static_cast< int >( vertices.size() ), MMG5_Scalar );
    /// Set the metric
    for( index_t p = 0; p < vertices.size(); p++ ) {
        MMG2D_Set_scalarSol( mmgSol, resolution,
            static_cast< int >( MMG_START_ID + p ) );
    }

    MMG2D_mmg2dmesh( mmg_mesh_reload_ptr, mmg_metric_ptr );

with resolution a double (=1), MMG_START_ID = 1.

BR
Pierre

Hi Pierre,

I am not able to reproduce your bug. In your code, you call the mmg2d library with the mmg_metric_ptr metric and not the mmgSol one, are they identical?

Can you please turn on the debug mode and increase the verbosity of Mmg and send me the Mmg output?

/** Higher verbosity level */
MMG2D_Set_iparameter(mmgMesh,mmgSol,MMG2D_IPARAM_verbose,6);

/** Debug mode */
MMG2D_Set_iparameter(mmgMesh,mmgSol,MMG2D_IPARAM_debug,1);

Thank you by advance,

Regards,

Hi Algiane,

thank you for the answer. Yes the 2 metrics are identical (at least, they are defined the same way).

I run my code with debug and verbosity mode and a get the following message for each call of MMG2D_Set_scalarSol.

Error: MMG2D_Set_scalarSol: unable to set a new solution.
max number of solutions: 0

Finally I get this one:

– MMG2DMESH: INPUT DATA

WARNING: WRONG SOLUTION NUMBER : 551 != 0

There are 551 vertices in the input mesh.

Regards,
Pierre

Hi Pierre,

I wasn’t expected this kind of errors…

It seems that Mmg think that you don’t have vertices.
As you work in C++ which is very close to C, you can print the mmg_mesh_reload_ptr->np and mmg_mesh_reload_ptr->npmax fields. Normally they are non-zero.

Hope we will understand what happens…

BR

Hi Algiane,

here is the log :

mmg_mesh_reload_ptr->npmax: 0
mmg_mesh_reload_ptr->np: 0

Regards,
Pierre

PS: for the mesh I had save:
mmg_mesh_ptr->npmax: 50000
mmg_mesh_ptr->np: 551

Ok the error comes from a wrong path given for loading the mesh. So the right log is now this one:

– READING DATA FILE (null)
**WARNING NO GIVEN TRIANGLE
MAXIMUM MEMORY AUTHORIZED (MB) 2000
_MMG2D_NPMAX 50000
_MMG2D_NTMAX 100000
NUMBER OF VERTICES 551 CORNERS 0
NUMBER OF TRIANGLES 0
NUMBER OF EDGES 551
mmg_mesh_reload_ptr->npmax: 50000
mmg_mesh_reload_ptr->np: 551
mmg_mesh_ptr->npmax: 50000
mmg_mesh_ptr->np: 551
– MMG2D, Release 5.3.8 (Apr. 10, 2017)
Copyright © IMB-LJLL, 2004-
Jun 11 2018 11:55:38

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

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
MODULE MMG2D-IMB/LJLL : 5.3.8 (Apr. 10, 2017) ISO
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
MAXIMUM NUMBER OF POINTS (NPMAX) : 50000
MAXIMUM NUMBER OF TRIANGLES (NTMAX) : 100000

– PHASE 1 : MESH GENERATION
449 vertex inserted 102 not inserted
34 vertex inserted 68 not inserted
2 vertex inserted 66 not inserted
0 vertex inserted 66 not inserted
Error: MMG2_insertpointdelone: some vertex are not inserted 3.

Warning: MMG2_pack: unexpected edge table… Ignored data.
NUMBER OF VERTICES 555 CORNERS 0
NUMBER OF TRIANGLES 1098
NUMBER OF EDGES 4

Sorry for the mistake
Best
Pierre

Have you rebuild and reinstall the Mmg2d library since the last debugging? Maybe you need to remove the library by hand and to rebuild it.

I think that you run an old version of Mmg2d.

BR

You are right: I have rebuild the lib but forgot to reinstall.

OK log are not the same. Thank you for for help it works now on the mesh I gave you previously. Hurray!
Here is the corresponding log: without_line_remeshing_OK.log (8.5 KB)

But I would like to generate a mesh with constant mesh size of 1 meter. So I resampled the given mesh:
here are the new mesh and sol files : before.sol (7.7 KB)
before.mesh (148.7 KB)

Using this meshes there are issues: see attached log here: with_line_remeshing_KO.log (1.9 KB)

Thank for all the help :wink:
I feel that we are very close to solve the problem.

Best
Pierre

Hi,

I have founded another wrong epsilon in the computation of the cavity of Delaunay (the modification is pushed on the develop branch). Now it works on this mesh.

Regards,

Algiane

Hi Algiane,

I have just tried with the updated develop branch and it works perfectly. :grin:
Thanks a lot for your help.

Best regards,
Pierre

Hi Algiane,

thank again for all your help.
I have a subsidiary question about bugs you have fixed. Do mmg use exact predicates for geometrical operations?

Regards
Pierre

Hi Pierre,

You’re welcome.

Mmg doesn’t use exact geometry reconstruction. We build a boundary approximation using fourth order bezier curves computed from the normals at nodes.

Details are available section 3.2 of this paper.

Regards,

Algiane