From 92cd33626406fde6e91dcd46a5a84af6687020a2 Mon Sep 17 00:00:00 2001 From: Alexander Grayver Date: Mon, 6 Nov 2017 17:00:46 +0100 Subject: [PATCH] Fix erroneous assert --- source/dofs/dof_handler.cc | 16 +++++- tests/mpi/subdomain_ids_parallel_08.cc | 52 +++++++++++++++++++ .../subdomain_ids_parallel_08.mpirun=2.output | 3 ++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 tests/mpi/subdomain_ids_parallel_08.cc create mode 100644 tests/mpi/subdomain_ids_parallel_08.mpirun=2.output diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index eba12ba457..0b455016fa 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -1104,9 +1104,21 @@ DoFHandler::renumber_dofs (const std::vector0, ExcMessage("You need to distribute DoFs before you can renumber them.")); - AssertDimension (new_numbers.size(), n_locally_owned_dofs()); - #ifdef DEBUG + if (dynamic_cast*> (&*tria) != nullptr) + { + Assert(new_numbers.size() == n_dofs() || new_numbers.size() == n_locally_owned_dofs(), + ExcMessage("Incorrect size of the input array.")); + } + else if (dynamic_cast*> (&*tria) != nullptr) + { + AssertDimension (new_numbers.size(), n_locally_owned_dofs()); + } + else + { + AssertDimension (new_numbers.size(), n_dofs()); + } + // assert that the new indices are // consecutively numbered if we are // working on a single diff --git a/tests/mpi/subdomain_ids_parallel_08.cc b/tests/mpi/subdomain_ids_parallel_08.cc new file mode 100644 index 0000000000..ffcdec162d --- /dev/null +++ b/tests/mpi/subdomain_ids_parallel_08.cc @@ -0,0 +1,52 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 - 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. +// +// --------------------------------------------------------------------- + +// test DoFRenumbering::subdomain_wise with parallel::shared::Triangulation + +#include "../tests.h" + +// all include files you need here +#include +#include +#include +#include +#include + +template +void test() +{ + parallel::shared::Triangulation tria(MPI_COMM_WORLD); + GridGenerator::hyper_cube(tria); + tria.refine_global(3); + + FE_Q fe(1); + DoFHandler dof_handler(tria); + dof_handler.distribute_dofs(fe); + DoFRenumbering::subdomain_wise(dof_handler); + + if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0) + deallog << "OK for " << dim << "d" << std::endl; +} + +int main (int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1); + MPILogInitAll log; + + test<2>(); + test<3>(); + + return 0; +} diff --git a/tests/mpi/subdomain_ids_parallel_08.mpirun=2.output b/tests/mpi/subdomain_ids_parallel_08.mpirun=2.output new file mode 100644 index 0000000000..5637e3faa0 --- /dev/null +++ b/tests/mpi/subdomain_ids_parallel_08.mpirun=2.output @@ -0,0 +1,3 @@ +DEAL:0::OK for 2d +DEAL:0::OK for 3d + -- 2.39.5