diff --git a/mesh_handle/README.md b/mesh_handle/README.md index 5339218920..7cb21192ec 100644 --- a/mesh_handle/README.md +++ b/mesh_handle/README.md @@ -6,6 +6,7 @@ Some application codes are designed for unstructured or uniform meshes and canno If you want to use the handle, note that is has its own library. Turn the option `T8CODE_BUILD_MESH_HANDLE` to `ON` and link against the target `T8_MESH_HANDLE` in addition to the usual t8code target please. -The [mesh.hxx](mesh.hxx) defines the mesh class of the handle. -The [element.hxx](element.hxx) defines the elements used in the mesh class. +The folder's most important files are: +The [mesh.hxx](mesh.hxx) defines the mesh class of the handle. This is the central file of the mesh handle. +The [element.hxx](element.hxx) defines the elements (mesh or ghost elements) of the mesh handle. The [competences.hxx](competences.hxx) defines additional competences/functionality of an element to access additional data. diff --git a/mesh_handle/competences.hxx b/mesh_handle/competences.hxx index c452555fd4..d4bc37a5b0 100644 --- a/mesh_handle/competences.hxx +++ b/mesh_handle/competences.hxx @@ -26,7 +26,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc., * is called are provided. * * All competences have the same inheritance pattern: - * We use the CRTP pattern as we may need to access members of the derived class \ref t8_mesh_handle::element. + * We use the CRTP pattern as we may need to access members of the derived classes like + * \ref t8_mesh_handle::element. * The t8_crtp_operator is used for convenience/clear code (avoid to type a static cast explicitly each time * we need functionality of TUnderlying). * Especially for the competences to cache functionality, the access of members is not necessary, @@ -41,8 +42,6 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#include -#include #include #include @@ -95,5 +94,49 @@ struct cache_centroid: public t8_crtp_operator m_centroid; /**< Cache for the coordinates of the centroid. Use optional to allow no value if cache is not filled. */ }; +/** + * Competence to cache the neighbors of an element at a specific face at the first function call. + * \tparam TUnderlying Use the \ref element with specified competences as template parameter. + */ +template +struct cache_neighbors: t8_crtp_operator +{ + public: + /** + * Function that checks if the neighbor cache for a face has been filled. + * \param [in] face The face for which the cache should be checked. + * \return true if the cache has been filled, false otherwise. + */ + bool + neighbor_cache_filled (int face) const + { + return m_num_neighbors[face].has_value (); + } + + /** + * Function that checks if the neighbor cache for any face has been filled. + * \return true if the cache has been filled, false otherwise. + */ + bool + neighbor_cache_filled_any () const + { + for (int iface = 0; iface < this->underlying ().get_num_faces (); ++iface) { + if (neighbor_cache_filled (iface)) { + return true; + } + } + return false; + } + + protected: + mutable std::vector> + m_neighbors; /**< Neighboring elements at each face. The length of the vectors is stored in \ref m_num_neighbors. */ + mutable std::vector> + m_num_neighbors; /**< Vector with the numbers of neighbor elements at each face. + num_neighbors is stored to indicate that the cache is filled if a face does not have any neighbor. */ + mutable std::vector> + m_dual_faces; /**< Face id's of the neighboring elements' faces for each face. */ +}; + } // namespace t8_mesh_handle #endif /* !T8_COMPETENCES_HXX */ diff --git a/mesh_handle/element.hxx b/mesh_handle/element.hxx index 685792e9f7..6701418ea9 100644 --- a/mesh_handle/element.hxx +++ b/mesh_handle/element.hxx @@ -21,7 +21,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc., */ /** \file element.hxx - * Definition of the elements used in the \ref t8_mesh_handle::mesh class. + * Definition of the element class of the \ref t8_mesh_handle::mesh handle (can be ghost or mesh elements). */ #ifndef T8_ELEMENT_HXX @@ -34,25 +34,26 @@ along with t8code; if not, write to the Free Software Foundation, Inc., #include #include #include -#include #include +#include namespace t8_mesh_handle { -/* Forward declaration of the \ref mesh class of the handle. +/** Forward declaration of the \ref mesh class of the handle. */ -template +template