From 1f40ce5d80df6ab505af6e857d4e67f69eba8e31 Mon Sep 17 00:00:00 2001 From: Ole Albers Date: Wed, 13 Nov 2024 14:37:01 +0100 Subject: [PATCH 01/12] add num_eclasses in t8_scheme_cxx --- src/t8_element.h | 3 +++ src/t8_schemes/t8_default/t8_default.cxx | 1 + 2 files changed, 4 insertions(+) diff --git a/src/t8_element.h b/src/t8_element.h index ce43592a47..4b942e3716 100644 --- a/src/t8_element.h +++ b/src/t8_element.h @@ -54,6 +54,9 @@ struct t8_scheme_cxx /** This array holds one virtual table per element class. */ t8_eclass_scheme_c *eclass_schemes[T8_ECLASS_COUNT]; + + /** Number of eclasses implemented in the scheme*/ + int num_eclasses; }; /** This array holds the reference coordinates of each vertex of each element. diff --git a/src/t8_schemes/t8_default/t8_default.cxx b/src/t8_schemes/t8_default/t8_default.cxx index 6c3f19b953..d0571565ac 100644 --- a/src/t8_schemes/t8_default/t8_default.cxx +++ b/src/t8_schemes/t8_default/t8_default.cxx @@ -72,6 +72,7 @@ t8_scheme_new_default_cxx (void) T8_ASSERT (s->eclass_schemes[T8_ECLASS_QUAD]->t8_element_maxlevel () >= s->eclass_schemes[T8_ECLASS_PYRAMID]->t8_element_maxlevel ()); + s->num_eclasses = T8_ECLASS_COUNT; return s; } From bf95e235440914b60990ece7051f6e7f12df152a Mon Sep 17 00:00:00 2001 From: Ole Albers Date: Wed, 13 Nov 2024 14:41:23 +0100 Subject: [PATCH 02/12] add iterator to test eclasses of multiple schemes --- test/t8_gtest_macros.hxx | 12 +++ test/t8_schemes/t8_gtest_iterator.cxx | 103 ++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 test/t8_schemes/t8_gtest_iterator.cxx diff --git a/test/t8_gtest_macros.hxx b/test/t8_gtest_macros.hxx index b3cdb559e2..7001dce94d 100644 --- a/test/t8_gtest_macros.hxx +++ b/test/t8_gtest_macros.hxx @@ -29,6 +29,12 @@ #include #include +#include +#include +#include + +extern t8_scheme_cxx * +t8_scheme_new_default_cxx (); /** * lambda to pass to an INSTANTIATE_TEST_SUITE_P to print the current cmesh_example_base @@ -46,6 +52,12 @@ auto print_eclass = [] (const testing::TestParamInfo &info) { return #define T8_NUM_SAMPLE_POINTS 10000 #endif +const t8_scheme_cxx *default_scheme = t8_scheme_new_default_cxx (); +const t8_scheme_cxx *sa_scheme = t8_scheme_new_default_cxx (); +const std::vector schemes = { default_scheme, sa_scheme }; +scheme_iterators scheme_iter (schemes); + +#define AllSchemesEclasses testing::ValuesIn (scheme_iter.begin (), scheme_iter.end ()) #define AllEclasses testing::Range (T8_ECLASS_ZERO, T8_ECLASS_COUNT) #define AllEclasses2D testing::Values (T8_ECLASS_QUAD, T8_ECLASS_TRIANGLE) diff --git a/test/t8_schemes/t8_gtest_iterator.cxx b/test/t8_schemes/t8_gtest_iterator.cxx new file mode 100644 index 0000000000..41aace071e --- /dev/null +++ b/test/t8_schemes/t8_gtest_iterator.cxx @@ -0,0 +1,103 @@ +#include +#include +#include +#include + +/** + * \class scheme_iterators + * Class to iterate over all eclasses of all schemes an return the t8_eclass_scheme_c*. + */ +class scheme_iterators { + public: + /** + * Initialize the iterator with a list of schemes. + * \param [in] schemes The list of schemes to iterate over. + */ + scheme_iterators (const std::vector& schemes): schemes (schemes) + { + } + + /** + * \struct Iterator + * Iterator to iterate over all eclasses of all schemes. + */ + struct Iterator + { + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; + using value_type = t8_eclass_scheme_c*; + using pointer = t8_eclass_scheme_c**; + using reference = t8_eclass_scheme_c*&; + + /** + * Constructor for the iterator. + * \param [in] schemes The list of schemes to iterate over. + * \param [in] is_end Flag to indicate if the iterator is at the end. + */ + Iterator (const std::vector& schemes, bool is_end = false) + : schemes (schemes), scheme_index (is_end ? schemes.size () : 0), eclass_index (0) + { + if (!is_end && !schemes.empty ()) { + eclass_count = schemes[scheme_index]->num_eclasses; + } + } + + /** + * Dereference operator. + * \return The current eclass scheme or tree scheme ts. + */ + t8_eclass_scheme_c* + operator* () const + { + const t8_scheme_cxx* current_scheme = schemes[scheme_index]; + return current_scheme->eclass_schemes[eclass_index]; + } + + /** + * Prefix increment operator to move the iterator to the next element. + * \return A reference to the updated iterator. + */ + Iterator& + operator++ () + { + if (++eclass_index >= eclass_count) { + eclass_index = 0; + if (++scheme_index < schemes.size ()) { + eclass_count = schemes[scheme_index]->num_eclasses; + } + } + return *this; + } + + /** + * Inequality operator to compare two iterators. + * \param [in] other Another iterator to compare with. + * \return True if the iterators are not equal, false otherwise. + */ + bool + operator!= (const Iterator& other) const + { + return scheme_index != other.scheme_index || eclass_index != other.eclass_index; + } + + private: + const std::vector& schemes; + size_t scheme_index; + size_t eclass_index; + size_t eclass_count; + }; + + Iterator + begin () const + { + return Iterator (schemes); + } + Iterator + end () const + { + return Iterator (schemes, true); + } + + private: + const std::vector& schemes; +}; From 0760a2b30037318f618c9d1e1aec60e20a717362 Mon Sep 17 00:00:00 2001 From: Ole Albers Date: Wed, 13 Nov 2024 14:43:39 +0100 Subject: [PATCH 03/12] adjust example test to work with scheme iterator --- test/t8_schemes/t8_gtest_root.cxx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/test/t8_schemes/t8_gtest_root.cxx b/test/t8_schemes/t8_gtest_root.cxx index 63d546c6b4..54d1ab359f 100644 --- a/test/t8_schemes/t8_gtest_root.cxx +++ b/test/t8_schemes/t8_gtest_root.cxx @@ -29,14 +29,12 @@ #include #include -class root: public testing::TestWithParam { +class root: public testing::TestWithParam { protected: void SetUp () override { - eclass = GetParam (); - scheme = t8_scheme_new_default_cxx (); - ts = scheme->eclass_schemes[eclass]; + ts = GetParam (); ts->t8_element_new (1, &element); ts->t8_element_root (element); } @@ -44,12 +42,9 @@ class root: public testing::TestWithParam { TearDown () override { ts->t8_element_destroy (1, &element); - t8_scheme_cxx_unref (&scheme); } t8_element_t *element; - t8_scheme_cxx *scheme; t8_eclass_scheme_c *ts; - t8_eclass_t eclass; }; /*Test root*/ @@ -68,4 +63,4 @@ TEST_P (root, equals_linear_id_0_0) ts->t8_element_destroy (1, &root_compare); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_root, root, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_root, root, AllSchemesEclasses); From 033bf70d3a60a66d29828141946c6f0a0261dbda Mon Sep 17 00:00:00 2001 From: Ole Albers <122293607+ole-alb@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:58:52 +0100 Subject: [PATCH 04/12] Update test/t8_schemes/t8_gtest_iterator.cxx Co-authored-by: David Knapp --- test/t8_schemes/t8_gtest_iterator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/t8_schemes/t8_gtest_iterator.cxx b/test/t8_schemes/t8_gtest_iterator.cxx index 41aace071e..560e79460f 100644 --- a/test/t8_schemes/t8_gtest_iterator.cxx +++ b/test/t8_schemes/t8_gtest_iterator.cxx @@ -34,7 +34,7 @@ class scheme_iterators { * \param [in] schemes The list of schemes to iterate over. * \param [in] is_end Flag to indicate if the iterator is at the end. */ - Iterator (const std::vector& schemes, bool is_end = false) + Iterator (const std::vector& schemes, const bool is_end = false) : schemes (schemes), scheme_index (is_end ? schemes.size () : 0), eclass_index (0) { if (!is_end && !schemes.empty ()) { From edbcfe36fd033ba0b3a6f2a6b22ca5ac5f2affb0 Mon Sep 17 00:00:00 2001 From: Ole Albers Date: Thu, 14 Nov 2024 14:56:30 +0100 Subject: [PATCH 05/12] add namespace for schemes in the macros --- test/t8_gtest_macros.hxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/t8_gtest_macros.hxx b/test/t8_gtest_macros.hxx index 7001dce94d..04fc77fd0e 100644 --- a/test/t8_gtest_macros.hxx +++ b/test/t8_gtest_macros.hxx @@ -52,12 +52,19 @@ auto print_eclass = [] (const testing::TestParamInfo &info) { return #define T8_NUM_SAMPLE_POINTS 10000 #endif +namespace t8code_schemes +{ const t8_scheme_cxx *default_scheme = t8_scheme_new_default_cxx (); + +// placeholder for testing two schemes const t8_scheme_cxx *sa_scheme = t8_scheme_new_default_cxx (); + const std::vector schemes = { default_scheme, sa_scheme }; + scheme_iterators scheme_iter (schemes); +} // namespace t8code_schemes -#define AllSchemesEclasses testing::ValuesIn (scheme_iter.begin (), scheme_iter.end ()) +#define AllSchemesEclasses testing::ValuesIn (t8code_schemes::scheme_iter.begin (), t8code_schemes::scheme_iter.end ()) #define AllEclasses testing::Range (T8_ECLASS_ZERO, T8_ECLASS_COUNT) #define AllEclasses2D testing::Values (T8_ECLASS_QUAD, T8_ECLASS_TRIANGLE) From 94c8e99c77f73252740e2a9bd0cc3122dcd3efb7 Mon Sep 17 00:00:00 2001 From: Ole Albers Date: Wed, 27 Nov 2024 14:14:32 +0100 Subject: [PATCH 06/12] update iterator for crtp scheme update --- test/t8_gtest_macros.hxx | 17 +++------- test/t8_schemes/t8_gtest_iterator.cxx | 46 ++++++++++++++++----------- test/t8_schemes/t8_gtest_root.cxx | 25 ++++++++------- 3 files changed, 47 insertions(+), 41 deletions(-) diff --git a/test/t8_gtest_macros.hxx b/test/t8_gtest_macros.hxx index 04fc77fd0e..927231f0cf 100644 --- a/test/t8_gtest_macros.hxx +++ b/test/t8_gtest_macros.hxx @@ -32,9 +32,7 @@ #include #include #include - -extern t8_scheme_cxx * -t8_scheme_new_default_cxx (); +#include /** * lambda to pass to an INSTANTIATE_TEST_SUITE_P to print the current cmesh_example_base @@ -52,19 +50,14 @@ auto print_eclass = [] (const testing::TestParamInfo &info) { return #define T8_NUM_SAMPLE_POINTS 10000 #endif -namespace t8code_schemes -{ -const t8_scheme_cxx *default_scheme = t8_scheme_new_default_cxx (); - -// placeholder for testing two schemes -const t8_scheme_cxx *sa_scheme = t8_scheme_new_default_cxx (); +t8_scheme *test_default_scheme = t8_scheme_new_default (); +t8_scheme *test_default_scheme_2 = t8_scheme_new_default (); -const std::vector schemes = { default_scheme, sa_scheme }; +const std::vector schemes = { test_default_scheme, test_default_scheme_2 }; scheme_iterators scheme_iter (schemes); -} // namespace t8code_schemes -#define AllSchemesEclasses testing::ValuesIn (t8code_schemes::scheme_iter.begin (), t8code_schemes::scheme_iter.end ()) +#define AllSchemesEclasses testing::ValuesIn (scheme_iter.begin (), scheme_iter.end ()) #define AllEclasses testing::Range (T8_ECLASS_ZERO, T8_ECLASS_COUNT) #define AllEclasses2D testing::Values (T8_ECLASS_QUAD, T8_ECLASS_TRIANGLE) diff --git a/test/t8_schemes/t8_gtest_iterator.cxx b/test/t8_schemes/t8_gtest_iterator.cxx index 560e79460f..4304602f90 100644 --- a/test/t8_schemes/t8_gtest_iterator.cxx +++ b/test/t8_schemes/t8_gtest_iterator.cxx @@ -2,10 +2,19 @@ #include #include #include +#include + +// Define the user-defined operator++ for t8_eclass_t +t8_eclass_t& +operator++ (t8_eclass_t& eclass) +{ + eclass = static_cast (static_cast (eclass) + 1); + return eclass; +} /** * \class scheme_iterators - * Class to iterate over all eclasses of all schemes an return the t8_eclass_scheme_c*. + * Class to iterate over all eclasses of all schemes and return the t8_scheme and the current t8_eclass_t. */ class scheme_iterators { public: @@ -13,7 +22,7 @@ class scheme_iterators { * Initialize the iterator with a list of schemes. * \param [in] schemes The list of schemes to iterate over. */ - scheme_iterators (const std::vector& schemes): schemes (schemes) + scheme_iterators (const std::vector& schemes): schemes (schemes) { } @@ -25,32 +34,33 @@ class scheme_iterators { { using iterator_category = std::forward_iterator_tag; using difference_type = std::ptrdiff_t; - using value_type = t8_eclass_scheme_c*; - using pointer = t8_eclass_scheme_c**; - using reference = t8_eclass_scheme_c*&; + using value_type = std::tuple; + using pointer = std::tuple*; + using reference = std::tuple&; /** * Constructor for the iterator. * \param [in] schemes The list of schemes to iterate over. * \param [in] is_end Flag to indicate if the iterator is at the end. */ - Iterator (const std::vector& schemes, const bool is_end = false) - : schemes (schemes), scheme_index (is_end ? schemes.size () : 0), eclass_index (0) + Iterator (const std::vector& schemes, const bool is_end = false) + : schemes (schemes), scheme_index (is_end ? schemes.size () : 0), eclass_index (t8_eclass_t (0)) { if (!is_end && !schemes.empty ()) { - eclass_count = schemes[scheme_index]->num_eclasses; + eclass_count = schemes[scheme_index]->get_num_eclass_schemes (); } } /** * Dereference operator. - * \return The current eclass scheme or tree scheme ts. + * \return The current scheme and eclass. */ - t8_eclass_scheme_c* + std::tuple operator* () const { - const t8_scheme_cxx* current_scheme = schemes[scheme_index]; - return current_scheme->eclass_schemes[eclass_index]; + t8_scheme* current_scheme = schemes[scheme_index]; + t8_eclass_t current_eclass = eclass_index; + return std::make_tuple (current_scheme, current_eclass); } /** @@ -60,10 +70,10 @@ class scheme_iterators { Iterator& operator++ () { - if (++eclass_index >= eclass_count) { - eclass_index = 0; + if (static_cast (++eclass_index) >= eclass_count) { + eclass_index = t8_eclass_t (0); if (++scheme_index < schemes.size ()) { - eclass_count = schemes[scheme_index]->num_eclasses; + eclass_count = schemes[scheme_index]->get_num_eclass_schemes (); } } return *this; @@ -81,9 +91,9 @@ class scheme_iterators { } private: - const std::vector& schemes; + const std::vector& schemes; size_t scheme_index; - size_t eclass_index; + t8_eclass_t eclass_index; size_t eclass_count; }; @@ -99,5 +109,5 @@ class scheme_iterators { } private: - const std::vector& schemes; + const std::vector& schemes; }; diff --git a/test/t8_schemes/t8_gtest_root.cxx b/test/t8_schemes/t8_gtest_root.cxx index 54d1ab359f..2a5f961b72 100644 --- a/test/t8_schemes/t8_gtest_root.cxx +++ b/test/t8_schemes/t8_gtest_root.cxx @@ -29,38 +29,41 @@ #include #include -class root: public testing::TestWithParam { +class root: public testing::TestWithParam> { protected: void SetUp () override { - ts = GetParam (); - ts->t8_element_new (1, &element); - ts->t8_element_root (element); + std::tie (scheme, tree_class) = GetParam (); + scheme = t8_scheme_new_default (); + scheme->element_new (tree_class, 1, &element); + scheme->get_root (tree_class, element); } void TearDown () override { - ts->t8_element_destroy (1, &element); + scheme->element_destroy (tree_class, 1, &element); + scheme->unref (); } t8_element_t *element; - t8_eclass_scheme_c *ts; + t8_scheme *scheme; + t8_eclass_t tree_class; }; /*Test root*/ TEST_P (root, has_level_zero) { - EXPECT_EQ (ts->t8_element_level (element), 0); + EXPECT_EQ (scheme->element_get_level (tree_class, element), 0); } TEST_P (root, equals_linear_id_0_0) { t8_element_t *root_compare; - ts->t8_element_new (1, &root_compare); - ts->t8_element_set_linear_id (root_compare, 0, 0); - EXPECT_ELEM_EQ (ts, element, root_compare); - ts->t8_element_destroy (1, &root_compare); + scheme->element_new (tree_class, 1, &root_compare); + scheme->element_set_linear_id (tree_class, root_compare, 0, 0); + EXPECT_ELEM_EQ (scheme, tree_class, element, root_compare); + scheme->element_destroy (tree_class, 1, &root_compare); } INSTANTIATE_TEST_SUITE_P (t8_gtest_root, root, AllSchemesEclasses); From 5dc2d6fc0b70131a521866467f2c4c4424181439 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 13 Dec 2024 12:36:48 +0100 Subject: [PATCH 07/12] Use a scheme-collection with all schemes --- test/t8_forest/t8_gtest_element_is_leaf.cxx | 2 +- .../t8_gtest_recursive.cxx | 15 +++-- test/t8_gtest_macros.hxx | 9 +-- test/t8_schemes/t8_gtest_boundary_extrude.cxx | 2 +- test/t8_schemes/t8_gtest_descendant.cxx | 6 +- test/t8_schemes/t8_gtest_dfs_base.hxx | 4 +- .../t8_gtest_element_count_leaves.cxx | 6 +- test/t8_schemes/t8_gtest_equal.cxx | 4 +- test/t8_schemes/t8_gtest_face_descendant.cxx | 4 +- test/t8_schemes/t8_gtest_face_neigh.cxx | 6 +- test/t8_schemes/t8_gtest_find_parent.cxx | 4 +- test/t8_schemes/t8_gtest_init_linear_id.cxx | 6 +- ...est_iterator.cxx => t8_gtest_iterator.hxx} | 57 ++++++++++++------- test/t8_schemes/t8_gtest_nca.cxx | 6 +- test/t8_schemes/t8_gtest_pack_unpack.cxx | 3 +- test/t8_schemes/t8_gtest_root.cxx | 12 ++-- test/t8_schemes/t8_gtest_successor.cxx | 6 +- 17 files changed, 86 insertions(+), 66 deletions(-) rename test/t8_schemes/{t8_gtest_iterator.cxx => t8_gtest_iterator.hxx} (65%) diff --git a/test/t8_forest/t8_gtest_element_is_leaf.cxx b/test/t8_forest/t8_gtest_element_is_leaf.cxx index df48161eaa..dd4a3e0f09 100644 --- a/test/t8_forest/t8_gtest_element_is_leaf.cxx +++ b/test/t8_forest/t8_gtest_element_is_leaf.cxx @@ -106,10 +106,10 @@ t8_test_element_is_leaf_for_forest (t8_forest_t forest) { const t8_locidx_t num_local_trees = t8_forest_get_num_local_trees (forest); + const t8_scheme *scheme = t8_forest_get_scheme (forest); for (t8_locidx_t itree = 0; itree < num_local_trees; ++itree) { const t8_locidx_t num_elements_in_tree = t8_forest_get_tree_num_elements (forest, itree); const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, itree); - const t8_scheme *scheme = t8_forest_get_scheme (forest); /* Allocate memory to build a non-leaf element. */ t8_element_t *not_leaf; scheme->element_new (tree_class, 1, ¬_leaf); diff --git a/test/t8_forest_incomplete/t8_gtest_recursive.cxx b/test/t8_forest_incomplete/t8_gtest_recursive.cxx index bd580d55bc..62d0740a48 100644 --- a/test/t8_forest_incomplete/t8_gtest_recursive.cxx +++ b/test/t8_forest_incomplete/t8_gtest_recursive.cxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include /* In this test, we recursively constructs a mesh containing only the first @@ -43,11 +43,14 @@ class recursive_tree: public testing::TestWithParam { SetUp () override { tree_class = GetParam (); + if (tree_class == T8_ECLASS_ZERO) { + GTEST_SKIP (); + } sc_MPI_Comm_size (sc_MPI_COMM_WORLD, &MPI_size); /* Construct a cmesh such that each process will get one rooted tree */ cmesh = t8_cmesh_new_bigmesh (tree_class, MPI_size, sc_MPI_COMM_WORLD); - scheme = t8_scheme_new_default (); + scheme = t8_scheme_all_schemes (); scheme->ref (); t8_cmesh_ref (cmesh); @@ -60,8 +63,10 @@ class recursive_tree: public testing::TestWithParam { void TearDown () override { - t8_forest_unref (&forest); - t8_forest_unref (&forest_base); + if (tree_class != T8_ECLASS_ZERO){ + t8_forest_unref (&forest); + t8_forest_unref (&forest_base); + } } int MPI_size; t8_eclass_t tree_class; @@ -145,5 +150,5 @@ TEST_P (recursive_tree, test_recursive) ASSERT_TRUE (t8_forest_is_equal (forest, forest_base)); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_recursive, recursive_tree, testing::Range (T8_ECLASS_LINE, T8_ECLASS_COUNT), +INSTANTIATE_TEST_SUITE_P (t8_gtest_recursive, recursive_tree, AllSchemes, print_eclass); diff --git a/test/t8_gtest_macros.hxx b/test/t8_gtest_macros.hxx index 927231f0cf..688c8c6a73 100644 --- a/test/t8_gtest_macros.hxx +++ b/test/t8_gtest_macros.hxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -50,14 +50,7 @@ auto print_eclass = [] (const testing::TestParamInfo &info) { return #define T8_NUM_SAMPLE_POINTS 10000 #endif -t8_scheme *test_default_scheme = t8_scheme_new_default (); -t8_scheme *test_default_scheme_2 = t8_scheme_new_default (); -const std::vector schemes = { test_default_scheme, test_default_scheme_2 }; - -scheme_iterators scheme_iter (schemes); - -#define AllSchemesEclasses testing::ValuesIn (scheme_iter.begin (), scheme_iter.end ()) #define AllEclasses testing::Range (T8_ECLASS_ZERO, T8_ECLASS_COUNT) #define AllEclasses2D testing::Values (T8_ECLASS_QUAD, T8_ECLASS_TRIANGLE) diff --git a/test/t8_schemes/t8_gtest_boundary_extrude.cxx b/test/t8_schemes/t8_gtest_boundary_extrude.cxx index 86d7e8e06f..5364107196 100644 --- a/test/t8_schemes/t8_gtest_boundary_extrude.cxx +++ b/test/t8_schemes/t8_gtest_boundary_extrude.cxx @@ -87,4 +87,4 @@ TEST_P (class_test_boundary_extrude, test_boundary_extrude_dfs) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_boundary_extrude, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_boundary_extrude, AllSchemes, print_eclass); diff --git a/test/t8_schemes/t8_gtest_descendant.cxx b/test/t8_schemes/t8_gtest_descendant.cxx index 92f6a2ebc1..e809548e76 100644 --- a/test/t8_schemes/t8_gtest_descendant.cxx +++ b/test/t8_schemes/t8_gtest_descendant.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -35,7 +35,7 @@ class class_schemes_descendant: public testing::TestWithParam { { tree_class = GetParam (); - scheme = t8_scheme_new_default (); + scheme = t8_scheme_all_schemes(); scheme->element_new (tree_class, 1, &elem); scheme->element_new (tree_class, 1, &desc); scheme->element_new (tree_class, 1, &test); @@ -157,4 +157,4 @@ TEST_P (class_schemes_descendant, test_recursive_descendant) t8_large_step_descendant (elem, desc, test, scheme, tree_class, maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_descendant, class_schemes_descendant, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_descendant, class_schemes_descendant, AllSchemes, print_eclass); diff --git a/test/t8_schemes/t8_gtest_dfs_base.hxx b/test/t8_schemes/t8_gtest_dfs_base.hxx index 500a984d9a..c11ffd7732 100644 --- a/test/t8_schemes/t8_gtest_dfs_base.hxx +++ b/test/t8_schemes/t8_gtest_dfs_base.hxx @@ -25,7 +25,7 @@ #include #include -#include +#include class TestDFS: public testing::TestWithParam { public: @@ -59,7 +59,7 @@ class TestDFS: public testing::TestWithParam { void dfs_test_setup () { - scheme = t8_scheme_new_default (); + scheme = t8_scheme_all_schemes (); tree_class = GetParam (); scheme->element_new (tree_class, 1, &element); scheme->get_root (tree_class, element); diff --git a/test/t8_schemes/t8_gtest_element_count_leaves.cxx b/test/t8_schemes/t8_gtest_element_count_leaves.cxx index 141b96831f..b429795466 100644 --- a/test/t8_schemes/t8_gtest_element_count_leaves.cxx +++ b/test/t8_schemes/t8_gtest_element_count_leaves.cxx @@ -21,7 +21,7 @@ */ #include -#include +#include #include /* @@ -47,7 +47,7 @@ class class_element_leaves: public testing::TestWithParam { scheme->unref (); } t8_eclass eclass; - t8_scheme *scheme = t8_scheme_new_default (); + t8_scheme *scheme = t8_scheme_all_schemes (); }; TEST_P (class_element_leaves, test_element_count_leaves_root) @@ -125,4 +125,4 @@ TEST_P (class_element_leaves, test_element_count_leaves_one_level) scheme->element_destroy (eclass, 1, &element); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_element_count_leaves, class_element_leaves, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_element_count_leaves, class_element_leaves, AllSchemes, print_eclass); diff --git a/test/t8_schemes/t8_gtest_equal.cxx b/test/t8_schemes/t8_gtest_equal.cxx index cb2359a70d..cea06bff2c 100644 --- a/test/t8_schemes/t8_gtest_equal.cxx +++ b/test/t8_schemes/t8_gtest_equal.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include "t8_gtest_dfs_base.hxx" @@ -84,4 +84,4 @@ TEST_P (class_test_equal, test_equal_dfs) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_equal, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_equal, AllSchemes, print_eclass); diff --git a/test/t8_schemes/t8_gtest_face_descendant.cxx b/test/t8_schemes/t8_gtest_face_descendant.cxx index b57b04965e..be278e02a3 100644 --- a/test/t8_schemes/t8_gtest_face_descendant.cxx +++ b/test/t8_schemes/t8_gtest_face_descendant.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include "t8_gtest_dfs_base.hxx" @@ -120,4 +120,4 @@ TEST_P (class_descendant, t8_check_face_desc) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_element_face_descendant, class_descendant, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_element_face_descendant, class_descendant, AllSchemes, print_eclass); diff --git a/test/t8_schemes/t8_gtest_face_neigh.cxx b/test/t8_schemes/t8_gtest_face_neigh.cxx index 573816b93a..2d247c9f52 100644 --- a/test/t8_schemes/t8_gtest_face_neigh.cxx +++ b/test/t8_schemes/t8_gtest_face_neigh.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -34,7 +34,7 @@ class face_neigh: public testing::TestWithParam { SetUp () override { tree_class = GetParam (); - scheme = t8_scheme_new_default (); + scheme = t8_scheme_all_schemes (); scheme->element_new (tree_class, 1, &element); scheme->element_new (tree_class, 1, &child); scheme->element_new (tree_class, 1, &neigh); @@ -199,4 +199,4 @@ TEST_P (face_neigh, recursive_check_diff) t8_recursive_check_diff (child, element, neigh, scheme, tree_class, maxlvl, level); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_face_neigh, face_neigh, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_face_neigh, face_neigh, AllSchemes, print_eclass); diff --git a/test/t8_schemes/t8_gtest_find_parent.cxx b/test/t8_schemes/t8_gtest_find_parent.cxx index fac7ee3d2c..f280f2c9b4 100644 --- a/test/t8_schemes/t8_gtest_find_parent.cxx +++ b/test/t8_schemes/t8_gtest_find_parent.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include "t8_gtest_dfs_base.hxx" #include @@ -74,4 +74,4 @@ TEST_P (class_find_parent, t8_compute_child_find_parent) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_find_parent, class_find_parent, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_find_parent, class_find_parent, AllSchemes, print_eclass); diff --git a/test/t8_schemes/t8_gtest_init_linear_id.cxx b/test/t8_schemes/t8_gtest_init_linear_id.cxx index f4a7cad307..7e49b4167e 100644 --- a/test/t8_schemes/t8_gtest_init_linear_id.cxx +++ b/test/t8_schemes/t8_gtest_init_linear_id.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -34,7 +34,7 @@ class linear_id: public testing::TestWithParam { SetUp () override { tree_class = GetParam (); - scheme = t8_scheme_new_default (); + scheme = t8_scheme_all_schemes (); scheme->element_new (tree_class, 1, &element); scheme->element_new (tree_class, 1, &child); scheme->element_new (tree_class, 1, &test); @@ -147,4 +147,4 @@ TEST_P (linear_id, id_at_other_level) } } -INSTANTIATE_TEST_SUITE_P (t8_test_init_linear_id, linear_id, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_test_init_linear_id, linear_id, AllSchemes, print_eclass); diff --git a/test/t8_schemes/t8_gtest_iterator.cxx b/test/t8_schemes/t8_gtest_iterator.hxx similarity index 65% rename from test/t8_schemes/t8_gtest_iterator.cxx rename to test/t8_schemes/t8_gtest_iterator.hxx index 4304602f90..773613984c 100644 --- a/test/t8_schemes/t8_gtest_iterator.cxx +++ b/test/t8_schemes/t8_gtest_iterator.hxx @@ -1,16 +1,35 @@ +/* + 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 classes in parallel. + + Copyright (C) 2024 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. +*/ + +#ifndef T8_GTEST_ITERATOR_HXX +#define T8_GTEST_ITERATOR_HXX + #include #include #include #include #include -// Define the user-defined operator++ for t8_eclass_t -t8_eclass_t& -operator++ (t8_eclass_t& eclass) -{ - eclass = static_cast (static_cast (eclass) + 1); - return eclass; -} + /** * \class scheme_iterators @@ -25,7 +44,6 @@ class scheme_iterators { scheme_iterators (const std::vector& schemes): schemes (schemes) { } - /** * \struct Iterator * Iterator to iterate over all eclasses of all schemes. @@ -34,9 +52,9 @@ class scheme_iterators { { using iterator_category = std::forward_iterator_tag; using difference_type = std::ptrdiff_t; - using value_type = std::tuple; - using pointer = std::tuple*; - using reference = std::tuple&; + using value_type = std::tuple; + using pointer = value_type*; + using reference = value_type&; /** * Constructor for the iterator. @@ -44,22 +62,21 @@ class scheme_iterators { * \param [in] is_end Flag to indicate if the iterator is at the end. */ Iterator (const std::vector& schemes, const bool is_end = false) - : schemes (schemes), scheme_index (is_end ? schemes.size () : 0), eclass_index (t8_eclass_t (0)) + : schemes (schemes), scheme_index (is_end ? schemes.size () : 0), eclass_index (0) { if (!is_end && !schemes.empty ()) { eclass_count = schemes[scheme_index]->get_num_eclass_schemes (); } } - /** * Dereference operator. * \return The current scheme and eclass. */ - std::tuple + value_type operator* () const { t8_scheme* current_scheme = schemes[scheme_index]; - t8_eclass_t current_eclass = eclass_index; + size_t current_eclass = eclass_index; return std::make_tuple (current_scheme, current_eclass); } @@ -70,8 +87,8 @@ class scheme_iterators { Iterator& operator++ () { - if (static_cast (++eclass_index) >= eclass_count) { - eclass_index = t8_eclass_t (0); + if (++eclass_index >= eclass_count) { + eclass_index = 0; if (++scheme_index < schemes.size ()) { eclass_count = schemes[scheme_index]->get_num_eclass_schemes (); } @@ -93,7 +110,7 @@ class scheme_iterators { private: const std::vector& schemes; size_t scheme_index; - t8_eclass_t eclass_index; + size_t eclass_index; size_t eclass_count; }; @@ -109,5 +126,7 @@ class scheme_iterators { } private: - const std::vector& schemes; + std::vector schemes; }; + +#endif // T8_GTEST_ITERATOR_HXX diff --git a/test/t8_schemes/t8_gtest_nca.cxx b/test/t8_schemes/t8_gtest_nca.cxx index 8503989dd4..a78eab6474 100644 --- a/test/t8_schemes/t8_gtest_nca.cxx +++ b/test/t8_schemes/t8_gtest_nca.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include class nca: public testing::TestWithParam { @@ -37,7 +37,7 @@ class nca: public testing::TestWithParam { SetUp () override { tree_class = GetParam (); - scheme = t8_scheme_new_default (); + scheme = t8_scheme_all_schemes (); scheme->element_new (tree_class, 1, &correct_nca); scheme->element_new (tree_class, 1, &desc_a); scheme->element_new (tree_class, 1, &desc_b); @@ -314,4 +314,4 @@ TEST_P (nca, recursive_check_higher_level) scheme->element_destroy (tree_class, 1, &correct_nca_high_level); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_nca, nca, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_nca, nca, AllSchemes, print_eclass); diff --git a/test/t8_schemes/t8_gtest_pack_unpack.cxx b/test/t8_schemes/t8_gtest_pack_unpack.cxx index 5a85da933f..d571927585 100644 --- a/test/t8_schemes/t8_gtest_pack_unpack.cxx +++ b/test/t8_schemes/t8_gtest_pack_unpack.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include "t8_gtest_dfs_base.hxx" /** Use DFS to check for all elements, if packing them, sending them to ourself and unpacking them results in the same element @@ -134,4 +135,4 @@ TEST_P (class_test_pack, test_equal_dfs) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_pack, AllEclasses); +INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_pack, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_root.cxx b/test/t8_schemes/t8_gtest_root.cxx index 2a5f961b72..41eee70442 100644 --- a/test/t8_schemes/t8_gtest_root.cxx +++ b/test/t8_schemes/t8_gtest_root.cxx @@ -26,16 +26,17 @@ #include #include #include +#include #include #include -class root: public testing::TestWithParam> { - protected: +class root: public testing::TestWithParam { + public: void SetUp () override { - std::tie (scheme, tree_class) = GetParam (); - scheme = t8_scheme_new_default (); + scheme = t8_scheme_all_schemes (); + tree_class = GetParam (); scheme->element_new (tree_class, 1, &element); scheme->get_root (tree_class, element); } @@ -45,6 +46,7 @@ class root: public testing::TestWithParam> scheme->element_destroy (tree_class, 1, &element); scheme->unref (); } + t8_element_t *element; t8_scheme *scheme; t8_eclass_t tree_class; @@ -66,4 +68,4 @@ TEST_P (root, equals_linear_id_0_0) scheme->element_destroy (tree_class, 1, &root_compare); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_root, root, AllSchemesEclasses); +INSTANTIATE_TEST_SUITE_P (t8_gtest_root, root, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_successor.cxx b/test/t8_schemes/t8_gtest_successor.cxx index 4bfd4de95e..4ac958e2ed 100644 --- a/test/t8_schemes/t8_gtest_successor.cxx +++ b/test/t8_schemes/t8_gtest_successor.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -32,7 +32,7 @@ class class_successor: public testing::TestWithParam { SetUp () override { tree_class = GetParam (); - scheme = t8_scheme_new_default (); + scheme = t8_scheme_all_schemes (); scheme->element_new (tree_class, 1, &element); scheme->element_new (tree_class, 1, &successor); scheme->element_new (tree_class, 1, &child); @@ -151,4 +151,4 @@ TEST_P (class_successor, test_recursive_and_deep_successor) t8_deep_successor (element, successor, last, scheme, tree_class); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_successor, class_successor, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_successor, class_successor, AllSchemes, print_eclass); From 440f3a782b3033159fb9e18f9e3ddf001828595d Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 13 Dec 2024 12:37:57 +0100 Subject: [PATCH 08/12] remove iterator --- test/t8_gtest_macros.hxx | 1 - test/t8_schemes/t8_gtest_iterator.hxx | 132 -------------------------- 2 files changed, 133 deletions(-) delete mode 100644 test/t8_schemes/t8_gtest_iterator.hxx diff --git a/test/t8_gtest_macros.hxx b/test/t8_gtest_macros.hxx index 688c8c6a73..1b361f0b22 100644 --- a/test/t8_gtest_macros.hxx +++ b/test/t8_gtest_macros.hxx @@ -30,7 +30,6 @@ #include #include #include -#include #include #include diff --git a/test/t8_schemes/t8_gtest_iterator.hxx b/test/t8_schemes/t8_gtest_iterator.hxx deleted file mode 100644 index 773613984c..0000000000 --- a/test/t8_schemes/t8_gtest_iterator.hxx +++ /dev/null @@ -1,132 +0,0 @@ -/* - 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 classes in parallel. - - Copyright (C) 2024 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. -*/ - -#ifndef T8_GTEST_ITERATOR_HXX -#define T8_GTEST_ITERATOR_HXX - -#include -#include -#include -#include -#include - - - -/** - * \class scheme_iterators - * Class to iterate over all eclasses of all schemes and return the t8_scheme and the current t8_eclass_t. - */ -class scheme_iterators { - public: - /** - * Initialize the iterator with a list of schemes. - * \param [in] schemes The list of schemes to iterate over. - */ - scheme_iterators (const std::vector& schemes): schemes (schemes) - { - } - /** - * \struct Iterator - * Iterator to iterate over all eclasses of all schemes. - */ - struct Iterator - { - using iterator_category = std::forward_iterator_tag; - using difference_type = std::ptrdiff_t; - using value_type = std::tuple; - using pointer = value_type*; - using reference = value_type&; - - /** - * Constructor for the iterator. - * \param [in] schemes The list of schemes to iterate over. - * \param [in] is_end Flag to indicate if the iterator is at the end. - */ - Iterator (const std::vector& schemes, const bool is_end = false) - : schemes (schemes), scheme_index (is_end ? schemes.size () : 0), eclass_index (0) - { - if (!is_end && !schemes.empty ()) { - eclass_count = schemes[scheme_index]->get_num_eclass_schemes (); - } - } - /** - * Dereference operator. - * \return The current scheme and eclass. - */ - value_type - operator* () const - { - t8_scheme* current_scheme = schemes[scheme_index]; - size_t current_eclass = eclass_index; - return std::make_tuple (current_scheme, current_eclass); - } - - /** - * Prefix increment operator to move the iterator to the next element. - * \return A reference to the updated iterator. - */ - Iterator& - operator++ () - { - if (++eclass_index >= eclass_count) { - eclass_index = 0; - if (++scheme_index < schemes.size ()) { - eclass_count = schemes[scheme_index]->get_num_eclass_schemes (); - } - } - return *this; - } - - /** - * Inequality operator to compare two iterators. - * \param [in] other Another iterator to compare with. - * \return True if the iterators are not equal, false otherwise. - */ - bool - operator!= (const Iterator& other) const - { - return scheme_index != other.scheme_index || eclass_index != other.eclass_index; - } - - private: - const std::vector& schemes; - size_t scheme_index; - size_t eclass_index; - size_t eclass_count; - }; - - Iterator - begin () const - { - return Iterator (schemes); - } - Iterator - end () const - { - return Iterator (schemes, true); - } - - private: - std::vector schemes; -}; - -#endif // T8_GTEST_ITERATOR_HXX From 82c6c9114619565b3574f2b8f744eebcc229e6fb Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 13 Dec 2024 12:45:16 +0100 Subject: [PATCH 09/12] Add test/t8_gtest_schemes.hxx A scheme collection of all schemes --- test/t8_gtest_schemes.hxx | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/t8_gtest_schemes.hxx diff --git a/test/t8_gtest_schemes.hxx b/test/t8_gtest_schemes.hxx new file mode 100644 index 0000000000..8444579c4e --- /dev/null +++ b/test/t8_gtest_schemes.hxx @@ -0,0 +1,49 @@ +/* + 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 classes in parallel. + + Copyright (C) 2024 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. +*/ + +#ifndef T8_GTEST_SCHEMES_HXX +#define T8_GTEST_SCHEMES_HXX + +#include +#include +#include + +t8_scheme * +t8_scheme_all_schemes(void) +{ + t8_scheme_builder builder; + + builder.add_eclass_scheme (); + builder.add_eclass_scheme (); + builder.add_eclass_scheme (); + builder.add_eclass_scheme (); + builder.add_eclass_scheme (); + builder.add_eclass_scheme (); + builder.add_eclass_scheme (); + builder.add_eclass_scheme (); + + return builder.build_scheme (); +} + +#define AllSchemes ::testing::Range(T8_ECLASS_ZERO, T8_ECLASS_COUNT) + +#endif /* T8_GTEST_SCHEMES_HXX */ \ No newline at end of file From eaca0b310787b5a4e38964351b037e60434661c4 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 13 Dec 2024 13:08:58 +0100 Subject: [PATCH 10/12] Indentation --- test/t8_gtest_macros.hxx | 1 - 1 file changed, 1 deletion(-) diff --git a/test/t8_gtest_macros.hxx b/test/t8_gtest_macros.hxx index 1b361f0b22..9ebae45da7 100644 --- a/test/t8_gtest_macros.hxx +++ b/test/t8_gtest_macros.hxx @@ -49,7 +49,6 @@ auto print_eclass = [] (const testing::TestParamInfo &info) { return #define T8_NUM_SAMPLE_POINTS 10000 #endif - #define AllEclasses testing::Range (T8_ECLASS_ZERO, T8_ECLASS_COUNT) #define AllEclasses2D testing::Values (T8_ECLASS_QUAD, T8_ECLASS_TRIANGLE) From 59a7562c81ddcda7059765f17542aac74ccc06ad Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 13 Dec 2024 13:17:09 +0100 Subject: [PATCH 11/12] Indentation --- test/t8_forest_incomplete/t8_gtest_recursive.cxx | 5 ++--- test/t8_gtest_schemes.hxx | 6 +++--- test/t8_schemes/t8_gtest_descendant.cxx | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/t8_forest_incomplete/t8_gtest_recursive.cxx b/test/t8_forest_incomplete/t8_gtest_recursive.cxx index 62d0740a48..52fa16bcb8 100644 --- a/test/t8_forest_incomplete/t8_gtest_recursive.cxx +++ b/test/t8_forest_incomplete/t8_gtest_recursive.cxx @@ -63,7 +63,7 @@ class recursive_tree: public testing::TestWithParam { void TearDown () override { - if (tree_class != T8_ECLASS_ZERO){ + if (tree_class != T8_ECLASS_ZERO) { t8_forest_unref (&forest); t8_forest_unref (&forest_base); } @@ -150,5 +150,4 @@ TEST_P (recursive_tree, test_recursive) ASSERT_TRUE (t8_forest_is_equal (forest, forest_base)); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_recursive, recursive_tree, AllSchemes, - print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_recursive, recursive_tree, AllSchemes, print_eclass); diff --git a/test/t8_gtest_schemes.hxx b/test/t8_gtest_schemes.hxx index 8444579c4e..e2624fe02a 100644 --- a/test/t8_gtest_schemes.hxx +++ b/test/t8_gtest_schemes.hxx @@ -28,7 +28,7 @@ #include t8_scheme * -t8_scheme_all_schemes(void) +t8_scheme_all_schemes (void) { t8_scheme_builder builder; @@ -44,6 +44,6 @@ t8_scheme_all_schemes(void) return builder.build_scheme (); } -#define AllSchemes ::testing::Range(T8_ECLASS_ZERO, T8_ECLASS_COUNT) +#define AllSchemes ::testing::Range (T8_ECLASS_ZERO, T8_ECLASS_COUNT) -#endif /* T8_GTEST_SCHEMES_HXX */ \ No newline at end of file +#endif /* T8_GTEST_SCHEMES_HXX */ diff --git a/test/t8_schemes/t8_gtest_descendant.cxx b/test/t8_schemes/t8_gtest_descendant.cxx index e809548e76..13a6c4b667 100644 --- a/test/t8_schemes/t8_gtest_descendant.cxx +++ b/test/t8_schemes/t8_gtest_descendant.cxx @@ -35,7 +35,7 @@ class class_schemes_descendant: public testing::TestWithParam { { tree_class = GetParam (); - scheme = t8_scheme_all_schemes(); + scheme = t8_scheme_all_schemes (); scheme->element_new (tree_class, 1, &elem); scheme->element_new (tree_class, 1, &desc); scheme->element_new (tree_class, 1, &test); From e4e5ff33bf83e14394c776274a923994284db141 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Mon, 6 Jan 2025 16:11:31 +0100 Subject: [PATCH 12/12] Distinguish between eclass and scheme_id --- src/t8_schemes/t8_scheme.hxx | 2 +- .../t8_gtest_recursive.cxx | 13 +- test/t8_gtest_custom_assertion.hxx | 13 +- test/t8_gtest_schemes.hxx | 4 +- test/t8_schemes/t8_gtest_boundary_extrude.cxx | 23 ++- .../t8_schemes/t8_gtest_child_parent_face.cxx | 16 +- test/t8_schemes/t8_gtest_descendant.cxx | 97 +++++----- test/t8_schemes/t8_gtest_dfs_base.hxx | 24 +-- .../t8_gtest_element_count_leaves.cxx | 40 +++-- test/t8_schemes/t8_gtest_equal.cxx | 24 +-- test/t8_schemes/t8_gtest_face_descendant.cxx | 28 +-- test/t8_schemes/t8_gtest_face_neigh.cxx | 69 +++---- test/t8_schemes/t8_gtest_find_parent.cxx | 18 +- test/t8_schemes/t8_gtest_init_linear_id.cxx | 41 +++-- test/t8_schemes/t8_gtest_nca.cxx | 168 +++++++++--------- test/t8_schemes/t8_gtest_pack_unpack.cxx | 30 ++-- test/t8_schemes/t8_gtest_root.cxx | 22 +-- test/t8_schemes/t8_gtest_successor.cxx | 37 ++-- 18 files changed, 346 insertions(+), 323 deletions(-) diff --git a/src/t8_schemes/t8_scheme.hxx b/src/t8_schemes/t8_scheme.hxx index 2b9fe901e0..db968ac1a8 100644 --- a/src/t8_schemes/t8_scheme.hxx +++ b/src/t8_schemes/t8_scheme.hxx @@ -149,7 +149,7 @@ class t8_scheme { return std::holds_alternative (eclass_schemes[tree_class]); } - /** Get the eclass an eclas scheme is valid for. \Note: This function should return the input value as long as the + /** Get the eclass an eclass scheme is valid for. \Note: This function should return the input value as long as the * eclass schemes are soreted correctly. In the future, the trees will access the schemes by a key and then this * function will make more sense. * \param [in] tree_class The eclass of the current tree. diff --git a/test/t8_forest_incomplete/t8_gtest_recursive.cxx b/test/t8_forest_incomplete/t8_gtest_recursive.cxx index 52fa16bcb8..468a074111 100644 --- a/test/t8_forest_incomplete/t8_gtest_recursive.cxx +++ b/test/t8_forest_incomplete/t8_gtest_recursive.cxx @@ -37,12 +37,14 @@ * Note, that each rank has its own local/global tree. No trees are shared. */ -class recursive_tree: public testing::TestWithParam { +class recursive_tree: public testing::TestWithParam { protected: void SetUp () override { - tree_class = GetParam (); + scheme_id = GetParam (); + scheme = t8_scheme_all_schemes (); + tree_class = scheme->get_eclass_scheme_eclass (static_cast(scheme_id)); if (tree_class == T8_ECLASS_ZERO) { GTEST_SKIP (); } @@ -50,7 +52,6 @@ class recursive_tree: public testing::TestWithParam { /* Construct a cmesh such that each process will get one rooted tree */ cmesh = t8_cmesh_new_bigmesh (tree_class, MPI_size, sc_MPI_COMM_WORLD); - scheme = t8_scheme_all_schemes (); scheme->ref (); t8_cmesh_ref (cmesh); @@ -67,8 +68,12 @@ class recursive_tree: public testing::TestWithParam { t8_forest_unref (&forest); t8_forest_unref (&forest_base); } + else { + scheme->unref (); + } } int MPI_size; + int scheme_id; t8_eclass_t tree_class; t8_scheme *scheme; t8_cmesh_t cmesh; @@ -150,4 +155,4 @@ TEST_P (recursive_tree, test_recursive) ASSERT_TRUE (t8_forest_is_equal (forest, forest_base)); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_recursive, recursive_tree, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_recursive, recursive_tree, AllSchemes); diff --git a/test/t8_gtest_custom_assertion.hxx b/test/t8_gtest_custom_assertion.hxx index bcb45a3a34..5e1eaf022e 100644 --- a/test/t8_gtest_custom_assertion.hxx +++ b/test/t8_gtest_custom_assertion.hxx @@ -46,18 +46,19 @@ */ testing::AssertionResult element_equality (const char *ts_expr, const char *tree_class_expr, const char *elem_1_expr, const char *elem_2_expr, - const t8_scheme *scheme, const t8_eclass_t tree_class, const t8_element_t *elem_1, + const t8_scheme *scheme, const int scheme_id, const t8_element_t *elem_1, const t8_element_t *elem_2) { - if (scheme->element_is_equal (tree_class, elem_1, elem_2)) { + if (scheme->element_is_equal (static_cast(scheme_id), elem_1, elem_2)) { return testing::AssertionSuccess (); } else { #if T8_ENABLE_DEBUG char elem_1_string[BUFSIZ]; char elem_2_string[BUFSIZ]; - scheme->element_to_string (tree_class, elem_1, elem_1_string, BUFSIZ); - scheme->element_to_string (tree_class, elem_2, elem_2_string, BUFSIZ); + const t8_eclass_t tree_class = scheme->get_eclass_scheme_eclass (static_cast(scheme_id)); + scheme->element_to_string (static_cast(scheme_id), elem_1, elem_1_string, BUFSIZ); + scheme->element_to_string (static_cast(scheme_id), elem_2, elem_2_string, BUFSIZ); return testing::AssertionFailure () << elem_1_expr << " " << elem_1_string << " is not equal to \n" << elem_2_expr << " " << elem_2_string << " given scheme " << ts_expr << " and tree class " << tree_class_expr << " " @@ -70,8 +71,8 @@ element_equality (const char *ts_expr, const char *tree_class_expr, const char * } } -#define EXPECT_ELEM_EQ(scheme, tree_class, elem1, elem2) \ - EXPECT_PRED_FORMAT4 (element_equality, (scheme), (tree_class), (elem1), (elem2)) +#define EXPECT_ELEM_EQ(scheme, scheme_id, elem1, elem2) \ + EXPECT_PRED_FORMAT4 (element_equality, (scheme), (scheme_id), (elem1), (elem2)) /** * \brief Test if two 3D vectors are equal with respect to a given precision diff --git a/test/t8_gtest_schemes.hxx b/test/t8_gtest_schemes.hxx index e2624fe02a..e62ea4b063 100644 --- a/test/t8_gtest_schemes.hxx +++ b/test/t8_gtest_schemes.hxx @@ -44,6 +44,8 @@ t8_scheme_all_schemes (void) return builder.build_scheme (); } -#define AllSchemes ::testing::Range (T8_ECLASS_ZERO, T8_ECLASS_COUNT) +#define NUM_SCHEMES 8 + +#define AllSchemes ::testing::Range (0, NUM_SCHEMES) #endif /* T8_GTEST_SCHEMES_HXX */ diff --git a/test/t8_schemes/t8_gtest_boundary_extrude.cxx b/test/t8_schemes/t8_gtest_boundary_extrude.cxx index 5364107196..52bd9b7f60 100644 --- a/test/t8_schemes/t8_gtest_boundary_extrude.cxx +++ b/test/t8_schemes/t8_gtest_boundary_extrude.cxx @@ -35,22 +35,25 @@ class class_test_boundary_extrude: public TestDFS { void check_element () override { - const int num_faces = scheme->element_get_num_faces (tree_class, element); + const int num_faces = scheme->element_get_num_faces (static_cast(scheme_id), element); for (int iface = 0; iface < num_faces; iface++) { /* Iterate over all faces that are also root faces and determine the face element */ - if (scheme->element_is_root_boundary (tree_class, element, iface)) { + if (scheme->element_is_root_boundary (static_cast(scheme_id), element, iface)) { /* Get face scheme */ - const int tree_face = scheme->element_get_tree_face (tree_class, element, iface); + const int tree_face = scheme->element_get_tree_face (static_cast(scheme_id), element, iface); + + /* Note: This wont work with non-default schemes, where the order of schemes is not the same as + * in the default scheme. */ const t8_eclass_t face_eclass = (t8_eclass_t) t8_eclass_face_types[tree_class][tree_face]; t8_element_t *boundary; scheme->element_new (face_eclass, 1, &boundary); - scheme->element_get_boundary_face (tree_class, element, iface, boundary); + scheme->element_get_boundary_face (static_cast(scheme_id), element, iface, boundary); - scheme->element_extrude_face (tree_class, boundary, check, tree_face); + scheme->element_extrude_face (static_cast(scheme_id), boundary, check, tree_face); - EXPECT_ELEM_EQ (scheme, tree_class, element, check); + EXPECT_ELEM_EQ (scheme, scheme_id, element, check); scheme->element_destroy (face_eclass, 1, &boundary); } @@ -63,17 +66,19 @@ class class_test_boundary_extrude: public TestDFS { { dfs_test_setup (); /* Get element and initialize it */ - scheme->element_new (tree_class, 1, &check); + scheme->element_new (static_cast(scheme_id), 1, &check); + tree_class = scheme->get_eclass_scheme_eclass (static_cast(scheme_id)); } void TearDown () override { /* Destroy element */ - scheme->element_destroy (tree_class, 1, &check); + scheme->element_destroy (static_cast(scheme_id), 1, &check); /* Destroy DFS test */ dfs_test_teardown (); } + t8_eclass_t tree_class; t8_element_t *check; }; @@ -87,4 +92,4 @@ TEST_P (class_test_boundary_extrude, test_boundary_extrude_dfs) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_boundary_extrude, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_boundary_extrude, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_child_parent_face.cxx b/test/t8_schemes/t8_gtest_child_parent_face.cxx index 34c903ed99..1e8c32a3ed 100644 --- a/test/t8_schemes/t8_gtest_child_parent_face.cxx +++ b/test/t8_schemes/t8_gtest_child_parent_face.cxx @@ -31,26 +31,26 @@ class class_child_parent_face: public TestDFS { void check_element () override { - const int num_faces = scheme->element_get_num_faces (tree_class, element); + const int num_faces = scheme->element_get_num_faces (static_cast(scheme_id), element); for (int iface = 0; iface < num_faces; iface++) { /* Iterate over all faces and determine the facechildren*/ - const int num_face_children = scheme->element_get_num_face_children (tree_class, element, iface); + const int num_face_children = scheme->element_get_num_face_children (static_cast(scheme_id), element, iface); t8_element_t **children; children = T8_ALLOC (t8_element_t *, num_face_children); - scheme->element_new (tree_class, num_face_children, children); + scheme->element_new (static_cast(scheme_id), num_face_children, children); - scheme->element_get_children_at_face (tree_class, element, iface, children, num_face_children, NULL); + scheme->element_get_children_at_face (static_cast(scheme_id), element, iface, children, num_face_children, NULL); for (int ifacechild = 0; ifacechild < num_face_children; ifacechild++) { /* Iterate over those children and determine the childface corresponding to the parentface */ - const int childface = scheme->element_face_get_child_face (tree_class, element, iface, ifacechild); + const int childface = scheme->element_face_get_child_face (static_cast(scheme_id), element, iface, ifacechild); ASSERT_NE (childface, -1); /* Determine the parentface corresponding to the childface */ - const int parentface = scheme->element_face_get_parent_face (tree_class, children[ifacechild], childface); + const int parentface = scheme->element_face_get_parent_face (static_cast(scheme_id), children[ifacechild], childface); /* Check, that this is equal to the face that we started with */ EXPECT_EQ (iface, parentface); } - scheme->element_destroy (tree_class, num_face_children, children); + scheme->element_destroy (static_cast(scheme_id), num_face_children, children); T8_FREE (children); } } @@ -80,4 +80,4 @@ TEST_P (class_child_parent_face, t8_recursive_dfs_child_parent_face) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_child_parent_face, class_child_parent_face, AllEclasses, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_child_parent_face, class_child_parent_face, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_descendant.cxx b/test/t8_schemes/t8_gtest_descendant.cxx index 13a6c4b667..c0246bb1bb 100644 --- a/test/t8_schemes/t8_gtest_descendant.cxx +++ b/test/t8_schemes/t8_gtest_descendant.cxx @@ -28,25 +28,25 @@ /* This program tests the descendant function of an element. */ -class class_schemes_descendant: public testing::TestWithParam { +class class_schemes_descendant: public testing::TestWithParam { protected: void SetUp () override { - tree_class = GetParam (); + scheme_id = GetParam (); scheme = t8_scheme_all_schemes (); - scheme->element_new (tree_class, 1, &elem); - scheme->element_new (tree_class, 1, &desc); - scheme->element_new (tree_class, 1, &test); - scheme->get_root (tree_class, elem); + scheme->element_new (static_cast(scheme_id), 1, &elem); + scheme->element_new (static_cast(scheme_id), 1, &desc); + scheme->element_new (static_cast(scheme_id), 1, &test); + scheme->get_root (static_cast(scheme_id), elem); } void TearDown () override { - scheme->element_destroy (tree_class, 1, &elem); - scheme->element_destroy (tree_class, 1, &desc); - scheme->element_destroy (tree_class, 1, &test); + scheme->element_destroy (static_cast(scheme_id), 1, &elem); + scheme->element_destroy (static_cast(scheme_id), 1, &desc); + scheme->element_destroy (static_cast(scheme_id), 1, &test); scheme->unref (); } #ifdef T8_ENABLE_DEBUG @@ -55,8 +55,8 @@ class class_schemes_descendant: public testing::TestWithParam { const int maxlvl = 4; #endif + int scheme_id; t8_scheme *scheme; - t8_eclass_t tree_class; t8_element_t *elem; t8_element_t *desc; t8_element_t *test; @@ -67,25 +67,25 @@ class class_schemes_descendant: public testing::TestWithParam { */ static void t8_recursive_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_scheme *scheme, - const t8_eclass_t tree_class, int maxlvl) + const int scheme_id, const int maxlvl) { - const int num_children = scheme->element_get_num_children (tree_class, elem); - const int level = scheme->element_get_level (tree_class, elem); + const int num_children = scheme->element_get_num_children (static_cast(scheme_id), elem); + const int level = scheme->element_get_level (static_cast(scheme_id), elem); for (int ichild = 0; ichild < num_children; ichild++) { - scheme->element_get_child (tree_class, elem, ichild, desc); + scheme->element_get_child (static_cast(scheme_id), elem, ichild, desc); /* first child == first descendant. */ if (ichild == 0) { - scheme->element_get_first_descendant (tree_class, elem, test, level + 1); - EXPECT_ELEM_EQ (scheme, tree_class, desc, test); + scheme->element_get_first_descendant (static_cast(scheme_id), elem, test, level + 1); + EXPECT_ELEM_EQ (scheme, scheme_id, desc, test); } /* last child == last descendant. */ else if (ichild == num_children - 1) { - scheme->element_get_last_descendant (tree_class, elem, test, level + 1); - EXPECT_ELEM_EQ (scheme, tree_class, desc, test); + scheme->element_get_last_descendant (static_cast(scheme_id), elem, test, level + 1); + EXPECT_ELEM_EQ (scheme, scheme_id, desc, test); } else if (level > maxlvl) { - t8_recursive_descendant (desc, elem, test, scheme, tree_class, maxlvl); - scheme->element_get_parent (tree_class, desc, elem); + t8_recursive_descendant (desc, elem, test, scheme, static_cast(scheme_id), maxlvl); + scheme->element_get_parent (static_cast(scheme_id), desc, elem); } } } @@ -95,17 +95,17 @@ t8_recursive_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *t */ static void t8_deep_first_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_scheme *scheme, - const t8_eclass_t tree_class, int level) + const int scheme_id, const int level) { - const int elem_level = scheme->element_get_level (tree_class, elem); - scheme->element_copy (tree_class, elem, test); + const int elem_level = scheme->element_get_level (static_cast(scheme_id), elem); + scheme->element_copy (static_cast(scheme_id), elem, test); for (int ilevel = elem_level; ilevel < level; ilevel++) { - scheme->element_get_child (tree_class, test, 0, desc); - scheme->element_copy (tree_class, desc, test); + scheme->element_get_child (static_cast(scheme_id), test, 0, desc); + scheme->element_copy (static_cast(scheme_id), desc, test); } - scheme->element_get_first_descendant (tree_class, elem, test, level); - EXPECT_ELEM_EQ (scheme, tree_class, desc, test); + scheme->element_get_first_descendant (static_cast(scheme_id), elem, test, level); + EXPECT_ELEM_EQ (scheme, scheme_id, desc, test); } /* Test, if the last descendant of an element is computed correctly over a range @@ -113,19 +113,19 @@ t8_deep_first_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t * */ static void t8_deep_last_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_scheme *scheme, - const t8_eclass_t tree_class, int level) + const int scheme_id, const int level) { - scheme->element_copy (tree_class, elem, test); + scheme->element_copy (static_cast(scheme_id), elem, test); /* Compute the correct element. */ - for (int ilevel = scheme->element_get_level (tree_class, elem); ilevel < level; ilevel++) { - const int num_children = scheme->element_get_num_children (tree_class, test); - scheme->element_get_child (tree_class, test, num_children - 1, desc); - scheme->element_copy (tree_class, desc, test); + for (int ilevel = scheme->element_get_level (static_cast(scheme_id), elem); ilevel < level; ilevel++) { + const int num_children = scheme->element_get_num_children (static_cast(scheme_id), test); + scheme->element_get_child (static_cast(scheme_id), test, num_children - 1, desc); + scheme->element_copy (static_cast(scheme_id), desc, test); } /* Check for equality. */ - scheme->element_get_last_descendant (tree_class, elem, test, level); - EXPECT_ELEM_EQ (scheme, tree_class, desc, test); + scheme->element_get_last_descendant (static_cast(scheme_id), elem, test, level); + EXPECT_ELEM_EQ (scheme, scheme_id, desc, test); } /* Test if the first and last descendant of an element are computed correctly. @@ -133,28 +133,29 @@ t8_deep_last_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *t */ static void t8_large_step_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_scheme *scheme, - const t8_eclass_t tree_class, int maxlvl) + const int scheme_id, const int maxlvl) { - for (int ilevel = scheme->element_get_level (tree_class, elem); ilevel < maxlvl; ilevel++) { + for (int ilevel = scheme->element_get_level (static_cast(scheme_id), elem); ilevel < maxlvl; ilevel++) { - const int num_children = scheme->element_get_num_children (tree_class, elem); + const int num_children = scheme->element_get_num_children (static_cast(scheme_id), elem); /* Use these functions to perform the actual test. */ - t8_deep_first_descendant (elem, desc, test, scheme, tree_class, maxlvl); - t8_deep_last_descendant (elem, desc, test, scheme, tree_class, maxlvl); + t8_deep_first_descendant (elem, desc, test, scheme, static_cast(scheme_id), maxlvl); + t8_deep_last_descendant (elem, desc, test, scheme, static_cast(scheme_id), maxlvl); for (int jchild = 0; jchild < num_children; jchild++) { - scheme->element_get_child (tree_class, elem, jchild, desc); - t8_large_step_descendant (desc, elem, test, scheme, tree_class, maxlvl); - scheme->element_get_parent (tree_class, desc, elem); + scheme->element_get_child (static_cast(scheme_id), elem, jchild, desc); + t8_large_step_descendant (desc, elem, test, scheme, static_cast(scheme_id), maxlvl); + scheme->element_get_parent (static_cast(scheme_id), desc, elem); } } } TEST_P (class_schemes_descendant, test_recursive_descendant) { - t8_recursive_descendant (elem, desc, test, scheme, tree_class, maxlvl); - t8_deep_first_descendant (elem, desc, test, scheme, tree_class, scheme->get_maxlevel (tree_class)); - t8_deep_last_descendant (elem, desc, test, scheme, tree_class, scheme->get_maxlevel (tree_class)); - t8_large_step_descendant (elem, desc, test, scheme, tree_class, maxlvl); + const int elem_maxlvl = scheme->get_maxlevel (static_cast(scheme_id)); + t8_recursive_descendant (elem, desc, test, scheme, scheme_id, maxlvl); + t8_deep_first_descendant (elem, desc, test, scheme, scheme_id, elem_maxlvl); + t8_deep_last_descendant (elem, desc, test, scheme, scheme_id, elem_maxlvl); + t8_large_step_descendant (elem, desc, test, scheme, scheme_id, maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_descendant, class_schemes_descendant, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_descendant, class_schemes_descendant, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_dfs_base.hxx b/test/t8_schemes/t8_gtest_dfs_base.hxx index c11ffd7732..01c0250365 100644 --- a/test/t8_schemes/t8_gtest_dfs_base.hxx +++ b/test/t8_schemes/t8_gtest_dfs_base.hxx @@ -27,7 +27,7 @@ #include #include -class TestDFS: public testing::TestWithParam { +class TestDFS: public testing::TestWithParam { public: /** recursive tests check something for all descendants of a starting element (currently only root) upto maxlevel */ @@ -38,20 +38,20 @@ class TestDFS: public testing::TestWithParam { void check_recursive_dfs_to_max_lvl (const int max_dfs_recursion_level) { - const int level = scheme->element_get_level (tree_class, element); + const int level = scheme->element_get_level (static_cast(scheme_id), element); ASSERT_LE (level, max_dfs_recursion_level); - ASSERT_LT (max_dfs_recursion_level, scheme->get_maxlevel (tree_class)); + ASSERT_LT (max_dfs_recursion_level, scheme->get_maxlevel (static_cast(scheme_id))); /** call the implementation of the specific test*/ check_element (); - if (scheme->element_get_level (tree_class, element) < max_dfs_recursion_level) { + if (scheme->element_get_level (static_cast(scheme_id), element) < max_dfs_recursion_level) { /* iterate over all children */ - const int num_children = scheme->element_get_num_children (tree_class, element); + const int num_children = scheme->element_get_num_children (static_cast(scheme_id), element); for (int ichild = 0; ichild < num_children; ichild++) { - scheme->element_get_child (tree_class, element, ichild, element); + scheme->element_get_child (static_cast(scheme_id), element, ichild, element); check_recursive_dfs_to_max_lvl (max_dfs_recursion_level); - scheme->element_get_parent (tree_class, element, element); + scheme->element_get_parent (static_cast(scheme_id), element, element); } } } @@ -60,14 +60,14 @@ class TestDFS: public testing::TestWithParam { dfs_test_setup () { scheme = t8_scheme_all_schemes (); - tree_class = GetParam (); - scheme->element_new (tree_class, 1, &element); - scheme->get_root (tree_class, element); + scheme_id = GetParam (); + scheme->element_new (static_cast(scheme_id), 1, &element); + scheme->get_root (static_cast(scheme_id), element); } void dfs_test_teardown () { - scheme->element_destroy (tree_class, 1, &element); + scheme->element_destroy (static_cast(scheme_id), 1, &element); scheme->unref (); } @@ -82,8 +82,8 @@ class TestDFS: public testing::TestWithParam { dfs_test_teardown (); } + int scheme_id; t8_scheme *scheme; - t8_eclass_t tree_class; t8_element_t *element; }; diff --git a/test/t8_schemes/t8_gtest_element_count_leaves.cxx b/test/t8_schemes/t8_gtest_element_count_leaves.cxx index b429795466..2eb2df1c65 100644 --- a/test/t8_schemes/t8_gtest_element_count_leaves.cxx +++ b/test/t8_schemes/t8_gtest_element_count_leaves.cxx @@ -34,31 +34,35 @@ /* Tests whether the leaf count for one additional level matches the number of children */ -class class_element_leaves: public testing::TestWithParam { +class class_element_leaves: public testing::TestWithParam { protected: void SetUp () override { - eclass = GetParam (); + scheme_id = GetParam (); + eclass = scheme->get_eclass_scheme_eclass (static_cast(scheme_id)); } void TearDown () override { scheme->unref (); } - t8_eclass eclass; + int scheme_id; t8_scheme *scheme = t8_scheme_all_schemes (); + t8_eclass_t eclass; }; TEST_P (class_element_leaves, test_element_count_leaves_root) { - const int maxlevel = scheme->get_maxlevel (eclass); + const int maxlevel = scheme->get_maxlevel (static_cast(scheme_id)); t8_gloidx_t compare_value = 1; t8_gloidx_t sum1 = 1; t8_gloidx_t sum2 = 1; + + for (int level = 0; level <= maxlevel; ++level) { - const t8_gloidx_t leaf_count = scheme->count_leaves_from_root (eclass, level); + const t8_gloidx_t leaf_count = scheme->count_leaves_from_root (static_cast(scheme_id), level); ASSERT_EQ (leaf_count, compare_value) << "Incorrect leaf count " << leaf_count << " at eclass " << t8_eclass_to_string[eclass] << " and level " << level << " (expecting " << compare_value << ")"; @@ -79,50 +83,50 @@ TEST_P (class_element_leaves, test_element_count_leaves_root) TEST_P (class_element_leaves, test_element_count_leaves_less_level) { t8_element_t *element; - const int maxlevel = scheme->get_maxlevel (eclass); + const int maxlevel = scheme->get_maxlevel (static_cast(scheme_id)); /* Allocate memory for an element */ - scheme->element_new (eclass, 1, &element); + scheme->element_new (static_cast(scheme_id), 1, &element); for (int level = 0; level <= maxlevel; ++level) { /* Create the first element on this level */ - scheme->element_set_linear_id (eclass, element, level, 0); + scheme->element_set_linear_id (static_cast(scheme_id), element, level, 0); /* Count the leaves of this element */ - const t8_gloidx_t leaf_count_same_level = scheme->element_count_leaves (eclass, element, level); + const t8_gloidx_t leaf_count_same_level = scheme->element_count_leaves (static_cast(scheme_id), element, level); /* Check if equals 1 */ ASSERT_EQ (leaf_count_same_level, 1); int lower_levels; for (lower_levels = level - 1; lower_levels >= 0; --lower_levels) { /* Count the leaves of this element on the lower levels */ - const t8_gloidx_t leaf_count = scheme->element_count_leaves (eclass, element, lower_levels); + const t8_gloidx_t leaf_count = scheme->element_count_leaves (static_cast(scheme_id), element, lower_levels); /* Check if equals 0 */ ASSERT_EQ (leaf_count, 0) << "Incorrect leaf count " << leaf_count << " at eclass " << t8_eclass_to_string[eclass] << " and level " << level << " for element level " << lower_levels << "(expecting 0)"; } } /* Free the element's memory */ - scheme->element_destroy (eclass, 1, &element); + scheme->element_destroy (static_cast(scheme_id), 1, &element); } /* Tests whether the leaf count for one additional level matches the number of children */ TEST_P (class_element_leaves, test_element_count_leaves_one_level) { t8_element_t *element; - const int maxlevel = scheme->get_maxlevel (eclass); + const int maxlevel = scheme->get_maxlevel (static_cast(scheme_id)); - scheme->element_new (eclass, 1, &element); + scheme->element_new (static_cast(scheme_id), 1, &element); for (int level = 1; level < maxlevel; ++level) { /* Create the first element on the previous level */ - scheme->element_set_linear_id (eclass, element, level - 1, 0); + scheme->element_set_linear_id (static_cast(scheme_id), element, level - 1, 0); /* Count the leaves of this element */ - const t8_gloidx_t leaf_count = scheme->element_count_leaves (eclass, element, level); + const t8_gloidx_t leaf_count = scheme->element_count_leaves (static_cast(scheme_id), element, level); /* Compute the number of children of the element */ - const int number_of_children = scheme->element_get_num_children (eclass, element); + const int number_of_children = scheme->element_get_num_children (static_cast(scheme_id), element); /* Check both values for equality */ ASSERT_EQ (leaf_count, number_of_children) << "Incorrect leaf count " << leaf_count << " at eclass " << t8_eclass_to_string[eclass] << " and level " << level << " (expecting " << number_of_children << ")"; } - scheme->element_destroy (eclass, 1, &element); + scheme->element_destroy (static_cast(scheme_id), 1, &element); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_element_count_leaves, class_element_leaves, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_element_count_leaves, class_element_leaves, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_equal.cxx b/test/t8_schemes/t8_gtest_equal.cxx index cea06bff2c..434dc681e3 100644 --- a/test/t8_schemes/t8_gtest_equal.cxx +++ b/test/t8_schemes/t8_gtest_equal.cxx @@ -31,21 +31,21 @@ class class_test_equal: public TestDFS { void check_element () override { - const int num_children = scheme->element_get_num_children (tree_class, element); + const int num_children = scheme->element_get_num_children (static_cast(scheme_id), element); for (int ichild1 = 0; ichild1 < num_children; ichild1++) { - scheme->element_get_child (tree_class, element, ichild1, child1); + scheme->element_get_child (static_cast(scheme_id), element, ichild1, child1); /* the child must be different than its parent */ - EXPECT_FALSE (scheme->element_is_equal (tree_class, element, child1)); + EXPECT_FALSE (scheme->element_is_equal (static_cast(scheme_id), element, child1)); for (int ichild2 = 0; ichild2 < num_children; ichild2++) { - scheme->element_get_child (tree_class, element, ichild2, child2); + scheme->element_get_child (static_cast(scheme_id), element, ichild2, child2); /* the child must be different than its parent */ - EXPECT_FALSE (scheme->element_is_equal (tree_class, element, child2)); - const int equal = scheme->element_is_equal (tree_class, child1, child2); + EXPECT_FALSE (scheme->element_is_equal (static_cast(scheme_id), element, child2)); + const int equal = scheme->element_is_equal (static_cast(scheme_id), child1, child2); /* The children must be equal if and only if their indices are equal. */ EXPECT_EQ (equal, ichild1 == ichild2); /* t8_element_equal should compute the same as t8_element_compare, * when we only check if compare has 0 as result. */ - const int compare_equal = !scheme->element_compare (tree_class, child1, child2); + const int compare_equal = !scheme->element_compare (static_cast(scheme_id), child1, child2); EXPECT_EQ (equal, compare_equal); } } @@ -57,15 +57,15 @@ class class_test_equal: public TestDFS { { dfs_test_setup (); /* Get element and initialize it */ - scheme->element_new (tree_class, 1, &child1); - scheme->element_new (tree_class, 1, &child2); + scheme->element_new (static_cast(scheme_id), 1, &child1); + scheme->element_new (static_cast(scheme_id), 1, &child2); } void TearDown () override { /* Destroy element */ - scheme->element_destroy (tree_class, 1, &child1); - scheme->element_destroy (tree_class, 1, &child2); + scheme->element_destroy (static_cast(scheme_id), 1, &child1); + scheme->element_destroy (static_cast(scheme_id), 1, &child2); /* Destroy DFS test */ dfs_test_teardown (); @@ -84,4 +84,4 @@ TEST_P (class_test_equal, test_equal_dfs) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_equal, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_test_all_imps, class_test_equal, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_face_descendant.cxx b/test/t8_schemes/t8_gtest_face_descendant.cxx index be278e02a3..921215ba3e 100644 --- a/test/t8_schemes/t8_gtest_face_descendant.cxx +++ b/test/t8_schemes/t8_gtest_face_descendant.cxx @@ -67,22 +67,22 @@ class class_descendant: public TestDFS { * by the scheme implementation t8_element_first_descendant for the first descendants over the levels. */ - const int level = scheme->element_get_level (tree_class, element); - const int num_faces = scheme->element_get_num_faces (tree_class, element); + const int level = scheme->element_get_level (static_cast(scheme_id), element); + const int num_faces = scheme->element_get_num_faces (static_cast(scheme_id), element); /* Testing the linear first descendant. */ for (int ilevel = level + 1; ilevel < max_test_lvl; ilevel++) { for (int jface = 0; jface < num_faces; jface++) { - t8_test_manual_first_last_face_descendant (scheme, element, tree_class, jface, ilevel, 0, manual_face_desc); - scheme->element_get_first_descendant_face (tree_class, element, jface, scheme_face_desc, ilevel); + t8_test_manual_first_last_face_descendant (scheme, element, static_cast(scheme_id), jface, ilevel, 0, manual_face_desc); + scheme->element_get_first_descendant_face (static_cast(scheme_id), element, jface, scheme_face_desc, ilevel); /* Compare the manually computed child with the result of t8_element_first_descendant_face. */ - EXPECT_ELEM_EQ (scheme, tree_class, scheme_face_desc, manual_face_desc); + EXPECT_ELEM_EQ (scheme, scheme_id, scheme_face_desc, manual_face_desc); - t8_test_manual_first_last_face_descendant (scheme, element, tree_class, jface, ilevel, 1, manual_face_desc); - scheme->element_get_last_descendant_face (tree_class, element, jface, scheme_face_desc, ilevel); + t8_test_manual_first_last_face_descendant (scheme, element, static_cast(scheme_id), jface, ilevel, 1, manual_face_desc); + scheme->element_get_last_descendant_face (static_cast(scheme_id), element, jface, scheme_face_desc, ilevel); /* Compare the manually computed child with the result of t8_element_last_descendant_face. */ - EXPECT_ELEM_EQ (scheme, tree_class, scheme_face_desc, manual_face_desc); + EXPECT_ELEM_EQ (scheme, scheme_id, scheme_face_desc, manual_face_desc); } } } @@ -92,15 +92,15 @@ class class_descendant: public TestDFS { SetUp () override { dfs_test_setup (); - max_test_lvl = scheme->get_maxlevel (tree_class); - scheme->element_new (tree_class, 1, &manual_face_desc); - scheme->element_new (tree_class, 1, &scheme_face_desc); + max_test_lvl = scheme->get_maxlevel (static_cast(scheme_id)); + scheme->element_new (static_cast(scheme_id), 1, &manual_face_desc); + scheme->element_new (static_cast(scheme_id), 1, &scheme_face_desc); } void TearDown () override { - scheme->element_destroy (tree_class, 1, &manual_face_desc); - scheme->element_destroy (tree_class, 1, &scheme_face_desc); + scheme->element_destroy (static_cast(scheme_id), 1, &manual_face_desc); + scheme->element_destroy (static_cast(scheme_id), 1, &scheme_face_desc); dfs_test_teardown (); } int max_test_lvl; @@ -120,4 +120,4 @@ TEST_P (class_descendant, t8_check_face_desc) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_element_face_descendant, class_descendant, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_element_face_descendant, class_descendant, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_face_neigh.cxx b/test/t8_schemes/t8_gtest_face_neigh.cxx index 2d247c9f52..5bc91daaf5 100644 --- a/test/t8_schemes/t8_gtest_face_neigh.cxx +++ b/test/t8_schemes/t8_gtest_face_neigh.cxx @@ -28,32 +28,32 @@ #include -class face_neigh: public testing::TestWithParam { +class face_neigh: public testing::TestWithParam { protected: void SetUp () override { - tree_class = GetParam (); + scheme_id = GetParam (); scheme = t8_scheme_all_schemes (); - scheme->element_new (tree_class, 1, &element); - scheme->element_new (tree_class, 1, &child); - scheme->element_new (tree_class, 1, &neigh); - scheme->get_root (tree_class, element); + scheme->element_new (static_cast(scheme_id), 1, &element); + scheme->element_new (static_cast(scheme_id), 1, &child); + scheme->element_new (static_cast(scheme_id), 1, &neigh); + scheme->get_root (static_cast(scheme_id), element); } void TearDown () override { - scheme->element_destroy (tree_class, 1, &element); - scheme->element_destroy (tree_class, 1, &child); - scheme->element_destroy (tree_class, 1, &neigh); + scheme->element_destroy (static_cast(scheme_id), 1, &element); + scheme->element_destroy (static_cast(scheme_id), 1, &child); + scheme->element_destroy (static_cast(scheme_id), 1, &neigh); scheme->unref (); } t8_element_t *element; t8_element_t *child; t8_element_t *neigh; + int scheme_id; t8_scheme *scheme; - t8_eclass_t tree_class; #ifdef T8_ENABLE_LESS_TESTS const int maxlvl = 3; @@ -64,7 +64,7 @@ class face_neigh: public testing::TestWithParam { void t8_test_face_neighbor_inside (int num_faces, t8_element_t *element, t8_element_t *child, t8_element_t *neigh, - t8_scheme *scheme, t8_eclass_t tree_class) + t8_scheme *scheme, const int scheme_id) { int face_num; int check; @@ -72,17 +72,17 @@ t8_test_face_neighbor_inside (int num_faces, t8_element_t *element, t8_element_t for (int iface = 0; iface < num_faces; iface++) { /* Compute the neighbors neighbor along a given face and check, if the result is the * original element. */ - scheme->element_get_face_neighbor_inside (tree_class, child, neigh, iface, &face_num); - scheme->element_get_face_neighbor_inside (tree_class, neigh, element, face_num, &check); + scheme->element_get_face_neighbor_inside (static_cast(scheme_id), child, neigh, iface, &face_num); + scheme->element_get_face_neighbor_inside (static_cast(scheme_id), neigh, element, face_num, &check); - EXPECT_TRUE (scheme->element_is_equal (tree_class, child, element)) << "Got a false neighbor."; - EXPECT_ELEM_EQ (scheme, tree_class, child, element); + EXPECT_TRUE (scheme->element_is_equal (static_cast(scheme_id), child, element)) << "Got a false neighbor."; + EXPECT_ELEM_EQ (scheme, scheme_id, child, element); } } int t8_test_get_middle_child (t8_eclass_t eclass, int ilevel, t8_element_t *element, t8_element_t *child, t8_scheme *scheme, - const t8_eclass_t tree_class) + const int scheme_id) { /* Get the child number of the child in the middle of the element, depending of the shape of the element. */ switch (eclass) { @@ -93,24 +93,24 @@ t8_test_get_middle_child (t8_eclass_t eclass, int ilevel, t8_element_t *element, case T8_ECLASS_QUAD: /* There are no inner children in level one refinement. The test starts with level two, because this is the first level, inner children exists. The third child of level one child 0 is one of four middle children in level two. */ - scheme->element_get_child (tree_class, element, 0, child); - scheme->element_copy (tree_class, child, element); + scheme->element_get_child (static_cast(scheme_id), element, 0, child); + scheme->element_copy (static_cast(scheme_id), child, element); return 3; case T8_ECLASS_TRIANGLE: return 3; case T8_ECLASS_HEX: /* There are no inner children in level one refinement. The test starts with level two, because this is the first level, inner children existing. The third child of level one child 4 is one of eight middle children in level two. */ - scheme->element_get_child (tree_class, element, 4, child); - scheme->element_copy (tree_class, child, element); + scheme->element_get_child (static_cast(scheme_id), element, 4, child); + scheme->element_copy (static_cast(scheme_id), child, element); return 3; case T8_ECLASS_TET: return 3; case T8_ECLASS_PRISM: /* There are no inner children in level one refinement. The test starts with level two, because this is the first level, inner children existing. The last child of level one child 4 is one of eight middle children in level two. */ - scheme->element_get_child (tree_class, element, 4, child); - scheme->element_copy (tree_class, child, element); + scheme->element_get_child (static_cast(scheme_id), element, 4, child); + scheme->element_copy (static_cast(scheme_id), child, element); return 7; case T8_ECLASS_PYRAMID: { t8_dpyramid_t *pyramid = (t8_dpyramid_t *) element; @@ -135,31 +135,31 @@ TEST_P (face_neigh, check_not_inside_root) { /* Are the neighbors of the element really outside?. */ - const int num_faces = scheme->element_get_num_faces (tree_class, element); + const int num_faces = scheme->element_get_num_faces (static_cast(scheme_id), element); for (int iface = 0; iface < num_faces; iface++) { - const int num_children = scheme->element_get_num_face_children (tree_class, element, iface); + const int num_children = scheme->element_get_num_face_children (static_cast(scheme_id), element, iface); int *child_indices = T8_ALLOC (int, num_children); t8_element_t **children = T8_ALLOC (t8_element_t *, num_children); - scheme->element_new (tree_class, num_children, children); - scheme->element_get_children_at_face (tree_class, element, iface, children, num_children, child_indices); + scheme->element_new (static_cast(scheme_id), num_children, children); + scheme->element_get_children_at_face (static_cast(scheme_id), element, iface, children, num_children, child_indices); for (int jchild = 0; jchild < num_children; jchild++) { const int child_id = child_indices[jchild]; - const int face_contact = scheme->element_face_get_child_face (tree_class, element, iface, jchild); + const int face_contact = scheme->element_face_get_child_face (static_cast(scheme_id), element, iface, jchild); - scheme->element_get_child (tree_class, element, child_id, child); + scheme->element_get_child (static_cast(scheme_id), element, child_id, child); int face_num; - int inside = scheme->element_get_face_neighbor_inside (tree_class, child, neigh, face_contact, &face_num); + int inside = scheme->element_get_face_neighbor_inside (static_cast(scheme_id), child, neigh, face_contact, &face_num); ASSERT_EQ (inside, 0) << "Element is not outside."; - inside = scheme->element_get_tree_face (tree_class, child, face_contact); + inside = scheme->element_get_tree_face (static_cast(scheme_id), child, face_contact); ASSERT_EQ (inside, iface) << "Wrong face."; } - scheme->element_destroy (tree_class, num_children, children); + scheme->element_destroy (static_cast(scheme_id), num_children, children); T8_FREE (children); T8_FREE (child_indices); } @@ -193,10 +193,11 @@ t8_recursive_check_diff (t8_element_t *element, t8_element_t *child, t8_element_ TEST_P (face_neigh, recursive_check_diff) { int level = 1; - const int middle_child_id = t8_test_get_middle_child (tree_class, level, element, child, scheme, tree_class); - scheme->element_get_child (tree_class, element, middle_child_id, child); + const t8_eclass_t tree_class = scheme->get_eclass_scheme_eclass(static_cast(scheme_id)); + const int middle_child_id = t8_test_get_middle_child (tree_class, level, element, child, scheme, scheme_id); + scheme->element_get_child (static_cast(scheme_id), element, middle_child_id, child); t8_recursive_check_diff (child, element, neigh, scheme, tree_class, maxlvl, level); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_face_neigh, face_neigh, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_face_neigh, face_neigh, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_find_parent.cxx b/test/t8_schemes/t8_gtest_find_parent.cxx index f280f2c9b4..012d26d643 100644 --- a/test/t8_schemes/t8_gtest_find_parent.cxx +++ b/test/t8_schemes/t8_gtest_find_parent.cxx @@ -31,13 +31,13 @@ class class_find_parent: public TestDFS { void check_element () override { - const int num_children = scheme->element_get_num_children (tree_class, element); + const int num_children = scheme->element_get_num_children (static_cast(scheme_id), element); for (int ichild = 0; ichild < num_children; ichild++) { - scheme->element_get_child (tree_class, element, ichild, child); + scheme->element_get_child (static_cast(scheme_id), element, ichild, child); /* Compute parent of child */ - scheme->element_get_parent (tree_class, child, test_parent); + scheme->element_get_parent (static_cast(scheme_id), child, test_parent); /* Check that it is equal to the original element */ - EXPECT_ELEM_EQ (scheme, tree_class, element, test_parent); + EXPECT_ELEM_EQ (scheme, scheme_id, element, test_parent); } } @@ -47,15 +47,15 @@ class class_find_parent: public TestDFS { { dfs_test_setup (); /* Get element and initialize it */ - scheme->element_new (tree_class, 1, &child); - scheme->element_new (tree_class, 1, &test_parent); + scheme->element_new (static_cast(scheme_id), 1, &child); + scheme->element_new (static_cast(scheme_id), 1, &test_parent); } void TearDown () override { /* Destroy element */ - scheme->element_destroy (tree_class, 1, &child); - scheme->element_destroy (tree_class, 1, &test_parent); + scheme->element_destroy (static_cast(scheme_id), 1, &child); + scheme->element_destroy (static_cast(scheme_id), 1, &test_parent); /* Destroy DFS test */ dfs_test_teardown (); @@ -74,4 +74,4 @@ TEST_P (class_find_parent, t8_compute_child_find_parent) check_recursive_dfs_to_max_lvl (maxlvl); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_find_parent, class_find_parent, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_find_parent, class_find_parent, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_init_linear_id.cxx b/test/t8_schemes/t8_gtest_init_linear_id.cxx index 7e49b4167e..df2e1de06c 100644 --- a/test/t8_schemes/t8_gtest_init_linear_id.cxx +++ b/test/t8_schemes/t8_gtest_init_linear_id.cxx @@ -28,31 +28,31 @@ #include #include -class linear_id: public testing::TestWithParam { +class linear_id: public testing::TestWithParam { protected: void SetUp () override { - tree_class = GetParam (); + scheme_id = GetParam (); scheme = t8_scheme_all_schemes (); - scheme->element_new (tree_class, 1, &element); - scheme->element_new (tree_class, 1, &child); - scheme->element_new (tree_class, 1, &test); - scheme->get_root (tree_class, element); + scheme->element_new (static_cast(scheme_id), 1, &element); + scheme->element_new (static_cast(scheme_id), 1, &child); + scheme->element_new (static_cast(scheme_id), 1, &test); + scheme->get_root (static_cast(scheme_id), element); } void TearDown () override { - scheme->element_destroy (tree_class, 1, &element); - scheme->element_destroy (tree_class, 1, &child); - scheme->element_destroy (tree_class, 1, &test); + scheme->element_destroy (static_cast(scheme_id), 1, &element); + scheme->element_destroy (static_cast(scheme_id), 1, &child); + scheme->element_destroy (static_cast(scheme_id), 1, &test); scheme->unref (); } t8_element_t *element; t8_element_t *child; t8_element_t *test; + int scheme_id; t8_scheme *scheme; - t8_eclass_t tree_class; sc_MPI_Comm comm = sc_MPI_COMM_WORLD; }; @@ -76,7 +76,7 @@ TEST_P (linear_id, uniform_forest) const int maxlvl = 6; #endif /* Construct a forest with a single element of the current class*/ - cmesh = t8_cmesh_new_from_class (tree_class, comm); + cmesh = t8_cmesh_new_from_class (static_cast(scheme_id), comm); t8_cmesh_ref (cmesh); forest = t8_forest_new_uniform (cmesh, scheme, 0, 0, comm); const t8_scheme *tc_scheme = t8_forest_get_scheme (forest); @@ -89,14 +89,13 @@ TEST_P (linear_id, uniform_forest) /*Get the number of elements in the tree*/ const t8_locidx_t num_elements_in_tree = t8_forest_get_tree_num_elements (forest, tree_id); /*Manually compute the id of the first element*/ - const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, tree_id); - const t8_locidx_t shift = tc_scheme->count_leaves_from_root (tree_class, level) - num_elements_in_tree; + const t8_locidx_t shift = tc_scheme->count_leaves_from_root (static_cast(scheme_id), level) - num_elements_in_tree; /*Iterate over elements */ for (t8_locidx_t id_iter = 0; id_iter < num_elements_in_tree; id_iter++) { /*Get the current element*/ const t8_element_t *element = t8_forest_get_element_in_tree (forest, tree_id, id_iter); /*Get the ID of the element at current level */ - const t8_locidx_t id = tc_scheme->element_get_linear_id (tree_class, element, level); + const t8_locidx_t id = tc_scheme->element_get_linear_id (static_cast(scheme_id), element, level); /* Check the computed id*/ EXPECT_EQ (id, id_iter + shift); } @@ -125,21 +124,21 @@ TEST_P (linear_id, id_at_other_level) #endif for (int level = 0; level < max_lvl; level++) { /* Compute the number of elements at the current level */ - const t8_linearidx_t num_desc = scheme->count_leaves_from_root (tree_class, level); + const t8_linearidx_t num_desc = scheme->count_leaves_from_root (static_cast(scheme_id), level); for (t8_linearidx_t id = 0; id < num_desc; id++) { /* Set the child at the current level */ - scheme->element_set_linear_id (tree_class, child, level, id); + scheme->element_set_linear_id (static_cast(scheme_id), child, level, id); /* Compute the id of child at a higher level. */ - const t8_linearidx_t id_at_lvl = scheme->element_get_linear_id (tree_class, child, level + add_lvl); + const t8_linearidx_t id_at_lvl = scheme->element_get_linear_id (static_cast(scheme_id), child, level + add_lvl); /* Compute how many leaves/descendants child has at level level+add_lvl */ - const t8_linearidx_t child_desc = scheme->element_count_leaves (tree_class, child, level + add_lvl); + const t8_linearidx_t child_desc = scheme->element_count_leaves (static_cast(scheme_id), child, level + add_lvl); /* Iterate over all descendants */ for (t8_linearidx_t leaf_id = 0; leaf_id < child_desc; leaf_id++) { /* Set the descendant (test) at level of the descendants and shift the * leaf_id into the region of the descendants of child*/ - scheme->element_set_linear_id (tree_class, test, level + add_lvl, id_at_lvl + leaf_id); + scheme->element_set_linear_id (static_cast(scheme_id), test, level + add_lvl, id_at_lvl + leaf_id); /* Compute the id of the descendant (test) at the current level */ - const t8_linearidx_t test_id = scheme->element_get_linear_id (tree_class, test, level); + const t8_linearidx_t test_id = scheme->element_get_linear_id (static_cast(scheme_id), test, level); /* test_id and id should be equal. */ EXPECT_EQ (id, test_id); } @@ -147,4 +146,4 @@ TEST_P (linear_id, id_at_other_level) } } -INSTANTIATE_TEST_SUITE_P (t8_test_init_linear_id, linear_id, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_test_init_linear_id, linear_id, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_nca.cxx b/test/t8_schemes/t8_gtest_nca.cxx index a78eab6474..9cdb9ff824 100644 --- a/test/t8_schemes/t8_gtest_nca.cxx +++ b/test/t8_schemes/t8_gtest_nca.cxx @@ -31,26 +31,27 @@ #include #include -class nca: public testing::TestWithParam { +class nca: public testing::TestWithParam { protected: void SetUp () override { - tree_class = GetParam (); + scheme_id = GetParam (); scheme = t8_scheme_all_schemes (); - scheme->element_new (tree_class, 1, &correct_nca); - scheme->element_new (tree_class, 1, &desc_a); - scheme->element_new (tree_class, 1, &desc_b); - scheme->element_new (tree_class, 1, &check); - scheme->element_set_linear_id (tree_class, correct_nca, 0, 0); + tree_class = scheme->get_eclass_scheme_eclass (static_cast(scheme_id)); + scheme->element_new (static_cast(scheme_id), 1, &correct_nca); + scheme->element_new (static_cast(scheme_id), 1, &desc_a); + scheme->element_new (static_cast(scheme_id), 1, &desc_b); + scheme->element_new (static_cast(scheme_id), 1, &check); + scheme->element_set_linear_id (static_cast(scheme_id), correct_nca, 0, 0); } void TearDown () override { - scheme->element_destroy (tree_class, 1, &correct_nca); - scheme->element_destroy (tree_class, 1, &desc_a); - scheme->element_destroy (tree_class, 1, &desc_b); - scheme->element_destroy (tree_class, 1, &check); + scheme->element_destroy (static_cast(scheme_id), 1, &correct_nca); + scheme->element_destroy (static_cast(scheme_id), 1, &desc_a); + scheme->element_destroy (static_cast(scheme_id), 1, &desc_b); + scheme->element_destroy (static_cast(scheme_id), 1, &check); scheme->unref (); } /* correct_nca -> the nearest common ancestor that we check for @@ -60,6 +61,7 @@ class nca: public testing::TestWithParam { */ t8_element_t *correct_nca, *desc_a, *desc_b, *check; t8_scheme *scheme; + int scheme_id; t8_eclass_t tree_class; }; @@ -69,16 +71,16 @@ class nca: public testing::TestWithParam { */ TEST_P (nca, nca_check_shallow) { - const int num_children = scheme->element_get_num_children (tree_class, correct_nca); + const int num_children = scheme->element_get_num_children (static_cast(scheme_id), correct_nca); /* Iterate over all combinations of two children from correct_nca */ for (int i = 0; i < num_children - 1; i++) { - scheme->element_get_child (tree_class, correct_nca, i, desc_a); + scheme->element_get_child (static_cast(scheme_id), correct_nca, i, desc_a); for (int j = i + 1; j < num_children; j++) { - scheme->element_get_child (tree_class, correct_nca, j, desc_b); + scheme->element_get_child (static_cast(scheme_id), correct_nca, j, desc_b); /*Compute the nca */ - scheme->element_get_nca (tree_class, desc_a, desc_b, check); + scheme->element_get_nca (static_cast(scheme_id), desc_a, desc_b, check); /*expect equality */ - EXPECT_ELEM_EQ (scheme, tree_class, check, correct_nca); + EXPECT_ELEM_EQ (scheme, scheme_id, check, correct_nca); } } } @@ -92,32 +94,32 @@ TEST_P (nca, nca_check_shallow) TEST_P (nca, nca_check_deep) { const int max_lvl = 10; - const int elem_max_level = scheme->get_maxlevel (tree_class); + const int elem_max_level = scheme->get_maxlevel (static_cast(scheme_id)); /* num_children is not a const here, cause this can change for pyramids */ int num_children; /* iterate over levels and children */ int lvl, check_lvl_a, check_lvl_b, child_id; t8_element_t *tmp; - scheme->element_new (tree_class, 1, &tmp); - scheme->element_copy (tree_class, correct_nca, tmp); + scheme->element_new (static_cast(scheme_id), 1, &tmp); + scheme->element_copy (static_cast(scheme_id), correct_nca, tmp); for (lvl = 1; lvl <= max_lvl; lvl++) { - num_children = scheme->element_get_num_children (tree_class, tmp); + num_children = scheme->element_get_num_children (static_cast(scheme_id), tmp); for (child_id = 0; child_id < num_children; child_id++) { - scheme->element_get_child (tree_class, tmp, child_id, correct_nca); + scheme->element_get_child (static_cast(scheme_id), tmp, child_id, correct_nca); /* Compute first and last descendant at every level up to elem_max_lvl. * They have the correct_nca as the nca */ for (check_lvl_a = lvl + 1; check_lvl_a < elem_max_level; check_lvl_a++) { - scheme->element_get_first_descendant (tree_class, correct_nca, desc_a, check_lvl_a); + scheme->element_get_first_descendant (static_cast(scheme_id), correct_nca, desc_a, check_lvl_a); for (check_lvl_b = lvl + 1; check_lvl_b < elem_max_level; check_lvl_b++) { - scheme->element_get_last_descendant (tree_class, correct_nca, desc_b, check_lvl_b); + scheme->element_get_last_descendant (static_cast(scheme_id), correct_nca, desc_b, check_lvl_b); /* Compute the nca of desc_a and desc_b */ - scheme->element_get_nca (tree_class, desc_a, desc_b, check); + scheme->element_get_nca (static_cast(scheme_id), desc_a, desc_b, check); if (tree_class == T8_ECLASS_VERTEX) { /* first- last-descendant logic does not hold for vertices. */ EXPECT_EQ ( - scheme->element_get_level (tree_class, check), - SC_MIN (scheme->element_get_level (tree_class, desc_a), scheme->element_get_level (tree_class, desc_b))); + scheme->element_get_level (static_cast(scheme_id), check), + SC_MIN (scheme->element_get_level (static_cast(scheme_id), desc_a), scheme->element_get_level (static_cast(scheme_id), desc_b))); } else { /* Expect equality of correct_nca and check for every other class */ @@ -128,15 +130,15 @@ TEST_P (nca, nca_check_deep) } /* Determine next element */ if (num_children != 1) { - scheme->element_copy (tree_class, tmp, correct_nca); + scheme->element_copy (static_cast(scheme_id), tmp, correct_nca); /* Continue in the middle */ - scheme->element_get_child (tree_class, correct_nca, num_children / 2, tmp); + scheme->element_get_child (static_cast(scheme_id), correct_nca, num_children / 2, tmp); } else { - scheme->element_copy (tree_class, correct_nca, tmp); + scheme->element_copy (static_cast(scheme_id), correct_nca, tmp); } } - scheme->element_destroy (tree_class, 1, &tmp); + scheme->element_destroy (static_cast(scheme_id), 1, &tmp); } /** @@ -155,66 +157,66 @@ TEST_P (nca, nca_check_deep) static void t8_recursive_nca_check (t8_element_t *check_nca, t8_element_t *desc_a, t8_element_t *desc_b, t8_element_t *check, t8_element_t *parent_a, t8_element_t *parent_b, const int max_lvl, t8_scheme *scheme, - const t8_eclass_t tree_class) + const int scheme_id) { - T8_ASSERT (max_lvl <= scheme->get_maxlevel (tree_class) - 1); + T8_ASSERT (max_lvl <= scheme->get_maxlevel (static_cast(scheme_id)) - 1); /* compute the level of the parents */ - int level_a = scheme->element_get_level (tree_class, parent_a); - int level_b = scheme->element_get_level (tree_class, parent_b); + int level_a = scheme->element_get_level (static_cast(scheme_id), parent_a); + int level_b = scheme->element_get_level (static_cast(scheme_id), parent_b); int num_children_a, num_children_b; int i, j; /* If one parent has reached the maximal level, the test returns */ if (level_a == max_lvl || level_b == max_lvl) { return; } - num_children_a = scheme->element_get_num_children (tree_class, parent_a); - num_children_b = scheme->element_get_num_children (tree_class, parent_b); + num_children_a = scheme->element_get_num_children (static_cast(scheme_id), parent_a); + num_children_b = scheme->element_get_num_children (static_cast(scheme_id), parent_b); /* Iterate over all children of parent_a */ for (i = 0; i < num_children_a; i++) { - scheme->element_get_child (tree_class, parent_a, i, desc_a); + scheme->element_get_child (static_cast(scheme_id), parent_a, i, desc_a); /* Iterate over all children of parent_b */ for (j = 0; j < num_children_b; j++) { - scheme->element_get_child (tree_class, parent_b, j, desc_b); - scheme->element_get_nca (tree_class, desc_a, desc_b, check); + scheme->element_get_child (static_cast(scheme_id), parent_b, j, desc_b); + scheme->element_get_nca (static_cast(scheme_id), desc_a, desc_b, check); - if (!scheme->element_is_equal (tree_class, check_nca, check)) { - level_a = scheme->element_get_level (tree_class, desc_a); - level_b = scheme->element_get_level (tree_class, desc_b); + if (!scheme->element_is_equal (static_cast(scheme_id), check_nca, check)) { + level_a = scheme->element_get_level (static_cast(scheme_id), desc_a); + level_b = scheme->element_get_level (static_cast(scheme_id), desc_b); - int level_c = scheme->element_get_level (tree_class, check_nca); - int level_nca = scheme->element_get_level (tree_class, check); + int level_c = scheme->element_get_level (static_cast(scheme_id), check_nca); + int level_nca = scheme->element_get_level (static_cast(scheme_id), check); /* Output the linear id of the descendants where the computation fails. * This makes debugging a lot easier, as one can reconstruct the descendants * via t8_element_set_linear_id and can directly test them instead of waiting * until the recursion reaches the faulty computation. */ t8_debugf ("id of desc_a: %li, level: %i\n", - static_cast (scheme->element_get_linear_id (tree_class, desc_a, level_a)), level_a); + static_cast (scheme->element_get_linear_id (static_cast(scheme_id), desc_a, level_a)), level_a); t8_debugf ("id of desc_b: %li, level: %i\n", - static_cast (scheme->element_get_linear_id (tree_class, desc_b, level_b)), level_b); + static_cast (scheme->element_get_linear_id (static_cast(scheme_id), desc_b, level_b)), level_b); for (int k = SC_MAX (level_a, level_b); k >= 0; k--) { t8_debugf ("id of desc_a: %li, level: %i\n", - static_cast (scheme->element_get_linear_id (tree_class, desc_a, k)), k); + static_cast (scheme->element_get_linear_id (static_cast(scheme_id), desc_a, k)), k); t8_debugf ("id of desc_b: %li, level: %i\n", - static_cast (scheme->element_get_linear_id (tree_class, desc_b, k)), k); + static_cast (scheme->element_get_linear_id (static_cast(scheme_id), desc_b, k)), k); } t8_debugf ("id of the correct nca: %li, level: %i\n", - static_cast (scheme->element_get_linear_id (tree_class, check_nca, level_c)), level_c); + static_cast (scheme->element_get_linear_id (static_cast(scheme_id), check_nca, level_c)), level_c); t8_debugf ("id of the computed nca: %li, level: %i\n", - static_cast (scheme->element_get_linear_id (tree_class, check, level_nca)), level_nca); + static_cast (scheme->element_get_linear_id (static_cast(scheme_id), check, level_nca)), level_nca); SC_ABORT ("Computed nca is not the correct nca!\n"); } /* parent_a stays fixed, b-part goes one level deeper into the recursion */ - t8_recursive_nca_check (check_nca, desc_a, parent_b, check, parent_a, desc_b, max_lvl, scheme, tree_class); + t8_recursive_nca_check (check_nca, desc_a, parent_b, check, parent_a, desc_b, max_lvl, scheme, scheme_id); /* We reused parent_b, hence we have to recompute the correct parent */ - scheme->element_get_parent (tree_class, desc_b, parent_b); + scheme->element_get_parent (static_cast(scheme_id), desc_b, parent_b); } /* We reused parent_a, hence we have to recompute the correct parent */ - scheme->element_get_parent (tree_class, desc_a, parent_a); + scheme->element_get_parent (static_cast(scheme_id), desc_a, parent_a); } } @@ -231,27 +233,27 @@ TEST_P (nca, recursive_check) #endif t8_element_t *parent_a, *parent_b; int num_children; - num_children = scheme->element_get_num_children (tree_class, correct_nca); + num_children = scheme->element_get_num_children (static_cast(scheme_id), correct_nca); int i, j; if (num_children > 1) { - scheme->element_new (tree_class, 1, &parent_a); - scheme->element_new (tree_class, 1, &parent_b); - scheme->element_get_child (tree_class, correct_nca, 0, parent_a); - scheme->element_get_child (tree_class, correct_nca, 1, parent_b); + scheme->element_new (static_cast(scheme_id), 1, &parent_a); + scheme->element_new (static_cast(scheme_id), 1, &parent_b); + scheme->element_get_child (static_cast(scheme_id), correct_nca, 0, parent_a); + scheme->element_get_child (static_cast(scheme_id), correct_nca, 1, parent_b); for (i = 0; i < num_children - 1; i++) { - scheme->element_get_child (tree_class, correct_nca, i, parent_a); + scheme->element_get_child (static_cast(scheme_id), correct_nca, i, parent_a); for (j = i + 1; j < num_children; j++) { - scheme->element_get_child (tree_class, correct_nca, j, parent_b); + scheme->element_get_child (static_cast(scheme_id), correct_nca, j, parent_b); t8_recursive_nca_check (correct_nca, desc_a, desc_b, check, parent_a, parent_b, recursion_depth, scheme, - tree_class); + scheme_id); } } } else { GTEST_SKIP (); } - scheme->element_destroy (tree_class, 1, &parent_a); - scheme->element_destroy (tree_class, 1, &parent_b); + scheme->element_destroy (static_cast(scheme_id), 1, &parent_a); + scheme->element_destroy (static_cast(scheme_id), 1, &parent_b); } /* Test the nca recursively for elements in the middle of the uniform refinement tree @@ -261,7 +263,7 @@ TEST_P (nca, recursive_check_higher_level) { const int recursion_depth = 3; - const int max_lvl = scheme->get_maxlevel (tree_class); + const int max_lvl = scheme->get_maxlevel (static_cast(scheme_id)); t8_element_t *parent_a; t8_element_t *parent_b; t8_element_t *correct_nca_high_level; @@ -270,48 +272,48 @@ TEST_P (nca, recursive_check_higher_level) t8_gloidx_t leaves_on_level; EXPECT_TRUE (max_lvl - recursion_depth >= 0); - scheme->element_new (tree_class, 1, &parent_a); - scheme->element_new (tree_class, 1, &parent_b); - scheme->element_new (tree_class, 1, &correct_nca_high_level); + scheme->element_new (static_cast(scheme_id), 1, &parent_a); + scheme->element_new (static_cast(scheme_id), 1, &parent_b); + scheme->element_new (static_cast(scheme_id), 1, &correct_nca_high_level); /* Test on different levels around the middle of the refinement tree */ for (i = recursion_depth; i < max_lvl; i++) { - leaves_on_level = scheme->element_count_leaves (tree_class, correct_nca, i - recursion_depth); + leaves_on_level = scheme->element_count_leaves (static_cast(scheme_id), correct_nca, i - recursion_depth); /* middle = leaves/2 */ - scheme->element_set_linear_id (tree_class, correct_nca_high_level, i - recursion_depth, leaves_on_level / 2); + scheme->element_set_linear_id (static_cast(scheme_id), correct_nca_high_level, i - recursion_depth, leaves_on_level / 2); /* Initialization for recursive_nca_check */ - num_children = scheme->element_get_num_children (tree_class, correct_nca_high_level); + num_children = scheme->element_get_num_children (static_cast(scheme_id), correct_nca_high_level); if (num_children > 1) { /* Compute children on to different branches in the tree an test them. * This ensures, that the nca of all their descendants has to be correct_nca_high_level*/ for (k = 0; k < num_children; k++) { - scheme->element_get_child (tree_class, correct_nca_high_level, k, parent_a); + scheme->element_get_child (static_cast(scheme_id), correct_nca_high_level, k, parent_a); for (l = 0; l < num_children; l++) { - scheme->element_get_child (tree_class, correct_nca_high_level, l, parent_b); + scheme->element_get_child (static_cast(scheme_id), correct_nca_high_level, l, parent_b); if (k != l) { t8_recursive_nca_check (correct_nca_high_level, desc_a, desc_b, check, parent_a, parent_b, i, scheme, - tree_class); + scheme_id); } else { - scheme->element_get_nca (tree_class, parent_a, parent_b, check); - EXPECT_ELEM_EQ (scheme, tree_class, parent_a, check); - EXPECT_ELEM_EQ (scheme, tree_class, parent_b, check); + scheme->element_get_nca (static_cast(scheme_id), parent_a, parent_b, check); + EXPECT_ELEM_EQ (scheme, scheme_id, parent_a, check); + EXPECT_ELEM_EQ (scheme, scheme_id, parent_b, check); } } } } else { - scheme->element_destroy (tree_class, 1, &parent_a); - scheme->element_destroy (tree_class, 1, &parent_b); - scheme->element_destroy (tree_class, 1, &correct_nca_high_level); + scheme->element_destroy (static_cast(scheme_id), 1, &parent_a); + scheme->element_destroy (static_cast(scheme_id), 1, &parent_b); + scheme->element_destroy (static_cast(scheme_id), 1, &correct_nca_high_level); GTEST_SKIP (); } } /* Clean-up */ - scheme->element_destroy (tree_class, 1, &parent_a); - scheme->element_destroy (tree_class, 1, &parent_b); - scheme->element_destroy (tree_class, 1, &correct_nca_high_level); + scheme->element_destroy (static_cast(scheme_id), 1, &parent_a); + scheme->element_destroy (static_cast(scheme_id), 1, &parent_b); + scheme->element_destroy (static_cast(scheme_id), 1, &correct_nca_high_level); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_nca, nca, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_nca, nca, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_pack_unpack.cxx b/test/t8_schemes/t8_gtest_pack_unpack.cxx index d571927585..ac553f059b 100644 --- a/test/t8_schemes/t8_gtest_pack_unpack.cxx +++ b/test/t8_schemes/t8_gtest_pack_unpack.cxx @@ -40,17 +40,17 @@ class class_test_pack: public TestDFS { /* Compute pack size and allocate send buffer */ int pack_size; - const int num_children = scheme->element_get_num_children (tree_class, element); - scheme->element_MPI_Pack_size (tree_class, count, comm, &pack_size); + const int num_children = scheme->element_get_num_children (static_cast(scheme_id), element); + scheme->element_MPI_Pack_size (static_cast(scheme_id), count, comm, &pack_size); pack_size *= (num_children + 1); char *sendbuf = T8_ALLOC (char, pack_size); /* pack data */ - scheme->element_MPI_Pack (tree_class, &element, count, sendbuf, pack_size, &position, comm); + scheme->element_MPI_Pack (static_cast(scheme_id), &element, count, sendbuf, pack_size, &position, comm); t8_element_t **children = T8_ALLOC (t8_element_t *, num_children); - scheme->element_new (tree_class, num_children, children); - scheme->element_get_children (tree_class, element, num_children, children); - scheme->element_MPI_Pack (tree_class, children, num_children, sendbuf, pack_size, &position, comm); + scheme->element_new (static_cast(scheme_id), num_children, children); + scheme->element_get_children (static_cast(scheme_id), element, num_children, children); + scheme->element_MPI_Pack (static_cast(scheme_id), children, num_children, sendbuf, pack_size, &position, comm); int recvBufferSize = pack_size; char *recvbuf = T8_ALLOC (char, recvBufferSize); @@ -78,22 +78,22 @@ class class_test_pack: public TestDFS { #endif /* Unpack data */ position = 0; - scheme->element_MPI_Unpack (tree_class, recvbuf, recvBufferSize, &position, &element_compare, count, comm); + scheme->element_MPI_Unpack (static_cast(scheme_id), recvbuf, recvBufferSize, &position, &element_compare, count, comm); t8_element_t **children_compare = T8_ALLOC (t8_element_t *, num_children); - scheme->element_new (tree_class, num_children, children_compare); - scheme->element_MPI_Unpack (tree_class, recvbuf, recvBufferSize, &position, children_compare, num_children, comm); + scheme->element_new (static_cast(scheme_id), num_children, children_compare); + scheme->element_MPI_Unpack (static_cast(scheme_id), recvbuf, recvBufferSize, &position, children_compare, num_children, comm); /* free buffers */ T8_FREE (sendbuf); T8_FREE (recvbuf); /* Check that data was sent and received correctly */ - EXPECT_ELEM_EQ (scheme, tree_class, element, element_compare); + EXPECT_ELEM_EQ (scheme, scheme_id, element, element_compare); for (int ichild = 0; ichild < num_children; ichild++) { - EXPECT_ELEM_EQ (scheme, tree_class, children[ichild], children_compare[ichild]); + EXPECT_ELEM_EQ (scheme, scheme_id, children[ichild], children_compare[ichild]); } - scheme->element_destroy (tree_class, num_children, children); - scheme->element_destroy (tree_class, num_children, children_compare); + scheme->element_destroy (static_cast(scheme_id), num_children, children); + scheme->element_destroy (static_cast(scheme_id), num_children, children_compare); T8_FREE (children); T8_FREE (children_compare); } @@ -104,7 +104,7 @@ class class_test_pack: public TestDFS { { dfs_test_setup (); /* Get element and initialize it */ - scheme->element_new (tree_class, 1, &element_compare); + scheme->element_new (static_cast(scheme_id), 1, &element_compare); comm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_rank (comm, &rank); @@ -114,7 +114,7 @@ class class_test_pack: public TestDFS { TearDown () override { /* Destroy element */ - scheme->element_destroy (tree_class, 1, &element_compare); + scheme->element_destroy (static_cast(scheme_id), 1, &element_compare); /* Destroy DFS test */ dfs_test_teardown (); diff --git a/test/t8_schemes/t8_gtest_root.cxx b/test/t8_schemes/t8_gtest_root.cxx index cacecb9ef2..4977e0b387 100644 --- a/test/t8_schemes/t8_gtest_root.cxx +++ b/test/t8_schemes/t8_gtest_root.cxx @@ -31,42 +31,42 @@ #include #include -class root: public testing::TestWithParam { +class root: public testing::TestWithParam { protected: void SetUp () override { scheme = t8_scheme_all_schemes (); - tree_class = GetParam (); - scheme->element_new (tree_class, 1, &element); - scheme->get_root (tree_class, element); + scheme_id = GetParam (); + scheme->element_new (static_cast(scheme_id), 1, &element); + scheme->get_root (static_cast(scheme_id), element); } void TearDown () override { - scheme->element_destroy (tree_class, 1, &element); + scheme->element_destroy (static_cast(scheme_id), 1, &element); scheme->unref (); } t8_element_t *element; t8_scheme *scheme; - t8_eclass_t tree_class; + int scheme_id; }; /*Test root*/ TEST_P (root, has_level_zero) { - EXPECT_EQ (scheme->element_get_level (tree_class, element), 0); + EXPECT_EQ (scheme->element_get_level (static_cast(scheme_id), element), 0); } TEST_P (root, equals_linear_id_0_0) { t8_element_t *root_compare; - scheme->element_new (tree_class, 1, &root_compare); - scheme->element_set_linear_id (tree_class, root_compare, 0, 0); - EXPECT_ELEM_EQ (scheme, tree_class, element, root_compare); - scheme->element_destroy (tree_class, 1, &root_compare); + scheme->element_new (static_cast(scheme_id), 1, &root_compare); + scheme->element_set_linear_id (static_cast(scheme_id), root_compare, 0, 0); + EXPECT_ELEM_EQ (scheme, scheme_id, element, root_compare); + scheme->element_destroy (static_cast(scheme_id), 1, &root_compare); } INSTANTIATE_TEST_SUITE_P (t8_gtest_root, root, AllSchemes); diff --git a/test/t8_schemes/t8_gtest_successor.cxx b/test/t8_schemes/t8_gtest_successor.cxx index 4ac958e2ed..bab7fa0953 100644 --- a/test/t8_schemes/t8_gtest_successor.cxx +++ b/test/t8_schemes/t8_gtest_successor.cxx @@ -26,37 +26,40 @@ #include #include -class class_successor: public testing::TestWithParam { +class class_successor: public testing::TestWithParam { protected: void SetUp () override { - tree_class = GetParam (); scheme = t8_scheme_all_schemes (); - scheme->element_new (tree_class, 1, &element); - scheme->element_new (tree_class, 1, &successor); - scheme->element_new (tree_class, 1, &child); - scheme->element_new (tree_class, 1, &last); + scheme_id = GetParam (); + scheme->element_new (static_cast(scheme_id), 1, &element); + scheme->element_new (static_cast(scheme_id), 1, &successor); + scheme->element_new (static_cast(scheme_id), 1, &child); + scheme->element_new (static_cast(scheme_id), 1, &last); - scheme->get_root (tree_class, element); + scheme->get_root (static_cast(scheme_id), element); + + tree_class = scheme->get_eclass_scheme_eclass (static_cast(scheme_id)); if (tree_class == T8_ECLASS_VERTEX) GTEST_SKIP (); } void TearDown () override { - scheme->element_destroy (tree_class, 1, &element); - scheme->element_destroy (tree_class, 1, &successor); - scheme->element_destroy (tree_class, 1, &child); - scheme->element_destroy (tree_class, 1, &last); + scheme->element_destroy (static_cast(scheme_id), 1, &element); + scheme->element_destroy (static_cast(scheme_id), 1, &successor); + scheme->element_destroy (static_cast(scheme_id), 1, &child); + scheme->element_destroy (static_cast(scheme_id), 1, &last); scheme->unref (); } - t8_eclass_t tree_class; + int scheme_id; t8_scheme *scheme; t8_element_t *element; t8_element_t *successor; t8_element_t *child; t8_element_t *last; + t8_eclass_t tree_class; }; /* Check the computation of the successor recursively. Iterate through the elements @@ -141,14 +144,14 @@ TEST_P (class_successor, test_recursive_and_deep_successor) /* Test at lower level. */ for (int ilevel = 1; ilevel <= maxlvl; ilevel++) { - scheme->element_set_linear_id (tree_class, successor, ilevel, 0); - scheme->element_get_last_descendant (tree_class, element, last, ilevel); + scheme->element_set_linear_id (static_cast(scheme_id), successor, ilevel, 0); + scheme->element_get_last_descendant (static_cast(scheme_id), element, last, ilevel); t8_recursive_successor (element, successor, child, last, scheme, tree_class, ilevel); } /* Test at Maxlevel. */ - scheme->element_set_linear_id (tree_class, element, scheme->get_maxlevel (tree_class) - 2, 0); - scheme->element_set_linear_id (tree_class, successor, scheme->get_maxlevel (tree_class), 0); + scheme->element_set_linear_id (static_cast(scheme_id), element, scheme->get_maxlevel (static_cast(scheme_id)) - 2, 0); + scheme->element_set_linear_id (static_cast(scheme_id), successor, scheme->get_maxlevel (static_cast(scheme_id)), 0); t8_deep_successor (element, successor, last, scheme, tree_class); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_successor, class_successor, AllSchemes, print_eclass); +INSTANTIATE_TEST_SUITE_P (t8_gtest_successor, class_successor, AllSchemes);