Skip to content

Loss of precision with adaptmesh and savemesh+loadmesh #361

@cmdoug

Description

@cmdoug

This issue stems from an email discussion with Stathis Charalampidis (@echarala).

He reported inconsistencies when evaluating linear forms on adapted meshes depending on whether integration on the mesh is considered directly or after saving and loading. I suspect this issue stems from a loss of precision when saving the adapted mesh. For consistency, I believe that either the precision of Th from adaptmesh should be reduced to match that of savemesh, or the precision of savemesh should be increased to match adaptmesh. Either way, their precision should be the same.

I have included a MWE below which shows that the result of integration changes when the mesh is saved and loaded. The result loses roughly 4 significant digits of precision.

mesh Th = square(5, 5, [-1+2*x, -1+2*y]);
fespace Vh(Th,P1);
Vh fh = 10.0*x^3 + y^3 + atan2(0.0001, sin(5.0*y)-2.0*x);
varf vf(f, v) = int2d(Th)(fh*v);

Th = adaptmesh(Th, fh);
fh = fh;

real[int] array = vf(0, Vh);
cout.precision(17);
cout << array.l2 << endl;

savemesh(Th, "Th.msh");
Th = readmesh("Th.msh");

array = vf(0, Vh);
cout << array.l2 << endl;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions