-
Notifications
You must be signed in to change notification settings - Fork 74
Feature: Added Element Methods (get_reference_coordinates, element_is_equal, t8_forest_leaf_face_orientation) #2360
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
Open
Vyp3er
wants to merge
17
commits into
DLR-AMR:main
Choose a base branch
from
Vyp3er:element_methods
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+56
−0
Open
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
05c741b
First Changes and File Creation
53199cb
Spellchecking correct
665d24c
Mesh_handle_tutorial Step3
9523fc5
Mesh_handle_tutorial Step3
604e003
Mesh_handle_tutorial Step3 fixed and Step4 added.
282f592
added bsd license
9f7696b
Merge remote-tracking branch 'origin/main' into mesh_handle_tutorials
bd84430
spell checking corrected
4042c00
Added get_reference_coordinates, element_is_equal, forest_leaf_face_o…
8f489fd
Apply suggestion from @lenaploetzke
Vyp3er 9faa3b1
Reverting unnecessary files
e3eb6c3
Adapted Pull request changes
a455900
Fixed test errors.
eb7b6e5
Merge remote-tracking branch 'origin' into element_methods
abdcdf1
Fixed documentation for doxygen test
c1dd824
Fixed gtests
4b91354
Removed unnecessary includes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| I place my contributions to t8code under the FreeBSD license. Vincent Schmitt (vinz@vincent-schmitt.de) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -583,6 +583,45 @@ class element: public TCompetences<element<TMeshClass, TCompetences...>>... { | |
| return m_is_ghost_element; | ||
| } | ||
|
|
||
| // get_reference_coordinates | ||
|
Vyp3er marked this conversation as resolved.
Outdated
|
||
| /** Function to convert points in reference space of an element to points of the | ||
|
Vyp3er marked this conversation as resolved.
Outdated
|
||
| * reference space of the tree. | ||
| * \param [in] ref_coords Pointer to the reference coordinates of the element. | ||
| * \param [in] num_coords Number of reference coordinates to convert. | ||
| * \param [out] tree_ref_coords Pointer to the reference coordinates of the tree. | ||
| */ | ||
| void | ||
| get_reference_coordinates (const double* ref_coords, std::size_t num_coords, double* tree_ref_coords) const | ||
|
Vyp3er marked this conversation as resolved.
Outdated
|
||
| { | ||
| t8_forest_get_scheme (m_mesh->m_forest) | ||
| ->element_get_reference_coords (get_tree_class (), m_element, ref_coords, num_coords, tree_ref_coords); | ||
| } | ||
|
|
||
| // element_is_equal | ||
| /** Check if two elements are equal. | ||
|
Vyp3er marked this conversation as resolved.
|
||
| * \param [in] elem1 The first element. | ||
| * \param [in] elem2 The second element. | ||
| * \return true if the elements are equal, false if they are not equal. | ||
| */ | ||
| bool | ||
| is_equal (const SelfType& elem1, const SelfType& elem2) const | ||
| { | ||
| return t8_forest_get_scheme (m_mesh->m_forest) | ||
| ->element_is_equal (get_tree_class (), elem1.get_forest_element (), elem2.get_forest_element ()); | ||
| } | ||
|
|
||
| //t8_forest_leaf_face_orientation | ||
| /** Compute the orientation of a face of an element with respect to its neighbor. | ||
| * \param [in] face The index of the face for which the orientation should be computed. | ||
| * \return The orientation of the face with respect to its neighbor. Returns 0 if the face has no neighbor. | ||
| */ | ||
|
Vyp3er marked this conversation as resolved.
Outdated
|
||
| int | ||
| get_face_orientation (int face) const | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very cool function, could you maybe use this one in dg_competences.hxx? |
||
| { | ||
| return t8_forest_leaf_face_orientation (m_mesh->m_forest, m_tree_id, t8_forest_get_scheme (m_mesh->m_forest), | ||
| m_element, face); | ||
| } | ||
|
|
||
| private: | ||
| // --- Private member variables. --- | ||
| TMeshClass* m_mesh; /**< Pointer to the mesh the element is defined for. */ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| /* | ||
| This file is part of t8code. | ||
| 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 | ||
|
|
||
| t8code is free software; you can redistribute it and/or modify | ||
| it under the terms of the GNU General Public License as published by | ||
| the Free Software Foundation; either version 2 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| t8code is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU General Public License | ||
| along with t8code; if not, write to the Free Software Foundation, Inc., | ||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| */ | ||
|
|
||
| /** \file t8_mesh_step3_adapt_forest.cxx | ||
| * This is the same as general/t8_step3_adapt_forest.cxx but using the mesh handle interface instead of the forest | ||
| * interface. | ||
| */ | ||
|
|
||
| #include <t8.h> | ||
| #include <mesh_handle/mesh.hxx> | ||
| #include <mesh_handle/competence_pack.hxx> | ||
| #include <mesh_handle/constructor_wrappers.hxx> | ||
| #include <mesh_handle/mesh_io.hxx> | ||
| #include <mesh_handle/concepts.hxx> | ||
| #include <t8_types/t8_vec.hxx> | ||
| #include <memory> | ||
| #include <span> | ||
|
|
||
| /* The data that determines the adaptation characteristics of our algorithm. | ||
| * In this example we want to adapt in a spherical shape around a given point. */ | ||
| struct adapt_data | ||
| { | ||
| std::array<double, 3> midpoint; /**< midpoint of our sphere. */ | ||
| double refine_radius; /**< We refine inside this radius of our sphere.*/ | ||
| double coarsen_radius; /**< We coarsen outside this radius of our sphere. */ | ||
| }; | ||
|
|
||
| /** The adaption callback function. This will refine elements inside of a given sphere and coarsen the elements | ||
| * outside of a given sphere. | ||
| * \tparam TMeshClass The mesh handle class. | ||
| * \param [in] mesh The mesh that should be adapted. | ||
| * \param [in] elements One element or a family of elements to consider for adaptation. | ||
| * \param [in] adapt_data The user data to be used during the adaptation process. | ||
| * \returns 1 if the first entry in \a elements should be refined, | ||
| * -1 if the family of elements should be coarsened, | ||
| * 0 else. | ||
| */ | ||
| template <t8_mesh_handle::T8MeshType TMeshClass> | ||
| int | ||
| adapt_callback ([[maybe_unused]] const TMeshClass &mesh, std::span<const typename TMeshClass::element_class> elements, | ||
| const adapt_data &adapt_data) | ||
| { | ||
| auto element_centroid = elements[0].get_centroid (); | ||
| double dist = t8_dist<t8_3D_vec, t8_3D_vec> (element_centroid, adapt_data.midpoint); | ||
| if (dist < adapt_data.refine_radius) { | ||
| return 1; // refine | ||
| } //first check if there is a family, and only if yes check if we should coarsen. | ||
| else if ((elements.size () > 1) && (dist > adapt_data.coarsen_radius)) { | ||
| return -1; // coarsen | ||
| } | ||
| return 0; // do nothing | ||
| } | ||
|
|
||
| /** Build our adapted mesh by transferring the adaption parameters and adapting once with our adapt_callback function. | ||
| * \tparam TMeshClass The mesh handle class. | ||
| * \param sc_MPI_Comm The MPI Communicator. | ||
| * \param level The initial uniform refinement level. | ||
| * \returns Unique pointer to the adapted mesh. | ||
| */ | ||
| template <t8_mesh_handle::T8MeshType TMeshClass> | ||
| std::unique_ptr<TMeshClass> | ||
| build_mesh (sc_MPI_Comm comm, int level) | ||
| { | ||
| /*Generate a hybrid hypercube, made out of cubes, prisms etc. */ | ||
| auto mesh = t8_mesh_handle::handle_hypercube_hybrid_uniform_default<TMeshClass> (level, comm); | ||
| /*Defining the adaption parameters. */ | ||
| struct adapt_data adapt_params = { { 0.5, 0.5, 1.0 }, 0.2, 0.4 }; | ||
| mesh->set_balance (); | ||
| mesh->set_partition (); | ||
| /*Adapting once with our adapt_callback function. */ | ||
| mesh->set_adapt ( | ||
| TMeshClass::template mesh_adapt_callback_wrapper<adapt_data> (adapt_callback<TMeshClass>, adapt_params)); | ||
| mesh->set_ghost (); | ||
| mesh->commit (); | ||
| return mesh; | ||
| } | ||
|
|
||
| /** Entry point of the program. */ | ||
| int | ||
| main (int argc, char **argv) | ||
| { | ||
| /*Initialize MPI. This has to happen before we initialize sc or t8code. */ | ||
| int mpiret = sc_MPI_Init (&argc, &argv); | ||
| /*Error check the MPI return value. */ | ||
| SC_CHECK_MPI (mpiret); | ||
| /* Initialize the sc library, has to happen before we initialize t8code. */ | ||
| sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); | ||
| /* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */ | ||
| t8_init (SC_LP_PRODUCTION); | ||
| /* We will use MPI_COMM_WORLD as a communicator. */ | ||
| sc_MPI_Comm comm = sc_MPI_COMM_WORLD; | ||
|
|
||
| /* Print a starting message. */ | ||
| t8_global_productionf (" [tutorial] \n"); | ||
| t8_global_productionf (" [tutorial] Hello, this is the mesh adaptation example of t8code using the mesh handle.\n"); | ||
| t8_global_productionf (" [tutorial] In this example we will adapt a mesh in a spherical shape around a given point " | ||
| "and write the adapted mesh to a vtu file.\n"); | ||
| t8_global_productionf (" [tutorial] \n"); | ||
|
|
||
| using mesh_type = t8_mesh_handle::mesh<>; | ||
|
|
||
| t8_global_productionf (" [tutorial] \n"); | ||
| t8_global_productionf (" [tutorial] Creating an adapted mesh.\n"); | ||
| t8_global_productionf (" [tutorial] \n"); | ||
| /* The initial uniform refinement level. */ | ||
| int uniform_level = 3; | ||
| /* Building the Mesh*/ | ||
| auto mesh = build_mesh<mesh_type> (comm, uniform_level); | ||
| /* Write the mesh to a vtu file. */ | ||
| t8_global_productionf (" [tutorial] \n"); | ||
| t8_global_productionf (" [tutorial] Writing adapted mesh to vtu file: adapted_mesh.vtu\n"); | ||
| t8_global_productionf (" [tutorial] \n"); | ||
| t8_mesh_handle::write_mesh_to_vtk (*mesh, "adapted_mesh.vtu"); | ||
|
|
||
| sc_finalize (); | ||
| mpiret = sc_MPI_Finalize (); | ||
| SC_CHECK_MPI (mpiret); | ||
| return 0; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.