How to increase mmg numerical accuracy?

Hi all, I am using mmg3d to adapt over a user defined metric.

Testing my code and inspecting my solution file, I have found out that mmg uses a too poor accuracy to read and/or process my solution file in my specific application, getting negative eigenvalues.

For instance, if my metric tensor is (copy-and-pasted from my .sol as it is)

8097.091091209694 1804.305060489222 402.2054081399274 -72518.23294020348 -16123.96737044247 658170.7035589842

with eigenvalues (computed using the above metric output in Matlab)

2.7982e-05        112.6875        6.6656e+05

The detected metric tensor in mmg is

 2.125447e+08 4.736212e+07 1.055769e+07 -1.903568e+09 -4.232462e+08 1.727666e+10

with eigenvalues (computed using the above values of the output and rescaled using the right scale factor):

-1.9187e-05         112.6877         6.6654e+05

or with eigenvalues (provided in the mmg error message):

-1.489912e+00 2.957994e+06 1.749680e+10

or with eigenvalues (provided in the mmg error message and rescaled by the scale factor):

 -5.675855238095237e-05 1.126854857142857e+02     6.665447619047619e+05  

How can I solve this issue? (Without imposing a maximum aspect ratio, i.e. max(lambda)/min(lambda) < tol)

EDIT:
Decreasing aspect ratio tolerance, it works for only one iteration. Then, mmg computes negative eigenvalues again in the second iteration.
On the lines of “intent.c” checking the positivity of eigenvalues (line 197 and 256) I put some fprintf, and all the eigenvalues were little below zero (values like -1e-5), so that I modified those lines imposing the eigenvalues = 100*MMG5_EPSD, for instance

    if ( lambda[i] < MMG5_EPSD )
    {
        lambda[i] = 100*MMG5_EPSD;
    }

in this way it works, and produces sensible results. But the above procedure appears quite ugly. What do you think?

Hi Francesco,

Sorry for the delay of my answer (I was in holidays). I will get back to you as soon as I understand what happens exactly.

Regards,

Algiane

Hi Francesco,

Thank you for all the additional informations that you provide, it has been very helpful.

  1. I have modified the eigenvalues computation in the develop branch of the project. In most of cases, the eigenvalues remains computed with a precision of 1e-05 for a normalized matrix (as it was done before) but now, if one of the computed eigenvalue is negative, a more accurate result is asked.
    It seems working on the matrix that you provide in your exemple (tested without the scaling step).

  2. It is a good idea to enforce a positive value of the metric when a negative one is founded but I am not sure of the behaviour of Mmg in such cases. My first tests, as yours, shows that Mmg fails further ahead. Thus, for now, I prefer keeping mmg failing directly after the eigenvalue computation.

I hope that my correction will work on your test case.

Regards,

Algiane