From: bangerth Date: Sat, 9 Mar 2013 12:59:18 +0000 (+0000) Subject: Add. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f838b9937858e828ea3111a4e908ea0c75db96f9;p=dealii-svn.git Add. git-svn-id: https://svn.dealii.org/trunk@28839 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/mpi/refinement_listener_02.cc b/tests/mpi/refinement_listener_02.cc new file mode 100644 index 0000000000..250c48df1e --- /dev/null +++ b/tests/mpi/refinement_listener_02.cc @@ -0,0 +1,116 @@ +//--------------------------------------------------------------------------- +// $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, + Triangulation<2>::MeshSmoothing(), + parallel::distributed::Triangulation<2>::mesh_reconstruction_after_repartitioning); + 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_02/ncpu_10/cmp/generic b/tests/mpi/refinement_listener_02/ncpu_10/cmp/generic new file mode 100644 index 0000000000..6bba3c5970 --- /dev/null +++ b/tests/mpi/refinement_listener_02/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_02/ncpu_20/cmp/generic b/tests/mpi/refinement_listener_02/ncpu_20/cmp/generic new file mode 100644 index 0000000000..6bba3c5970 --- /dev/null +++ b/tests/mpi/refinement_listener_02/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_02/ncpu_4/cmp/generic b/tests/mpi/refinement_listener_02/ncpu_4/cmp/generic new file mode 100644 index 0000000000..76a26b7779 --- /dev/null +++ b/tests/mpi/refinement_listener_02/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