Skip to content

Add progress callback support for all remeshing modules#324

Open
kmarchais wants to merge 2 commits into
MmgTools:developfrom
kmarchais:feature/progress-callback
Open

Add progress callback support for all remeshing modules#324
kmarchais wants to merge 2 commits into
MmgTools:developfrom
kmarchais:feature/progress-callback

Conversation

@kmarchais

@kmarchais kmarchais commented Apr 5, 2026

Copy link
Copy Markdown

Adds an optional progress callback to mmg3d / mmg2d / mmgs that reports iteration progress and supports cooperative cancellation (return 0 to abort). When unset (the default), the only runtime cost is a NULL check on the existing iterative loops.

PR324_progress_demo

Incidental change worth flagging: MMG5_adpdel previously discarded the return value of MMG5_optbad. With this PR a cancellation can originate inside optbad, so the return value is now checked and propagated.

Happy to add a libexamples/<module>/progress_callback/ style example as a follow-up if useful.

@CLAassistant

CLAassistant commented Apr 5, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kmarchais
kmarchais force-pushed the feature/progress-callback branch from bd75c98 to 282c297 Compare April 5, 2026 15:46
@kmarchais
kmarchais changed the base branch from master to develop April 5, 2026 15:46
@kmarchais
kmarchais force-pushed the feature/progress-callback branch from 282c297 to c58ae35 Compare May 14, 2026 09:13
@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.24%. Comparing base (ae7d305) to head (c58ae35).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #324      +/-   ##
===========================================
- Coverage    50.31%   50.24%   -0.07%     
===========================================
  Files          177      177              
  Lines        47831    47913      +82     
  Branches     10352    10372      +20     
===========================================
+ Hits         24065    24073       +8     
- Misses       16037    16099      +62     
- Partials      7729     7741      +12     

☔ View full report in Codecov by Harness.
📢 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.

@corentin-prigent corentin-prigent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello,

Thank you for your submission. As you suggested, it would be interesting to had an example to illustrate how this option is used, and specifically, how to set the function that goes into mesh.info.progressCb.

Additionnally, this option is currently only available for library usage. Is there a way to extend this option for command line execution ?

Thank you very much in advance for your answers.

@kmarchais

Copy link
Copy Markdown
Author

The latest commit adds the libexamples/mmg3d/progress_callback_example0 example and the -progress CLI option.

To get progress information from the API, create a callback function:

static int progress_cb(void *mesh, int phase, int it, int maxit,
                       int64_t nsplit, int64_t ncollapse,
                       int64_t nswap, int64_t nmove, void *user_data) {
  int pct = maxit > 0 ? 100 * (it + 1) / maxit : 100;
  if ( pct > 100 ) pct = 100;

  printf("\rprogress %3d%%", pct);
  fflush(stdout);
  return 1; /* return 0 to cancel */
}

/* before MMG3D_mmg3dlib */
MMG3D_Set_progressCallback(mmgMesh, progress_cb, NULL);

This progress information can then be used by external tools such as GUIs, Python wrappers, or custom progress bars.

To test the CLI progress bar from the repository root:
mmg3d -progress libexamples\mmg3d\adaptation_example2\2spheres.mesh

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.

3 participants