From c23da04a6c126f7b756e7d76d55c4822f879b3c1 Mon Sep 17 00:00:00 2001 From: Marc Fehling Date: Wed, 24 Mar 2021 14:12:13 -0600 Subject: [PATCH] Divide parallel tests `limit_p_level_difference` between Triangulation types. --- tests/mpi/limit_p_level_difference_01.cc | 48 +----- ...ference_01.with_p4est=true.mpirun=1.output | 27 ---- ...ference_01.with_p4est=true.mpirun=4.output | 27 ---- tests/mpi/limit_p_level_difference_02.cc | 48 +----- ...ference_02.with_p4est=true.mpirun=1.output | 63 -------- ...ference_02.with_p4est=true.mpirun=4.output | 63 -------- tests/mpi/limit_p_level_difference_03.cc | 48 +----- ...ference_03.with_p4est=true.mpirun=1.output | 9 -- ...ference_03.with_p4est=true.mpirun=4.output | 9 -- tests/mpi/limit_p_level_difference_04.cc | 56 +------ ...ference_04.with_p4est=true.mpirun=1.output | 22 --- ...ference_04.with_p4est=true.mpirun=4.output | 34 ----- .../sharedtria/limit_p_level_difference_01.cc | 134 +++++++++++++++++ ...ifference_01.with_mpi=true.mpirun=1.output | 27 ++++ ...ifference_01.with_mpi=true.mpirun=4.output | 27 ++++ .../sharedtria/limit_p_level_difference_02.cc | 140 ++++++++++++++++++ ...ifference_02.with_mpi=true.mpirun=1.output | 63 ++++++++ ...ifference_02.with_mpi=true.mpirun=4.output | 63 ++++++++ .../sharedtria/limit_p_level_difference_03.cc | 139 +++++++++++++++++ ...ifference_03.with_mpi=true.mpirun=1.output | 9 ++ ...ifference_03.with_mpi=true.mpirun=4.output | 9 ++ 21 files changed, 631 insertions(+), 434 deletions(-) create mode 100644 tests/sharedtria/limit_p_level_difference_01.cc create mode 100644 tests/sharedtria/limit_p_level_difference_01.with_mpi=true.mpirun=1.output create mode 100644 tests/sharedtria/limit_p_level_difference_01.with_mpi=true.mpirun=4.output create mode 100644 tests/sharedtria/limit_p_level_difference_02.cc create mode 100644 tests/sharedtria/limit_p_level_difference_02.with_mpi=true.mpirun=1.output create mode 100644 tests/sharedtria/limit_p_level_difference_02.with_mpi=true.mpirun=4.output create mode 100644 tests/sharedtria/limit_p_level_difference_03.cc create mode 100644 tests/sharedtria/limit_p_level_difference_03.with_mpi=true.mpirun=1.output create mode 100644 tests/sharedtria/limit_p_level_difference_03.with_mpi=true.mpirun=4.output diff --git a/tests/mpi/limit_p_level_difference_01.cc b/tests/mpi/limit_p_level_difference_01.cc index f9e36450ee..9ca79b1e5f 100644 --- a/tests/mpi/limit_p_level_difference_01.cc +++ b/tests/mpi/limit_p_level_difference_01.cc @@ -24,9 +24,7 @@ #include #include -#include #include -#include #include @@ -44,11 +42,8 @@ template void -test(parallel::TriangulationBase &tria, - const unsigned int fes_size, - const unsigned int max_difference) +test(const unsigned int fes_size, const unsigned int max_difference) { - Assert(tria.n_levels() == 0, ExcInternalError()); Assert(fes_size > 0, ExcInternalError()); Assert(max_difference > 0, ExcInternalError()); @@ -61,6 +56,7 @@ test(parallel::TriangulationBase &tria, const auto sequence = fes.get_hierarchy_sequence(contains_fe_index); // setup cross-shaped mesh + parallel::distributed::Triangulation tria(MPI_COMM_WORLD); { std::vector sizes(Utilities::pow(2, dim), static_cast( @@ -123,41 +119,7 @@ main(int argc, char *argv[]) if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0) initlog(); - constexpr const unsigned int dim = 2; - - deallog << "parallel::shared::Triangulation" << std::endl; - { - parallel::shared::Triangulation tria(MPI_COMM_WORLD); - - test(tria, 4, 1); - tria.clear(); - test(tria, 8, 2); - tria.clear(); - test(tria, 12, 3); - } - - deallog << "parallel::shared::Triangulation with artificial cells" - << std::endl; - { - parallel::shared::Triangulation tria(MPI_COMM_WORLD, - Triangulation::none, - /*allow_artificial_cells=*/true); - - test(tria, 4, 1); - tria.clear(); - test(tria, 8, 2); - tria.clear(); - test(tria, 12, 3); - } - - deallog << "parallel::distributed::Triangulation" << std::endl; - { - parallel::distributed::Triangulation tria(MPI_COMM_WORLD); - - test(tria, 4, 1); - tria.clear(); - test(tria, 8, 2); - tria.clear(); - test(tria, 12, 3); - } + test<2>(4, 1); + test<2>(8, 2); + test<2>(12, 3); } diff --git a/tests/mpi/limit_p_level_difference_01.with_p4est=true.mpirun=1.output b/tests/mpi/limit_p_level_difference_01.with_p4est=true.mpirun=1.output index 065ac3fadb..a7bf63f5df 100644 --- a/tests/mpi/limit_p_level_difference_01.with_p4est=true.mpirun=1.output +++ b/tests/mpi/limit_p_level_difference_01.with_p4est=true.mpirun=1.output @@ -1,31 +1,4 @@ -DEAL::parallel::shared::Triangulation -DEAL::ncells:13, nfes:4 -DEAL::sequence:0 1 2 3 -DEAL::fe count:4 4 4 1 -DEAL::OK -DEAL::ncells:13, nfes:8 -DEAL::sequence:0 1 2 3 4 5 6 7 -DEAL::fe count:0 4 0 4 0 4 0 1 -DEAL::OK -DEAL::ncells:13, nfes:12 -DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 -DEAL::fe count:0 0 4 0 0 4 0 0 4 0 0 1 -DEAL::OK -DEAL::parallel::shared::Triangulation with artificial cells -DEAL::ncells:13, nfes:4 -DEAL::sequence:0 1 2 3 -DEAL::fe count:4 4 4 1 -DEAL::OK -DEAL::ncells:13, nfes:8 -DEAL::sequence:0 1 2 3 4 5 6 7 -DEAL::fe count:0 4 0 4 0 4 0 1 -DEAL::OK -DEAL::ncells:13, nfes:12 -DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 -DEAL::fe count:0 0 4 0 0 4 0 0 4 0 0 1 -DEAL::OK -DEAL::parallel::distributed::Triangulation DEAL::ncells:13, nfes:4 DEAL::sequence:0 1 2 3 DEAL::fe count:4 4 4 1 diff --git a/tests/mpi/limit_p_level_difference_01.with_p4est=true.mpirun=4.output b/tests/mpi/limit_p_level_difference_01.with_p4est=true.mpirun=4.output index 065ac3fadb..a7bf63f5df 100644 --- a/tests/mpi/limit_p_level_difference_01.with_p4est=true.mpirun=4.output +++ b/tests/mpi/limit_p_level_difference_01.with_p4est=true.mpirun=4.output @@ -1,31 +1,4 @@ -DEAL::parallel::shared::Triangulation -DEAL::ncells:13, nfes:4 -DEAL::sequence:0 1 2 3 -DEAL::fe count:4 4 4 1 -DEAL::OK -DEAL::ncells:13, nfes:8 -DEAL::sequence:0 1 2 3 4 5 6 7 -DEAL::fe count:0 4 0 4 0 4 0 1 -DEAL::OK -DEAL::ncells:13, nfes:12 -DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 -DEAL::fe count:0 0 4 0 0 4 0 0 4 0 0 1 -DEAL::OK -DEAL::parallel::shared::Triangulation with artificial cells -DEAL::ncells:13, nfes:4 -DEAL::sequence:0 1 2 3 -DEAL::fe count:4 4 4 1 -DEAL::OK -DEAL::ncells:13, nfes:8 -DEAL::sequence:0 1 2 3 4 5 6 7 -DEAL::fe count:0 4 0 4 0 4 0 1 -DEAL::OK -DEAL::ncells:13, nfes:12 -DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 -DEAL::fe count:0 0 4 0 0 4 0 0 4 0 0 1 -DEAL::OK -DEAL::parallel::distributed::Triangulation DEAL::ncells:13, nfes:4 DEAL::sequence:0 1 2 3 DEAL::fe count:4 4 4 1 diff --git a/tests/mpi/limit_p_level_difference_02.cc b/tests/mpi/limit_p_level_difference_02.cc index e660e42fe8..f87bad8190 100644 --- a/tests/mpi/limit_p_level_difference_02.cc +++ b/tests/mpi/limit_p_level_difference_02.cc @@ -24,9 +24,7 @@ #include #include -#include #include -#include #include @@ -44,11 +42,8 @@ template void -test(parallel::TriangulationBase &tria, - const unsigned int fes_size, - const unsigned int max_difference) +test(const unsigned int fes_size, const unsigned int max_difference) { - Assert(tria.n_levels() == 0, ExcInternalError()); Assert(fes_size > 0, ExcInternalError()); Assert(max_difference > 0, ExcInternalError()); @@ -61,6 +56,7 @@ test(parallel::TriangulationBase &tria, const auto sequence = fes.get_hierarchy_sequence(contains_fe_index); // setup cross-shaped mesh + parallel::distributed::Triangulation tria(MPI_COMM_WORLD); { std::vector sizes(Utilities::pow(2, dim), static_cast( @@ -129,41 +125,7 @@ main(int argc, char *argv[]) if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0) initlog(); - constexpr const unsigned int dim = 2; - - deallog << "parallel::shared::Triangulation" << std::endl; - { - parallel::shared::Triangulation tria(MPI_COMM_WORLD); - - test(tria, 4, 1); - tria.clear(); - test(tria, 8, 2); - tria.clear(); - test(tria, 12, 3); - } - - deallog << "parallel::shared::Triangulation with artificial cells" - << std::endl; - { - parallel::shared::Triangulation tria(MPI_COMM_WORLD, - Triangulation::none, - /*allow_artificial_cells=*/true); - - test(tria, 4, 1); - tria.clear(); - test(tria, 8, 2); - tria.clear(); - test(tria, 12, 3); - } - - deallog << "parallel::distributed::Triangulation" << std::endl; - { - parallel::distributed::Triangulation tria(MPI_COMM_WORLD); - - test(tria, 4, 1); - tria.clear(); - test(tria, 8, 2); - tria.clear(); - test(tria, 12, 3); - } + test<2>(4, 1); + test<2>(8, 2); + test<2>(12, 3); } diff --git a/tests/mpi/limit_p_level_difference_02.with_p4est=true.mpirun=1.output b/tests/mpi/limit_p_level_difference_02.with_p4est=true.mpirun=1.output index 562cc53c58..1c07c11cb5 100644 --- a/tests/mpi/limit_p_level_difference_02.with_p4est=true.mpirun=1.output +++ b/tests/mpi/limit_p_level_difference_02.with_p4est=true.mpirun=1.output @@ -1,67 +1,4 @@ -DEAL::parallel::shared::Triangulation -DEAL::ncells:13, nfes:4 -DEAL::sequence:0 1 2 3 -DEAL::cycle:0, fe count:12 1 0 0 -DEAL::cycle:1, fe count:8 4 1 0 -DEAL::cycle:2, fe count:4 4 4 1 -DEAL::OK -DEAL::ncells:13, nfes:8 -DEAL::sequence:0 1 2 3 4 5 6 7 -DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 -DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 -DEAL::cycle:2, fe count:8 4 0 1 0 0 0 0 -DEAL::cycle:3, fe count:8 0 4 0 1 0 0 0 -DEAL::cycle:4, fe count:4 4 0 4 0 1 0 0 -DEAL::cycle:5, fe count:4 0 4 0 4 0 1 0 -DEAL::cycle:6, fe count:0 4 0 4 0 4 0 1 -DEAL::OK -DEAL::ncells:13, nfes:12 -DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 -DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 0 0 0 0 -DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 0 0 0 0 -DEAL::cycle:2, fe count:12 0 0 1 0 0 0 0 0 0 0 0 -DEAL::cycle:3, fe count:8 4 0 0 1 0 0 0 0 0 0 0 -DEAL::cycle:4, fe count:8 0 4 0 0 1 0 0 0 0 0 0 -DEAL::cycle:5, fe count:8 0 0 4 0 0 1 0 0 0 0 0 -DEAL::cycle:6, fe count:4 4 0 0 4 0 0 1 0 0 0 0 -DEAL::cycle:7, fe count:4 0 4 0 0 4 0 0 1 0 0 0 -DEAL::cycle:8, fe count:4 0 0 4 0 0 4 0 0 1 0 0 -DEAL::cycle:9, fe count:0 4 0 0 4 0 0 4 0 0 1 0 -DEAL::cycle:10, fe count:0 0 4 0 0 4 0 0 4 0 0 1 -DEAL::OK -DEAL::parallel::shared::Triangulation with artificial cells -DEAL::ncells:13, nfes:4 -DEAL::sequence:0 1 2 3 -DEAL::cycle:0, fe count:12 1 0 0 -DEAL::cycle:1, fe count:8 4 1 0 -DEAL::cycle:2, fe count:4 4 4 1 -DEAL::OK -DEAL::ncells:13, nfes:8 -DEAL::sequence:0 1 2 3 4 5 6 7 -DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 -DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 -DEAL::cycle:2, fe count:8 4 0 1 0 0 0 0 -DEAL::cycle:3, fe count:8 0 4 0 1 0 0 0 -DEAL::cycle:4, fe count:4 4 0 4 0 1 0 0 -DEAL::cycle:5, fe count:4 0 4 0 4 0 1 0 -DEAL::cycle:6, fe count:0 4 0 4 0 4 0 1 -DEAL::OK -DEAL::ncells:13, nfes:12 -DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 -DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 0 0 0 0 -DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 0 0 0 0 -DEAL::cycle:2, fe count:12 0 0 1 0 0 0 0 0 0 0 0 -DEAL::cycle:3, fe count:8 4 0 0 1 0 0 0 0 0 0 0 -DEAL::cycle:4, fe count:8 0 4 0 0 1 0 0 0 0 0 0 -DEAL::cycle:5, fe count:8 0 0 4 0 0 1 0 0 0 0 0 -DEAL::cycle:6, fe count:4 4 0 0 4 0 0 1 0 0 0 0 -DEAL::cycle:7, fe count:4 0 4 0 0 4 0 0 1 0 0 0 -DEAL::cycle:8, fe count:4 0 0 4 0 0 4 0 0 1 0 0 -DEAL::cycle:9, fe count:0 4 0 0 4 0 0 4 0 0 1 0 -DEAL::cycle:10, fe count:0 0 4 0 0 4 0 0 4 0 0 1 -DEAL::OK -DEAL::parallel::distributed::Triangulation DEAL::ncells:13, nfes:4 DEAL::sequence:0 1 2 3 DEAL::cycle:0, fe count:12 1 0 0 diff --git a/tests/mpi/limit_p_level_difference_02.with_p4est=true.mpirun=4.output b/tests/mpi/limit_p_level_difference_02.with_p4est=true.mpirun=4.output index 562cc53c58..1c07c11cb5 100644 --- a/tests/mpi/limit_p_level_difference_02.with_p4est=true.mpirun=4.output +++ b/tests/mpi/limit_p_level_difference_02.with_p4est=true.mpirun=4.output @@ -1,67 +1,4 @@ -DEAL::parallel::shared::Triangulation -DEAL::ncells:13, nfes:4 -DEAL::sequence:0 1 2 3 -DEAL::cycle:0, fe count:12 1 0 0 -DEAL::cycle:1, fe count:8 4 1 0 -DEAL::cycle:2, fe count:4 4 4 1 -DEAL::OK -DEAL::ncells:13, nfes:8 -DEAL::sequence:0 1 2 3 4 5 6 7 -DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 -DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 -DEAL::cycle:2, fe count:8 4 0 1 0 0 0 0 -DEAL::cycle:3, fe count:8 0 4 0 1 0 0 0 -DEAL::cycle:4, fe count:4 4 0 4 0 1 0 0 -DEAL::cycle:5, fe count:4 0 4 0 4 0 1 0 -DEAL::cycle:6, fe count:0 4 0 4 0 4 0 1 -DEAL::OK -DEAL::ncells:13, nfes:12 -DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 -DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 0 0 0 0 -DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 0 0 0 0 -DEAL::cycle:2, fe count:12 0 0 1 0 0 0 0 0 0 0 0 -DEAL::cycle:3, fe count:8 4 0 0 1 0 0 0 0 0 0 0 -DEAL::cycle:4, fe count:8 0 4 0 0 1 0 0 0 0 0 0 -DEAL::cycle:5, fe count:8 0 0 4 0 0 1 0 0 0 0 0 -DEAL::cycle:6, fe count:4 4 0 0 4 0 0 1 0 0 0 0 -DEAL::cycle:7, fe count:4 0 4 0 0 4 0 0 1 0 0 0 -DEAL::cycle:8, fe count:4 0 0 4 0 0 4 0 0 1 0 0 -DEAL::cycle:9, fe count:0 4 0 0 4 0 0 4 0 0 1 0 -DEAL::cycle:10, fe count:0 0 4 0 0 4 0 0 4 0 0 1 -DEAL::OK -DEAL::parallel::shared::Triangulation with artificial cells -DEAL::ncells:13, nfes:4 -DEAL::sequence:0 1 2 3 -DEAL::cycle:0, fe count:12 1 0 0 -DEAL::cycle:1, fe count:8 4 1 0 -DEAL::cycle:2, fe count:4 4 4 1 -DEAL::OK -DEAL::ncells:13, nfes:8 -DEAL::sequence:0 1 2 3 4 5 6 7 -DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 -DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 -DEAL::cycle:2, fe count:8 4 0 1 0 0 0 0 -DEAL::cycle:3, fe count:8 0 4 0 1 0 0 0 -DEAL::cycle:4, fe count:4 4 0 4 0 1 0 0 -DEAL::cycle:5, fe count:4 0 4 0 4 0 1 0 -DEAL::cycle:6, fe count:0 4 0 4 0 4 0 1 -DEAL::OK -DEAL::ncells:13, nfes:12 -DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 -DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 0 0 0 0 -DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 0 0 0 0 -DEAL::cycle:2, fe count:12 0 0 1 0 0 0 0 0 0 0 0 -DEAL::cycle:3, fe count:8 4 0 0 1 0 0 0 0 0 0 0 -DEAL::cycle:4, fe count:8 0 4 0 0 1 0 0 0 0 0 0 -DEAL::cycle:5, fe count:8 0 0 4 0 0 1 0 0 0 0 0 -DEAL::cycle:6, fe count:4 4 0 0 4 0 0 1 0 0 0 0 -DEAL::cycle:7, fe count:4 0 4 0 0 4 0 0 1 0 0 0 -DEAL::cycle:8, fe count:4 0 0 4 0 0 4 0 0 1 0 0 -DEAL::cycle:9, fe count:0 4 0 0 4 0 0 4 0 0 1 0 -DEAL::cycle:10, fe count:0 0 4 0 0 4 0 0 4 0 0 1 -DEAL::OK -DEAL::parallel::distributed::Triangulation DEAL::ncells:13, nfes:4 DEAL::sequence:0 1 2 3 DEAL::cycle:0, fe count:12 1 0 0 diff --git a/tests/mpi/limit_p_level_difference_03.cc b/tests/mpi/limit_p_level_difference_03.cc index ece1b8681d..127e339b2a 100644 --- a/tests/mpi/limit_p_level_difference_03.cc +++ b/tests/mpi/limit_p_level_difference_03.cc @@ -21,9 +21,7 @@ #include -#include #include -#include #include @@ -46,11 +44,8 @@ divide_and_ceil(unsigned int x, unsigned int y) template void -test(parallel::TriangulationBase &tria, - const unsigned int fes_size, - const unsigned int max_difference) +test(const unsigned int fes_size, const unsigned int max_difference) { - Assert(tria.n_levels() == 0, ExcInternalError()); Assert(max_difference > 0, ExcInternalError()); Assert(fes_size > 1, ExcInternalError()); @@ -75,6 +70,7 @@ test(parallel::TriangulationBase &tria, // after prepare_coarsening_and_refinement(), each p-level will correspond to // a unique column of cells and thus h-level + parallel::distributed::Triangulation tria(MPI_COMM_WORLD); TestGrids::hyper_line(tria, 2); const unsigned int n_refinements = divide_and_ceil(sequence.size() - 1, max_difference); @@ -128,41 +124,7 @@ main(int argc, char *argv[]) if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0) initlog(); - constexpr const unsigned int dim = 2; - - deallog << "parallel::shared::Triangulation" << std::endl; - { - parallel::shared::Triangulation tria(MPI_COMM_WORLD); - - test(tria, 5, 1); - tria.clear(); - test(tria, 10, 2); - tria.clear(); - test(tria, 15, 3); - } - - deallog << "parallel::shared::Triangulation with artificial cells" - << std::endl; - { - parallel::shared::Triangulation tria(MPI_COMM_WORLD, - Triangulation::none, - /*allow_artificial_cells=*/true); - - test(tria, 5, 1); - tria.clear(); - test(tria, 10, 2); - tria.clear(); - test(tria, 15, 3); - } - - deallog << "parallel::distributed::Triangulation" << std::endl; - { - parallel::distributed::Triangulation tria(MPI_COMM_WORLD); - - test(tria, 5, 1); - tria.clear(); - test(tria, 10, 2); - tria.clear(); - test(tria, 15, 3); - } + test<2>(5, 1); + test<2>(10, 2); + test<2>(15, 3); } diff --git a/tests/mpi/limit_p_level_difference_03.with_p4est=true.mpirun=1.output b/tests/mpi/limit_p_level_difference_03.with_p4est=true.mpirun=1.output index 7715c474e9..fb71de2867 100644 --- a/tests/mpi/limit_p_level_difference_03.with_p4est=true.mpirun=1.output +++ b/tests/mpi/limit_p_level_difference_03.with_p4est=true.mpirun=1.output @@ -1,13 +1,4 @@ -DEAL::parallel::shared::Triangulation -DEAL::OK -DEAL::OK -DEAL::OK -DEAL::parallel::shared::Triangulation with artificial cells -DEAL::OK -DEAL::OK -DEAL::OK -DEAL::parallel::distributed::Triangulation DEAL::OK DEAL::OK DEAL::OK diff --git a/tests/mpi/limit_p_level_difference_03.with_p4est=true.mpirun=4.output b/tests/mpi/limit_p_level_difference_03.with_p4est=true.mpirun=4.output index 7715c474e9..fb71de2867 100644 --- a/tests/mpi/limit_p_level_difference_03.with_p4est=true.mpirun=4.output +++ b/tests/mpi/limit_p_level_difference_03.with_p4est=true.mpirun=4.output @@ -1,13 +1,4 @@ -DEAL::parallel::shared::Triangulation -DEAL::OK -DEAL::OK -DEAL::OK -DEAL::parallel::shared::Triangulation with artificial cells -DEAL::OK -DEAL::OK -DEAL::OK -DEAL::parallel::distributed::Triangulation DEAL::OK DEAL::OK DEAL::OK diff --git a/tests/mpi/limit_p_level_difference_04.cc b/tests/mpi/limit_p_level_difference_04.cc index 28b375334d..f3e2d1c5f4 100644 --- a/tests/mpi/limit_p_level_difference_04.cc +++ b/tests/mpi/limit_p_level_difference_04.cc @@ -19,9 +19,7 @@ // on h-coarsened grids -#include #include -#include #include @@ -37,9 +35,8 @@ template void -test(parallel::TriangulationBase &tria, const unsigned int max_difference) +test(const unsigned int max_difference) { - Assert(tria.n_levels() == 0, ExcInternalError()); Assert(max_difference > 0, ExcInternalError()); // setup FE collection @@ -65,6 +62,7 @@ test(parallel::TriangulationBase &tria, const unsigned int max_difference) // after prepare_coarsening_and_refinement(), the p-levels should propagate // through the central cells as if they were already coarsened + parallel::distributed::Triangulation tria(MPI_COMM_WORLD); TestGrids::hyper_line(tria, 3); // refine the central cell @@ -91,12 +89,6 @@ test(parallel::TriangulationBase &tria, const unsigned int max_difference) (void)fe_indices_changed; Assert(fe_indices_changed, ExcInternalError()); - deallog << "future FE indices before adaptation:" << std::endl; - for (const auto &cell : dofh.active_cell_iterators()) - if (cell->is_locally_owned()) - deallog << " " << cell->id().to_string() << " " << cell->future_fe_index() - << std::endl; - tria.execute_coarsening_and_refinement(); deallog << "active FE indices after adaptation:" << std::endl; @@ -115,45 +107,7 @@ main(int argc, char *argv[]) Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); MPILogInitAll log; - constexpr const unsigned int dim = 2; - - // Known bug: - // Collecting FE indices for parent cells on children fails for p::s::T - // at the moment whenever siblings belong to the different processors. - // - // deallog << "parallel::shared::Triangulation" << std::endl; - // { - // parallel::shared::Triangulation tria(MPI_COMM_WORLD); - // - // test(tria, 1); - // tria.clear(); - // test(tria, 2); - // tria.clear(); - // test(tria, 3); - // } - // - // deallog << "parallel::shared::Triangulation with artificial cells" - // << std::endl; - // { - // parallel::shared::Triangulation tria(MPI_COMM_WORLD, - // Triangulation::none, - // /*allow_artificial_cells=*/true); - // - // test(tria, 1); - // tria.clear(); - // test(tria, 2); - // tria.clear(); - // test(tria, 3); - // } - - deallog << "parallel::distributed::Triangulation" << std::endl; - { - parallel::distributed::Triangulation tria(MPI_COMM_WORLD); - - test(tria, 1); - tria.clear(); - test(tria, 2); - tria.clear(); - test(tria, 3); - } + test<2>(1); + test<2>(2); + test<2>(3); } diff --git a/tests/mpi/limit_p_level_difference_04.with_p4est=true.mpirun=1.output b/tests/mpi/limit_p_level_difference_04.with_p4est=true.mpirun=1.output index ce0582b4c0..1b336b6703 100644 --- a/tests/mpi/limit_p_level_difference_04.with_p4est=true.mpirun=1.output +++ b/tests/mpi/limit_p_level_difference_04.with_p4est=true.mpirun=1.output @@ -1,36 +1,14 @@ -DEAL:0::parallel::distributed::Triangulation -DEAL:0::future FE indices before adaptation: -DEAL:0:: 0_0: 3 -DEAL:0:: 2_0: 1 -DEAL:0:: 1_1:0 2 -DEAL:0:: 1_1:1 2 -DEAL:0:: 1_1:2 2 -DEAL:0:: 1_1:3 2 DEAL:0::active FE indices after adaptation: DEAL:0:: 0_0: 3 DEAL:0:: 1_0: 2 DEAL:0:: 2_0: 1 DEAL:0::OK -DEAL:0::future FE indices before adaptation: -DEAL:0:: 0_0: 5 -DEAL:0:: 2_0: 1 -DEAL:0:: 1_1:0 3 -DEAL:0:: 1_1:1 3 -DEAL:0:: 1_1:2 3 -DEAL:0:: 1_1:3 3 DEAL:0::active FE indices after adaptation: DEAL:0:: 0_0: 5 DEAL:0:: 1_0: 3 DEAL:0:: 2_0: 1 DEAL:0::OK -DEAL:0::future FE indices before adaptation: -DEAL:0:: 0_0: 7 -DEAL:0:: 2_0: 1 -DEAL:0:: 1_1:0 4 -DEAL:0:: 1_1:1 4 -DEAL:0:: 1_1:2 4 -DEAL:0:: 1_1:3 4 DEAL:0::active FE indices after adaptation: DEAL:0:: 0_0: 7 DEAL:0:: 1_0: 4 diff --git a/tests/mpi/limit_p_level_difference_04.with_p4est=true.mpirun=4.output b/tests/mpi/limit_p_level_difference_04.with_p4est=true.mpirun=4.output index 12eec573d9..11fa4fb37c 100644 --- a/tests/mpi/limit_p_level_difference_04.with_p4est=true.mpirun=4.output +++ b/tests/mpi/limit_p_level_difference_04.with_p4est=true.mpirun=4.output @@ -1,73 +1,39 @@ -DEAL:0::parallel::distributed::Triangulation -DEAL:0::future FE indices before adaptation: -DEAL:0:: 0_0: 3 DEAL:0::active FE indices after adaptation: DEAL:0::OK -DEAL:0::future FE indices before adaptation: -DEAL:0:: 0_0: 5 DEAL:0::active FE indices after adaptation: DEAL:0::OK -DEAL:0::future FE indices before adaptation: -DEAL:0:: 0_0: 7 DEAL:0::active FE indices after adaptation: DEAL:0::OK -DEAL:1::parallel::distributed::Triangulation -DEAL:1::future FE indices before adaptation: -DEAL:1:: 1_1:0 2 -DEAL:1:: 1_1:1 2 -DEAL:1:: 1_1:2 2 -DEAL:1:: 1_1:3 2 DEAL:1::active FE indices after adaptation: DEAL:1:: 0_0: 3 DEAL:1::OK -DEAL:1::future FE indices before adaptation: -DEAL:1:: 1_1:0 3 -DEAL:1:: 1_1:1 3 -DEAL:1:: 1_1:2 3 -DEAL:1:: 1_1:3 3 DEAL:1::active FE indices after adaptation: DEAL:1:: 0_0: 5 DEAL:1::OK -DEAL:1::future FE indices before adaptation: -DEAL:1:: 1_1:0 4 -DEAL:1:: 1_1:1 4 -DEAL:1:: 1_1:2 4 -DEAL:1:: 1_1:3 4 DEAL:1::active FE indices after adaptation: DEAL:1:: 0_0: 7 DEAL:1::OK -DEAL:2::parallel::distributed::Triangulation -DEAL:2::future FE indices before adaptation: DEAL:2::active FE indices after adaptation: DEAL:2:: 1_0: 2 DEAL:2::OK -DEAL:2::future FE indices before adaptation: DEAL:2::active FE indices after adaptation: DEAL:2:: 1_0: 3 DEAL:2::OK -DEAL:2::future FE indices before adaptation: DEAL:2::active FE indices after adaptation: DEAL:2:: 1_0: 4 DEAL:2::OK -DEAL:3::parallel::distributed::Triangulation -DEAL:3::future FE indices before adaptation: -DEAL:3:: 2_0: 1 DEAL:3::active FE indices after adaptation: DEAL:3:: 2_0: 1 DEAL:3::OK -DEAL:3::future FE indices before adaptation: -DEAL:3:: 2_0: 1 DEAL:3::active FE indices after adaptation: DEAL:3:: 2_0: 1 DEAL:3::OK -DEAL:3::future FE indices before adaptation: -DEAL:3:: 2_0: 1 DEAL:3::active FE indices after adaptation: DEAL:3:: 2_0: 1 DEAL:3::OK diff --git a/tests/sharedtria/limit_p_level_difference_01.cc b/tests/sharedtria/limit_p_level_difference_01.cc new file mode 100644 index 0000000000..22a43433af --- /dev/null +++ b/tests/sharedtria/limit_p_level_difference_01.cc @@ -0,0 +1,134 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2021 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// verify restrictions on level differences imposed by +// DoFHandler::prepare_coarsening_and_refinement() +// +// set the center cell to the highest p-level in a hyper_cross geometry +// and verify that all other cells comply to the level difference + + +#include +#include + +#include + +#include + +#include + +#include + +#include +#include + +#include + +#include "../tests.h" + + +template +void +test(const unsigned int fes_size, + const unsigned int max_difference, + const bool allow_artificial_cells) +{ + Assert(fes_size > 0, ExcInternalError()); + Assert(max_difference > 0, ExcInternalError()); + + // setup FE collection + hp::FECollection fes; + while (fes.size() < fes_size) + fes.push_back(FE_Q(1)); + + const unsigned int contains_fe_index = 0; + const auto sequence = fes.get_hierarchy_sequence(contains_fe_index); + + // setup cross-shaped mesh + parallel::shared::Triangulation tria(MPI_COMM_WORLD, + Triangulation::none, + allow_artificial_cells); + { + std::vector sizes(Utilities::pow(2, dim), + static_cast( + (sequence.size() - 1) / max_difference)); + GridGenerator::hyper_cross(tria, sizes); + } + + deallog << "ncells:" << tria.n_cells() << ", nfes:" << fes.size() << std::endl + << "sequence:" << sequence << std::endl; + + DoFHandler dofh(tria); + dofh.distribute_dofs(fes); + + // set center cell to highest p-level + for (const auto &cell : dofh.active_cell_iterators()) + if (cell->is_locally_owned() && cell->center() == Point()) + cell->set_active_fe_index(sequence.back()); + + const bool fe_indices_changed = + hp::Refinement::limit_p_level_difference(dofh, + max_difference, + contains_fe_index); + tria.execute_coarsening_and_refinement(); + + (void)fe_indices_changed; + Assert(fe_indices_changed, ExcInternalError()); + + // display number of cells for each FE index + std::vector count(fes.size(), 0); + for (const auto &cell : dofh.active_cell_iterators()) + if (cell->is_locally_owned()) + count[cell->active_fe_index()]++; + Utilities::MPI::sum(count, tria.get_communicator(), count); + deallog << "fe count:" << count << std::endl; + +#ifdef DEBUG + // check each cell's active FE index by its distance from the center + for (const auto &cell : dofh.active_cell_iterators()) + if (cell->is_locally_owned()) + { + const double distance = cell->center().distance(Point()); + const unsigned int expected_level = + (sequence.size() - 1) - + max_difference * static_cast(std::round(distance)); + + Assert(cell->active_fe_index() == sequence[expected_level], + ExcInternalError()); + } +#endif + + deallog << "OK" << std::endl; +} + + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + + if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0) + initlog(); + + deallog << std::boolalpha; + for (const bool allow_artificial_cells : {false, true}) + { + deallog << "artificial cells: " << allow_artificial_cells << std::endl; + test<2>(4, 1, allow_artificial_cells); + test<2>(8, 2, allow_artificial_cells); + test<2>(12, 3, allow_artificial_cells); + } +} diff --git a/tests/sharedtria/limit_p_level_difference_01.with_mpi=true.mpirun=1.output b/tests/sharedtria/limit_p_level_difference_01.with_mpi=true.mpirun=1.output new file mode 100644 index 0000000000..34920d6459 --- /dev/null +++ b/tests/sharedtria/limit_p_level_difference_01.with_mpi=true.mpirun=1.output @@ -0,0 +1,27 @@ + +DEAL::artificial cells: false +DEAL::ncells:13, nfes:4 +DEAL::sequence:0 1 2 3 +DEAL::fe count:4 4 4 1 +DEAL::OK +DEAL::ncells:13, nfes:8 +DEAL::sequence:0 1 2 3 4 5 6 7 +DEAL::fe count:0 4 0 4 0 4 0 1 +DEAL::OK +DEAL::ncells:13, nfes:12 +DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 +DEAL::fe count:0 0 4 0 0 4 0 0 4 0 0 1 +DEAL::OK +DEAL::artificial cells: true +DEAL::ncells:13, nfes:4 +DEAL::sequence:0 1 2 3 +DEAL::fe count:4 4 4 1 +DEAL::OK +DEAL::ncells:13, nfes:8 +DEAL::sequence:0 1 2 3 4 5 6 7 +DEAL::fe count:0 4 0 4 0 4 0 1 +DEAL::OK +DEAL::ncells:13, nfes:12 +DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 +DEAL::fe count:0 0 4 0 0 4 0 0 4 0 0 1 +DEAL::OK diff --git a/tests/sharedtria/limit_p_level_difference_01.with_mpi=true.mpirun=4.output b/tests/sharedtria/limit_p_level_difference_01.with_mpi=true.mpirun=4.output new file mode 100644 index 0000000000..34920d6459 --- /dev/null +++ b/tests/sharedtria/limit_p_level_difference_01.with_mpi=true.mpirun=4.output @@ -0,0 +1,27 @@ + +DEAL::artificial cells: false +DEAL::ncells:13, nfes:4 +DEAL::sequence:0 1 2 3 +DEAL::fe count:4 4 4 1 +DEAL::OK +DEAL::ncells:13, nfes:8 +DEAL::sequence:0 1 2 3 4 5 6 7 +DEAL::fe count:0 4 0 4 0 4 0 1 +DEAL::OK +DEAL::ncells:13, nfes:12 +DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 +DEAL::fe count:0 0 4 0 0 4 0 0 4 0 0 1 +DEAL::OK +DEAL::artificial cells: true +DEAL::ncells:13, nfes:4 +DEAL::sequence:0 1 2 3 +DEAL::fe count:4 4 4 1 +DEAL::OK +DEAL::ncells:13, nfes:8 +DEAL::sequence:0 1 2 3 4 5 6 7 +DEAL::fe count:0 4 0 4 0 4 0 1 +DEAL::OK +DEAL::ncells:13, nfes:12 +DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 +DEAL::fe count:0 0 4 0 0 4 0 0 4 0 0 1 +DEAL::OK diff --git a/tests/sharedtria/limit_p_level_difference_02.cc b/tests/sharedtria/limit_p_level_difference_02.cc new file mode 100644 index 0000000000..5a96a5b328 --- /dev/null +++ b/tests/sharedtria/limit_p_level_difference_02.cc @@ -0,0 +1,140 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2021 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// verify restrictions on level differences imposed by +// DoFHandler::prepare_coarsening_and_refinement() +// +// sequentially increase the p-level of the center cell in a hyper_cross +// geometry and verify that all other comply to the level difference + + +#include +#include + +#include + +#include + +#include + +#include + +#include +#include + +#include + +#include "../tests.h" + + +template +void +test(const unsigned int fes_size, + const unsigned int max_difference, + const bool allow_artificial_cells) +{ + Assert(fes_size > 0, ExcInternalError()); + Assert(max_difference > 0, ExcInternalError()); + + // setup FE collection + hp::FECollection fes; + while (fes.size() < fes_size) + fes.push_back(FE_Q(1)); + + const unsigned int contains_fe_index = 0; + const auto sequence = fes.get_hierarchy_sequence(contains_fe_index); + + // setup cross-shaped mesh + parallel::shared::Triangulation tria(MPI_COMM_WORLD, + Triangulation::none, + allow_artificial_cells); + { + std::vector sizes(Utilities::pow(2, dim), + static_cast( + (sequence.size() - 1) / max_difference)); + GridGenerator::hyper_cross(tria, sizes); + } + + deallog << "ncells:" << tria.n_cells() << ", nfes:" << fes.size() << std::endl + << "sequence:" << sequence << std::endl; + + DoFHandler dofh(tria); + dofh.distribute_dofs(fes); + + // increase p-level in center subsequently + for (unsigned int i = 0; i < sequence.size() - 1; ++i) + { + // find center cell + for (const auto &cell : dofh.active_cell_iterators()) + if (cell->is_locally_owned() && cell->center() == Point()) + cell->set_future_fe_index( + fes.next_in_hierarchy(cell->active_fe_index())); + + const bool fe_indices_changed = + hp::Refinement::limit_p_level_difference(dofh, + max_difference, + contains_fe_index); + tria.execute_coarsening_and_refinement(); + + (void)fe_indices_changed; + if (i >= max_difference) + Assert(fe_indices_changed, ExcInternalError()); + + // display number of cells for each FE index + std::vector count(fes.size(), 0); + for (const auto &cell : dofh.active_cell_iterators()) + if (cell->is_locally_owned()) + count[cell->active_fe_index()]++; + Utilities::MPI::sum(count, tria.get_communicator(), count); + deallog << "cycle:" << i << ", fe count:" << count << std::endl; + } + +#ifdef DEBUG + // check each cell's active FE index by its distance from the center + for (const auto &cell : dofh.active_cell_iterators()) + if (cell->is_locally_owned()) + { + const double distance = cell->center().distance(Point()); + const unsigned int expected_level = + (sequence.size() - 1) - + max_difference * static_cast(std::round(distance)); + + Assert(cell->active_fe_index() == sequence[expected_level], + ExcInternalError()); + } +#endif + + deallog << "OK" << std::endl; +} + + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + + if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0) + initlog(); + + deallog << std::boolalpha; + for (const bool allow_artificial_cells : {false, true}) + { + deallog << "artificial cells: " << allow_artificial_cells << std::endl; + test<2>(4, 1, allow_artificial_cells); + test<2>(8, 2, allow_artificial_cells); + test<2>(12, 3, allow_artificial_cells); + } +} diff --git a/tests/sharedtria/limit_p_level_difference_02.with_mpi=true.mpirun=1.output b/tests/sharedtria/limit_p_level_difference_02.with_mpi=true.mpirun=1.output new file mode 100644 index 0000000000..a3bfc2b188 --- /dev/null +++ b/tests/sharedtria/limit_p_level_difference_02.with_mpi=true.mpirun=1.output @@ -0,0 +1,63 @@ + +DEAL::artificial cells: false +DEAL::ncells:13, nfes:4 +DEAL::sequence:0 1 2 3 +DEAL::cycle:0, fe count:12 1 0 0 +DEAL::cycle:1, fe count:8 4 1 0 +DEAL::cycle:2, fe count:4 4 4 1 +DEAL::OK +DEAL::ncells:13, nfes:8 +DEAL::sequence:0 1 2 3 4 5 6 7 +DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 +DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 +DEAL::cycle:2, fe count:8 4 0 1 0 0 0 0 +DEAL::cycle:3, fe count:8 0 4 0 1 0 0 0 +DEAL::cycle:4, fe count:4 4 0 4 0 1 0 0 +DEAL::cycle:5, fe count:4 0 4 0 4 0 1 0 +DEAL::cycle:6, fe count:0 4 0 4 0 4 0 1 +DEAL::OK +DEAL::ncells:13, nfes:12 +DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 +DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 0 0 0 0 +DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 0 0 0 0 +DEAL::cycle:2, fe count:12 0 0 1 0 0 0 0 0 0 0 0 +DEAL::cycle:3, fe count:8 4 0 0 1 0 0 0 0 0 0 0 +DEAL::cycle:4, fe count:8 0 4 0 0 1 0 0 0 0 0 0 +DEAL::cycle:5, fe count:8 0 0 4 0 0 1 0 0 0 0 0 +DEAL::cycle:6, fe count:4 4 0 0 4 0 0 1 0 0 0 0 +DEAL::cycle:7, fe count:4 0 4 0 0 4 0 0 1 0 0 0 +DEAL::cycle:8, fe count:4 0 0 4 0 0 4 0 0 1 0 0 +DEAL::cycle:9, fe count:0 4 0 0 4 0 0 4 0 0 1 0 +DEAL::cycle:10, fe count:0 0 4 0 0 4 0 0 4 0 0 1 +DEAL::OK +DEAL::artificial cells: true +DEAL::ncells:13, nfes:4 +DEAL::sequence:0 1 2 3 +DEAL::cycle:0, fe count:12 1 0 0 +DEAL::cycle:1, fe count:8 4 1 0 +DEAL::cycle:2, fe count:4 4 4 1 +DEAL::OK +DEAL::ncells:13, nfes:8 +DEAL::sequence:0 1 2 3 4 5 6 7 +DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 +DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 +DEAL::cycle:2, fe count:8 4 0 1 0 0 0 0 +DEAL::cycle:3, fe count:8 0 4 0 1 0 0 0 +DEAL::cycle:4, fe count:4 4 0 4 0 1 0 0 +DEAL::cycle:5, fe count:4 0 4 0 4 0 1 0 +DEAL::cycle:6, fe count:0 4 0 4 0 4 0 1 +DEAL::OK +DEAL::ncells:13, nfes:12 +DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 +DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 0 0 0 0 +DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 0 0 0 0 +DEAL::cycle:2, fe count:12 0 0 1 0 0 0 0 0 0 0 0 +DEAL::cycle:3, fe count:8 4 0 0 1 0 0 0 0 0 0 0 +DEAL::cycle:4, fe count:8 0 4 0 0 1 0 0 0 0 0 0 +DEAL::cycle:5, fe count:8 0 0 4 0 0 1 0 0 0 0 0 +DEAL::cycle:6, fe count:4 4 0 0 4 0 0 1 0 0 0 0 +DEAL::cycle:7, fe count:4 0 4 0 0 4 0 0 1 0 0 0 +DEAL::cycle:8, fe count:4 0 0 4 0 0 4 0 0 1 0 0 +DEAL::cycle:9, fe count:0 4 0 0 4 0 0 4 0 0 1 0 +DEAL::cycle:10, fe count:0 0 4 0 0 4 0 0 4 0 0 1 +DEAL::OK diff --git a/tests/sharedtria/limit_p_level_difference_02.with_mpi=true.mpirun=4.output b/tests/sharedtria/limit_p_level_difference_02.with_mpi=true.mpirun=4.output new file mode 100644 index 0000000000..a3bfc2b188 --- /dev/null +++ b/tests/sharedtria/limit_p_level_difference_02.with_mpi=true.mpirun=4.output @@ -0,0 +1,63 @@ + +DEAL::artificial cells: false +DEAL::ncells:13, nfes:4 +DEAL::sequence:0 1 2 3 +DEAL::cycle:0, fe count:12 1 0 0 +DEAL::cycle:1, fe count:8 4 1 0 +DEAL::cycle:2, fe count:4 4 4 1 +DEAL::OK +DEAL::ncells:13, nfes:8 +DEAL::sequence:0 1 2 3 4 5 6 7 +DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 +DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 +DEAL::cycle:2, fe count:8 4 0 1 0 0 0 0 +DEAL::cycle:3, fe count:8 0 4 0 1 0 0 0 +DEAL::cycle:4, fe count:4 4 0 4 0 1 0 0 +DEAL::cycle:5, fe count:4 0 4 0 4 0 1 0 +DEAL::cycle:6, fe count:0 4 0 4 0 4 0 1 +DEAL::OK +DEAL::ncells:13, nfes:12 +DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 +DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 0 0 0 0 +DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 0 0 0 0 +DEAL::cycle:2, fe count:12 0 0 1 0 0 0 0 0 0 0 0 +DEAL::cycle:3, fe count:8 4 0 0 1 0 0 0 0 0 0 0 +DEAL::cycle:4, fe count:8 0 4 0 0 1 0 0 0 0 0 0 +DEAL::cycle:5, fe count:8 0 0 4 0 0 1 0 0 0 0 0 +DEAL::cycle:6, fe count:4 4 0 0 4 0 0 1 0 0 0 0 +DEAL::cycle:7, fe count:4 0 4 0 0 4 0 0 1 0 0 0 +DEAL::cycle:8, fe count:4 0 0 4 0 0 4 0 0 1 0 0 +DEAL::cycle:9, fe count:0 4 0 0 4 0 0 4 0 0 1 0 +DEAL::cycle:10, fe count:0 0 4 0 0 4 0 0 4 0 0 1 +DEAL::OK +DEAL::artificial cells: true +DEAL::ncells:13, nfes:4 +DEAL::sequence:0 1 2 3 +DEAL::cycle:0, fe count:12 1 0 0 +DEAL::cycle:1, fe count:8 4 1 0 +DEAL::cycle:2, fe count:4 4 4 1 +DEAL::OK +DEAL::ncells:13, nfes:8 +DEAL::sequence:0 1 2 3 4 5 6 7 +DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 +DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 +DEAL::cycle:2, fe count:8 4 0 1 0 0 0 0 +DEAL::cycle:3, fe count:8 0 4 0 1 0 0 0 +DEAL::cycle:4, fe count:4 4 0 4 0 1 0 0 +DEAL::cycle:5, fe count:4 0 4 0 4 0 1 0 +DEAL::cycle:6, fe count:0 4 0 4 0 4 0 1 +DEAL::OK +DEAL::ncells:13, nfes:12 +DEAL::sequence:0 1 2 3 4 5 6 7 8 9 10 11 +DEAL::cycle:0, fe count:12 1 0 0 0 0 0 0 0 0 0 0 +DEAL::cycle:1, fe count:12 0 1 0 0 0 0 0 0 0 0 0 +DEAL::cycle:2, fe count:12 0 0 1 0 0 0 0 0 0 0 0 +DEAL::cycle:3, fe count:8 4 0 0 1 0 0 0 0 0 0 0 +DEAL::cycle:4, fe count:8 0 4 0 0 1 0 0 0 0 0 0 +DEAL::cycle:5, fe count:8 0 0 4 0 0 1 0 0 0 0 0 +DEAL::cycle:6, fe count:4 4 0 0 4 0 0 1 0 0 0 0 +DEAL::cycle:7, fe count:4 0 4 0 0 4 0 0 1 0 0 0 +DEAL::cycle:8, fe count:4 0 0 4 0 0 4 0 0 1 0 0 +DEAL::cycle:9, fe count:0 4 0 0 4 0 0 4 0 0 1 0 +DEAL::cycle:10, fe count:0 0 4 0 0 4 0 0 4 0 0 1 +DEAL::OK diff --git a/tests/sharedtria/limit_p_level_difference_03.cc b/tests/sharedtria/limit_p_level_difference_03.cc new file mode 100644 index 0000000000..8ce3b27711 --- /dev/null +++ b/tests/sharedtria/limit_p_level_difference_03.cc @@ -0,0 +1,139 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2021 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// verify restrictions on level differences imposed by +// DoFHandler::prepare_coarsening_and_refinement() +// on h-refined grids + + +#include + +#include + +#include + +#include + +#include +#include + +#include "../tests.h" + +#include "../test_grids.h" + + +unsigned int +divide_and_ceil(unsigned int x, unsigned int y) +{ + return x / y + (x % y > 0); +} + + +template +void +test(const unsigned int fes_size, + const unsigned int max_difference, + const bool allow_artificial_cells) +{ + Assert(max_difference > 0, ExcInternalError()); + Assert(fes_size > 1, ExcInternalError()); + + // setup FE collection + hp::FECollection fes; + while (fes.size() < fes_size) + fes.push_back(FE_Q(1)); + + const unsigned int contains_fe_index = 0; + const auto sequence = fes.get_hierarchy_sequence(contains_fe_index); + + // set up line grid + // - refine leftmost column of cells consecutively + // - assign highest p-level to rightmost cell + // + // +++-+---+------+ + // +++ | | | + // +++-+---+ | + // +++ | | | + // +++-+---+------+ + // + // after prepare_coarsening_and_refinement(), each p-level will correspond to + // a unique column of cells and thus h-level + + parallel::shared::Triangulation tria(MPI_COMM_WORLD, + Triangulation::none, + allow_artificial_cells); + TestGrids::hyper_line(tria, 2); + const unsigned int n_refinements = + divide_and_ceil(sequence.size() - 1, max_difference); + for (unsigned int i = 0; i < n_refinements; ++i) + { + for (const auto &cell : tria.active_cell_iterators()) + for (unsigned int v = 0; v < cell->n_vertices(); ++v) + if (cell->vertex(v)[0] == 0.) + cell->set_refine_flag(); + + tria.execute_coarsening_and_refinement(); + } + + DoFHandler dofh(tria); + for (const auto &cell : dofh.cell_iterators_on_level(0)) + if (cell->is_active() && cell->is_locally_owned()) + cell->set_active_fe_index(sequence.back()); + dofh.distribute_dofs(fes); + + const bool fe_indices_changed = + hp::Refinement::limit_p_level_difference(dofh, + max_difference, + contains_fe_index); + tria.execute_coarsening_and_refinement(); + + (void)fe_indices_changed; + Assert(fe_indices_changed, ExcInternalError()); + +#ifdef DEBUG + // check each cell's active FE by its h-level + for (unsigned int l = 0; l < tria.n_global_levels(); ++l) + for (const auto &cell : dofh.cell_iterators_on_level(l)) + if (cell->is_active() && cell->is_locally_owned()) + { + const unsigned int expected_level = std::max( + 0, static_cast(sequence.size() - 1 - l * max_difference)); + Assert(cell->active_fe_index() == sequence[expected_level], + ExcInternalError()); + } +#endif + + deallog << "OK" << std::endl; +} + + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + + if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0) + initlog(); + + deallog << std::boolalpha; + for (const bool allow_artificial_cells : {false, true}) + { + deallog << "artificial cells: " << allow_artificial_cells << std::endl; + test<2>(5, 1, allow_artificial_cells); + test<2>(10, 2, allow_artificial_cells); + test<2>(15, 3, allow_artificial_cells); + } +} diff --git a/tests/sharedtria/limit_p_level_difference_03.with_mpi=true.mpirun=1.output b/tests/sharedtria/limit_p_level_difference_03.with_mpi=true.mpirun=1.output new file mode 100644 index 0000000000..a5bb1e1e69 --- /dev/null +++ b/tests/sharedtria/limit_p_level_difference_03.with_mpi=true.mpirun=1.output @@ -0,0 +1,9 @@ + +DEAL::artificial cells: false +DEAL::OK +DEAL::OK +DEAL::OK +DEAL::artificial cells: true +DEAL::OK +DEAL::OK +DEAL::OK diff --git a/tests/sharedtria/limit_p_level_difference_03.with_mpi=true.mpirun=4.output b/tests/sharedtria/limit_p_level_difference_03.with_mpi=true.mpirun=4.output new file mode 100644 index 0000000000..a5bb1e1e69 --- /dev/null +++ b/tests/sharedtria/limit_p_level_difference_03.with_mpi=true.mpirun=4.output @@ -0,0 +1,9 @@ + +DEAL::artificial cells: false +DEAL::OK +DEAL::OK +DEAL::OK +DEAL::artificial cells: true +DEAL::OK +DEAL::OK +DEAL::OK -- 2.39.5