From: Lei Qiao Date: Tue, 13 Oct 2015 16:22:31 +0000 (-0500) Subject: add test case grid/tria_signals_01 X-Git-Tag: v8.4.0-rc2~285^2~6 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed3875500d743b6c51b3e8a02412b031b91cd8b6;p=dealii.git add test case grid/tria_signals_01 --- diff --git a/tests/grid/tria_signals_01.cc b/tests/grid/tria_signals_01.cc new file mode 100644 index 0000000000..5d5482ed33 --- /dev/null +++ b/tests/grid/tria_signals_01.cc @@ -0,0 +1,199 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 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 signals of Triangulation class + +#include "../tests.h" +#include +#include + +int signal_counter_create = 0; +int signal_counter_pre_refinement = 0; +int signal_counter_post_refinement = 0; +int signal_counter_pre_coarsening_on_cell = 0; +int signal_counter_post_refinement_on_cell = 0; +int signal_counter_copy = 0; +int signal_counter_clear = 0; +int signal_counter_any_change = 0; + +void f_create () +{ + ++signal_counter_create; + return; +} + +void f_pre_refinement () +{ + ++signal_counter_pre_refinement; + return; +} + +void f_post_refinement () +{ + ++signal_counter_post_refinement; + return; +} + +template +void f_pre_coarsening_on_cell (const typename Triangulation::cell_iterator &) +{ + ++signal_counter_pre_coarsening_on_cell; + return; +} + +template +void f_post_refinement_on_cell (const typename Triangulation::cell_iterator &) +{ + ++signal_counter_post_refinement_on_cell; + return; +} + +template +void f_copy (const Triangulation &) +{ + ++signal_counter_copy; + return; +} + +void f_clear () +{ + ++signal_counter_clear; + return; +} + +void f_any_change () +{ + ++signal_counter_any_change; + return; +} + + +template +void test() +{ + signal_counter_create = 0; + signal_counter_pre_refinement = 0; + signal_counter_post_refinement = 0; + signal_counter_pre_coarsening_on_cell = 0; + signal_counter_post_refinement_on_cell = 0; + signal_counter_copy = 0; + signal_counter_clear = 0; + signal_counter_any_change = 0; + + { + const std::string title = Utilities::int_to_string (dim, 1) + + "d-" + + Utilities::int_to_string (spacedim, 1) + + "d"; + deallog.push(title.c_str()); + } + + Triangulation tria; + + tria.signals.create.connect (&f_create); + tria.signals.pre_refinement.connect (&f_pre_refinement); + tria.signals.post_refinement.connect (&f_post_refinement); + tria.signals.pre_coarsening_on_cell.connect (&f_pre_coarsening_on_cell); + tria.signals.post_refinement_on_cell.connect (&f_post_refinement_on_cell); + tria.signals.copy.connect (&f_copy); + tria.signals.clear.connect (&f_clear); + tria.signals.any_change.connect (&f_any_change); + + GridGenerator::hyper_cube(tria); + tria.refine_global(2); + + // Test signal on copying + { + Triangulation tria_cpoier; + tria_cpoier.copy_triangulation(tria); + } + + // Test signal on coarsening + { + typename Triangulation::active_cell_iterator + cell = tria.begin_active(); + const typename Triangulation::active_cell_iterator + endc = tria.end(); + for (; cell != endc; ++cell) + { + cell->set_coarsen_flag(); + } + tria.execute_coarsening_and_refinement(); + } + + tria.clear(); + + deallog << "n_signal_create : " << signal_counter_create << std::endl; + deallog << "n_signal_pre_refinement : " << signal_counter_pre_refinement << std::endl; + deallog << "n_signal_post_refinement : " << signal_counter_post_refinement << std::endl; + deallog << "n_signal_pre_coarsening_on_cell : " << signal_counter_pre_coarsening_on_cell << std::endl; + deallog << "n_signal_post_refinement_on_cell : " << signal_counter_post_refinement_on_cell << std::endl; + deallog << "n_signal_copy : " << signal_counter_copy << std::endl; + deallog << "n_signal_clear : " << signal_counter_clear << std::endl; + deallog << "n_signal_any_change : " << signal_counter_any_change << std::endl; + + deallog.pop(); + deallog << std::endl << std::endl; + + return; +} + +int main(int argc, char *argv[]) +{ + + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + { + const int dim = 1; + const int spacedim = 1; + test (); + } + + { + const int dim = 1; + const int spacedim = 2; + test (); + } + + { + const int dim = 1; + const int spacedim = 3; + test (); + } + + { + const int dim = 2; + const int spacedim = 2; + test (); + } + + { + const int dim = 2; + const int spacedim = 3; + test (); + } + + { + const int dim = 3; + const int spacedim = 3; + test (); + } + + return (0); +} diff --git a/tests/grid/tria_signals_01.output b/tests/grid/tria_signals_01.output new file mode 100644 index 0000000000..b7296255ae --- /dev/null +++ b/tests/grid/tria_signals_01.output @@ -0,0 +1,61 @@ + +DEAL:1d-1d::n_signal_create : 1 +DEAL:1d-1d::n_signal_pre_refinement : 3 +DEAL:1d-1d::n_signal_post_refinement : 3 +DEAL:1d-1d::n_signal_pre_coarsening_on_cell : 2 +DEAL:1d-1d::n_signal_post_refinement_on_cell : 3 +DEAL:1d-1d::n_signal_copy : 1 +DEAL:1d-1d::n_signal_clear : 1 +DEAL:1d-1d::n_signal_any_change : 5 +DEAL:: +DEAL:: +DEAL:1d-2d::n_signal_create : 1 +DEAL:1d-2d::n_signal_pre_refinement : 3 +DEAL:1d-2d::n_signal_post_refinement : 3 +DEAL:1d-2d::n_signal_pre_coarsening_on_cell : 2 +DEAL:1d-2d::n_signal_post_refinement_on_cell : 3 +DEAL:1d-2d::n_signal_copy : 1 +DEAL:1d-2d::n_signal_clear : 1 +DEAL:1d-2d::n_signal_any_change : 5 +DEAL:: +DEAL:: +DEAL:1d-3d::n_signal_create : 1 +DEAL:1d-3d::n_signal_pre_refinement : 3 +DEAL:1d-3d::n_signal_post_refinement : 3 +DEAL:1d-3d::n_signal_pre_coarsening_on_cell : 2 +DEAL:1d-3d::n_signal_post_refinement_on_cell : 3 +DEAL:1d-3d::n_signal_copy : 1 +DEAL:1d-3d::n_signal_clear : 1 +DEAL:1d-3d::n_signal_any_change : 5 +DEAL:: +DEAL:: +DEAL:2d-2d::n_signal_create : 1 +DEAL:2d-2d::n_signal_pre_refinement : 3 +DEAL:2d-2d::n_signal_post_refinement : 3 +DEAL:2d-2d::n_signal_pre_coarsening_on_cell : 4 +DEAL:2d-2d::n_signal_post_refinement_on_cell : 5 +DEAL:2d-2d::n_signal_copy : 1 +DEAL:2d-2d::n_signal_clear : 1 +DEAL:2d-2d::n_signal_any_change : 5 +DEAL:: +DEAL:: +DEAL:2d-3d::n_signal_create : 1 +DEAL:2d-3d::n_signal_pre_refinement : 3 +DEAL:2d-3d::n_signal_post_refinement : 3 +DEAL:2d-3d::n_signal_pre_coarsening_on_cell : 4 +DEAL:2d-3d::n_signal_post_refinement_on_cell : 5 +DEAL:2d-3d::n_signal_copy : 1 +DEAL:2d-3d::n_signal_clear : 1 +DEAL:2d-3d::n_signal_any_change : 5 +DEAL:: +DEAL:: +DEAL:3d-3d::n_signal_create : 1 +DEAL:3d-3d::n_signal_pre_refinement : 3 +DEAL:3d-3d::n_signal_post_refinement : 3 +DEAL:3d-3d::n_signal_pre_coarsening_on_cell : 8 +DEAL:3d-3d::n_signal_post_refinement_on_cell : 9 +DEAL:3d-3d::n_signal_copy : 1 +DEAL:3d-3d::n_signal_clear : 1 +DEAL:3d-3d::n_signal_any_change : 5 +DEAL:: +DEAL::