Skip to content

Improvement: Mesh handle tutorials - #2348

Open
Vyp3er wants to merge 25 commits into
DLR-AMR:mainfrom
Vyp3er:mesh_handle_tutorials
Open

Vyp3er wants to merge 25 commits into
DLR-AMR:mainfrom
Vyp3er:mesh_handle_tutorials

Conversation

@Vyp3er

@Vyp3er Vyp3er commented Jun 22, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes here:

All these boxes must be checked by the AUTHOR before requesting review:

  • The PR is small enough to be reviewed easily. If not, consider splitting up the changes in multiple PRs.
  • The title starts with one of the following prefixes: Documentation:, Bugfix:, Feature:, Improvement: or Other:.
  • If the PR is related to an issue, make sure to link it.
  • The author made sure that, as a reviewer, he/she would check all boxes below.

All these boxes must be checked by the REVIEWERS before merging the pull request:

As a reviewer please read through all the code lines and make sure that the code is fully understood, bug free, well-documented and well-structured.

General

  • The reviewer executed the new code features at least once and checked the results manually.
  • The code follows the t8code coding guidelines.
  • New source/header files are properly added to the CMake files.
  • The code is well documented. In particular, all function declarations, structs/classes and their members have a proper doxygen documentation. Make sure to add a file documentation for each file!
  • README.md files are updated if necessary.
  • All new algorithms and data structures are sufficiently optimal in terms of memory and runtime (If this should be merged, but there is still potential for optimization, create a new issue).

Tests

  • The code is covered in an existing or new test case using Google Test.
  • The code coverage of the project (reported in the CI) should not decrease. If coverage is decreased, make sure that this is reasonable and acceptable.
  • Valgrind doesn't find any bugs in the new code. This script can be used to check for errors; see also this wiki article.

If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):

  • Should this use case be added to the github action?
  • If not, does the specific use case compile and all tests pass (check manually).

Scripts and Wiki

  • If a new directory with source files is added, it must be covered by the scripts/internal/find_all_source_files.sh to check the indentation of these files.
  • If this PR introduces a new feature, it must be covered in an example or tutorial and a Wiki article.

License

  • The author added a BSD statement to doc/ (or already has one).

@Vyp3er Vyp3er changed the title Mesh handle tutorials Improvement: Mesh handle tutorials Jul 1, 2026
@Vyp3er
Vyp3er marked this pull request as ready for review July 1, 2026 08:46
@lenaploetzke
lenaploetzke self-requested a review July 1, 2026 08:52
@lenaploetzke lenaploetzke self-assigned this Jul 1, 2026
@codecov

codecov Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.80%. Comparing base (e1593be) to head (80cbf78).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2348   +/-   ##
=======================================
  Coverage   82.80%   82.80%           
=======================================
  Files         139      139           
  Lines       21584    21584           
=======================================
  Hits        17872    17872           
  Misses       3712     3712           

☔ 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.

@lenaploetzke lenaploetzke 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.

Partial review. Thank you for your work, this is really nice and my comments are mainly documentation! :)

Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_forest.cxx
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_forest.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_forest.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_forest.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_forest.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_forest.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_forest.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_forest.cxx Outdated
Comment thread tutorials/CMakeLists.txt
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_forest.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated

@lenaploetzke lenaploetzke 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.

Review adapt callback file

Comment thread tutorials/mesh_handle/t8_mesh_tutorials_common.hxx Outdated
Comment thread tutorials/mesh_handle/default_adapt_callback.hxx Outdated
Comment thread tutorials/mesh_handle/default_adapt_callback.hxx Outdated
Comment thread tutorials/mesh_handle/default_adapt_callback.hxx Outdated
Comment thread tutorials/mesh_handle/default_adapt_callback.hxx Outdated
Comment thread tutorials/mesh_handle/default_adapt_callback.hxx Outdated
Comment thread tutorials/mesh_handle/default_adapt_callback.hxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
@lenaploetzke

lenaploetzke commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Could you please have a look at the failing workflows?
Please also make sure in the future to try your code once before committing.

Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
@lenaploetzke lenaploetzke assigned Vyp3er and unassigned lenaploetzke Jul 22, 2026

@lenaploetzke lenaploetzke 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.

