Skip to content

Feature: Add interpolate data functionality to mesh handle - #2382

Open
lenaploetzke wants to merge 22 commits into
mainfrom
handle-interpolate-data
Open

Feature: Add interpolate data functionality to mesh handle#2382
lenaploetzke wants to merge 22 commits into
mainfrom
handle-interpolate-data

Conversation

@lenaploetzke

@lenaploetzke lenaploetzke commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Closes #2383
This also Closes #2115 as we dont need this functionality for the feature (expected before) and also PR #2248 is not needed anymore.
I think we can also
Closes #1654
as this completes the core functionality.

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

@lenaploetzke
lenaploetzke marked this pull request as draft August 3, 2026 06:17
@lenaploetzke
lenaploetzke marked this pull request as ready for review August 6, 2026 10:17
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.50549% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.36%. Comparing base (f63e8b8) to head (a7bdf99).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
mesh_handle/internal/interpolate.hxx 91.17% 3 Missing ⚠️
mesh_handle/mesh.hxx 93.93% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2382      +/-   ##
==========================================
+ Coverage   82.28%   82.36%   +0.08%     
==========================================
  Files         125      126       +1     
  Lines       20701    20791      +90     
==========================================
+ Hits        17033    17125      +92     
+ Misses       3668     3666       -2     

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

@spenke91 spenke91 self-assigned this Aug 10, 2026
@spenke91
spenke91 self-requested a review August 10, 2026 13:31

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

Well, that was a nice dive into modern C++ template magic! 🪄
Took some time to get it, but I think the code is quite well designed. Great work @lenaploetzke !

I only have a bunch of small remarks and questions. To avoid spamming, I mostly refrained from adding hyphen-related comments; instead I would suggest the following replacements

user defined -> user-defined
index based -> index-based
span based -> span-based
element data handling -> element-data handling

But enough of being picky! Great feature, thanks a lot! 🙂
``

Comment thread src/t8_vtk/t8_vtk.h
* This header file collects macros that are needed for
* the forest and cmesh vtk routines.
* \see t8_forest_vtk.h \see t8_cmesh_vtk_writer.h \see t8_cmesh_vtk_reader.hxx
* \see t8_forest_vtk.h \see t8_cmesh_vtk_writer.h \see t8_cmesh_vtk_reader.hxx TODO

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.

☝️

Comment thread mesh_handle/mesh.hxx
= std::function<int (const SelfType& mesh, std::span<const element_class> elements, TUserDataType user_data)>;

/** Callback function prototype to interpolate the element data after refining or coarsening.
* \note You need to include \ref interpolate_element_data_mesh_competence to you competences to be able to

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
* \note You need to include \ref interpolate_element_data_mesh_competence to you competences to be able to
* \note You need to include \ref interpolate_element_data_mesh_competence to your competences to be able to

* Use both competences together if you want to manage element data for the elements of the mesh and access it directly for each element.
* The file defines mesh and element competences for element data handling.
* The mesh competences make it possible to manage element data and exchange it for ghost elements between processes.
* The element competences makes it possible to access these element data directly for each element of the 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
* The element competences makes it possible to access these element data directly for each element of the mesh.
* The element competences makes it possible to access this element data directly for each element of the mesh.

* The file defines mesh and element competences for element data handling.
* The mesh competences make it possible to manage element data and exchange it for ghost elements between processes.
* The element competences makes it possible to access these element data directly for each element of the mesh.
* A competence to interpolate data after adaptation using a user defined callback is provided.

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
* A competence to interpolate data after adaptation using a user defined callback is provided.
* Also, a competence to interpolate data after adaptation using a user-defined callback is provided.

Comment thread mesh_handle/mesh.hxx

/** Templated callback function prototype to interpolate the element data after refining or coarsening,
* including user data.
* See the version without user_data \ref interpolate_callback_type for more details!

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 the version without user_data \ref interpolate_callback_type for more details!
* See the version without user_data \ref interpolate_callback_type for more details.

🙂

* \param [in] forest_to The committed forest that was partitioned from \a forest_from.
* \note Both forests could also be accessed directly (by this->underlying()) but this requires that the function is
* called on the exact right states of m_forest and m_uncommitted_forest.
* Providing the variables is the saver implementation.

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
* Providing the variables is the saver implementation.
* Providing the variables is the safer implementation.

Comment thread mesh_handle/mesh.hxx
SelfType new_mesh (m_uncommitted_forest.value ());
t8_forest_ref (m_uncommitted_forest.value ());
// Register the interpolate context with the callback for the new mesh. With this, the standard
// iterate replace can be called.

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
// iterate replace can be called.
// iterate replace can be called, passing the mesh's callback.

Comment thread mesh_handle/mesh.hxx
Comment on lines +531 to +536
t8_global_infof ("No interpolation context set.\n");
}
}
else {
t8_global_infof ("The element data was not interpolated during adaptation. Use set_element_data() to provide "
"new data or use the mesh competence interpolate_element_data_mesh_competence.\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.

Should this even be errors?

Comment thread mesh_handle/mesh.hxx
Comment on lines +557 to +565
/** Function that checks if a competence for the interpolation of element data is given.
* \return true if mesh has the competence, false otherwise.
*/
static constexpr bool
has_interpolate_data_competence ()
{
return requires (SelfType& mesh) { mesh.set_partition_called (); };
}

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.

Is this really a clean way of checking it has the competence? Seems strange and weird to maintain to me 🤔

static std::unordered_map<t8_forest_t, std::unique_ptr<mesh_interpolate_context_base>>&
get_map ()
{
static std::unordered_map<t8_forest_t, std::unique_ptr<mesh_interpolate_context_base>> map;

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.

The whole std::unorder_map construct seems a little over-engineered to me. Out of curiosity: Do we already know whether we might ever register more than one forest-context pair at a time? If not, maybe we could make this whole registry more lightweight. On the other hand, I also don't mind having it a little too generic and flexible...

@spenke91 spenke91 assigned lenaploetzke and unassigned spenke91 Sep 1, 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.

Feature: Add interpolate data functionality to mesh handle Mesh handle: Add set_new_element_data routine Add an unstructured mesh interface

2 participants