From 663b6fc5722d982a975b27ac978af80bda6d08c2 Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 22 Aug 2011 15:37:53 +0000 Subject: [PATCH] New test. git-svn-id: https://svn.dealii.org/trunk@24166 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/p4est_3d_refine_04.cc | 146 ++++++++++++++++++ .../mpi/p4est_3d_refine_04/ncpu_1/cmp/generic | 4 + .../p4est_3d_refine_04/ncpu_10/cmp/generic | 4 + .../p4est_3d_refine_04/ncpu_24/cmp/generic | 4 + .../mpi/p4est_3d_refine_04/ncpu_4/cmp/generic | 4 + 5 files changed, 162 insertions(+) create mode 100644 tests/mpi/p4est_3d_refine_04.cc create mode 100644 tests/mpi/p4est_3d_refine_04/ncpu_1/cmp/generic create mode 100644 tests/mpi/p4est_3d_refine_04/ncpu_10/cmp/generic create mode 100644 tests/mpi/p4est_3d_refine_04/ncpu_24/cmp/generic create mode 100644 tests/mpi/p4est_3d_refine_04/ncpu_4/cmp/generic diff --git a/tests/mpi/p4est_3d_refine_04.cc b/tests/mpi/p4est_3d_refine_04.cc new file mode 100644 index 0000000000..e5e63c1e69 --- /dev/null +++ b/tests/mpi/p4est_3d_refine_04.cc @@ -0,0 +1,146 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2009, 2010, 2011 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. +// +//--------------------------------------------------------------------------- + + +// create a relatively simple 3d mesh and refine a few cells. this +// should produce the same output regardless of the number of +// processors +// +// this test is extracted from step-32 while searching for some +// apparently rather subtle and indeed pretty frustrating bug... + +#include "../tests.h" +#include "coarse_grid_common.h" +#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); + + if (true) + { + parallel::distributed::Triangulation + triangulation(MPI_COMM_WORLD); + + // create a mesh for the + // hypershell and refine it + // twice globally + const double R0 = 6371000.-2890000.; + const double R1 = 6371000.- 35000.; + GridGenerator::hyper_shell (triangulation, + Point(), + R0, + R1, + (dim==3) ? 96 : 12, + true); + triangulation.refine_global (2); + + // then flag all cells for + // refinement that are close to + // the north pole + unsigned int x_flagged_cells = 0; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) + if (!cell->is_ghost() && !cell->is_artificial()) + if (cell->center()[2] > R1*0.75) + { + ++x_flagged_cells; + cell->set_refine_flag(); + } + + // count how many cells + // actually have the refinement + // flag after preparing for + // refinement, and ensure that + // this number is still the + // same as before + triangulation.prepare_coarsening_and_refinement (); + { + unsigned int n_flagged_cells = 0; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) + if (!cell->is_ghost() && !cell->is_artificial()) + if (cell->refine_flag_set()) + ++n_flagged_cells; + + Assert (n_flagged_cells == x_flagged_cells, + ExcInternalError()); + + unsigned int global_f_c = 0; + MPI_Allreduce (&n_flagged_cells, &global_f_c, 1, MPI_UNSIGNED, + MPI_SUM, MPI_COMM_WORLD); + + if (myid == 0) + deallog << "# flagged cells = " << global_f_c << std::endl; + } + + triangulation.execute_coarsening_and_refinement (); + + if (myid == 0) + deallog << "#cells = " << triangulation.n_global_active_cells() + << std::endl; + } + + if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0) + deallog << "OK" << 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("p4est_3d_refine_04").c_str()); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog.push("3d"); + test<3>(); + deallog.pop(); + } + else + test<3>(); + + +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + MPI_Finalize(); +#endif +} diff --git a/tests/mpi/p4est_3d_refine_04/ncpu_1/cmp/generic b/tests/mpi/p4est_3d_refine_04/ncpu_1/cmp/generic new file mode 100644 index 0000000000..855fb18655 --- /dev/null +++ b/tests/mpi/p4est_3d_refine_04/ncpu_1/cmp/generic @@ -0,0 +1,4 @@ + +DEAL:0:3d::# flagged cells = 120 +DEAL:0:3d::#cells = 6984 +DEAL:0:3d::OK diff --git a/tests/mpi/p4est_3d_refine_04/ncpu_10/cmp/generic b/tests/mpi/p4est_3d_refine_04/ncpu_10/cmp/generic new file mode 100644 index 0000000000..855fb18655 --- /dev/null +++ b/tests/mpi/p4est_3d_refine_04/ncpu_10/cmp/generic @@ -0,0 +1,4 @@ + +DEAL:0:3d::# flagged cells = 120 +DEAL:0:3d::#cells = 6984 +DEAL:0:3d::OK diff --git a/tests/mpi/p4est_3d_refine_04/ncpu_24/cmp/generic b/tests/mpi/p4est_3d_refine_04/ncpu_24/cmp/generic new file mode 100644 index 0000000000..855fb18655 --- /dev/null +++ b/tests/mpi/p4est_3d_refine_04/ncpu_24/cmp/generic @@ -0,0 +1,4 @@ + +DEAL:0:3d::# flagged cells = 120 +DEAL:0:3d::#cells = 6984 +DEAL:0:3d::OK diff --git a/tests/mpi/p4est_3d_refine_04/ncpu_4/cmp/generic b/tests/mpi/p4est_3d_refine_04/ncpu_4/cmp/generic new file mode 100644 index 0000000000..855fb18655 --- /dev/null +++ b/tests/mpi/p4est_3d_refine_04/ncpu_4/cmp/generic @@ -0,0 +1,4 @@ + +DEAL:0:3d::# flagged cells = 120 +DEAL:0:3d::#cells = 6984 +DEAL:0:3d::OK -- 2.39.5