Skip to content

Improvement: Step 2 tutorial and get_num_global_elements to mesh.hxx - #2371

Open
Vyp3er wants to merge 4 commits into
DLR-AMR:mainfrom
Vyp3er:step_2_creating_uniform_mesh_tutorial
Open

Improvement: Step 2 tutorial and get_num_global_elements to mesh.hxx#2371
Vyp3er wants to merge 4 commits into
DLR-AMR:mainfrom
Vyp3er:step_2_creating_uniform_mesh_tutorial

Conversation

@Vyp3er

@Vyp3er Vyp3er commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

…mesh.hxx.

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 marked this pull request as ready for review July 20, 2026 14:02
@codecov

codecov Bot commented Jul 20, 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 (34b8c2a).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2371   +/-   ##
=======================================
  Coverage   82.28%   82.28%           
=======================================
  Files         125      125           
  Lines       20701    20703    +2     
=======================================
+ Hits        17033    17035    +2     
  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 self-assigned this Jul 21, 2026
@lenaploetzke
lenaploetzke self-requested a review July 21, 2026 07:55

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

Thanks for your nice work :)

Comment thread mesh_handle/mesh.hxx
Comment thread tutorials/mesh_handle/t8_mesh_step2_uniform_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step2_uniform_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step2_uniform_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step2_uniform_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step2_uniform_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step2_uniform_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step2_uniform_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step2_uniform_mesh.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_step2_uniform_mesh.cxx Outdated
@lenaploetzke lenaploetzke assigned Vyp3er and unassigned lenaploetzke Jul 27, 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.

Thank you, i think we are nearly ready to merge here

/* Build the uniform mesh, it is automatically partitioned among the processes. */
std::unique_ptr<MeshType> mesh = t8_mesh_handle::handle_new_uniform<MeshType> (cmesh, scheme, level, comm);

t8_global_productionf (" [t8_step2] Constructed uniform mesh with refinement level %d.\n", level);

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 do like t8_step2 better but maybe mesh_step2 is even better? Then it is clear that we are not in the general folder? Sorry for the inconvenience. And you missed one in l. 61

#include <t8.h> /** General t8code header, always include this. */
#include <mesh_handle/mesh.hxx> /** General Mesh Header, always needed for mesh_handle code. */
#include <t8_cmesh/t8_cmesh.h> /** cmesh definition and basic interface. */
#include <mesh_handle/constructor_wrappers.hxx> /** Wrapper for basic Cmesh to mesh_handle conversions. */

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/constructor_wrappers.hxx> /** Wrapper for basic Cmesh to mesh_handle conversions. */
#include <mesh_handle/constructor_wrappers.hxx> /** Wrapper for basic cmesh to mesh_handle conversions. */

#include <t8_cmesh/t8_cmesh.h> /** cmesh definition and basic interface. */
#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 <t8_schemes/t8_default/t8_default.hxx> /** default refinement scheme. */

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_schemes/t8_default/t8_default.hxx> /** default refinement scheme. */
#include <t8_schemes/t8_default/t8_default.hxx> /** Default refinement scheme. */

#include <memory>

/** Builds cmesh of 2 prisms that build up a unit cube.
* See step1 for a detailed description.

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
* See step1 for a detailed description.
* See \ref tutorials/general/t8_step1_coarsemesh.cxx for a detailed description.

* \return A uniform mesh with the given refinement level that is
* partitioned across the processes in \a comm.
*/
template <typename MeshType>

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.

In general, we start template parameters with T. I used TMeshClass throughout the code.
Please also add a doxygen doc for this. You could also use the concept t8_mesh_handle::T8MeshType here (and include the concepts header.). I think its maybe cool to learn about the concept here. (also add a comment about the concept then.)


/** Print a message on the root process. */
t8_global_productionf (" [t8_step2] \n");
t8_global_productionf (" [t8_step2] Hello, this is the step2 example of t8code using the mesh handle.\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.

Suggested change
t8_global_productionf (" [t8_step2] Hello, this is the step2 example of t8code using the mesh handle.\n");
t8_global_productionf (" [t8_step2] Hello, this is step 2 of t8code's mesh handle tutorials.\n");

/** Print a message on the root process. */
t8_global_productionf (" [t8_step2] \n");
t8_global_productionf (" [t8_step2] Hello, this is the step2 example of t8code using the mesh handle.\n");
t8_global_productionf (" [t8_step2] In this example we build our first uniform mesh and output it to vtu files.\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.

Suggested change
t8_global_productionf (" [t8_step2] In this example we build our first uniform mesh and output it to vtu files.\n");
t8_global_productionf (" [t8_step2] In this tutorial we build our first uniform mesh and output it to vtu files.\n");

/** Create the cmesh. */
t8_cmesh_t cmesh = t8_step2_build_prismcube_coarse_mesh (comm);
/**
* We will put the Mesh in a separate scope here,

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
* We will put the Mesh in a separate scope here,
* We will put the mesh in a separate scope here,

t8_cmesh_t cmesh = t8_step2_build_prismcube_coarse_mesh (comm);
/**
* We will put the Mesh in a separate scope here,
* because it will destroy itself completely on its own when reaching the end of this scope.

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
* because it will destroy itself completely on its own when reaching the end of this scope.
* because it will be destroyed automatically at the end of this scope. This is only needed because SC_CHECK_MPI checks for leftover references. Otherwise, it would be destroyed at the end of the main function.

I think we need a line break here, sorry

* because it will destroy itself completely on its own when reaching the end of this scope.
*/
{
/** Build the uniform 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 even be cleaner if we write using mesh_class= .... here and add the explanation:
The mesh class is templated so that further competences/features that are not needed by default can be added to it. This is explained in more detail in the further tutorials. In our case, the default mesh class is sufficient.

@lenaploetzke lenaploetzke removed their assignment Aug 6, 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