diff --git a/src/t8_schemes/t8_scheme.hxx b/src/t8_schemes/t8_scheme.hxx index 0e71753390..6cf98c6ff1 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/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..89533f30cc 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 @@ -37,17 +37,22 @@ * 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 (); + const int scheme_id = std::get<0> (GetParam ()); + scheme = create_from_scheme_id (scheme_id); + tree_class = std::get<1> (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->ref (); t8_cmesh_ref (cmesh); @@ -60,8 +65,13 @@ 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); + } + else { + scheme->unref (); + } } int MPI_size; t8_eclass_t tree_class; @@ -145,5 +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, testing::Range (T8_ECLASS_LINE, T8_ECLASS_COUNT), - 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 8fb7fef755..17245b99f3 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 t8_eclass_t eclass, 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 (eclass, 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 (eclass); + scheme->element_to_string (eclass, elem_1, elem_1_string, BUFSIZ); + scheme->element_to_string (eclass, 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, eclass, elem1, elem2) \ + EXPECT_PRED_FORMAT4 (element_equality, (scheme), (eclass), (elem1), (elem2)) #define ASSERT_ELEM_EQ(scheme, tree_class, elem1, elem2) \ ASSERT_PRED_FORMAT4 (element_equality, (scheme), (tree_class), (elem1), (elem2)) diff --git a/test/t8_gtest_macros.hxx b/test/t8_gtest_macros.hxx index b3cdb559e2..9ebae45da7 100644 --- a/test/t8_gtest_macros.hxx +++ b/test/t8_gtest_macros.hxx @@ -29,6 +29,9 @@ #include #include +#include +#include +#include /** * lambda to pass to an INSTANTIATE_TEST_SUITE_P to print the current cmesh_example_base diff --git a/test/t8_gtest_schemes.hxx b/test/t8_gtest_schemes.hxx new file mode 100644 index 0000000000..01ea38a007 --- /dev/null +++ b/test/t8_gtest_schemes.hxx @@ -0,0 +1,44 @@ +/* + 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 * +create_from_scheme_id (const int scheme_id) +{ + switch (scheme_id) { + case 0: + return t8_scheme_new_default (); + default: + SC_ABORT_NOT_REACHED (); + return nullptr; + } +} + +#define AllSchemes ::testing::Combine (::testing::Values (0), ::testing::Range (T8_ECLASS_ZERO, T8_ECLASS_COUNT)) + +#endif /* T8_GTEST_SCHEMES_HXX */ diff --git a/test/t8_schemes/t8_gtest_ancestor.cxx b/test/t8_schemes/t8_gtest_ancestor.cxx index 352a5f7097..98b3afc153 100644 --- a/test/t8_schemes/t8_gtest_ancestor.cxx +++ b/test/t8_schemes/t8_gtest_ancestor.cxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include class ancestor: public testing::TestWithParam { protected: diff --git a/test/t8_schemes/t8_gtest_boundary_extrude.cxx b/test/t8_schemes/t8_gtest_boundary_extrude.cxx index 86d7e8e06f..db07ff89b1 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 (eclass, 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 (eclass, 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 (eclass, 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 (eclass, element, iface, boundary); - scheme->element_extrude_face (tree_class, boundary, check, tree_face); + scheme->element_extrude_face (eclass, boundary, check, tree_face); - EXPECT_ELEM_EQ (scheme, tree_class, element, check); + EXPECT_ELEM_EQ (scheme, eclass, 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 (eclass, 1, &check); + tree_class = scheme->get_eclass_scheme_eclass (eclass); } void TearDown () override { /* Destroy element */ - scheme->element_destroy (tree_class, 1, &check); + scheme->element_destroy (eclass, 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, AllEclasses, 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..fa2e0d9280 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 (eclass, 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 (eclass, 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 (eclass, 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 (eclass, 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 (eclass, 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 (eclass, 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 (eclass, 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 92f6a2ebc1..b8bebd848a 100644 --- a/test/t8_schemes/t8_gtest_descendant.cxx +++ b/test/t8_schemes/t8_gtest_descendant.cxx @@ -22,31 +22,32 @@ #include #include -#include +#include #include #include /* 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 = t8_scheme_new_default (); - 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); + const int scheme_id = std::get<0> (GetParam ()); + scheme = create_from_scheme_id (scheme_id); + eclass = std::get<1> (GetParam ()); + + scheme->element_new (eclass, 1, &elem); + scheme->element_new (eclass, 1, &desc); + scheme->element_new (eclass, 1, &test); + scheme->get_root (eclass, 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 (eclass, 1, &elem); + scheme->element_destroy (eclass, 1, &desc); + scheme->element_destroy (eclass, 1, &test); scheme->unref (); } #ifdef T8_ENABLE_DEBUG @@ -55,8 +56,8 @@ class class_schemes_descendant: public testing::TestWithParam { const int maxlvl = 4; #endif + t8_eclass_t eclass; t8_scheme *scheme; - t8_eclass_t tree_class; t8_element_t *elem; t8_element_t *desc; t8_element_t *test; @@ -67,25 +68,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 t8_eclass_t eclass, 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 (eclass, elem); + const int level = scheme->element_get_level (eclass, elem); for (int ichild = 0; ichild < num_children; ichild++) { - scheme->element_get_child (tree_class, elem, ichild, desc); + scheme->element_get_child (eclass, 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 (eclass, elem, test, level + 1); + EXPECT_ELEM_EQ (scheme, eclass, 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 (eclass, elem, test, level + 1); + EXPECT_ELEM_EQ (scheme, eclass, 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, eclass, maxlvl); + scheme->element_get_parent (eclass, desc, elem); } } } @@ -95,17 +96,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 t8_eclass_t eclass, 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 (eclass, elem); + scheme->element_copy (eclass, 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 (eclass, test, 0, desc); + scheme->element_copy (eclass, 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 (eclass, elem, test, level); + EXPECT_ELEM_EQ (scheme, eclass, desc, test); } /* Test, if the last descendant of an element is computed correctly over a range @@ -113,19 +114,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 t8_eclass_t eclass, const int level) { - scheme->element_copy (tree_class, elem, test); + scheme->element_copy (eclass, 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 (eclass, elem); ilevel < level; ilevel++) { + const int num_children = scheme->element_get_num_children (eclass, test); + scheme->element_get_child (eclass, test, num_children - 1, desc); + scheme->element_copy (eclass, 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 (eclass, elem, test, level); + EXPECT_ELEM_EQ (scheme, eclass, desc, test); } /* Test if the first and last descendant of an element are computed correctly. @@ -133,28 +134,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 t8_eclass_t eclass, const int maxlvl) { - for (int ilevel = scheme->element_get_level (tree_class, elem); ilevel < maxlvl; ilevel++) { + for (int ilevel = scheme->element_get_level (eclass, 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 (eclass, 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, eclass, maxlvl); + t8_deep_last_descendant (elem, desc, test, scheme, eclass, 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 (eclass, elem, jchild, desc); + t8_large_step_descendant (desc, elem, test, scheme, eclass, maxlvl); + scheme->element_get_parent (eclass, 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 (eclass); + t8_recursive_descendant (elem, desc, test, scheme, eclass, maxlvl); + t8_deep_first_descendant (elem, desc, test, scheme, eclass, elem_maxlvl); + t8_deep_last_descendant (elem, desc, test, scheme, eclass, elem_maxlvl); + t8_large_step_descendant (elem, desc, test, scheme, eclass, 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); diff --git a/test/t8_schemes/t8_gtest_dfs_base.hxx b/test/t8_schemes/t8_gtest_dfs_base.hxx index 500a984d9a..70b1ab62c6 100644 --- a/test/t8_schemes/t8_gtest_dfs_base.hxx +++ b/test/t8_schemes/t8_gtest_dfs_base.hxx @@ -25,9 +25,9 @@ #include #include -#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 (eclass, 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 (eclass)); /** 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 (eclass, 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 (eclass, element); for (int ichild = 0; ichild < num_children; ichild++) { - scheme->element_get_child (tree_class, element, ichild, element); + scheme->element_get_child (eclass, 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 (eclass, element, element); } } } @@ -59,15 +59,16 @@ class TestDFS: public testing::TestWithParam { void dfs_test_setup () { - scheme = t8_scheme_new_default (); - tree_class = GetParam (); - scheme->element_new (tree_class, 1, &element); - scheme->get_root (tree_class, element); + const int scheme_id = std::get<0> (GetParam ()); + scheme = create_from_scheme_id (scheme_id); + eclass = std::get<1> (GetParam ()); + scheme->element_new (eclass, 1, &element); + scheme->get_root (eclass, element); } void dfs_test_teardown () { - scheme->element_destroy (tree_class, 1, &element); + scheme->element_destroy (eclass, 1, &element); scheme->unref (); } @@ -82,8 +83,8 @@ class TestDFS: public testing::TestWithParam { dfs_test_teardown (); } + t8_eclass_t eclass; 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 141b96831f..bd54b79c27 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 /* @@ -34,20 +34,23 @@ /* 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 (); + const int scheme_id = std::get<0> (GetParam ()); + scheme = create_from_scheme_id (scheme_id); + eclass = std::get<1> (GetParam ()); + eclass = scheme->get_eclass_scheme_eclass (eclass); } void TearDown () override { scheme->unref (); } - t8_eclass eclass; - t8_scheme *scheme = t8_scheme_new_default (); + t8_scheme *scheme; + t8_eclass_t eclass; }; TEST_P (class_element_leaves, test_element_count_leaves_root) @@ -125,4 +128,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); diff --git a/test/t8_schemes/t8_gtest_equal.cxx b/test/t8_schemes/t8_gtest_equal.cxx index cb2359a70d..c38516d990 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" @@ -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 (eclass, element); for (int ichild1 = 0; ichild1 < num_children; ichild1++) { - scheme->element_get_child (tree_class, element, ichild1, child1); + scheme->element_get_child (eclass, 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 (eclass, element, child1)); for (int ichild2 = 0; ichild2 < num_children; ichild2++) { - scheme->element_get_child (tree_class, element, ichild2, child2); + scheme->element_get_child (eclass, 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 (eclass, element, child2)); + const int equal = scheme->element_is_equal (eclass, 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 (eclass, 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 (eclass, 1, &child1); + scheme->element_new (eclass, 1, &child2); } void TearDown () override { /* Destroy element */ - scheme->element_destroy (tree_class, 1, &child1); - scheme->element_destroy (tree_class, 1, &child2); + scheme->element_destroy (eclass, 1, &child1); + scheme->element_destroy (eclass, 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, AllEclasses, 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 b57b04965e..b83c1f4892 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" @@ -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 (eclass, element); + const int num_faces = scheme->element_get_num_faces (eclass, 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, eclass, jface, ilevel, 0, manual_face_desc); + scheme->element_get_first_descendant_face (eclass, 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, eclass, 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, eclass, jface, ilevel, 1, manual_face_desc); + scheme->element_get_last_descendant_face (eclass, 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, eclass, 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 (eclass); + scheme->element_new (eclass, 1, &manual_face_desc); + scheme->element_new (eclass, 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 (eclass, 1, &manual_face_desc); + scheme->element_destroy (eclass, 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, AllEclasses, 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 f62ac53b88..3c92549a80 100644 --- a/test/t8_schemes/t8_gtest_face_neigh.cxx +++ b/test/t8_schemes/t8_gtest_face_neigh.cxx @@ -23,37 +23,38 @@ #include #include #include -#include +#include #include #include -class face_neigh: public testing::TestWithParam { +class face_neigh: public testing::TestWithParam> { protected: void SetUp () override { - tree_class = GetParam (); - scheme = t8_scheme_new_default (); - 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); + const int scheme_id = std::get<0> (GetParam ()); + scheme = create_from_scheme_id (scheme_id); + eclass = std::get<1> (GetParam ()); + scheme->element_new (eclass, 1, &element); + scheme->element_new (eclass, 1, &child); + scheme->element_new (eclass, 1, &neigh); + scheme->get_root (eclass, 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 (eclass, 1, &element); + scheme->element_destroy (eclass, 1, &child); + scheme->element_destroy (eclass, 1, &neigh); scheme->unref (); } t8_element_t *element; t8_element_t *child; t8_element_t *neigh; t8_scheme *scheme; - t8_eclass_t tree_class; + t8_eclass_t eclass; #ifdef T8_ENABLE_LESS_TESTS const int maxlvl = 3; @@ -64,7 +65,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 t8_eclass_t eclass) { int face_num; int check; @@ -72,16 +73,16 @@ 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 (eclass, child, neigh, iface, &face_num); + scheme->element_get_face_neighbor_inside (eclass, neigh, element, face_num, &check); - EXPECT_ELEM_EQ (scheme, tree_class, child, element) << "Got a false neighbor."; + EXPECT_ELEM_EQ (scheme, eclass, child, element) << "Got a false neighbor."; } } 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) +t8_test_get_middle_child (const t8_eclass_t eclass, int ilevel, t8_element_t *element, t8_element_t *child, + t8_scheme *scheme) { /* Get the child number of the child in the middle of the element, depending of the shape of the element. */ switch (eclass) { @@ -92,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 (eclass, element, 0, child); + scheme->element_copy (eclass, 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 (eclass, element, 4, child); + scheme->element_copy (eclass, 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 (eclass, element, 4, child); + scheme->element_copy (eclass, child, element); return 7; case T8_ECLASS_PYRAMID: { t8_dpyramid_t *pyramid = (t8_dpyramid_t *) element; @@ -134,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 (eclass, 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 (eclass, 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 (eclass, num_children, children); + scheme->element_get_children_at_face (eclass, 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 (eclass, element, iface, jchild); - scheme->element_get_child (tree_class, element, child_id, child); + scheme->element_get_child (eclass, 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 (eclass, 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 (eclass, child, face_contact); ASSERT_EQ (inside, iface) << "Wrong face."; } - scheme->element_destroy (tree_class, num_children, children); + scheme->element_destroy (eclass, num_children, children); T8_FREE (children); T8_FREE (child_indices); } @@ -166,7 +167,7 @@ TEST_P (face_neigh, check_not_inside_root) void t8_recursive_check_diff (t8_element_t *element, t8_element_t *child, t8_element_t *neigh, t8_scheme *scheme, - const t8_eclass_t tree_class, int maxlvl, int level) + const t8_eclass_t tree_class, const int maxlvl, const int level) { T8_ASSERT (level <= maxlvl && maxlvl <= scheme->get_maxlevel (tree_class) - 1); @@ -191,11 +192,11 @@ t8_recursive_check_diff (t8_element_t *element, t8_element_t *child, t8_element_ /* Recursively check, if all neighbors are computed correct up to a given level. */ 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 int level = 1; + const int middle_child_id = t8_test_get_middle_child (eclass, level, element, child, scheme); + scheme->element_get_child (eclass, element, middle_child_id, child); - t8_recursive_check_diff (child, element, neigh, scheme, tree_class, maxlvl, level); + t8_recursive_check_diff (child, element, neigh, scheme, eclass, 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); diff --git a/test/t8_schemes/t8_gtest_find_parent.cxx b/test/t8_schemes/t8_gtest_find_parent.cxx index fac7ee3d2c..1e6dcf8519 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 @@ -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 (eclass, element); for (int ichild = 0; ichild < num_children; ichild++) { - scheme->element_get_child (tree_class, element, ichild, child); + scheme->element_get_child (eclass, element, ichild, child); /* Compute parent of child */ - scheme->element_get_parent (tree_class, child, test_parent); + scheme->element_get_parent (eclass, 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, eclass, 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 (eclass, 1, &child); + scheme->element_new (eclass, 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 (eclass, 1, &child); + scheme->element_destroy (eclass, 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, AllEclasses, 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 f4a7cad307..61a0f6a16b 100644 --- a/test/t8_schemes/t8_gtest_init_linear_id.cxx +++ b/test/t8_schemes/t8_gtest_init_linear_id.cxx @@ -23,36 +23,38 @@ #include #include #include -#include +#include #include #include #include -class linear_id: public testing::TestWithParam { +class linear_id: public testing::TestWithParam> { protected: void SetUp () override { - tree_class = GetParam (); - scheme = t8_scheme_new_default (); - 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); + const int scheme_id = std::get<0> (GetParam ()); + scheme = create_from_scheme_id (scheme_id); + eclass = std::get<1> (GetParam ()); + scheme->element_new (eclass, 1, &element); + scheme->element_new (eclass, 1, &child); + scheme->element_new (eclass, 1, &test); + scheme->get_root (eclass, 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 (eclass, 1, &element); + scheme->element_destroy (eclass, 1, &child); + scheme->element_destroy (eclass, 1, &test); scheme->unref (); } t8_element_t *element; t8_element_t *child; t8_element_t *test; t8_scheme *scheme; - t8_eclass_t tree_class; + t8_eclass_t eclass; sc_MPI_Comm comm = sc_MPI_COMM_WORLD; }; @@ -76,7 +78,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 (eclass, 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 +91,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 (eclass, 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 (eclass, element, level); /* Check the computed id*/ EXPECT_EQ (id, id_iter + shift); } @@ -125,21 +126,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 (eclass, 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 (eclass, 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 (eclass, 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 (eclass, 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 (eclass, 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 (eclass, test, level); /* test_id and id should be equal. */ EXPECT_EQ (id, test_id); } @@ -147,4 +148,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); diff --git a/test/t8_schemes/t8_gtest_nca.cxx b/test/t8_schemes/t8_gtest_nca.cxx index 8503989dd4..db0fd1a373 100644 --- a/test/t8_schemes/t8_gtest_nca.cxx +++ b/test/t8_schemes/t8_gtest_nca.cxx @@ -28,16 +28,17 @@ #include #include #include -#include +#include #include -class nca: public testing::TestWithParam { +class nca: public testing::TestWithParam> { protected: void SetUp () override { - tree_class = GetParam (); - scheme = t8_scheme_new_default (); + const int scheme_id = std::get<0> (GetParam ()); + scheme = create_from_scheme_id (scheme_id); + tree_class = std::get<1> (GetParam ()); 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 +315,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); diff --git a/test/t8_schemes/t8_gtest_pack_unpack.cxx b/test/t8_schemes/t8_gtest_pack_unpack.cxx index 5a85da933f..22e68b08fd 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 @@ -39,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 (eclass, element); + scheme->element_MPI_Pack_size (eclass, 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 (eclass, &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 (eclass, num_children, children); + scheme->element_get_children (eclass, element, num_children, children); + scheme->element_MPI_Pack (eclass, children, num_children, sendbuf, pack_size, &position, comm); int recvBufferSize = pack_size; char *recvbuf = T8_ALLOC (char, recvBufferSize); @@ -77,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 (eclass, 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 (eclass, num_children, children_compare); + scheme->element_MPI_Unpack (eclass, 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, eclass, 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, eclass, 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 (eclass, num_children, children); + scheme->element_destroy (eclass, num_children, children_compare); T8_FREE (children); T8_FREE (children_compare); } @@ -103,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 (eclass, 1, &element_compare); comm = sc_MPI_COMM_WORLD; mpiret = sc_MPI_Comm_rank (comm, &rank); @@ -113,7 +114,7 @@ class class_test_pack: public TestDFS { TearDown () override { /* Destroy element */ - scheme->element_destroy (tree_class, 1, &element_compare); + scheme->element_destroy (eclass, 1, &element_compare); /* Destroy DFS test */ dfs_test_teardown (); @@ -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 2a7a861978..b9062b6952 100644 --- a/test/t8_schemes/t8_gtest_root.cxx +++ b/test/t8_schemes/t8_gtest_root.cxx @@ -25,46 +25,49 @@ #include #include +#include +#include #include #include #include -class root: public testing::TestWithParam { - +class root: public testing::TestWithParam> { protected: void SetUp () override { - tree_class = GetParam (); - scheme = t8_scheme_new_default (); - scheme->element_new (tree_class, 1, &element); - scheme->get_root (tree_class, element); + const int scheme_id = std::get<0> (GetParam ()); + scheme = create_from_scheme_id (scheme_id); + eclass = std::get<1> (GetParam ()); + scheme->element_new (eclass, 1, &element); + scheme->get_root (eclass, element); } void TearDown () override { - scheme->element_destroy (tree_class, 1, &element); + scheme->element_destroy (eclass, 1, &element); scheme->unref (); } + t8_element_t *element; t8_scheme *scheme; - t8_eclass_t tree_class; + t8_eclass_t eclass; }; /*Test root*/ TEST_P (root, has_level_zero) { - EXPECT_EQ (scheme->element_get_level (tree_class, element), 0); + EXPECT_EQ (scheme->element_get_level (eclass, 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 (eclass, 1, &root_compare); + scheme->element_set_linear_id (eclass, root_compare, 0, 0); + EXPECT_ELEM_EQ (scheme, eclass, element, root_compare); + scheme->element_destroy (eclass, 1, &root_compare); } -INSTANTIATE_TEST_SUITE_P (t8_gtest_root, root, AllEclasses, print_eclass); +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 172472d39e..18b8895938 100644 --- a/test/t8_schemes/t8_gtest_successor.cxx +++ b/test/t8_schemes/t8_gtest_successor.cxx @@ -22,23 +22,26 @@ #include #include -#include +#include #include #include -class class_successor: public testing::TestWithParam { +class class_successor: public testing::TestWithParam> { protected: void SetUp () override { - tree_class = GetParam (); - scheme = t8_scheme_new_default (); + const int scheme_id = std::get<0> (GetParam ()); + scheme = create_from_scheme_id (scheme_id); + tree_class = std::get<1> (GetParam ()); 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->get_root (tree_class, element); + + tree_class = scheme->get_eclass_scheme_eclass (tree_class); if (tree_class == T8_ECLASS_VERTEX) GTEST_SKIP (); } @@ -51,12 +54,12 @@ class class_successor: public testing::TestWithParam { scheme->element_destroy (tree_class, 1, &last); scheme->unref (); } - t8_eclass_t tree_class; 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 @@ -151,4 +154,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);