]> https://gitweb.dealii.org/ - dealii.git/commitdiff
throw exception if p4est maximum refinement level is reached
authorTimo Heister <timo.heister@gmail.com>
Thu, 2 May 2013 01:12:05 +0000 (01:12 +0000)
committerTimo Heister <timo.heister@gmail.com>
Thu, 2 May 2013 01:12:05 +0000 (01:12 +0000)
git-svn-id: https://svn.dealii.org/trunk@29423 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/source/distributed/tria.cc

index 9136c2375149f4a8a234330bd29d5a9ec4a40b91..415883084e18cc12284ea440d10ff6f3dca82ef6 100644 (file)
@@ -111,6 +111,12 @@ this function.
 
 <ol>
 
+<li> Fixed: Generate an error if the users tries to refine a cell
+that is already on the maximum level in a distributed triangulation.
+<br>
+(Timo Heister, 2013/05/01)
+</li>
+
 <li> Fixed: The version of ParameterHandler::set that takes a boolean
 as second argument was broken and did not work. This is now fixed.
 <br>
index ebc48f14838a61ece8d9f6e10e7a066f07d251d5..f8052d1a2cb7759dcf7d64b2f5207b4b323fbacd 100644 (file)
@@ -197,6 +197,8 @@ namespace internal
 
       static
       size_t (&connectivity_memory_used) (types<2>::connectivity *p4est);
+
+      static const unsigned max_level;
     };
 
     int (&functions<2>::quadrant_compare) (const void *v1, const void *v2)
@@ -327,6 +329,7 @@ namespace internal
     size_t (&functions<2>::connectivity_memory_used) (types<2>::connectivity *p4est)
       = p4est_connectivity_memory_used;
 
+    const unsigned int functions<2>::max_level = P4EST_MAXLEVEL;
 
     template <> struct functions<3>
     {
@@ -457,6 +460,8 @@ namespace internal
 
       static
       size_t (&connectivity_memory_used) (types<3>::connectivity *p4est);
+
+      static const unsigned max_level;
     };
 
 
@@ -590,6 +595,7 @@ namespace internal
     size_t (&functions<3>::connectivity_memory_used) (types<3>::connectivity *p4est)
       = p8est_connectivity_memory_used;
 
+    const unsigned int functions<3>::max_level = P8EST_MAXLEVEL;
 
 
     template <int dim>
@@ -2849,6 +2855,18 @@ namespace parallel
 #endif
 
 
+      // safety check: p4est has an upper limit on the level of a cell
+      if (this->n_levels()==dealii::internal::p4est::functions<dim>::max_level)
+        {
+          for (typename Triangulation<dim,spacedim>::active_cell_iterator
+                     cell = this->begin_active(dealii::internal::p4est::functions<dim>::max_level-1);
+                     cell != this->end(dealii::internal::p4est::functions<dim>::max_level-1); ++cell)
+            {
+              AssertThrow(cell->refine_flag_set(),
+                  ExcMessage("Fatal Error: maximum refinement level of p4est reached."));
+            }
+        }
+
       // now do the work we're
       // supposed to do when we are
       // in charge

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.