Feature: Add interpolate data functionality to mesh handle - #2382
Feature: Add interpolate data functionality to mesh handle#2382lenaploetzke wants to merge 22 commits into
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
spenke91
left a comment
There was a problem hiding this comment.
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! 🙂
``
| * 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 |
| = 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 |
There was a problem hiding this comment.
| * \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. |
There was a problem hiding this comment.
| * 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. |
There was a problem hiding this comment.
| * 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. |
|
|
||
| /** 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! |
There was a problem hiding this comment.
| * 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. |
There was a problem hiding this comment.
| * Providing the variables is the saver implementation. | |
| * Providing the variables is the safer implementation. |
| 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. |
There was a problem hiding this comment.
| // iterate replace can be called. | |
| // iterate replace can be called, passing the mesh's callback. |
| 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"); |
There was a problem hiding this comment.
Should this even be errors?
| /** 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 (); }; | ||
| } | ||
|
|
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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...
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:
Documentation:,Bugfix:,Feature:,Improvement:orOther:.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
Tests
If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):
Scripts and Wiki
scripts/internal/find_all_source_files.shto check the indentation of these files.License
doc/(or already has one).