From: Wolfgang Bangerth Date: Sun, 31 Dec 2017 23:33:21 +0000 (-0700) Subject: Add a test. X-Git-Tag: v9.0.0-rc1~589^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30dc99b6fc907d9566a858943c265f31f895d588;p=dealii.git Add a test. --- diff --git a/tests/mpi/renumber_z_order_04.cc b/tests/mpi/renumber_z_order_04.cc new file mode 100644 index 0000000000..cda7fcd7f8 --- /dev/null +++ b/tests/mpi/renumber_z_order_04.cc @@ -0,0 +1,106 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + + + +// Test that DofRenumbering::hierarchical() gives the same DoF numbers +// independent of their previous ordering. This was broken before where +// the hierarchical numbering on each processor re-used the indices +// the processor previously owned. This worked just fine with the +// original ordering used by default by DoFHandler, but not if there +// was another reordering step in between + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +void test() +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + + parallel::distributed::Triangulation<2> tr (MPI_COMM_WORLD); + GridGenerator::subdivided_hyper_rectangle (tr, std::vector {{2,2}}, Point<2>(), Point<2>(2,2)); + + const FE_Q<2> fe (1); + + for (unsigned int test=0; test<2; ++test) + { + DoFHandler<2> dof_handler (tr); + dof_handler.distribute_dofs (fe); + + // in the second test run, revert the global order of DoF + // indices. the point is to make sure that processors do not + // have strictly increasing, contiguous groups of DoF indices. + if (test==1) + { + IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs (); + std::vector new_numbers (locally_owned_dofs.n_elements()); + for (auto i : locally_owned_dofs) + new_numbers[locally_owned_dofs.index_within_set(i)] + = dof_handler.n_dofs() - i - 1; + dof_handler.renumber_dofs (new_numbers); + } + + // next, let the hierarchical numbering work on it. the + // important aspect is that the result of hierarchical + // renumbering should not depend on the *previous* numbering. so + // we should be getting the same output as in the first run + DoFRenumbering::hierarchical (dof_handler); + + // output DoF indices + deallog << (test == 0 ? "Without " : "With ") << "prior reordering:" << std::endl; + const unsigned int dofs_per_cell = fe.dofs_per_cell; + std::vector local_dof_indices (dofs_per_cell); + DoFHandler<2>::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + for (; cell != endc; ++cell) + if (cell->subdomain_id() == tr.locally_owned_subdomain()) + { + deallog << "Cell=" << cell << std::endl; + cell->get_dof_indices (local_dof_indices); + for (auto i : local_dof_indices) + deallog << i << ' '; + deallog << 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/renumber_z_order_04.with_p4est=true.mpirun=4.output b/tests/mpi/renumber_z_order_04.with_p4est=true.mpirun=4.output new file mode 100644 index 0000000000..e917cb3595 --- /dev/null +++ b/tests/mpi/renumber_z_order_04.with_p4est=true.mpirun=4.output @@ -0,0 +1,31 @@ + +DEAL:0::Without prior reordering: +DEAL:0::Cell=0.0 +DEAL:0::0 1 2 3 +DEAL:0::With prior reordering: +DEAL:0::Cell=0.0 +DEAL:0::0 1 2 3 + +DEAL:1::Without prior reordering: +DEAL:1::Cell=0.1 +DEAL:1::1 4 3 5 +DEAL:1::With prior reordering: +DEAL:1::Cell=0.1 +DEAL:1::1 4 3 5 + + +DEAL:2::Without prior reordering: +DEAL:2::Cell=0.2 +DEAL:2::2 3 6 7 +DEAL:2::With prior reordering: +DEAL:2::Cell=0.2 +DEAL:2::2 3 6 7 + + +DEAL:3::Without prior reordering: +DEAL:3::Cell=0.3 +DEAL:3::3 5 7 8 +DEAL:3::With prior reordering: +DEAL:3::Cell=0.3 +DEAL:3::3 5 7 8 +