Skip to content

Mesh competence tutorial - #2370

Open
Vyp3er wants to merge 13 commits into
DLR-AMR:mainfrom
Vyp3er:mesh_competence_tutorial
Open

Mesh competence tutorial#2370
Vyp3er wants to merge 13 commits into
DLR-AMR:mainfrom
Vyp3er:mesh_competence_tutorial

Conversation

@Vyp3er

@Vyp3er Vyp3er commented Jul 20, 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 marked this pull request as ready for review July 20, 2026 11:33
@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 (761d9df).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2370   +/-   ##
=======================================
  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 self-requested a review July 20, 2026 12:14
@lenaploetzke lenaploetzke self-assigned this Jul 21, 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.

Nice tutorial! Maybe a bit more of explanation would help :)

Comment thread tutorials/CMakeLists.txt Outdated
Comment thread tutorials/mesh_handle/t8_mesh_competences.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_competences.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_competences.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_competences.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_competences.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_competences.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_competences.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_competences.cxx Outdated
Comment thread tutorials/mesh_handle/t8_mesh_competences.cxx Outdated
@lenaploetzke lenaploetzke assigned Vyp3er and unassigned lenaploetzke Jul 27, 2026
* These so called competences are a way to extend the functionality of the mesh handle and its elements.
*
* The competences are organized in different types, depending the functionality.
* Element data competences are used to store data in the mesh elements and work with it in different ways

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
* Element data competences are used to store data in the mesh elements and work with it in different ways
* Element data competences are used to store data in the mesh elements and work with it in different ways.

*
* The competences are organized in different types, depending the functionality.
* Element data competences are used to store data in the mesh elements and work with it in different ways
* Cache competences are used to store data in the mesh elements to work with it more efficiently, e.g. to avoid recomputing the same data multiple times.

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
* Cache competences are used to store data in the mesh elements to work with it more efficiently, e.g. to avoid recomputing the same data multiple times.
* Cache competences are used to store data in the mesh elements to avoid recomputing the same data multiple times.


#include <t8.h> /** General t8code header. Always include this. */

#include <mesh_handle/mesh.hxx> /** General Mesh header, always needed for mesh_handle code. */

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 correct capitalization in all the descriptions pls

* Creating a simple custom competence that computes the squared volume of an element.
*
* All custom competences follow the same CRTP inheritance pattern:
* They are templated on the underlying element type and inherit from

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
* They are templated on the underlying element type and inherit from
* They are templated on the underlying element type TUnderlying and inherit from

* They are templated on the underlying element type and inherit from
* t8_crtp_operator<TUnderlying, Competence>. This gives the competence access to the functionality
* of the underlying element with using this->underlying(), allowing it to extend the element with additional methods.
* The use of t8_crtp_operator also avoids diamond-shaped inheritance when multiple competences are combined into one pack.

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
* The use of t8_crtp_operator also avoids diamond-shaped inheritance when multiple competences are combined into one pack.

I think we don't need this for the user. This would need some more explanation, i think we can leave it out

* We will now create a second mesh with our custom competence pack that includes the volume competence and our custom defined competence 'volume_squared'.
*/
/* Defining a competence pack with the volume cache competence and our custom defined competence. */
using custom_element_competences = element_competence_pack<cache_volume, volume_squared_custom_competence>;

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.

Can you also include the cache competences header?

using custom_element_competences = element_competence_pack<cache_volume, volume_squared_custom_competence>;

/* Defining a custom mesh_type with our competence pack. */
using custom_mesh = mesh<custom_element_competences>;

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
using custom_mesh = mesh<custom_element_competences>;
using custom_mesh_class = mesh<custom_element_competences>;

level);
t8_global_productionf (" [t8 Step A Mesh handle] \n");

/* Creating a custom mesh with the mesh_type including our custom competence pack and the initial refinement level 2. */

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 a custom mesh with the mesh_type including our custom competence pack and the initial refinement level 2. */
/* Creating a mesh with the mesh_type including our custom competence pack. */

t8_global_productionf (" [t8 Step A Mesh handle] \n");

/* Creating a custom mesh with the mesh_type including our custom competence pack and the initial refinement level 2. */
auto custom = handle_hypercube_hybrid_uniform_default<custom_mesh> (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.

Suggested change
auto custom = handle_hypercube_hybrid_uniform_default<custom_mesh> (level, comm);
auto custom_mesh = handle_hypercube_hybrid_uniform_default<custom_mesh> (level, comm);

auto custom = handle_hypercube_hybrid_uniform_default<custom_mesh> (level, comm);

t8_global_productionf (" [t8 Step A Mesh handle] \n");
t8_global_productionf (" [t8 Step A Mesh handle] Demonstrating the custom competence 'Squared Value'.\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 Step A Mesh handle] Demonstrating the custom competence 'Squared Value'.\n");
t8_global_productionf (" [t8 Step A Mesh handle] Demonstrating the custom competence 'squared volume'.\n");

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