From c14a97ac832e2d68f70cebc92a6668d83cd9c6d9 Mon Sep 17 00:00:00 2001 From: Marc Fehling Date: Tue, 21 May 2024 16:50:02 +0200 Subject: [PATCH] Add a test that failed before. --- tests/mpi/hp_choose_p_over_h.cc | 103 ++++++++++++++++++ ...e_p_over_h.with_p4est=true.mpirun=4.output | 18 +++ 2 files changed, 121 insertions(+) create mode 100644 tests/mpi/hp_choose_p_over_h.cc create mode 100644 tests/mpi/hp_choose_p_over_h.with_p4est=true.mpirun=4.output diff --git a/tests/mpi/hp_choose_p_over_h.cc b/tests/mpi/hp_choose_p_over_h.cc new file mode 100644 index 0000000000..48c3ac11d3 --- /dev/null +++ b/tests/mpi/hp_choose_p_over_h.cc @@ -0,0 +1,103 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2019 - 2024 by the deal.II authors +// +// This file is part of the deal.II library. +// +// Part of the source code is dual licensed under Apache-2.0 WITH +// LLVM-exception OR LGPL-2.1-or-later. Detailed license information +// governing the source code and code contributions can be found in +// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +// +// ------------------------------------------------------------------------ + + + +// verify hp::Refinement::choose_p_over_h() on strongly distributed meshes + + +#include + +#include + +#include + +#include +#include + +#include +#include + +#include "../tests.h" + + + +void +test() +{ + constexpr unsigned int dim = 2; + + // Setup distributed triangulation. + parallel::distributed::Triangulation tr(MPI_COMM_WORLD); + GridGenerator::hyper_cube(tr, -1, 1); + tr.refine_global(1); + + tr.begin_active()->set_refine_flag(); + tr.execute_coarsening_and_refinement(); + + // For two dimensions in this particular scenario, each quadrant in the + // coordinate system will be assigned to single MPI process. + // + // See also the corresponding output file and this ASCII sketch on how p4est + // decided to partition this mesh with four MPI processes. + // + // +---+---+ + // | | | + // | 3 | 3 | + // | | | + // +-+-+---+ + // |1|1| | + // +-+-+ 2 | + // |1|1| | + // +-+-+---+ + + // Set h-coarsen and p-refinement flags on the coarser cells. + DoFHandler dh(tr); + for (const auto &cell : dh.active_cell_iterators_on_level(1) | + IteratorFilters::LocallyOwnedCell()) + { + cell->set_coarsen_flag(); + cell->set_future_fe_index(1); + } + + // Setup FEs. + hp::FECollection fes; + for (unsigned int d = 1; d <= 2; ++d) + fes.push_back(FE_Q(d)); + dh.distribute_dofs(fes); + + // Check whether choose_p_over_h() finishes. + // (It triggered an assertion in the past.) + hp::Refinement::choose_p_over_h(dh); + + // Check the new flags. + for (const auto &cell : + dh.active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) + deallog << cell->id().to_string() + << ": future_fe=" << cell->future_fe_index() + << " coarsen=" << cell->coarsen_flag_set() << std::endl; + + deallog << "OK" << std::endl; +} + + + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll log; + + test(); +} diff --git a/tests/mpi/hp_choose_p_over_h.with_p4est=true.mpirun=4.output b/tests/mpi/hp_choose_p_over_h.with_p4est=true.mpirun=4.output new file mode 100644 index 0000000000..3f2cf89526 --- /dev/null +++ b/tests/mpi/hp_choose_p_over_h.with_p4est=true.mpirun=4.output @@ -0,0 +1,18 @@ + +DEAL:0::OK + +DEAL:1::0_2:00: future_fe=0 coarsen=0 +DEAL:1::0_2:01: future_fe=0 coarsen=0 +DEAL:1::0_2:02: future_fe=0 coarsen=0 +DEAL:1::0_2:03: future_fe=0 coarsen=0 +DEAL:1::OK + + +DEAL:2::0_1:1: future_fe=1 coarsen=0 +DEAL:2::OK + + +DEAL:3::0_1:2: future_fe=1 coarsen=0 +DEAL:3::0_1:3: future_fe=1 coarsen=0 +DEAL:3::OK + -- 2.39.5