From a279d0d7ccb68cccef3504eef1ad77fc9928993d Mon Sep 17 00:00:00 2001 From: heister Date: Wed, 24 Aug 2011 20:35:09 +0000 Subject: [PATCH] add failing test for DoFRenumbering::hierarchical() git-svn-id: https://svn.dealii.org/trunk@24186 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/renumber_z_order_02.cc | 155 ++++++++++++++++++ .../renumber_z_order_02/ncpu_1/cmp/generic | 3 + .../renumber_z_order_02/ncpu_10/cmp/generic | 3 + .../renumber_z_order_02/ncpu_4/cmp/generic | 3 + 4 files changed, 164 insertions(+) create mode 100644 tests/mpi/renumber_z_order_02.cc create mode 100644 tests/mpi/renumber_z_order_02/ncpu_1/cmp/generic create mode 100644 tests/mpi/renumber_z_order_02/ncpu_10/cmp/generic create mode 100644 tests/mpi/renumber_z_order_02/ncpu_4/cmp/generic diff --git a/tests/mpi/renumber_z_order_02.cc b/tests/mpi/renumber_z_order_02.cc new file mode 100644 index 0000000000..d4244667ae --- /dev/null +++ b/tests/mpi/renumber_z_order_02.cc @@ -0,0 +1,155 @@ +//--------------------------------------------------------------------------- +// $Id: p4est_2d_dofhandler_01.cc 23710 2011-05-17 04:50:10Z bangerth $ +// Version: $Name$ +// +// Copyright (C) 2009, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +// Test that DofRenumbering::hierarchical() gives the same DoFs independent of +// the number of processors. We do this by constructing a vector where each +// element depends on the location and the index. We output the l2_norm() of +// that vector and hope the output is that same. + + +#include "../tests.h" +#include "coarse_grid_common.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +void test() +{ + unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD); + + parallel::distributed::Triangulation tr (MPI_COMM_WORLD); + + GridGenerator::hyper_shell (tr, + Point(), + 0.3, + 1.0, + 12, true); +// GridGenerator::hyper_cube (tr, -1.0, 1.0); + tr.refine_global (1); + + for (typename Triangulation::active_cell_iterator + cell = tr.begin_active(); + cell != tr.end(); ++cell) + if (!cell->is_ghost() && !cell->is_artificial()) + if (cell->center()[0] < 0.0) + { + cell->set_refine_flag(); + } + + tr.execute_coarsening_and_refinement (); + + DoFHandler dofh (tr); + + static const FE_Q fe (1); + dofh.distribute_dofs (fe); + DoFRenumbering::hierarchical (dofh); + + if (myid == 0) + deallog << "n_global_active_cells: " << tr.n_global_active_cells() << std::endl; + + TrilinosWrappers::MPI::Vector vector; + vector.reinit (dofh.locally_owned_dofs(), MPI_COMM_WORLD); + { + ConstraintMatrix cm; + cm.close(); + QGauss quadrature_formula (2); + FEValues fe_values (fe, quadrature_formula, update_quadrature_points | + update_JxW_values | update_values); + const unsigned int dofs_per_cell = fe.dofs_per_cell; + std::vector local_dof_indices (dofs_per_cell); + Vector local_vector (dofs_per_cell); + const unsigned int n_q_points = quadrature_formula.size(); + + typename DoFHandler::active_cell_iterator + cell = dofh.begin_active(), + endc = dofh.end(); + for (; cell != endc; ++cell) + if (cell->subdomain_id() == tr.locally_owned_subdomain()) + { + fe_values.reinit (cell); + cell->get_dof_indices (local_dof_indices); + local_vector = 0; + + for (unsigned int q = 0; q < n_q_points; ++q) + { + for (unsigned int i = 0; i < dofs_per_cell; ++i) + { + local_vector (i) += fe_values.shape_value (i, q) * + 1.0 * local_dof_indices[i] * + (fe_values.quadrature_point (q) [0] + + fe_values.quadrature_point (q).square()) + * fe_values.JxW (q); + } + } + cm.distribute_local_to_global (local_vector, local_dof_indices, vector); + } + vector.compress(); + } + double norm = vector.l2_norm(); + if (myid == 0) + deallog << "Norm: " << norm << std::endl; +} + + +int main (int argc, char *argv[]) +{ +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + MPI_Init (&argc, &argv); +#else + (void) argc; + (void) argv; +#endif + + unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD); + + + deallog.push (Utilities::int_to_string (myid)); + + if (myid == 0) + { + std::ofstream logfile (output_file_for_mpi ("renumber_z_order_02").c_str()); + deallog.attach (logfile); + deallog.depth_console (0); + deallog.threshold_double (1.e-10); + + deallog.push ("2d"); + test<2>(); + deallog.pop(); + } + else + test<2>(); + +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + MPI_Finalize(); +#endif +} diff --git a/tests/mpi/renumber_z_order_02/ncpu_1/cmp/generic b/tests/mpi/renumber_z_order_02/ncpu_1/cmp/generic new file mode 100644 index 0000000000..dae0f36972 --- /dev/null +++ b/tests/mpi/renumber_z_order_02/ncpu_1/cmp/generic @@ -0,0 +1,3 @@ + +DEAL:0:2d::n_global_active_cells: 76 +DEAL:0:2d::Norm: 27.5617 diff --git a/tests/mpi/renumber_z_order_02/ncpu_10/cmp/generic b/tests/mpi/renumber_z_order_02/ncpu_10/cmp/generic new file mode 100644 index 0000000000..dae0f36972 --- /dev/null +++ b/tests/mpi/renumber_z_order_02/ncpu_10/cmp/generic @@ -0,0 +1,3 @@ + +DEAL:0:2d::n_global_active_cells: 76 +DEAL:0:2d::Norm: 27.5617 diff --git a/tests/mpi/renumber_z_order_02/ncpu_4/cmp/generic b/tests/mpi/renumber_z_order_02/ncpu_4/cmp/generic new file mode 100644 index 0000000000..dae0f36972 --- /dev/null +++ b/tests/mpi/renumber_z_order_02/ncpu_4/cmp/generic @@ -0,0 +1,3 @@ + +DEAL:0:2d::n_global_active_cells: 76 +DEAL:0:2d::Norm: 27.5617 -- 2.39.5