diff --git a/test/Makefile.am b/test/Makefile.am index d7c1ec92f5..682c05c452 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -42,6 +42,7 @@ t8code_googletest_programs = \ test/t8_forest/t8_gtest_user_data \ test/t8_forest/t8_gtest_transform \ test/t8_forest/t8_gtest_ghost_exchange \ + test/t8_forest/t8_gtest_ghost_delete \ test/t8_forest/t8_gtest_ghost_and_owner \ test/t8_IO/t8_gtest_vtk_reader \ test/t8_forest_incomplete/t8_gtest_permute_hole \ @@ -210,6 +211,10 @@ test_t8_forest_t8_gtest_ghost_exchange_SOURCES = \ test/t8_gtest_main.cxx \ test/t8_forest/t8_gtest_ghost_exchange.cxx +test_t8_forest_t8_gtest_ghost_delete_SOURCES = \ + test/t8_gtest_main.cxx \ + test/t8_forest/t8_gtest_ghost_delete.cxx + test_t8_forest_t8_gtest_ghost_and_owner_SOURCES = \ test/t8_gtest_main.cxx \ test/t8_forest/t8_gtest_ghost_and_owner.cxx @@ -399,6 +404,10 @@ test_t8_forest_t8_gtest_ghost_exchange_LDADD = $(t8_gtest_target_ld_add) test_t8_forest_t8_gtest_ghost_exchange_LDFLAGS = $(t8_gtest_target_ld_flags) test_t8_forest_t8_gtest_ghost_exchange_CPPFLAGS = $(t8_gtest_target_cpp_flags) +test_t8_forest_t8_gtest_ghost_delete_LDADD = $(t8_gtest_target_ld_add) +test_t8_forest_t8_gtest_ghost_delete_LDFLAGS = $(t8_gtest_target_ld_flags) +test_t8_forest_t8_gtest_ghost_delete_CPPFLAGS = $(t8_gtest_target_cpp_flags) + test_t8_forest_t8_gtest_ghost_and_owner_LDADD = $(t8_gtest_target_ld_add) test_t8_forest_t8_gtest_ghost_and_owner_LDFLAGS = $(t8_gtest_target_ld_flags) test_t8_forest_t8_gtest_ghost_and_owner_CPPFLAGS = $(t8_gtest_target_cpp_flags) @@ -469,6 +478,7 @@ test_t8_geometry_t8_gtest_point_inside_CPPFLAGS += $(t8_gtest_target_mpi_cpp_fla test_t8_forest_t8_gtest_user_data_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_forest_t8_gtest_transform_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_forest_t8_gtest_ghost_exchange_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) +test_t8_forest_t8_gtest_ghost_delete_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_forest_t8_gtest_ghost_and_owner_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_IO_t8_gtest_vtk_reader_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) test_t8_forest_incomplete_t8_gtest_permute_hole_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags) diff --git a/test/t8_forest/t8_gtest_ghost_delete.cxx b/test/t8_forest/t8_gtest_ghost_delete.cxx new file mode 100644 index 0000000000..43d2983b59 --- /dev/null +++ b/test/t8_forest/t8_gtest_ghost_delete.cxx @@ -0,0 +1,122 @@ +/* + 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) 2015 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. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* This test is executed on a subcommunicator of exactly 2 procs, because it demonstrates a configuration that is currently not working. See https://github.com/DLR-AMR/t8code/issues/825. + * A partitioned square of uniform refinement level 1 is adapted once, where only the lower half is refined. + * Then the mesh is adapted again, where only the upper half of the lower elements is deleted. + * Now, no element actually has a face connection to an existing element on the other proc, thus the Ghost structure should be empty. + * Within the bug discussed in https://github.com/DLR-AMR/t8code/issues/825 they send a message anyway. + * Once, https://github.com/DLR-AMR/t8code/issues/825 is resolved, no messages should be send and the test should pass. + */ + + +/* refine elements, whose lower left y coordinate is 0, so that the lowest row is refined + * delete elements, whose lower left y coordniate is 0.25, so that the second row is deleted + */ +static int +test_adapt_holes (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, + t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) +{ + double coordinates[3]; + t8_forest_element_coordinate (forest_from, which_tree, elements[0], 0, coordinates); + if (fabs (coordinates[1]) < T8_PRECISION_EPS) + return 1; // refine the lowest row + if (fabs (coordinates[1] - 0.25) < T8_PRECISION_EPS) + return -2; // delete the higher row in the lower quadrants + return 0; +} + +class forest_ghost_exchange_holes: public testing::Test { + protected: + void + SetUp () override + { + /* adjust communicator size, we split the comm here, because we know that the test fails on 2 procs*/ + int size, rank, color, key; + + sc_MPI_Comm_size (sc_MPI_COMM_WORLD, &size); + sc_MPI_Comm_rank (sc_MPI_COMM_WORLD, &rank); + + if (rank < 2) { + color = 0; + key = rank; + } + else { + color = sc_MPI_UNDEFINED; + key = -1; + } + sc_MPI_Comm_split (sc_MPI_COMM_WORLD, color, key, &comm); + T8_ASSERT (rank < 2 || comm == sc_MPI_COMM_NULL); + + if (comm != sc_MPI_COMM_NULL) { + sc_MPI_Comm_size (comm, &size); + T8_ASSERT(size <= 2); + scheme = t8_scheme_new_default_cxx (); + /* Construct a cmesh */ + cmesh = t8_cmesh_new_hypercube (T8_ECLASS_QUAD, comm, 0, 0, 0); + }else{ + T8_ASSERT(rank >= 2); + } + } + void + TearDown () override + { + //cmesh and scheme are freed taken and freed by forest + if (comm != sc_MPI_COMM_NULL) { + sc_MPI_Comm_free (&comm); + } + sc_MPI_Barrier (sc_MPI_COMM_WORLD); + t8_cmesh_unref (&cmesh); + t8_scheme_cxx_unref (&scheme); + } + sc_MPI_Comm comm; + t8_scheme_cxx_t *scheme; + t8_cmesh_t cmesh; +}; + +TEST_F (forest_ghost_exchange_holes, errorTest) +{ + /* This test tests the functionality described in Issue: https://github.com/DLR-AMR/t8code/issues/825 + * Remove the GTEST_SKIP() macros when you start working on the issue. + */ + GTEST_SKIP(); + if (comm != sc_MPI_COMM_NULL) { + const int level = 1; + const int execute_ghost = 1; + t8_cmesh_ref(cmesh); + t8_scheme_cxx_ref(scheme); + t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, level, 1, comm); + forest = t8_forest_new_adapt (forest, test_adapt_holes, 0, execute_ghost, NULL); + forest = t8_forest_new_adapt (forest, test_adapt_holes, 0, execute_ghost, NULL); + t8_forest_unref (&forest); + } +}