Skip to content

Improvement: Mesh handle tutorials#2348

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

Improvement: Mesh handle tutorials#2348
Vyp3er wants to merge 16 commits into
DLR-AMR:mainfrom
Vyp3er:mesh_handle_tutorials

Conversation

@Vyp3er

@Vyp3er Vyp3er commented Jun 22, 2026

Copy link
Copy Markdown

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.28%. Comparing base (66cd94f) to head (7b316f3).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2348   +/-   ##
=======================================
  Coverage   82.28%   82.28%           
=======================================
  Files         125      125           
  Lines       20701    20701           
=======================================
  Hits        17033    17033           
  Misses       3668     3668           

☔ 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
sc_MPI_Comm comm = sc_MPI_COMM_WORLD;

/* Print a starting message. */
t8_global_productionf (" [tutorial] \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.

We should also think of something different than "tutorial" here. Any ideas?

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
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_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
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
@@ -21,18 +21,26 @@
*/

/** \file t8_mesh_element_data.cxx
* This is the same as general/t8_step5_element_data.cxx but using the mesh handle interface instead of the forest
* This is step5 of the t8code tutorials.
* Therefor, this is the same as general/t8_step5_element_data.cxx but using the mesh handle interface instead of the forest

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
* Therefor, this is the same as general/t8_step5_element_data.cxx but using the mesh handle interface instead of the forest
* Therefore, this is the same as general/t8_step5_element_data.cxx but using the mesh handle interface instead of the forest

@@ -21,18 +21,26 @@
*/

/** \file t8_mesh_element_data.cxx
* This is the same as general/t8_step5_element_data.cxx but using the mesh handle interface instead of the forest
* This is step5 of the t8code tutorials.

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
* This is step5 of the t8code tutorials.
* This is step5 of the mesh handle tutorials.

#include <mesh_handle/mesh.hxx> /** General Mesh header. Always needed for mesh_handle code. */
#include <mesh_handle/competence_pack.hxx> /** Competence Pack for basic mesh_handle features. Look into tutorials/mesh_handle/t8_mesh_competences for more information. */
#include <mesh_handle/constructor_wrappers.hxx> /** Wrapper for basic Cmesh to mesh_handle conversions. */
#include <mesh_handle/mesh_io.hxx> /** Used to export mesh to vtk files. */
#include <mesh_handle/concepts.hxx>

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 <mesh_handle/concepts.hxx>
#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. */

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.

Could you also add this to other tutorials where needed?

@@ -100,7 +73,7 @@ build_mesh (sc_MPI_Comm comm, int level)
mesh_handle->set_balance ();
mesh_handle->set_partition ();
mesh_handle->set_adapt (
TMeshClass::template mesh_adapt_callback_wrapper<user_data> (adapt_callback<TMeshClass>, adapt_data));
TMeshClass::template mesh_adapt_callback_wrapper<adapt_data> (&default_adapt_callback<TMeshClass>, adapt_params));

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.

Could you please explain shortly why the & is valid here? :) I am not saying that it is wrong, just wondering why i left it out and why it is fine this way.

sc_MPI_Comm comm = sc_MPI_COMM_WORLD;

/* Print a starting message. */
t8_global_productionf (" [tutorial] \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.

This [tutorial] is not good. Maybe [Step 3 Mesh handle]?

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 also adapt this in all other tutorials

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

#include <mesh_handle/mesh_io.hxx> /** Used to export mesh to vtk files. */
#include <mesh_handle/concepts.hxx>
#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. */

#include <t8_types/t8_vec.hxx> /** t8 vector dataclass. */
#include "t8_mesh_tutorials_common.hxx" /** Default adaption function. */
#include <memory>
#include <span>

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 <span>

Not used anymore

#include <mesh_handle/constructor_wrappers.hxx> /** Wrapper for basic Cmesh to mesh_handle conversions. */
#include <mesh_handle/mesh_io.hxx> /** Used to export mesh to vtk files. */
#include <mesh_handle/concepts.hxx>
#include <t8_types/t8_vec.hxx> /** t8 vector dataclass. */

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_types/t8_vec.hxx> /** t8 vector dataclass. */

unused

/* Generate a hybrid hypercube, made out of cubes, prisms etc. */
auto mesh = t8_mesh_handle::handle_hypercube_hybrid_uniform_default<TMeshClass> (level, comm);
/* Defining the adaption parameters. */
struct adapt_data adapt_params = { { 0.5, 0.5, 1.0 }, 0.2, 0.4 };

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
struct adapt_data adapt_params = { { 0.5, 0.5, 1.0 }, 0.2, 0.4 };
adapt_data adapt_params = { { 0.5, 0.5, 1.0 }, 0.2, 0.4 };

I think with struct it is C code and without is modern cpp

Comment on lines +64 to +65
mesh->set_balance ();
mesh->set_partition ();

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.

Why is balance, partition and ghost here?

Comment on lines +103 to +105

/* Committing the initial mesh. */
mesh->commit ();

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.

You dont need to commit before doing something

Comment on lines +122 to +124
/* Creating the adapted mesh as a copy of the initial mesh (Initial mesh can't be refined because it is already committed.) */
auto mesh_adapt = std::make_unique<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.

I think it would be good to have seperate functions for this just as in step 3.

Comment on lines +149 to +150
/* Partitioning the mesh.*/
mesh_partition_balance->set_partition ();

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.

Balance makes no sense after adapting only once. You will need 2 times adaption for this to see a result. ( or recursive but this si not possible for the mesh handle at the moment)

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