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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/t8_forest/t8_forest_pfc_message.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions test/t8_cmesh_generator/t8_cmesh_example_sets.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ auto pretty_print_base_example_scheme = [] (const testing::TestParamInfo<std::tu
return name;
};

/** Define a lambda to beautify gtest output for tuples <scheme, level, cmesh>.
* 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<std::tuple<int, int, cmesh_example_base *>> &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. */
Expand Down
13 changes: 0 additions & 13 deletions test/t8_forest/t8_gtest_element_is_leaf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <scheme, level, cmesh>.
* 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<std::tuple<int, int, cmesh_example_base *>> &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),
Expand Down
32 changes: 22 additions & 10 deletions test/t8_forest/t8_gtest_partition_for_coarsening.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::tuple<int, cmesh_example_base *>>
struct t8_test_partition_for_coarsening_test: public testing::TestWithParam<std::tuple<int, int, cmesh_example_base *>>
{

protected:
Expand All @@ -145,9 +145,12 @@ struct t8_test_partition_for_coarsening_test: public testing::TestWithParam<std:
const int scheme_id = std::get<0> (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)) {
Expand Down Expand Up @@ -200,6 +203,7 @@ struct t8_test_partition_for_coarsening_test: public testing::TestWithParam<std:

// Member variables: The currently tested scheme and eclass.
const t8_scheme *scheme; /**< The currently tested scheme. */
int level; /**< The currently initial uniform refinement level. */
t8_cmesh_t cmesh; /**< The currently tested cmesh. */
std::string cmesh_name; /**< Name of the currently tested cmesh.*/
};
Expand All @@ -213,9 +217,6 @@ TEST_P (t8_test_partition_for_coarsening_test, test_partition_for_coarsening)
// -------------------------------------------
t8_global_productionf ("Create uniform forest.\n");

// Initial uniform refinement level
const int level = 2;

// Increase reference counters of cmesh and scheme to avoid reaching zero.
t8_cmesh_ref (cmesh);
scheme->ref ();
Expand All @@ -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.
Expand Down Expand Up @@ -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);