From 7e4f513884d4396be932a353650bfc9f4d494efc Mon Sep 17 00:00:00 2001 From: bangerth Date: Sat, 9 Mar 2013 12:46:30 +0000 Subject: [PATCH] New test. git-svn-id: https://svn.dealii.org/trunk@28838 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/refinement_listener_01.cc | 113 ++++++++++++++++++ .../ncpu_10/cmp/generic | 7 ++ .../ncpu_20/cmp/generic | 7 ++ .../refinement_listener_01/ncpu_4/cmp/generic | 7 ++ 4 files changed, 134 insertions(+) create mode 100644 tests/mpi/refinement_listener_01.cc create mode 100644 tests/mpi/refinement_listener_01/ncpu_10/cmp/generic create mode 100644 tests/mpi/refinement_listener_01/ncpu_20/cmp/generic create mode 100644 tests/mpi/refinement_listener_01/ncpu_4/cmp/generic diff --git a/tests/mpi/refinement_listener_01.cc b/tests/mpi/refinement_listener_01.cc new file mode 100644 index 0000000000..38cc730408 --- /dev/null +++ b/tests/mpi/refinement_listener_01.cc @@ -0,0 +1,113 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2009, 2010, 2013 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 mesh and attach a function to the signal that is triggered +// whenever we refine the mesh. count how often it is called on each +// processor. (note: this is more than once per refinement cycle because we +// have to re-balance and rebuild the mesh.) + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + +int counter = 0; +void listener () +{ + ++counter; +} + + +void test() +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + + parallel::distributed::Triangulation<2> tr(MPI_COMM_WORLD); + GridGenerator::hyper_cube(tr); + tr.signals.post_refinement.connect (&listener); + + // try some global refinement + counter = 0; + tr.refine_global (1); + if (myid == 0) + deallog << "refine_global(1) results in a total of " << counter + << std::endl; + + counter = 0; + tr.refine_global (3); + if (myid == 0) + deallog << "refine_global(3) results in a total of " << counter + << std::endl; + + + // now also find the bottom left corner of the domain and, on the processor + // that owns this cell, refine it 4 times + for (unsigned int i=0; i<4; ++i) + { + counter = 0; + Triangulation<2>::cell_iterator cell = tr.begin(0); + while (cell->has_children()) + cell = cell->child(0); + if (cell->is_locally_owned()) + cell->set_refine_flag(); + tr.execute_coarsening_and_refinement (); + if (myid == 0) + deallog << "local refinement results in a total of " << counter + << 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::MPI::this_mpi_process (MPI_COMM_WORLD); + + + deallog.push(Utilities::int_to_string(myid)); + + if (myid == 0) + { + std::ofstream logfile(output_file_for_mpi("refinement_listener_01").c_str()); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test(); + } + else + test(); + + +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + MPI_Finalize(); +#endif +} diff --git a/tests/mpi/refinement_listener_01/ncpu_10/cmp/generic b/tests/mpi/refinement_listener_01/ncpu_10/cmp/generic new file mode 100644 index 0000000000..6bba3c5970 --- /dev/null +++ b/tests/mpi/refinement_listener_01/ncpu_10/cmp/generic @@ -0,0 +1,7 @@ + +DEAL:0::refine_global(1) results in a total of 1 +DEAL:0::refine_global(3) results in a total of 7 +DEAL:0::local refinement results in a total of 2 +DEAL:0::local refinement results in a total of 2 +DEAL:0::local refinement results in a total of 2 +DEAL:0::local refinement results in a total of 2 diff --git a/tests/mpi/refinement_listener_01/ncpu_20/cmp/generic b/tests/mpi/refinement_listener_01/ncpu_20/cmp/generic new file mode 100644 index 0000000000..6bba3c5970 --- /dev/null +++ b/tests/mpi/refinement_listener_01/ncpu_20/cmp/generic @@ -0,0 +1,7 @@ + +DEAL:0::refine_global(1) results in a total of 1 +DEAL:0::refine_global(3) results in a total of 7 +DEAL:0::local refinement results in a total of 2 +DEAL:0::local refinement results in a total of 2 +DEAL:0::local refinement results in a total of 2 +DEAL:0::local refinement results in a total of 2 diff --git a/tests/mpi/refinement_listener_01/ncpu_4/cmp/generic b/tests/mpi/refinement_listener_01/ncpu_4/cmp/generic new file mode 100644 index 0000000000..76a26b7779 --- /dev/null +++ b/tests/mpi/refinement_listener_01/ncpu_4/cmp/generic @@ -0,0 +1,7 @@ + +DEAL:0::refine_global(1) results in a total of 2 +DEAL:0::refine_global(3) results in a total of 6 +DEAL:0::local refinement results in a total of 2 +DEAL:0::local refinement results in a total of 2 +DEAL:0::local refinement results in a total of 2 +DEAL:0::local refinement results in a total of 2 -- 2.39.5