-
Notifications
You must be signed in to change notification settings - Fork 63
Feature: Add element and user data to mesh handle #2005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: handle-neighbor-and-ghost
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## handle-neighbor-and-ghost #2005 +/- ##
=============================================================
+ Coverage 77.42% 77.48% +0.05%
=============================================================
Files 112 112
Lines 19037 19086 +49
=============================================================
+ Hits 14739 14788 +49
Misses 4298 4298 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| * Element data for non-ghost elements can be accessed (if set) directly. | ||
| * \return Element data with data of Type mesh_class::ElementDataType. | ||
| */ | ||
| template <typename E = typename mesh_class::ElementDataType, typename = std::enable_if_t<!std::is_void<E>::value>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use proper template parameter names
| * \note You can only set element data for non-ghost elements. | ||
| * \param [in] element_data The element data to be set. | ||
| */ | ||
| template <typename E = typename mesh_class::ElementDataType, typename = std::enable_if_t<!std::is_void<E>::value>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter name
| // Resize for the case that no data vector has been set previously. | ||
| m_mesh->m_element_data.resize (m_mesh->get_num_local_elements () + m_mesh->get_num_ghosts ()); | ||
| m_mesh->m_element_data[get_element_handle_id ()] = element_data; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we could also overload the dereference operator. In my head it makes total sense that an element handle stores data and that you can access its data by dereferencing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah but then we cannot check if the user tries to set data for a ghost element
| const E& | ||
| get_element_data () const | ||
| { | ||
| return m_mesh->m_element_data[get_element_handle_id ()]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a check if the element has data in the first place?
| SC_CHECK_ABORT (!m_is_ghost_element, "Element data cannot be set for ghost elements.\n"); | ||
| // Resize for the case that no data vector has been set previously. | ||
| m_mesh->m_element_data.resize (m_mesh->get_num_local_elements () + m_mesh->get_num_ghosts ()); | ||
| m_mesh->m_element_data[get_element_handle_id ()] = element_data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| m_mesh->m_element_data[get_element_handle_id ()] = element_data; | |
| m_mesh->m_element_data[get_element_handle_id ()] = std::move(element_data); |
| t8_forest_t forest = t8_forest_new_uniform (cmesh, init_scheme, level, 1, sc_MPI_COMM_WORLD); | ||
|
|
||
| using mesh_class = t8_mesh_handle::mesh<t8_mesh_handle::competence_pack<>, void, data_per_element>; | ||
| mesh_class mesh = mesh_class (forest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| mesh_class mesh = mesh_class (forest); | |
| mesh_class mesh (forest); |
| using element_class = mesh_class::element_class; | ||
| mesh_class mesh = mesh_class (forest); | ||
| using element_class = typename mesh_class::element_class; | ||
| const mesh_class mesh = mesh_class (forest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const mesh_class mesh = mesh_class (forest); | |
| const mesh_class mesh (forest); |
| using competence_vertex_coordinates = t8_mesh_handle::competence_pack<t8_mesh_handle::cache_vertex_coordinates>; | ||
| using mesh_class_vertex = t8_mesh_handle::mesh<competence_vertex_coordinates>; | ||
| using element_class_vertex = typename mesh_class_vertex::element_class; | ||
| const mesh_class_vertex mesh_vertex = mesh_class_vertex (forest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const mesh_class_vertex mesh_vertex = mesh_class_vertex (forest); | |
| const mesh_class_vertex mesh_vertex (forest); |
| using competence_centroid = t8_mesh_handle::competence_pack<t8_mesh_handle::cache_centroid>; | ||
| using mesh_class_centroid = t8_mesh_handle::mesh<competence_centroid>; | ||
| using element_class_centroid = typename mesh_class_centroid::element_class; | ||
| const mesh_class_centroid mesh_centroid = mesh_class_centroid (forest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const mesh_class_centroid mesh_centroid = mesh_class_centroid (forest); | |
| const mesh_class_centroid mesh_centroid (forest); |
| mesh_class mesh = mesh_class (forest); | ||
| using mesh_class = t8_mesh_handle::mesh<t8_mesh_handle::cache_competences>; | ||
| using element_class = typename mesh_class::element_class; | ||
| const mesh_class mesh = mesh_class (forest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const mesh_class mesh = mesh_class (forest); | |
| const mesh_class mesh (forest); |
Closes #2006
Describe your changes here:
The mesh handle class is now able to handle element and user data. Template parameters are used to specify the classes (instead of the void* used in the forest for the user data). To specify them as template parameters, i needed to somehow pack the Competences into one template parameter (see parameter_pack.hxx) (because i wanted defaults for the element and user data classes but a parameter pack also always has to be the last template parameter). I think its a feature to have them all in one template parameter for the user and makes it easier to use (although slightly more complicated as a developer). Additionally, i can now provide predefined parameter packs e.g. cache_competences, where all cache competences are included.
The element data is stored in a vector in the mesh (and not in the elements). This is easier for the ghost exchange.
Additionally, the volume of the elements can now be accessed and cached. A tutorial used this as element data which is why i got inspired and also implemented the functionality for the handle. The calculation can be somehow complicated which is why i also provide a cached version.
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
script/find_all_source_files.scpto check the indentation of these files.License
doc/(or already has one).