Most things are just typos and capitalization.

Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_tutorials_common.hxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_tutorials_common.hxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
@lenaploetzke lenaploetzke removed their assignment Aug 6, 2026
Vyp3er and others added 2 commits August 10, 2026 13:43
Co-authored-by: lenaploetzke <70579874+lenaploetzke@users.noreply.github.com>
@Vyp3er Vyp3er assigned lenaploetzke and unassigned Vyp3er Aug 10, 2026
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
@lenaploetzke lenaploetzke assigned Vyp3er and unassigned lenaploetzke Aug 14, 2026
@Vyp3er Vyp3er assigned lenaploetzke and unassigned Vyp3er Aug 23, 2026
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
@lenaploetzke lenaploetzke assigned Vyp3er and unassigned lenaploetzke Sep 11, 2026
@Vyp3er Vyp3er assigned lenaploetzke and unassigned Vyp3er Oct 1, 2026

@lenaploetzke lenaploetzke 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.

Thanks for your work :) I am sorry for all the comments but i think consistency is really important for tutorials that a beginner should learn with :)

Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step3_adapt_mesh.cxx
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx
Comment thread tutorials/mesh_handle/t8_mesh_step5_element_data.cxx
@lenaploetzke lenaploetzke assigned Vyp3er and unassigned lenaploetzke Oct 2, 2026
@Vyp3er Vyp3er assigned lenaploetzke and unassigned Vyp3er Oct 8, 2026
Create a coarse mesh, output it to vtu and destroy it. We need a coarse mesh to initialize our mesh handle mesh.

[step2] -
[step2] (mesh_handle/t8_mesh_step2_uniform_mesh.cxx) -

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.

I think the space between ] ( is too much. In the readme, this is not clickable :)

[step4] (mesh_handle/t8_mesh_step4_partition_balance_ghost.cxx) -
Partitioning, balancing and creating a ghost layer for a mesh.

[step5](mesh_handle/t8_mesh_step5_element_data.cxx) -

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.

Moreover i thinkk the mesh_handle/ is too much. You can check this in github by just switching the branch. Please check that all links work.


/* Printing the mesh information. */
print_stats_and_export (*mesh, "Ghost mesh", prefix_ghost);
int ghost_elements = mesh->get_num_ghosts ();

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.

This also does not return type int right

Comment on lines +73 to +76
/** This is not doing anything here, because we only adapt once before this line,
* so the difference between elements is +1 or -1 at most.
* We still include it here for demonstration purposes.
*/

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.

Suggested change
/** This is not doing anything here, because we only adapt once before this line,
* so the difference between elements is +1 or -1 at most.
* We still include it here for demonstration purposes.
*/

Sorry i think this is not true although i said it... Because you can of course coarsen one element and refine its neighbor so we have a level diff of 2

t8_global_productionf (" [mesh_step4] Total elements: %li \n", global_elements);

/* Writing the mesh to vtu and pvtu files, using the extended version of the function to ensure additional data like ghost elements, treeid etc. to be written into the files. */
t8_mesh_handle::write_mesh_to_vtk_ext (mesh, prefix, 0, nullptr, true, true, true, true, true, false, false);

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.

There are many bools, can you maybe add inline comments like /* write_treeid */ true, /* write_mpirank */ true
?

t8_global_productionf (" [mesh_step4] Adapt the mesh.\n");
t8_global_productionf (" [mesh_step4] \n");

/** Call adaption helper function. */

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.

This /** style comments are only for declarations for doxygen. So please use normal /* comments inside function bodies.

#include <mesh_handle/mesh.hxx> /** General mesh header. Always needed for mesh_handle code. */
#include <mesh_handle/mesh_io.hxx> /** Used to export mesh to vtk files. */
#include <mesh_handle/constructor_wrappers.hxx> /** Wrapper for basic cmesh to mesh_handle conversions. */
#include <mesh_handle/concepts.hxx> /** Include this to use c++ concepts related to the mesh handle. This can be used to constrain the template parameters to only allow mesh handle classes. */

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.

concept is not used here because of your using mesh type

#include <mesh_handle/mesh_io.hxx> /** Used to export mesh to vtk files. */
#include <mesh_handle/constructor_wrappers.hxx> /** Wrapper for basic cmesh to mesh_handle conversions. */
#include <mesh_handle/concepts.hxx> /** Include this to use c++ concepts related to the mesh handle. This can be used to constrain the template parameters to only allow mesh handle classes. */
#include <t8_types/t8_vec.hxx> /** t8 vector dataclass. */

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.

Do you use this here explicitly?

* \param [in] mesh The initial mesh to adapt.
* \param [in] adapt_params The adaptation parameters to use for the adaptation.
*/

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.

Why the blank lines? Please remove these everywhere in the file

* outside of a given sphere.
*
* \tparam TMeshClass The mesh handle class.
* \param[in] mesh The mesh that should be adapted.

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.

I think everywhere else in the tutorials you used \param [in] right so with a space

This branch has not been deployed

No deployments
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.

2 participants