From ecf5fd22e04977f0e53d9958218cfdc321312b87 Mon Sep 17 00:00:00 2001 From: Marc Fehling Date: Fri, 20 Jul 2018 11:21:33 -0600 Subject: [PATCH] Add test for hp::distribute_dofs on p::d::Triangulation. --- tests/mpi/hp_distribute_dofs_01.cc | 89 +++++++++++++++++++ .../mpi/hp_distribute_dofs_01.mpirun=1.output | 3 + .../mpi/hp_distribute_dofs_01.mpirun=2.output | 3 + 3 files changed, 95 insertions(+) create mode 100644 tests/mpi/hp_distribute_dofs_01.cc create mode 100644 tests/mpi/hp_distribute_dofs_01.mpirun=1.output create mode 100644 tests/mpi/hp_distribute_dofs_01.mpirun=2.output diff --git a/tests/mpi/hp_distribute_dofs_01.cc b/tests/mpi/hp_distribute_dofs_01.cc new file mode 100644 index 0000000000..6a7db602dc --- /dev/null +++ b/tests/mpi/hp_distribute_dofs_01.cc @@ -0,0 +1,89 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2009 - 2018 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. +// +// --------------------------------------------------------------------- + + + +// hp::DoFHandler::distribute_dofs failed +// if a processor only owns artificial cells + +#include + +#include + +#include + +#include + +#include "../tests.h" + + +template +void +test() +{ + parallel::distributed::Triangulation tria( + MPI_COMM_WORLD, + typename Triangulation::MeshSmoothing( + Triangulation::smoothing_on_refinement | + Triangulation::smoothing_on_coarsening)); + + GridGenerator::hyper_cube(tria, -1.0, 1.0); + tria.refine_global(1); + + const unsigned int max_degree = (dim == 2) ? 4 : 8; + + hp::DoFHandler dh(tria); + hp::FECollection fe_collection; + for (unsigned int degree = 1; degree <= max_degree; ++degree) + fe_collection.push_back(FE_Q(degree)); + + dh.distribute_dofs(fe_collection); // <-- fails + + // make sure no processor is + // hanging + MPI_Barrier(MPI_COMM_WORLD); + + if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0) + deallog << "OK" << std::endl; +} + + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + + + unsigned int myid = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + + deallog.push(Utilities::int_to_string(myid)); + + if (myid == 0) + { + initlog(); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + deallog.push("3d"); + test<3>(); + deallog.pop(); + } + else + { + test<2>(); + test<3>(); + } +} diff --git a/tests/mpi/hp_distribute_dofs_01.mpirun=1.output b/tests/mpi/hp_distribute_dofs_01.mpirun=1.output new file mode 100644 index 0000000000..995f6e446b --- /dev/null +++ b/tests/mpi/hp_distribute_dofs_01.mpirun=1.output @@ -0,0 +1,3 @@ + +DEAL:0:2d::OK +DEAL:0:3d::OK diff --git a/tests/mpi/hp_distribute_dofs_01.mpirun=2.output b/tests/mpi/hp_distribute_dofs_01.mpirun=2.output new file mode 100644 index 0000000000..995f6e446b --- /dev/null +++ b/tests/mpi/hp_distribute_dofs_01.mpirun=2.output @@ -0,0 +1,3 @@ + +DEAL:0:2d::OK +DEAL:0:3d::OK -- 2.39.5