From 00cccce74753b5cbb8698b13063fcaa217e85cb6 Mon Sep 17 00:00:00 2001 From: bangerth Date: Sun, 17 Aug 2008 22:43:22 +0000 Subject: [PATCH] Simplify code a slight bit. git-svn-id: https://svn.dealii.org/trunk@16584 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/grid/tria.cc | 58 ++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 42336633dc..98ae30b105 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -11156,40 +11156,40 @@ bool Triangulation::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; in_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 combined_ref_case = RefinementCase::no_refinement; - for (unsigned int i=0; ichild(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; in_children(); ++i) + combined_ref_case = combined_ref_case | + cell->child(i)->refine_flag_set(); if (combined_ref_case != RefinementCase::no_refinement) - { - for (unsigned int i=0; ichild(i); - - child->clear_coarsen_flag(); - child->set_refine_flag(combined_ref_case); - } - } + for (unsigned int i=0; in_children(); ++i) + { + cell_iterator child = cell->child(i); + + child->clear_coarsen_flag(); + child->set_refine_flag(combined_ref_case); + } } // Loop over all patches of -- 2.39.5