From: Wolfgang Bangerth Date: Tue, 14 Apr 2015 21:46:56 +0000 (-0500) Subject: Replace a double loop over cells and indices by a single loop and the use of cell... X-Git-Tag: v8.3.0-rc1~263^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5490829784eafc0e3ec50f409e655ff27043afc8;p=dealii.git Replace a double loop over cells and indices by a single loop and the use of cell->active_cell_index(). --- diff --git a/source/grid/grid_refinement.cc b/source/grid/grid_refinement.cc index 5dace02757..c8b44a438a 100644 --- a/source/grid/grid_refinement.cc +++ b/source/grid/grid_refinement.cc @@ -225,7 +225,6 @@ void GridRefinement::refine (Triangulation &tria, if (criteria.all_zero()) return; - typename Triangulation::active_cell_iterator cell = tria.begin_active(); const unsigned int n_cells = criteria.size(); //TODO: This is undocumented, looks fishy and seems unnecessary @@ -244,8 +243,9 @@ void GridRefinement::refine (Triangulation &tria, } unsigned int marked=0; - for (unsigned int index=0; index= new_threshold) + for (typename Triangulation::active_cell_iterator cell = tria.begin_active(); + cell != tria.end(); ++cell) + if (std::fabs(criteria(cell->active_cell_index())) >= new_threshold) { if (max_to_mark!=numbers::invalid_unsigned_int && marked>=max_to_mark) break; @@ -265,11 +265,9 @@ void GridRefinement::coarsen (Triangulation &tria, ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); Assert (criteria.is_non_negative (), ExcNegativeCriteria()); - typename Triangulation::active_cell_iterator cell = tria.begin_active(); - const unsigned int n_cells = criteria.size(); - - for (unsigned int index=0; index::active_cell_iterator cell = tria.begin_active(); + cell != tria.end(); ++cell) + if (std::fabs(criteria(cell->active_cell_index())) <= threshold) if (!cell->refine_flag_set()) cell->set_coarsen_flag(); }