#include <deal.II/base/point.h>
#include <deal.II/base/utilities.h>
-#include <deal.II/distributed/shared_tria.h>
#include <deal.II/distributed/tria.h>
-#include <deal.II/distributed/tria_base.h>
#include <deal.II/dofs/dof_handler.h>
template <int dim>
void
-test(parallel::TriangulationBase<dim> &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());
const auto sequence = fes.get_hierarchy_sequence(contains_fe_index);
// setup cross-shaped mesh
+ parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
{
std::vector<unsigned int> sizes(Utilities::pow(2, dim),
static_cast<unsigned int>(
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<dim> tria(MPI_COMM_WORLD);
-
- test<dim>(tria, 4, 1);
- tria.clear();
- test<dim>(tria, 8, 2);
- tria.clear();
- test<dim>(tria, 12, 3);
- }
-
- deallog << "parallel::shared::Triangulation with artificial cells"
- << std::endl;
- {
- parallel::shared::Triangulation<dim> tria(MPI_COMM_WORLD,
- Triangulation<dim>::none,
- /*allow_artificial_cells=*/true);
-
- test<dim>(tria, 4, 1);
- tria.clear();
- test<dim>(tria, 8, 2);
- tria.clear();
- test<dim>(tria, 12, 3);
- }
-
- deallog << "parallel::distributed::Triangulation" << std::endl;
- {
- parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
-
- test<dim>(tria, 4, 1);
- tria.clear();
- test<dim>(tria, 8, 2);
- tria.clear();
- test<dim>(tria, 12, 3);
- }
+ test<2>(4, 1);
+ test<2>(8, 2);
+ test<2>(12, 3);
}
-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
-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
#include <deal.II/base/point.h>
#include <deal.II/base/utilities.h>
-#include <deal.II/distributed/shared_tria.h>
#include <deal.II/distributed/tria.h>
-#include <deal.II/distributed/tria_base.h>
#include <deal.II/dofs/dof_handler.h>
template <int dim>
void
-test(parallel::TriangulationBase<dim> &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());
const auto sequence = fes.get_hierarchy_sequence(contains_fe_index);
// setup cross-shaped mesh
+ parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
{
std::vector<unsigned int> sizes(Utilities::pow(2, dim),
static_cast<unsigned int>(
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<dim> tria(MPI_COMM_WORLD);
-
- test<dim>(tria, 4, 1);
- tria.clear();
- test<dim>(tria, 8, 2);
- tria.clear();
- test<dim>(tria, 12, 3);
- }
-
- deallog << "parallel::shared::Triangulation with artificial cells"
- << std::endl;
- {
- parallel::shared::Triangulation<dim> tria(MPI_COMM_WORLD,
- Triangulation<dim>::none,
- /*allow_artificial_cells=*/true);
-
- test<dim>(tria, 4, 1);
- tria.clear();
- test<dim>(tria, 8, 2);
- tria.clear();
- test<dim>(tria, 12, 3);
- }
-
- deallog << "parallel::distributed::Triangulation" << std::endl;
- {
- parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
-
- test<dim>(tria, 4, 1);
- tria.clear();
- test<dim>(tria, 8, 2);
- tria.clear();
- test<dim>(tria, 12, 3);
- }
+ test<2>(4, 1);
+ test<2>(8, 2);
+ test<2>(12, 3);
}
-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
-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
#include <deal.II/base/point.h>
-#include <deal.II/distributed/shared_tria.h>
#include <deal.II/distributed/tria.h>
-#include <deal.II/distributed/tria_base.h>
#include <deal.II/dofs/dof_handler.h>
template <int dim>
void
-test(parallel::TriangulationBase<dim> &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());
// after prepare_coarsening_and_refinement(), each p-level will correspond to
// a unique column of cells and thus h-level
+ parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
TestGrids::hyper_line(tria, 2);
const unsigned int n_refinements =
divide_and_ceil(sequence.size() - 1, max_difference);
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<dim> tria(MPI_COMM_WORLD);
-
- test<dim>(tria, 5, 1);
- tria.clear();
- test<dim>(tria, 10, 2);
- tria.clear();
- test<dim>(tria, 15, 3);
- }
-
- deallog << "parallel::shared::Triangulation with artificial cells"
- << std::endl;
- {
- parallel::shared::Triangulation<dim> tria(MPI_COMM_WORLD,
- Triangulation<dim>::none,
- /*allow_artificial_cells=*/true);
-
- test<dim>(tria, 5, 1);
- tria.clear();
- test<dim>(tria, 10, 2);
- tria.clear();
- test<dim>(tria, 15, 3);
- }
-
- deallog << "parallel::distributed::Triangulation" << std::endl;
- {
- parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
-
- test<dim>(tria, 5, 1);
- tria.clear();
- test<dim>(tria, 10, 2);
- tria.clear();
- test<dim>(tria, 15, 3);
- }
+ test<2>(5, 1);
+ test<2>(10, 2);
+ test<2>(15, 3);
}
-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
-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
// on h-coarsened grids
-#include <deal.II/distributed/shared_tria.h>
#include <deal.II/distributed/tria.h>
-#include <deal.II/distributed/tria_base.h>
#include <deal.II/dofs/dof_handler.h>
template <int dim>
void
-test(parallel::TriangulationBase<dim> &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
// after prepare_coarsening_and_refinement(), the p-levels should propagate
// through the central cells as if they were already coarsened
+ parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
TestGrids::hyper_line(tria, 3);
// refine the central cell
(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;
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<dim> tria(MPI_COMM_WORLD);
- //
- // test<dim>(tria, 1);
- // tria.clear();
- // test<dim>(tria, 2);
- // tria.clear();
- // test<dim>(tria, 3);
- // }
- //
- // deallog << "parallel::shared::Triangulation with artificial cells"
- // << std::endl;
- // {
- // parallel::shared::Triangulation<dim> tria(MPI_COMM_WORLD,
- // Triangulation<dim>::none,
- // /*allow_artificial_cells=*/true);
- //
- // test<dim>(tria, 1);
- // tria.clear();
- // test<dim>(tria, 2);
- // tria.clear();
- // test<dim>(tria, 3);
- // }
-
- deallog << "parallel::distributed::Triangulation" << std::endl;
- {
- parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD);
-
- test<dim>(tria, 1);
- tria.clear();
- test<dim>(tria, 2);
- tria.clear();
- test<dim>(tria, 3);
- }
+ test<2>(1);
+ test<2>(2);
+ test<2>(3);
}
-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
-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
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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 <deal.II/base/point.h>
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/distributed/shared_tria.h>
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/refinement.h>
+
+#include <vector>
+
+#include "../tests.h"
+
+
+template <int dim>
+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<dim> fes;
+ while (fes.size() < fes_size)
+ fes.push_back(FE_Q<dim>(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<dim> tria(MPI_COMM_WORLD,
+ Triangulation<dim>::none,
+ allow_artificial_cells);
+ {
+ std::vector<unsigned int> sizes(Utilities::pow(2, dim),
+ static_cast<unsigned int>(
+ (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<dim> 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<dim>())
+ 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<unsigned int> 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<dim>());
+ const unsigned int expected_level =
+ (sequence.size() - 1) -
+ max_difference * static_cast<unsigned int>(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);
+ }
+}
--- /dev/null
+
+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
--- /dev/null
+
+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
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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 <deal.II/base/point.h>
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/distributed/shared_tria.h>
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/refinement.h>
+
+#include <vector>
+
+#include "../tests.h"
+
+
+template <int dim>
+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<dim> fes;
+ while (fes.size() < fes_size)
+ fes.push_back(FE_Q<dim>(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<dim> tria(MPI_COMM_WORLD,
+ Triangulation<dim>::none,
+ allow_artificial_cells);
+ {
+ std::vector<unsigned int> sizes(Utilities::pow(2, dim),
+ static_cast<unsigned int>(
+ (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<dim> 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<dim>())
+ 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<unsigned int> 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<dim>());
+ const unsigned int expected_level =
+ (sequence.size() - 1) -
+ max_difference * static_cast<unsigned int>(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);
+ }
+}
--- /dev/null
+
+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
--- /dev/null
+
+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
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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 <deal.II/base/point.h>
+
+#include <deal.II/distributed/shared_tria.h>
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/refinement.h>
+
+#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 <int dim>
+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<dim> fes;
+ while (fes.size() < fes_size)
+ fes.push_back(FE_Q<dim>(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<dim> tria(MPI_COMM_WORLD,
+ Triangulation<dim>::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<dim> 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<int>(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);
+ }
+}
--- /dev/null
+
+DEAL::artificial cells: false
+DEAL::OK
+DEAL::OK
+DEAL::OK
+DEAL::artificial cells: true
+DEAL::OK
+DEAL::OK
+DEAL::OK
--- /dev/null
+
+DEAL::artificial cells: false
+DEAL::OK
+DEAL::OK
+DEAL::OK
+DEAL::artificial cells: true
+DEAL::OK
+DEAL::OK
+DEAL::OK