]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Tests for the parent relation.
authorMarkus Buerg <buerg@math.tamu.edu>
Thu, 26 Aug 2010 15:14:14 +0000 (15:14 +0000)
committerMarkus Buerg <buerg@math.tamu.edu>
Thu, 26 Aug 2010 15:14:14 +0000 (15:14 +0000)
git-svn-id: https://svn.dealii.org/trunk@21726 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
tests/bits/refine_and_coarsen_1d/cmp/generic
tests/bits/refine_and_coarsen_for_parents.cc [new file with mode: 0644]

index 6cf8dfa9fb91b44a111f79cc4b5be47ba54c5c06..f5b3bb9703120f41ea64afea9fa2d7e21a1dcd84 100644 (file)
@@ -44,6 +44,12 @@ through DoFHandler::get_tria() and DoFHandler::get_fe(), respectively.
 <h3>General</h3>
 
 <ol>
+  <li>
+  <p>New: Tests for the parent relations.
+  <br>
+  (Markus Buerg 2010/08/26)
+  </p>
+
   <li>
   <p>Fixed: When using Trilinos and deal.II both with static libraries,
   a linker error would occur whenever a program linked both the 2d and
index f3ec0fd88358c412affa2b685e84de755f9acaef..292df5f8127b0f90478aa5de55f7ca40623a554c 100644 (file)
@@ -1,3 +1,4 @@
 
-DEAL::5
-DEAL::5 5
+DEAL::OK for 1d
+DEAL::OK for 2d
+DEAL::OK for 3d
diff --git a/tests/bits/refine_and_coarsen_for_parents.cc b/tests/bits/refine_and_coarsen_for_parents.cc
new file mode 100644 (file)
index 0000000..2e5859b
--- /dev/null
@@ -0,0 +1,126 @@
+//----------------------------  refine_and_coarsen_3d.cc  ---------------------------
+//    $Id: refine_and_coarsen_3d.cc 15183 2007-09-10 01:10:03Z bangerth $
+//    Version: $Name$ 
+//
+//    Copyright (C) 2010 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.
+//
+//----------------------------  refine_and_coarsen_for_parents.cc  ---------------------------
+
+
+// check that, if we take an locally refined mesh, refine it globally once,
+// then coarsen it globally again, the parent relation holds
+
+#include "../tests.h"
+
+#include <base/geometry_info.h>
+#include <base/logstream.h>
+#include <base/quadrature_lib.h>
+#include <grid/tria.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.h>
+#include <grid/grid_generator.h>
+
+#include <fstream>
+
+
+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<dim>::cut_x);
+  tria.execute_coarsening_and_refinement ();
+  tria.begin_active ()->set_refine_flag (RefinementPossibilities<dim>::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<dim>::cut_x);
+  tria.execute_coarsening_and_refinement ();
+  tria.begin_active()->set_refine_flag(RefinementPossibilities<dim>::cut_y);
+  tria.execute_coarsening_and_refinement ();
+  tria.begin_active()->set_refine_flag(RefinementPossibilities<dim>::cut_z);
+  tria.execute_coarsening_and_refinement ();
+  tria.begin_active()->set_refine_flag(RefinementPossibilities<dim>::cut_xy);
+  tria.execute_coarsening_and_refinement ();
+  tria.begin_active()->set_refine_flag(RefinementPossibilities<dim>::cut_xz);
+  tria.execute_coarsening_and_refinement ();
+  tria.begin_active()->set_refine_flag(RefinementPossibilities<dim>::cut_yz);
+  tria.execute_coarsening_and_refinement ();
+}
+
+
+template <int dim>
+void check ()
+{
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube (tria);
+  do_refine (tria);
+                                  // refine the mesh globally and
+                                  // verify that the parent relation
+                                  // holds
+  tria.refine_global (1);
+
+  for (typename Triangulation<dim>::cell_iterator cell = tria.begin();
+       cell != tria.end (); ++cell)
+    for (unsigned int child = 0; child < cell->n_children (); ++child)
+      Assert (cell->child (child)->parent () == cell,
+              ExcInternalError ());
+  
+                                  // coarsen the mesh globally and
+                                  // verify that the parent relation
+                                  // holds
+  for (typename Triangulation<dim>::active_cell_iterator cell = tria.begin_active ();
+       cell != tria.end (); ++cell)
+    cell->set_coarsen_flag ();
+  
+  tria.execute_coarsening_and_refinement ();
+  
+  for (typename Triangulation<dim>::cell_iterator cell = tria.begin ();
+       cell != tria.end(); ++cell)
+    for (unsigned int child = 0; child < cell->n_children (); ++child)
+      Assert (cell->child (child)->parent () == cell,
+                 ExcInternalError());
+  
+  deallog << "OK for " << dim << "d" << std::endl;
+}
+
+
+int main () 
+{
+  std::ofstream logfile("refine_and_coarsen_for_parents/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  check<1> ();
+  check<2> ();
+  check<3> ();
+}
+
+  
+  

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.