Improvement: Step 2 tutorial and get_num_global_elements to mesh.hxx - #2371
Improvement: Step 2 tutorial and get_num_global_elements to mesh.hxx#2371Vyp3er wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2371 +/- ##
=======================================
Coverage 82.28% 82.28%
=======================================
Files 125 125
Lines 20701 20701
=======================================
Hits 17033 17033
Misses 3668 3668 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lenaploetzke
left a comment
There was a problem hiding this comment.
Thanks for your nice work :)
| /** | ||
| * Getter for the number of global elements in the mesh. | ||
| * \return Number of global elements in the mesh. | ||
| */ | ||
| t8_gloidx_t | ||
| get_num_global_elements () const | ||
| { | ||
| return t8_forest_get_global_num_leaf_elements (m_forest); | ||
| } | ||
|
|
There was a problem hiding this comment.
Could you test this function somewhere? :)
As we discussed, please open separate PRs for each feature in the future.
| t8code is a C library to manage a collection (a forest) of multiple | ||
| connected adaptive space-trees of general element types in parallel. | ||
|
|
||
| Copyright (C) 2015 the developers |
There was a problem hiding this comment.
Please always adapt the year if you are creating a new file!
|
|
||
| /** \file t8_mesh_step2_uniform_mesh.cxx | ||
| * This is step 2 of the t8code mesh handle tutorials. | ||
| * Therefor, this is the same as general/t8_step2_uniform_forest.cxx but using the mesh handle interface instead of the forest |
There was a problem hiding this comment.
| * Therefor, this is the same as general/t8_step2_uniform_forest.cxx but using the mesh handle interface instead of the forest | |
| * Therefore, this is the same as general/t8_step2_uniform_forest.cxx but using the mesh handle interface instead of the forest |
| * uniform (every element has the same refinement level) and can then be adapted | ||
| * later (see the following steps). | ||
| * Together with the cmesh, we also need a refinement scheme. This scheme tells the | ||
| * mesh how elements of each shape (t8_eclass_t) are refined, what their neighbor |
There was a problem hiding this comment.
| * mesh how elements of each shape (t8_eclass_t) are refined, what their neighbor | |
| * mesh how elements of each shape (t8_eclass_t) are refined, what their neighbors |
| * mesh how elements of each shape (t8_eclass_t) are refined, what their neighbor | ||
| * are etc. | ||
| * The default scheme in t8_schemes/t8_default/t8_default.hxx provides an implementation for | ||
| * all element shapes that t8code supports (with pyramids currently under construction). |
There was a problem hiding this comment.
| * all element shapes that t8code supports (with pyramids currently under construction). | |
| * all element shapes that t8code supports. |
Where did you copy this from? Could you maybe also adapt it also there? :) The scheme for pyramids is usable :)
| t8_global_productionf (" [tutorial] Wrote mesh to vtu files:\t%s*\n", prefix); | ||
|
|
||
| /** Destroy the mesh. */ | ||
| mesh.reset (); |
There was a problem hiding this comment.
Yes, this destroys the mesh but by resetting the unique pointer to nullptr.
I prefer the {} lifetime declaration as in the other tutorials because we have no leftover pointer :)
There was a problem hiding this comment.
(The cool part about the mesh is that you do not need to destroy the mesh mannually), only need the {} for the lifetime, please also explain this in a comment
| * \return A uniform mesh with the given refinement level that is | ||
| * partitioned across the processes in \a comm. | ||
| */ | ||
| static std::unique_ptr<t8_mesh_handle::mesh<t8_mesh_handle::all_cache_element_competences>> |
There was a problem hiding this comment.
I am not sure if its maybe better to write a templated function here.
|
|
||
| /* Build the uniform mesh, it is automatically partitioned among the processes. */ | ||
| auto mesh = t8_mesh_handle::handle_new_uniform<t8_mesh_handle::mesh<t8_mesh_handle::all_cache_element_competences>> ( | ||
| cmesh, scheme, level, comm, false); |
There was a problem hiding this comment.
As the last parameter is optional, and we want to write a tutorial that is as easy as possible, i would leave out the false here.
| const t8_scheme *scheme = t8_scheme_new_default (); /** Default refinement scheme. */ | ||
|
|
||
| /* Build the uniform mesh, it is automatically partitioned among the processes. */ | ||
| auto mesh = t8_mesh_handle::handle_new_uniform<t8_mesh_handle::mesh<t8_mesh_handle::all_cache_element_competences>> ( |
There was a problem hiding this comment.
Auto is in general fine here but could you state the full type here such that it is clear why we return a unique pointer?
| * \return A uniform mesh with the given refinement level that is | ||
| * partitioned across the processes in \a comm. | ||
| */ | ||
| static std::unique_ptr<t8_mesh_handle::mesh<t8_mesh_handle::all_cache_element_competences>> |
There was a problem hiding this comment.
unique_ptr is declared in header, could you include it?
…mesh.hxx.
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).