Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mesh_handle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ 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 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 [mesh.hxx](mesh.hxx) defines the mesh 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.
8 changes: 3 additions & 5 deletions mesh_handle/competences.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc.,
*/

/** \file competences.hxx
* Definition of the additional competences/functionalities that can be used for the mesh class.
* Definition of the additional competences/functionalities that can be used for \ref t8_mesh_handle::mesh.
* Especially, competences to cache functionalities of elements instead of calculating them each time a function
* is called are provided.
*
Expand All @@ -33,11 +33,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc.,
* Especially for the competences to cache functionality, the access of members is not necessary,
* such that it is not obvious why we use the crtp. For competences that extend the functionality of the element,
* this is required.
* We use it for all competences for consistency and compatibility with the \ref t8_mesh_handle::element class.
* We use it for all competences for consistency and compatibility with \ref t8_mesh_handle::element.
*/

#ifndef T8_COMPETENCES_HXX
#define T8_COMPETENCES_HXX
#pragma once

#include <t8.h>
#include <t8_types/t8_operators.hxx>
Expand Down Expand Up @@ -139,4 +138,3 @@ struct cache_neighbors: t8_crtp_operator<TUnderlying, cache_neighbors>
};

} // namespace t8_mesh_handle
#endif /* !T8_COMPETENCES_HXX */
37 changes: 18 additions & 19 deletions mesh_handle/element.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc.,
*/

/** \file element.hxx
* Definition of the element class of the \ref t8_mesh_handle::mesh handle (can be ghost or mesh elements).
* Definition of an element of the \ref t8_mesh_handle::mesh handle (can be ghost or mesh elements).
*/

#ifndef T8_ELEMENT_HXX
#define T8_ELEMENT_HXX
#pragma once

#include <t8.h>
#include <t8_element.h>
Expand All @@ -39,10 +38,10 @@ along with t8code; if not, write to the Free Software Foundation, Inc.,

