]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Simplify code a slight bit.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 17 Aug 2008 22:43:22 +0000 (22:43 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 17 Aug 2008 22:43:22 +0000 (22:43 +0000)
git-svn-id: https://svn.dealii.org/trunk@16584 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/grid/tria.cc

index 42336633dcb797f8fb5fd73dad8425c9b2c8719d..98ae30b10549ddf327619e43462e88babff787f5 100644 (file)
@@ -11156,40 +11156,40 @@ bool Triangulation<dim>::prepare_coarsening_and_refinement ()
                                           // clear_coarsen_flag of
                                           // all children.
          for (cell_iterator cell = begin(); cell != end(); ++cell)
-           if (!cell->active() && cell->child(0)->active())
+           if (!cell->active())
              {
-               const unsigned int n_children=cell->n_children();
+               bool n_active_children = 0;
+               for (unsigned int i=0; i<cell->n_children(); ++i)
+                 if (cell->child(i)->active())
+                   ++n_active_children;
+
+                                                // if none of the
+                                                // children are
+                                                // active, continue
+                                                // with next cell
+               if (n_active_children == 0)
+                 continue;
                
                                                 // cell is found to
-                                                // be a patch
+                                                // be a patch.
+                                                // combine the refine
+                                                // cases of all
+                                                // children
+               Assert (n_active_children == cell->n_children(),
+                       ExcInternalError());
+
                RefinementCase<dim> combined_ref_case = RefinementCase<dim>::no_refinement;
-               for (unsigned int i=0; i<n_children; ++i)
-                 {
-                   cell_iterator child=cell->child(i);
-                                                    // check
-                                                    // consistency:
-                                                    // cell is really
-                                                    // a patch,
-                                                    // i.e. no child
-                                                    // is refined.
-                   Assert(child->active(), ExcInternalError());
-                                                    // combine the refine cases
-                                                    // of all children
-                   combined_ref_case=combined_ref_case |
-                                     child->refine_flag_set();
-                   
-                   
-                 }
+               for (unsigned int i=0; i<cell->n_children(); ++i)
+                 combined_ref_case = combined_ref_case |
+                                     cell->child(i)->refine_flag_set();
                if (combined_ref_case != RefinementCase<dim>::no_refinement)
-                 {
-                   for (unsigned int i=0; i<n_children; ++i)
-                     {
-                       cell_iterator child=cell->child(i);
-
-                       child->clear_coarsen_flag();
-                       child->set_refine_flag(combined_ref_case);
-                     }
-                 }
+                 for (unsigned int i=0; i<cell->n_children(); ++i)
+                   {
+                     cell_iterator child = cell->child(i);
+                     
+                     child->clear_coarsen_flag();
+                     child->set_refine_flag(combined_ref_case);
+                   }
              }
 
                                           // Loop over all patches of

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.