Skip to content

Improvement: Element data for mesh handle is now defined via mesh competence#2242

Open
lenaploetzke wants to merge 4 commits intomainfrom
new-handle-mesh-competences
Open

Improvement: Element data for mesh handle is now defined via mesh competence#2242
lenaploetzke wants to merge 4 commits intomainfrom
new-handle-mesh-competences

Conversation

@lenaploetzke
Copy link
Copy Markdown
Collaborator

Describe your changes here:
Closes #2185. Update of #2184 because something got messed up in git.

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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.49%. Comparing base (8d05ca2) to head (a669865).
⚠️ Report is 16 commits behind head on new-handle-partition-and-balance.

Additional details and impacted files
@@                         Coverage Diff                          @@
##           new-handle-partition-and-balance    #2242      +/-   ##
====================================================================
- Coverage                             78.51%   78.49%   -0.02%     
====================================================================
  Files                                   115      116       +1     
  Lines                                 19196    19207      +11     
====================================================================
+ Hits                                  15071    15076       +5     
- Misses                                 4125     4131       +6     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Collaborator

@Davknapp Davknapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first round of comments.

const auto num_local_elements = this->underlying ().get_num_local_elements ();
const auto num_ghosts = this->underlying ().get_num_ghosts ();
T8_ASSERT (element_data.size () == static_cast<size_t> (num_local_elements));
m_element_data.reserve (num_local_elements + num_ghosts);
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 we don't need to reserve the memory for the vector. std::move should only swap pointers here, so we don't need to allocate new memory. However you should mention in the comment, that element_data is moved, not copied.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought i needed the reserve to avoid a reallocation if we later exchange ghost data (therefore i reserve more space then needed for element_data). What do you think?

this->underlying ().m_mesh->m_element_data.reserve (this->underlying ().m_mesh->get_num_local_elements ()
+ this->underlying ().m_mesh->get_num_ghosts ());
this->underlying ().m_mesh->m_element_data.resize (this->underlying ().m_mesh->get_num_local_elements ());
this->underlying ().m_mesh->m_element_data[this->underlying ().get_element_handle_id ()] = std::move (element_data);
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 move command should be sufficient, if I get it right that this is a std::vector again.
Otherwise I don't realy understand why you first reserve for num_local_elements + num_ghosts and then resize it to num_local_elements. Shouldn't it be enough to just allocate for num_local_elements (if we need an allocation).
If moving is enough, please tell so in the comment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes i dont need the resize (but still reserve for the ghost elements and move, see above)

@Davknapp Davknapp assigned lenaploetzke and unassigned Davknapp Mar 31, 2026
@lenaploetzke lenaploetzke assigned Davknapp and unassigned lenaploetzke Apr 1, 2026
Base automatically changed from new-handle-partition-and-balance to main April 1, 2026 15:49
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