Skip to content

Additional option to remesh only the elements of bad quality#321

Open
fsalmon001 wants to merge 4 commits intoMmgTools:developfrom
fsalmon001:localized_mesh_adaptation
Open

Additional option to remesh only the elements of bad quality#321
fsalmon001 wants to merge 4 commits intoMmgTools:developfrom
fsalmon001:localized_mesh_adaptation

Conversation

@fsalmon001
Copy link

Same functionalities as the nextsim branch, but the velocity field is incorporated within the mesh structure to avoid heavy modifications in some function variables.

@CLAassistant
Copy link

CLAassistant commented Jan 27, 2026

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.20%. Comparing base (57ccdc0) to head (7787afc).
⚠️ Report is 11 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #321      +/-   ##
===========================================
- Coverage    50.31%   50.20%   -0.11%     
===========================================
  Files          177      177              
  Lines        47845    47971     +126     
  Branches     10355    10388      +33     
===========================================
+ Hits         24071    24082      +11     
- Misses       16043    16156     +113     
- Partials      7731     7733       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fsalmon001
Copy link
Author

The corrections have been made and some comments have been added in the new commit

mesh->info.min[0]= 0.;
mesh->info.min[1]= 0.;
mesh->info.min[2]= 0.;
if (mesh->dim == 3) mesh->info.min[2]= 0.;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And otherwise? I think this field should always be initialized.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mesh->info.min[2] is not used in 2D. In addition, this is not an initialisation, but a reset of the values (see comment just above these lines). So, without the if condition, it would reset the value of min[2] while it must remain during all the adaptation

/* [0/1] ,avoid/enforce isotropic smoothing even with anisotropic metric */
mesh->info.isotropic_pt_relocation = MMG5_OFF;
/* limit angle to avoid remeshing some good triangles */
mesh->info.limit_angle = 5.*atan(1.);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a simpler value?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can. The value is just here to be high enough to avoid triggering the localized adaptation. I replaced it by 10.

/* Ridge detection */
mesh->info.dhd = MMG5_ANGEDG;
/* to adapt more thoroughly close to boundaries */
mesh->info.bdy_adaptation = MMG5_OFF;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was that variable already there? Is the name really explicit?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it wasn't. Regarding the name, I don't know, this option is to extend the mesh adaptation to boundaries using less tolerant criteria about the triangle angle and size.

\f$k^th\f$ quadrilaterals are adjacent and share their
edges \a j and \a l (resp.) */
int *ipar; /*!< Store indices of the local parameters */
double *velocity; /*!< Velocity of the vertices when Lagrangian resolution */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lagrangian_velocity?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

// #warning Luca: check consistency with 3D
}
if ( !mesh->info.noinsert ) {
if ( !mesh->info.noinsert && mesh->info.limit_angle >= 4.*atan(1.)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this value ? (it was 5 above ...)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value is just here to trigger the reduced mesh adaptation. If the user doesn't modify the limit_angle, this condition is always false. I will replace this value by M_PI to make cleaner

mesh->base++;

if (mesh->info.limit_angle <= 4*atan(1.)) mesh->info.fem = 0;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is tricky as is. Can you please comment extra ifs ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


mesh->mark = mesh->np;
for (int i = 1; i <= mesh->np; i++) mesh->point[i].tmp = -1;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The criterion on the minimal angle is applied during all the process, but the mesh is modified, and so we don't have the velocity on the new nodes during the process. We use mesh->mark and mesh->point.tmp to spot the vertices that exist since the beginning and where we have the velocity.

It changes nothing in the calculation even when the reduced adaptation is not used, so I didn't put these lines inside an if condition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants