]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test for the preceding bug fix.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 15 Jul 2009 04:25:26 +0000 (04:25 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 15 Jul 2009 04:25:26 +0000 (04:25 +0000)
git-svn-id: https://svn.dealii.org/trunk@19084 0785d39b-7218-0410-832d-ea1e28bc413d

tests/deal.II/Makefile
tests/deal.II/recursively_set_material_id.cc [new file with mode: 0644]
tests/deal.II/recursively_set_material_id/cmp/generic [new file with mode: 0644]

index 875c79bf958020164673b3a3aa7228e409c237ce..fb49128eee3f61f80616ba815cda33f7e88aceec 100644 (file)
@@ -82,7 +82,8 @@ tests_x = block_matrices \
        rt_covariant \
        coarsening_* \
        number_cache_* \
-       kelly_crash_*
+       kelly_crash_* \
+       recursively_set_material_id
 
 # from above list of regular expressions, generate the real set of
 # tests
diff --git a/tests/deal.II/recursively_set_material_id.cc b/tests/deal.II/recursively_set_material_id.cc
new file mode 100644 (file)
index 0000000..c0c26cd
--- /dev/null
@@ -0,0 +1,97 @@
+//----------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2007, 2008, 2009 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.
+//
+//----------------------------------------------------------------------
+
+
+// TriaAccessor::recursively_set_material_id had a bug in that it only
+// set the material_id for two of its children, not all
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.h>
+
+#include <fstream>
+#include <iomanip>
+
+
+
+template<int dim>
+void test()
+{
+  for (unsigned int t=0; t<2; ++t)
+    {
+      deallog << "dim=" << dim << ", test=" << t << std::endl;
+      
+      Triangulation<dim> tr;
+      if (dim > 1)
+       GridGenerator::hyper_ball(tr);
+      else
+       GridGenerator::hyper_cube(tr);
+
+      tr.refine_global(1);
+
+                                      // for test 1, refine a second
+                                      // time isotropically. for test
+                                      // 2, cut in only one direction
+      if (t==0)
+       tr.refine_global(1);
+      else
+       {
+         for (typename Triangulation<dim>::active_cell_iterator
+                cell = tr.begin_active(); cell != tr.end(); ++cell)
+           cell->set_refine_flag (RefinementCase<dim>::cut_x);
+         tr.execute_coarsening_and_refinement();
+       }
+
+      deallog << tr.n_active_cells() << std::endl;
+
+                                      // now call the function once
+                                      // for one of the cells on
+                                      // level 1
+      tr.begin(1)->recursively_set_material_id (1);
+
+                                      // and then count how many
+                                      // active cells inherited this
+                                      // flag
+      unsigned int n=0;
+      for (typename Triangulation<dim>::active_cell_iterator
+            cell = tr.begin_active(); cell != tr.end(); ++cell)
+       if (cell->material_id() == 1)
+         ++n;
+      
+      deallog << n << std::endl;
+
+      if (t==0)
+       Assert (n == GeometryInfo<dim>::max_children_per_cell,
+               ExcInternalError())
+      else
+       Assert (n == 2,
+               ExcInternalError());
+    }
+}
+
+
+int main()
+{
+  std::ofstream logfile ("recursively_set_material_id/output");
+  deallog << std::setprecision (2);
+
+  deallog.attach(logfile);
+  deallog.depth_console (0);
+  deallog.threshold_double(1.e-12);
+
+  test<1>();
+  test<2>();
+  test<3>();
+}
diff --git a/tests/deal.II/recursively_set_material_id/cmp/generic b/tests/deal.II/recursively_set_material_id/cmp/generic
new file mode 100644 (file)
index 0000000..283148b
--- /dev/null
@@ -0,0 +1,19 @@
+
+DEAL::dim=1, test=0
+DEAL::4
+DEAL::2
+DEAL::dim=1, test=1
+DEAL::4
+DEAL::2
+DEAL::dim=2, test=0
+DEAL::80
+DEAL::4
+DEAL::dim=2, test=1
+DEAL::40
+DEAL::2
+DEAL::dim=3, test=0
+DEAL::448
+DEAL::8
+DEAL::dim=3, test=1
+DEAL::168
+DEAL::2

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.