From: Wolfgang Bangerth Date: Fri, 10 Apr 2015 22:26:22 +0000 (-0500) Subject: Adapt a few existing tests to test the new active_cell_index() function. X-Git-Tag: v8.3.0-rc1~274^2~9 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7426b7826d458af92e758d620d36d6514625b9f;p=dealii.git Adapt a few existing tests to test the new active_cell_index() function. --- diff --git a/tests/bits/refine_and_coarsen_for_active_cell_index.cc b/tests/bits/refine_and_coarsen_for_active_cell_index.cc new file mode 100644 index 0000000000..0bb066d89d --- /dev/null +++ b/tests/bits/refine_and_coarsen_for_active_cell_index.cc @@ -0,0 +1,128 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2010 - 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. +// +// --------------------------------------------------------------------- + + + +// check that cell->active_cell_index() works as advertised + +#include "../tests.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + + +template +void check (const Triangulation &tria) +{ + unsigned int index = 0; + for (typename Triangulation::active_cell_iterator cell=tria.begin_active(); + cell!=tria.end(); ++cell, ++index) + Assert (cell->active_cell_index() == index, ExcInternalError()); +} + +void do_refine (Triangulation<1> &tria) +{ + const int dim = 1; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); +} + + +void do_refine (Triangulation<2> &tria) +{ + const int dim = 2; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); + tria.begin_active ()->set_refine_flag (RefinementPossibilities::cut_x); + tria.execute_coarsening_and_refinement (); + tria.begin_active ()->set_refine_flag (RefinementPossibilities::cut_y); + tria.execute_coarsening_and_refinement (); +} + + +void do_refine (Triangulation<3> &tria) +{ + const int dim = 3; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_x); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_y); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_z); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_xy); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_xz); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_yz); + tria.execute_coarsening_and_refinement (); +} + + +template +void check () +{ + Triangulation tria; + GridGenerator::hyper_cube (tria); + do_refine (tria); + // refine the mesh globally and + // verify that the parent relation + // holds + tria.refine_global (1); + + check (tria); + + // coarsen the mesh globally and + // verify again + for (typename Triangulation::active_cell_iterator cell = tria.begin_active (); + cell != tria.end (); ++cell) + cell->set_coarsen_flag (); + + tria.execute_coarsening_and_refinement (); + + check (tria); + + deallog << "OK for " << dim << "d" << std::endl; +} + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + check<1> (); + check<2> (); + check<3> (); +} + + + diff --git a/tests/bits/refine_and_coarsen_for_active_cell_index.output b/tests/bits/refine_and_coarsen_for_active_cell_index.output new file mode 100644 index 0000000000..292df5f812 --- /dev/null +++ b/tests/bits/refine_and_coarsen_for_active_cell_index.output @@ -0,0 +1,4 @@ + +DEAL::OK for 1d +DEAL::OK for 2d +DEAL::OK for 3d diff --git a/tests/bits/refine_and_coarsen_for_active_cell_index_02.cc b/tests/bits/refine_and_coarsen_for_active_cell_index_02.cc new file mode 100644 index 0000000000..91be163f3d --- /dev/null +++ b/tests/bits/refine_and_coarsen_for_active_cell_index_02.cc @@ -0,0 +1,132 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2010 - 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. +// +// --------------------------------------------------------------------- + + + +// check that cell->active_cell_index() works as advertised + +#include "../tests.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +template +void check (const Triangulation &tria) +{ + unsigned int index = 0; + for (typename Triangulation::active_cell_iterator cell=tria.begin_active(); + cell!=tria.end(); ++cell, ++index) + Assert (cell->active_cell_index() == index, ExcInternalError()); +} + + + +void do_refine (Triangulation<1> &tria) +{ + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); +} + + +void do_refine (Triangulation<2> &tria) +{ + const int dim = 2; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); + tria.begin_active ()->set_refine_flag (RefinementPossibilities::cut_x); + tria.execute_coarsening_and_refinement (); + tria.begin_active ()->set_refine_flag (RefinementPossibilities::cut_y); + tria.execute_coarsening_and_refinement (); +} + + +void do_refine (Triangulation<3> &tria) +{ + const int dim = 3; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_x); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_y); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_z); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_xy); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_xz); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_yz); + tria.execute_coarsening_and_refinement (); +} + + +template +void check () +{ + Triangulation tria; + GridGenerator::hyper_cube (tria); + do_refine (tria); + // refine the mesh globally and + // verify that the parent relation + // holds + tria.refine_global (1); + + DoFHandler dof_handler (tria); + + check (tria); + + // coarsen the mesh globally and + // verify again + for (typename Triangulation::active_cell_iterator cell = tria.begin_active (); + cell != tria.end (); ++cell) + cell->set_coarsen_flag (); + + tria.execute_coarsening_and_refinement (); + + check (tria); + + deallog << "OK for " << dim << "d" << std::endl; +} + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + check<1> (); + check<2> (); + check<3> (); +} + + + diff --git a/tests/bits/refine_and_coarsen_for_active_cell_index_02.output b/tests/bits/refine_and_coarsen_for_active_cell_index_02.output new file mode 100644 index 0000000000..292df5f812 --- /dev/null +++ b/tests/bits/refine_and_coarsen_for_active_cell_index_02.output @@ -0,0 +1,4 @@ + +DEAL::OK for 1d +DEAL::OK for 2d +DEAL::OK for 3d diff --git a/tests/bits/refine_and_coarsen_for_active_cell_index_03.cc b/tests/bits/refine_and_coarsen_for_active_cell_index_03.cc new file mode 100644 index 0000000000..28779bc067 --- /dev/null +++ b/tests/bits/refine_and_coarsen_for_active_cell_index_03.cc @@ -0,0 +1,131 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2010 - 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. +// +// --------------------------------------------------------------------- + + + +// check that cell->active_cell_index() works as advertised + +#include "../tests.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + + + +template +void check (const Triangulation &tria) +{ + unsigned int index = 0; + for (typename Triangulation::active_cell_iterator cell=tria.begin_active(); + cell!=tria.end(); ++cell, ++index) + Assert (cell->active_cell_index() == index, ExcInternalError()); +} + + + +void do_refine (Triangulation<1> &tria) +{ + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); +} + + +void do_refine (Triangulation<2> &tria) +{ + const int dim = 2; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); + tria.begin_active ()->set_refine_flag (RefinementPossibilities::cut_x); + tria.execute_coarsening_and_refinement (); + tria.begin_active ()->set_refine_flag (RefinementPossibilities::cut_y); + tria.execute_coarsening_and_refinement (); +} + + +void do_refine (Triangulation<3> &tria) +{ + const int dim = 3; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_x); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_y); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_z); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_xy); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_xz); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_yz); + tria.execute_coarsening_and_refinement (); +} + + +template +void check () +{ + Triangulation tria; + GridGenerator::hyper_cube (tria); + do_refine (tria); + // refine the mesh globally and + // verify that the parent relation + // holds + tria.refine_global (1); + + DoFHandler dof_handler (tria); + + check (tria); + + // coarsen the mesh globally and + // verify again + for (typename Triangulation::active_cell_iterator cell = tria.begin_active (); + cell != tria.end (); ++cell) + cell->set_coarsen_flag (); + + tria.execute_coarsening_and_refinement (); + + check (tria); + + deallog << "OK for " << dim << "d" << std::endl; +} + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + check<1> (); + check<2> (); + check<3> (); +} + + + diff --git a/tests/bits/refine_and_coarsen_for_active_cell_index_03.output b/tests/bits/refine_and_coarsen_for_active_cell_index_03.output new file mode 100644 index 0000000000..292df5f812 --- /dev/null +++ b/tests/bits/refine_and_coarsen_for_active_cell_index_03.output @@ -0,0 +1,4 @@ + +DEAL::OK for 1d +DEAL::OK for 2d +DEAL::OK for 3d