From c645eb3561a9c9839f44dd4060f71016376fd762 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 25 Sep 2017 15:51:47 -0600 Subject: [PATCH] Add a test. --- tests/mpi/hp_unify_dof_indices_01.cc | 111 ++++++++++++++++++ .../hp_unify_dof_indices_01.mpirun=1.output | 11 ++ .../hp_unify_dof_indices_01.mpirun=2.output | 11 ++ 3 files changed, 133 insertions(+) create mode 100644 tests/mpi/hp_unify_dof_indices_01.cc create mode 100644 tests/mpi/hp_unify_dof_indices_01.mpirun=1.output create mode 100644 tests/mpi/hp_unify_dof_indices_01.mpirun=2.output diff --git a/tests/mpi/hp_unify_dof_indices_01.cc b/tests/mpi/hp_unify_dof_indices_01.cc new file mode 100644 index 0000000000..c1b402d650 --- /dev/null +++ b/tests/mpi/hp_unify_dof_indices_01.cc @@ -0,0 +1,111 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// have a 2x1 coarse mesh (or 2x1x1) and verify DoF indices in the hp +// case with an FECollection that contains multiple copies of the same +// FE_Q(2) element. in the sequential case, the hp code will unify DoF +// indices on boundaries between locally owned subdomains, but in +// parallel, we don't do that + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + parallel::distributed::Triangulation + triangulation (MPI_COMM_WORLD, + Triangulation::limit_level_difference_at_vertices); + + std::vector reps(dim, 1U); + reps[0] = 2; + Point top_right; + for (unsigned int d=0; d(), + top_right); + Assert (triangulation.n_global_active_cells() == 2, + ExcInternalError()); + Assert (triangulation.n_active_cells() == 2, + ExcInternalError()); + + hp::FECollection fe; + fe.push_back (FE_Q(2)); + fe.push_back (FE_Q(2)); + + hp::DoFHandler dof_handler (triangulation); + if (dof_handler.begin_active()->is_locally_owned()) + dof_handler.begin_active()->set_active_fe_index(0); + if ((++dof_handler.begin_active())->is_locally_owned()) + (++dof_handler.begin_active())->set_active_fe_index(1); + dof_handler.distribute_dofs (fe); + + deallog << "Processor: " << Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) + << std::endl; + for (auto cell : dof_handler.active_cell_iterators()) + { + deallog << " Cell: " << cell << std::endl; + + std::vector dof_indices (cell->get_fe().dofs_per_cell); + cell->get_dof_indices (dof_indices); + deallog << " "; + for (auto i : dof_indices) + deallog << i << ' '; + deallog << 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); + 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_unify_dof_indices_01.mpirun=1.output b/tests/mpi/hp_unify_dof_indices_01.mpirun=1.output new file mode 100644 index 0000000000..8de3c8fa4a --- /dev/null +++ b/tests/mpi/hp_unify_dof_indices_01.mpirun=1.output @@ -0,0 +1,11 @@ + +DEAL:2d::Processor: 0 +DEAL:2d:: Cell: 0.0 +DEAL:2d:: 0 1 2 3 4 5 6 7 8 +DEAL:2d:: Cell: 0.1 +DEAL:2d:: 1 9 3 10 5 11 12 13 14 +DEAL:3d::Processor: 0 +DEAL:3d:: Cell: 0.0 +DEAL:3d:: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 +DEAL:3d:: Cell: 0.1 +DEAL:3d:: 1 27 3 28 5 29 7 30 9 31 32 33 13 34 35 36 17 37 19 38 21 39 40 41 42 43 44 diff --git a/tests/mpi/hp_unify_dof_indices_01.mpirun=2.output b/tests/mpi/hp_unify_dof_indices_01.mpirun=2.output new file mode 100644 index 0000000000..621d745f8a --- /dev/null +++ b/tests/mpi/hp_unify_dof_indices_01.mpirun=2.output @@ -0,0 +1,11 @@ + +DEAL:2d::Processor: 0 +DEAL:2d:: Cell: 0.0 +DEAL:2d:: 0 1 2 3 4 5 6 7 8 +DEAL:2d:: Cell: 0.1 +DEAL:2d:: 9 10 11 12 13 14 15 16 17 +DEAL:3d::Processor: 0 +DEAL:3d:: Cell: 0.0 +DEAL:3d:: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 +DEAL:3d:: Cell: 0.1 +DEAL:3d:: 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 -- 2.39.5