namespace t8_mesh_handle
{
/** Forward declaration of the \ref mesh class of the handle.
/** Forward declaration of the \ref mesh the elements will belong to.
*/
template <template <typename> class... TCompetences>
class mesh;
template <template <typename> class... TCompetence>
struct mesh;

/**
* Definition of the mesh element class of the \ref mesh handle.
Expand All @@ -51,22 +50,23 @@ class mesh;
* the function is called.
* Use the competences defined in \ref competences.hxx as template parameter to cache the functionality instead of
* recalculation in every function call.
* To add functionality to the element, you can also simply write your own competence class and give it as a template parameter.
* To add functionality to the element, you can also simply write your own competence and give it as a template parameter.
* You can access the functions implemented in your competence via the element.
* Please note that the competence should be valid for both, mesh elements and ghost elements.
*
* The inheritance pattern is inspired by the \ref T8Type class (which also uses the CRTP).
* The inheritance pattern is inspired by \ref T8Type (which also uses the CRTP).
* We decided to use this structure 1.) to be able to add new functionality easily and
* 2.) for the cached options to keep the number of class member variables of the default to a minimum to save memory.
* 2.) for the cached options to keep the number of member variables of the default element to a minimum to save memory.
* The choice between calculate and cache is a tradeoff between runtime and memory usage.
*
* \tparam TCompetences The competences you want to add to the default functionality of the element.
*/
template <template <typename> class... TCompetences>
class element: public TCompetences<element<TCompetences...>>... {
struct element: public TCompetences<element<TCompetences...>>...
{
private:
using SelfType = element<TCompetences...>; /**< Type of the current class with all template parameters specified. */
using mesh_class = mesh<TCompetences...>; /**< Type of the mesh class used. */
using SelfType = element<TCompetences...>; /**< Type of the element with all template parameters specified. */
using mesh_class = mesh<TCompetences...>; /**< Type of the mesh used. */
friend mesh_class; /**< Define mesh_class as friend to be able to access e.g. the constructor. */

/**
Expand Down Expand Up @@ -100,8 +100,8 @@ class element: public TCompetences<element<TCompetences...>>... {

// --- Variables to check which functionality is defined in TCompetences. ---
/** Helper function to check if \a TCompetence implements the function vertex_cache_filled.
* \tparam T The competence to be checked.
* \return true if T implements the function, false if not.
* \tparam TCompetence The competence to be checked.
* \return true if \a TCompetence implements the function, false if not.
*/
template <template <typename> class TCompetence>
static constexpr bool
Expand All @@ -114,8 +114,8 @@ class element: public TCompetences<element<TCompetences...>>... {
static constexpr bool vertex_cache_exists = (false || ... || vertex_cache_defined<TCompetences> ());

/** Helper function to check if \a TCompetence implements the function centroid_cache_filled.
* \tparam T The competence to be checked.
* \return true if T implements the function, false if not.
* \tparam TCompetence The competence to be checked.
* \return true if \a TCompetence implements the function, false if not.
*/
template <template <typename> class TCompetence>
static constexpr bool
Expand All @@ -128,8 +128,8 @@ class element: public TCompetences<element<TCompetences...>>... {
static constexpr bool centroid_cache_exists = (false || ... || centroid_cache_defined<TCompetences> ());

/** Helper function to check if \a TCompetence implements the function neighbor_cache_filled.
* \tparam T The competence to be checked.
* \return true if T implements the function, false if not.
* \tparam TCompetence The competence to be checked.
* \return true if \a TCompetence implements the function, false if not.
*/
template <template <typename> class TCompetence>
static constexpr bool
Expand Down Expand Up @@ -420,4 +420,3 @@ class element: public TCompetences<element<TCompetences...>>... {
};

} // namespace t8_mesh_handle
#endif /* !T8_ELEMENT_HXX */
2 changes: 1 addition & 1 deletion mesh_handle/mesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/** \file mesh.cxx
* This file is only necessary for cmake to build the library as static or shared library.
* (At least one source file is needed.)
* The implementation of the mesh class is in the header file \ref mesh.hxx as it is a
* The implementation of the mesh is in the header file \ref mesh.hxx as it is a
* templated class.
*/

Expand Down
11 changes: 5 additions & 6 deletions mesh_handle/mesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
* Definition of the mesh class of the handle.
*/

#ifndef T8_MESH_HXX
#define T8_MESH_HXX
#pragma once

#include <t8.h>
#include <t8_forest/t8_forest_general.h>
Expand All @@ -42,10 +41,11 @@ namespace t8_mesh_handle
* \see element for more details on the choice of the template parameter.
*/
template <template <typename> class... TCompetences>
class mesh {
struct mesh
{
public:
using element_class = element<TCompetences...>; /**< The element class of the mesh with given competences. */
friend element_class; /**< Element class as friend such that private members (e.g. the forest) can be accessed. */
using element_class = element<TCompetences...>; /**< The element of the mesh with given competences. */
friend element_class; /**< Declare element_class as friend such that private members (e.g. the forest) can be accessed. */
using mesh_const_iterator =
typename std::vector<element_class>::const_iterator; /**< Constant iterator type for the mesh elements. */

Expand Down Expand Up @@ -206,4 +206,3 @@ class mesh {
};

} // namespace t8_mesh_handle
#endif /* !T8_MESH_HXX */
11 changes: 6 additions & 5 deletions test/mesh_handle/t8_gtest_cache_competence.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc.,
#include <t8_types/t8_vec.hxx>
#include <vector>

/** Child class of \ref t8_mesh_handle::cache_vertex_coordinates that allows to modify the cache variable for test purposes. */
/** Child of \ref t8_mesh_handle::cache_vertex_coordinates that allows to modify the cache variable for test purposes. */
template <typename TUnderlying>
struct cache_vertex_coordinates_overwrite: public t8_mesh_handle::cache_vertex_coordinates<TUnderlying>
{
Expand All @@ -52,7 +52,7 @@ struct cache_vertex_coordinates_overwrite: public t8_mesh_handle::cache_vertex_c
}
};

/** Child class of \ref t8_mesh_handle::cache_centroid that allows to modify the cache variable for test purposes. */
/** Child of \ref t8_mesh_handle::cache_centroid that allows to modify the cache variable for test purposes. */
template <typename TUnderlying>
struct cache_centroid_overwrite: public t8_mesh_handle::cache_centroid<TUnderlying>
{
Expand All @@ -68,7 +68,8 @@ struct cache_centroid_overwrite: public t8_mesh_handle::cache_centroid<TUnderlyi
};

/** Test fixture for cache competence tests. */
class t8_gtest_cache_competence: public testing::Test {
struct t8_gtest_cache_competence: public testing::Test
{
protected:
void
SetUp () override
Expand All @@ -83,7 +84,7 @@ class t8_gtest_cache_competence: public testing::Test {
int level;
};

/** Use child class of \ref t8_mesh_handle::cache_vertex_coordinates class to check that the cache is actually set
/** Use child of \ref t8_mesh_handle::cache_vertex_coordinates to check that the cache is actually set
* and accessed correctly. This is done by modifying the cache to an unrealistic value and
* checking that the functionality actually outputs this unrealistic value.
*/
Expand Down Expand Up @@ -116,7 +117,7 @@ TEST_F (t8_gtest_cache_competence, cache_vertex_coordinates)
}
}

/** Use child class of \ref t8_mesh_handle::cache_centroid class to check that the cache is actually set
/** Use child of \ref t8_mesh_handle::cache_centroid to check that the cache is actually set
* and accessed correctly. This is done by modifying the cache to an unrealistic value and
* checking that the functionality actually outputs this unrealistic value.
*/
Expand Down
2 changes: 1 addition & 1 deletion test/mesh_handle/t8_gtest_custom_competence.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct dummy_trivial: public t8_crtp_operator<TUnderlying, dummy_trivial>
}
};

/** This tests checks that custom defined competences can be used for the mesh class
/** This tests checks that custom defined competences can be used for \ref t8_mesh_handle::mesh
* and that we can use the functionality defined in the competence.
* Also checks that we can use more than one custom competence and that predefined competences can be additionally used.
*/
Expand Down
7 changes: 4 additions & 3 deletions test/mesh_handle/t8_gtest_ghost.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc.,
#include <vector>

/** Parametrized test fixture for the ghost tests. */
class t8_mesh_ghost_test: public testing::TestWithParam<std::tuple<t8_eclass_t, int>> {
struct t8_mesh_ghost_test: public testing::TestWithParam<std::tuple<t8_eclass_t, int>>
{
protected:
void
SetUp () override
Expand Down Expand Up @@ -150,7 +151,7 @@ TEST_P (t8_mesh_ghost_test, compare_neighbors_to_forest)
}
}

/** Child class of \ref t8_mesh_handle::cache_neighbors that allows to modify the cache variables for test purposes. */
/** Child of \ref t8_mesh_handle::cache_neighbors that allows to modify the cache variables for test purposes. */
template <typename TUnderlying>
struct cache_neighbors_overwrite: public t8_mesh_handle::cache_neighbors<TUnderlying>
{
Expand All @@ -168,7 +169,7 @@ struct cache_neighbors_overwrite: public t8_mesh_handle::cache_neighbors<TUnderl
}
};

/** Use child class of \ref t8_mesh_handle::cache_neighbors class to check that the cache is actually set
/** Use child of \ref t8_mesh_handle::cache_neighbors to check that the cache is actually set
* and accessed correctly. This is done by modifying the cache variables to a unrealistic values and
* checking that the functionality actually outputs this unrealistic value.
*/
Expand Down
9 changes: 5 additions & 4 deletions test/mesh_handle/t8_gtest_mesh_handle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ along with t8code; if not, write to the Free Software Foundation, Inc.,

/**
* \file t8_gtest_mesh_handle.cxx
* Tests if the mesh class of the handle works as intended for different types of predefined template parameter classes.
* Tests if \ref t8_mesh_handle::mesh works as intended for different types of predefined template parameters.
*/

#include <gtest/gtest.h>
Expand All @@ -37,7 +37,8 @@ along with t8code; if not, write to the Free Software Foundation, Inc.,
#include <t8_schemes/t8_default/t8_default.hxx>

/** Parametrized test fixture for the mesh handle tests. */
class t8_mesh_handle_test: public testing::TestWithParam<std::tuple<t8_eclass_t, int>> {
struct t8_mesh_handle_test: public testing::TestWithParam<std::tuple<t8_eclass_t, int>>
{
protected:
void
SetUp () override
Expand All @@ -53,7 +54,7 @@ class t8_mesh_handle_test: public testing::TestWithParam<std::tuple<t8_eclass_t,
int level;
};

/** Test some default functionality and the iterator of \ref t8_mesh_handle::mesh class. */
/** Test some default functionality and the iterator of \ref t8_mesh_handle::mesh. */
TEST_P (t8_mesh_handle_test, test_iterator)
{
// --- Check default functionality. ---
Expand Down Expand Up @@ -152,7 +153,7 @@ TEST_P (t8_mesh_handle_test, test_competences)
}
}

/** Test mesh (element) class with more than one competence. */
/** Test \ref t8_mesh_handle::mesh with more than one competence. */
TEST_P (t8_mesh_handle_test, test_2_competences)
{
// --- Use competences to cache level and centroid. ---
Expand Down