diff --git a/src/t8_forest/t8_forest_pfc_message.hxx b/src/t8_forest/t8_forest_pfc_message.hxx index 868aae6d24..9041e5dc86 100644 --- a/src/t8_forest/t8_forest_pfc_message.hxx +++ b/src/t8_forest/t8_forest_pfc_message.hxx @@ -212,14 +212,18 @@ struct t8_forest_pfc_message scheme = t8_forest_get_scheme (forest); eclass = t8_forest_get_eclass (forest, t8_forest_get_local_id (forest, itree)); + // Allocate memory for the parent element. + t8_element_new (scheme, eclass, 1, &parent); + // If we are already the root element, we cannot be part of a split family, so we send any(the root) element and no num_siblings. if (scheme->element_get_level (eclass, element_closest_to_receiver) == 0) { - parent = element_closest_to_receiver; + // Copy the root element to the allocated parent element. + scheme->element_copy (eclass, element_closest_to_receiver, parent); + // Set the number of siblings to zero, since there are none on the root level. num_siblings = 0; } else { // Compute parent. - t8_element_new (scheme, eclass, 1, &parent); scheme->element_get_parent (eclass, element_closest_to_receiver, parent); // Distinguish send "direction" diff --git a/test/t8_cmesh_generator/t8_cmesh_example_sets.hxx b/test/t8_cmesh_generator/t8_cmesh_example_sets.hxx index 83ece334e7..7c0b94f3a6 100644 --- a/test/t8_cmesh_generator/t8_cmesh_example_sets.hxx +++ b/test/t8_cmesh_generator/t8_cmesh_example_sets.hxx @@ -63,6 +63,20 @@ auto pretty_print_base_example_scheme = [] (const testing::TestParamInfo. + * Intended as a lambda to pass to an INSTANTIATE_TEST_SUITE_P + * to print the current scheme, level and \ref cmesh_example_base. */ +auto pretty_print_level_and_cmesh_params + = [] (const testing::TestParamInfo> &info) { + std::string name = std::string ("Level_") + std::to_string (std::get<1> (info.param)); + std::string cmesh_name; + std::get<2> (info.param)->param_to_string (cmesh_name); + name += std::string ("_") + cmesh_name; + name += std::string ("scheme_") + std::to_string (std::get<0> (info.param)); + name += std::string ("_") + std::to_string (info.index); + return name; + }; + namespace cmesh_list { /** Vector of all example cmesh sets. */ diff --git a/test/t8_forest/t8_gtest_element_is_leaf.cxx b/test/t8_forest/t8_gtest_element_is_leaf.cxx index c297f2f856..474eed21cf 100644 --- a/test/t8_forest/t8_gtest_element_is_leaf.cxx +++ b/test/t8_forest/t8_gtest_element_is_leaf.cxx @@ -181,19 +181,6 @@ TEST_P (element_is_leaf_or_ghost, element_is_ghost_adapt) t8_test_element_is_leaf_for_forest (forest_adapt); } -/* Define a lambda to beautify gtest output for tuples . - * This will set the correct scheme, level and cmesh name as part of the test case name. */ -auto pretty_print_level_and_cmesh_params - = [] (const testing::TestParamInfo> &info) { - std::string name = std::string ("Level_") + std::to_string (std::get<1> (info.param)); - std::string cmesh_name; - std::get<2> (info.param)->param_to_string (cmesh_name); - name += std::string ("_") + cmesh_name; - name += std::string ("scheme_") + std::to_string (std::get<0> (info.param)); - name += std::string ("_") + std::to_string (info.index); - return name; - }; - INSTANTIATE_TEST_SUITE_P (t8_gtest_element_is_leaf_or_ghost, element_is_leaf_or_ghost, testing::Combine (AllSchemeCollections, testing::Range (0, T8_IS_LEAF_MAX_LVL), AllCmeshsParam), diff --git a/test/t8_forest/t8_gtest_partition_for_coarsening.cxx b/test/t8_forest/t8_gtest_partition_for_coarsening.cxx index bda11ed815..5f6a9cc71d 100644 --- a/test/t8_forest/t8_gtest_partition_for_coarsening.cxx +++ b/test/t8_forest/t8_gtest_partition_for_coarsening.cxx @@ -126,14 +126,14 @@ coarsen_all_callback ([[maybe_unused]] t8_forest_t forest, [[maybe_unused]] t8_f const int is_family, [[maybe_unused]] const int num_elements, [[maybe_unused]] t8_element_t *elements[]) { - // Coarsen revery family. + // Coarsen every family. return (is_family ? -1 : 0); } /** * Class to test the partition-for-coarsening functionality. */ -struct t8_test_partition_for_coarsening_test: public testing::TestWithParam> +struct t8_test_partition_for_coarsening_test: public testing::TestWithParam> { protected: @@ -145,9 +145,12 @@ struct t8_test_partition_for_coarsening_test: public testing::TestWithParam (GetParam ()); scheme = create_from_scheme_id (scheme_id); + // Get the initial uniform refinement level. + level = std::get<1> (GetParam ()); + // Construct cmesh and store name. - cmesh = std::get<1> (GetParam ())->cmesh_create (); - cmesh_name = std::get<1> (GetParam ())->name; + cmesh = std::get<2> (GetParam ())->cmesh_create (); + cmesh_name = std::get<2> (GetParam ())->name; // Skip empty meshes. if (t8_cmesh_is_empty (cmesh)) { @@ -200,6 +203,7 @@ struct t8_test_partition_for_coarsening_test: public testing::TestWithParamref (); @@ -233,8 +234,18 @@ TEST_P (t8_test_partition_for_coarsening_test, test_partition_for_coarsening) // ----------------------------------------------------------- t8_global_productionf ("Adapt uniform forest.\n"); - // Create adapted base forest. - t8_forest_t adapted_base_forest = t8_forest_new_adapt (uniform_forest, refine_some_callback, 0, 0, nullptr); + // In some cases, we will adapt the uniform base forest. + t8_forest_t adapted_base_forest; + + /* Ensure that in case of the root level test there is no adaptation, such that the partition bound will + * definitely fall upon a root level element and the corresponding code section is covered. */ + if (level != 0) { + // In any other case, we perform some adaptation. + adapted_base_forest = t8_forest_new_adapt (uniform_forest, refine_some_callback, 0, 0, nullptr); + } + else { + adapted_base_forest = uniform_forest; + } #if T8_ENABLE_DEBUG // If debug mode and an additional manual flag are set, write forest to vtk. @@ -331,4 +342,5 @@ TEST_P (t8_test_partition_for_coarsening_test, test_partition_for_coarsening) // Instantiate parameterized test to be run for all schemes. INSTANTIATE_TEST_SUITE_P (t8_gtest_partition_for_coarsening, t8_test_partition_for_coarsening_test, - testing::Combine (AllSchemeCollections, AllCmeshsParam), pretty_print_base_example_scheme); + testing::Combine (AllSchemeCollections, testing::Values (0, 2), AllCmeshsParam), + pretty_print_level_and_cmesh_params);