Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abort message if all elements of a tree are removed #1143

Merged
merged 7 commits into from
Jul 18, 2024
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
7 changes: 7 additions & 0 deletions src/t8_forest/t8_forest_adapt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,13 @@ t8_forest_adapt (t8_forest_t forest)
/* Possibly shrink the telements array to the correct size */
t8_element_array_resize (telements, el_inserted);

/* It is not supported to delete all elements from a tree.
* In this case, we will abort. */
SC_CHECK_ABORTF (el_inserted != 0,
"ERROR: All elements of tree %i were removed. Removing all elements of a tree "
"is currently not supported. See also https://github.com/DLR-AMR/t8code/issues/1137.",
ltree_id);

/* clean up */
T8_FREE (elements);
T8_FREE (elements_from);
Expand Down
11 changes: 7 additions & 4 deletions test/t8_forest_incomplete/t8_gtest_empty_local_tree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
* The two resulting forests must be equal.
*/

class local_tree: public testing::TestWithParam<t8_eclass_t> {
/** This test covers the functionality described in Issue: https://github.com/DLR-AMR/t8code/issues/1137
* Remove `DISABLED_` from the name of the Test(suite) or use `--gtest_also_run_disabled_tests` when you start working on the issue. */
class DISABLED_local_tree: public testing::TestWithParam<t8_eclass_t> {
protected:
void
SetUp () override
Expand All @@ -64,6 +66,7 @@ class local_tree: public testing::TestWithParam<t8_eclass_t> {

forest = t8_forest_new_uniform (t8_cmesh_new_from_class (eclass, sc_MPI_COMM_WORLD), t8_scheme_new_default_cxx (),
MPI_size, 0, sc_MPI_COMM_WORLD);
/* TODO: The level does not need to be as big as MPI_SIZE, only as big so that each process has at least one element */

if (MPI_size == 1 || MPI_size > MAX_NUM_RANKS) {
GTEST_SKIP ();
Expand Down Expand Up @@ -123,7 +126,7 @@ t8_adapt_forest (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, int do_ada
return forest_new;
}

TEST_P (local_tree, test_empty_local_tree)
TEST_P (DISABLED_local_tree, test_empty_local_tree)
{
/* Number of instances/testcases */
const uint32_t num_instances = 1 << MPI_size;
Expand Down Expand Up @@ -157,5 +160,5 @@ TEST_P (local_tree, test_empty_local_tree)
}
}

INSTANTIATE_TEST_SUITE_P (t8_gtest_empty_local_tree, local_tree, testing::Range (T8_ECLASS_LINE, T8_ECLASS_COUNT),
print_eclass);
INSTANTIATE_TEST_SUITE_P (t8_gtest_empty_local_tree, DISABLED_local_tree,
testing::Range (T8_ECLASS_LINE, T8_ECLASS_COUNT), print_eclass);