Skip to content

Improvement: Mesh handle tutorials - #2348

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

Improvement: Mesh handle tutorials#2348
Vyp3er wants to merge 26 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.36%. Comparing base (c7d150a) to head (a0c918c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2348   +/-   ##
=======================================
  Coverage   82.36%   82.36%           
=======================================
  Files         125      125           
  Lines       20708    20708           
=======================================
  Hits        17056    17056           
  Misses       3652     3652           

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

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
Collaborator

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
Collaborator

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
Collaborator

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
auto mesh = build_mesh<mesh_type> (comm, uniform_level);
/* Write the mesh to a vtu file. */
t8_global_productionf (" [t8 step 3 Mesh handle] \n");
t8_global_productionf (" [t8 step 3 Mesh handle] Writing adapted mesh to vtu file: step3_adapted_mesh.vtu\n");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would be better to introduce a variable for the name and reusing it! That way if you change the name, you do not have to change it everywhere :)

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
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 on lines +113 to +115
t8_global_productionf (" [mesh_step3] Writing adapted mesh to vtu file: step3_adapted_mesh.vtu\n");
t8_global_productionf (" [mesh_step3] \n");
t8_mesh_handle::write_mesh_to_vtk (*mesh, "step3_adapted_mesh.vtu");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please introduce a variable file_name or something like this for the vtu file name

#include "t8_mesh_tutorials_common.hxx" /** Adaption function definition used for this tutorial. */
#include <memory>

/** Build our adapted mesh by transferring the adaption parameters and adapting once with our adapt_callback_sphere function.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/** Build our adapted mesh by transferring the adaption parameters and adapting once with our adapt_callback_sphere function.
/** Build our adapted mesh by transferring the adaption parameters and adapting once with the adapt_callback_sphere function defined in \ref t8_mesh_tutorials_common.hxx.

* according to our own criterion.
*
* The geometry (coarse mesh) is again a cube, this time modelled with
* 6 tetrahedra, 6 prisms and 4 cubes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* 6 tetrahedra, 6 prisms and 4 cubes.
* 6 tetrahedra, 6 prisms and 4 hexahedra.

I know cube is also used in the forest tutorial but we do not use "cube" for elements in general.

std::unique_ptr<TMeshClass>
build_mesh (sc_MPI_Comm comm, int level)
{
/* Generate a hybrid hypercube, made out of cubes, prisms etc. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/* Generate a hybrid hypercube, made out of cubes, prisms etc. */
/* Generate a hybrid hypercube, made out of hexahedra, prisms etc. */

build_mesh (sc_MPI_Comm comm, int level)
{
/* Generate a hybrid hypercube, made out of cubes, prisms etc. */
auto mesh = t8_mesh_handle::handle_hypercube_hybrid_uniform_default<TMeshClass> (level, comm);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you think it is clearer if we also build the mesh in the main just as in the forest step 3 tutorial? And have the function only for adaption? Maybe it is clearer to isolate only the part that is new for this tutorial.

* \param mesh The initial mesh to adapt.
*/
void
create_partitioned_balanced_mesh (const std::unique_ptr<mesh_type>& mesh)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as for adapt: we do not create a mesh here, we partition & balance an existing mesh

* \param mesh The initial mesh to adapt.
*/
void
create_ghost_mesh (const std::unique_ptr<mesh_type>& mesh)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same

void
create_ghost_mesh (const std::unique_ptr<mesh_type>& mesh)
{
/* Creating the ghost layers. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/* Creating the ghost layers. */
/* Set flag such that ghost layer is created on commit. */

true, false, false);

/**
* GHOST MESH

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* GHOST MESH
* GHOST LAYER

#include <mesh_handle/mesh_io.hxx> /** Used to export mesh to vtk files. */
#include <mesh_handle/concepts.hxx> /** Include this to use c++ concepts related to the mesh handle. This can be used to constraint the template parameters to only allow mesh handle classes. */
#include <t8_types/t8_vec.hxx> /** t8 vector dataclass. */
#include "t8_mesh_tutorials_common.hxx" /** Default adaption function. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#include "t8_mesh_tutorials_common.hxx" /** Default adaption function. */
#include "t8_mesh_tutorials_common.hxx" /** Adaption function definition used for this tutorial. */

@lenaploetzke lenaploetzke assigned Vyp3er and unassigned lenaploetzke Sep 11, 2026
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