]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Split existing test into two: the original one, and a redux.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 18 Aug 2008 04:52:52 +0000 (04:52 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 18 Aug 2008 04:52:52 +0000 (04:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@16589 0785d39b-7218-0410-832d-ea1e28bc413d

tests/fail/mesh_smoothing_01.cc [moved from tests/fail/mesh_smoothing.cc with 95% similarity]
tests/fail/mesh_smoothing_01/cmp/generic [moved from tests/fail/mesh_smoothing/cmp/generic with 100% similarity]
tests/fail/mesh_smoothing_02.cc [new file with mode: 0644]
tests/fail/mesh_smoothing_02/cmp/generic [new file with mode: 0644]

similarity index 95%
rename from tests/fail/mesh_smoothing.cc
rename to tests/fail/mesh_smoothing_01.cc
index 28da334928ff068956d9e04b4fab207e44eb5d1c..420fe765e8bbf92cfd1f95cba97481644fcfe29d 100644 (file)
@@ -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 <iostream>
 #include <cstring>
 
-#include <fe/fe_q.h>
-#include <grid/grid_out.h>
-#include <dofs/dof_constraints.h>
-#include <grid/grid_refinement.h>
-#include <numerics/error_estimator.h>
-
-#include <complex>
 
                                 // Finally, this is as in previous
                                 // programs:
diff --git a/tests/fail/mesh_smoothing_02.cc b/tests/fail/mesh_smoothing_02.cc
new file mode 100644 (file)
index 0000000..175c570
--- /dev/null
@@ -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 <base/logstream.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.h>
+
+#include <fstream>
+#include <iostream>
+
+
+using namespace dealii;
+
+
+
+template <int dim>
+bool cell_is_patch_level_1 (const TriaIterator<dim, dealii::CellAccessor<dim> > &cell)
+{
+  Assert (cell->active() == false, ExcInternalError());
+
+  unsigned int n_active_children = 0;
+  for (unsigned int i=0; i<cell->n_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 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.