From 1423ec5f0fa93a59148dbbd484794de31c0c8509 Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 18 Aug 2008 04:52:52 +0000 Subject: [PATCH] Split existing test into two: the original one, and a redux. git-svn-id: https://svn.dealii.org/trunk@16589 0785d39b-7218-0410-832d-ea1e28bc413d --- ...mesh_smoothing.cc => mesh_smoothing_01.cc} | 16 +- .../cmp/generic | 0 tests/fail/mesh_smoothing_02.cc | 146 ++++++++++++++++++ tests/fail/mesh_smoothing_02/cmp/generic | 1 + 4 files changed, 153 insertions(+), 10 deletions(-) rename tests/fail/{mesh_smoothing.cc => mesh_smoothing_01.cc} (95%) rename tests/fail/{mesh_smoothing => mesh_smoothing_01}/cmp/generic (100%) create mode 100644 tests/fail/mesh_smoothing_02.cc create mode 100644 tests/fail/mesh_smoothing_02/cmp/generic diff --git a/tests/fail/mesh_smoothing.cc b/tests/fail/mesh_smoothing_01.cc similarity index 95% rename from tests/fail/mesh_smoothing.cc rename to tests/fail/mesh_smoothing_01.cc index 28da334928..420fe765e8 100644 --- a/tests/fail/mesh_smoothing.cc +++ b/tests/fail/mesh_smoothing_01.cc @@ -1,4 +1,4 @@ -//---------------------------- mesh_smoothing.cc --------------------------- +//---------------------------- mesh_smoothing_01.cc --------------------------- // $Id$ // Version: $Name$ // @@ -9,13 +9,16 @@ // to the file deal.II/doc/license.html for the text and // further information on this license. // -//---------------------------- mesh_smoothing.cc --------------------------- +//---------------------------- mesh_smoothing_01.cc --------------------------- // something went wrong with smoothing a mesh when a particular set of // cells were set to be refined. found in step-31 +// +// a redux is in mesh_smoothing_02 + -char logname[] = "mesh_smoothing/output"; +char logname[] = "mesh_smoothing_01/output"; #include "../tests.h" @@ -31,13 +34,6 @@ char logname[] = "mesh_smoothing/output"; #include #include -#include -#include -#include -#include -#include - -#include // Finally, this is as in previous // programs: diff --git a/tests/fail/mesh_smoothing/cmp/generic b/tests/fail/mesh_smoothing_01/cmp/generic similarity index 100% rename from tests/fail/mesh_smoothing/cmp/generic rename to tests/fail/mesh_smoothing_01/cmp/generic diff --git a/tests/fail/mesh_smoothing_02.cc b/tests/fail/mesh_smoothing_02.cc new file mode 100644 index 0000000000..175c570e38 --- /dev/null +++ b/tests/fail/mesh_smoothing_02.cc @@ -0,0 +1,146 @@ +//---------------------------- mesh_smoothing_02.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006, 2007, 2008 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. +// +//---------------------------- mesh_smoothing_02.cc --------------------------- + + +// a redux of mesh_smoothing_01: when we have patch_level_1 set, and if we +// have a mesh like this: +// +// *-*-*-*-*---*---* +// *-*-*-*-* | | +// *-*-*-*-*---*---* +// *-*-*-*-* * | +// *-*-*-*-*---*---* +// | | | | | +// *---*---*---*---* +// | | | | | +// *---*---*---*---* +// +// Note that this is a patch-level-1 mesh. Now, if we set coarsen flags on all +// cells, then the result is no longer a patch-level-1 +// mesh. Triangulation::prepare_coarsen_and_refinement didn't see this coming, +// and we violate the invariant that we hit again the next time we call this +// function + + +char logname[] = "mesh_smoothing_02/output"; + + +#include "../tests.h" + + +#include +#include +#include +#include +#include + +#include +#include + + +using namespace dealii; + + + +template +bool cell_is_patch_level_1 (const TriaIterator > &cell) +{ + Assert (cell->active() == false, ExcInternalError()); + + unsigned int n_active_children = 0; + for (unsigned int i=0; in_children(); ++i) + if (cell->child(i)->active()) + ++n_active_children; + + return (n_active_children == 0) || (n_active_children == cell->n_children()); +} + + +void test () +{ + Triangulation<2> triangulation (Triangulation<2>::maximum_smoothing); + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (2); + + // refine the offspring of one of the cells + // on level 1 + for (unsigned int i=0; i<4; ++i) + triangulation.begin(1)->child(i)->set_refine_flag (); + triangulation.execute_coarsening_and_refinement (); + + // now flag everything for coarsening + // again + for (Triangulation<2>::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) + cell->set_coarsen_flag (); + triangulation.execute_coarsening_and_refinement (); + + + for (Triangulation<2>::cell_iterator + cell = triangulation.begin(); + cell != triangulation.end(); ++cell) + { + Assert ((cell->refine_flag_set() == false) + && + (cell->coarsen_flag_set() == false), + ExcInternalError()); + if (!cell->active()) + Assert (cell_is_patch_level_1(cell), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile(logname); + logfile.precision (3); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + try + { + test(); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + } + + return 0; +} diff --git a/tests/fail/mesh_smoothing_02/cmp/generic b/tests/fail/mesh_smoothing_02/cmp/generic new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/tests/fail/mesh_smoothing_02/cmp/generic @@ -0,0 +1 @@ + -- 2.39.5