From 5490829784eafc0e3ec50f409e655ff27043afc8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 14 Apr 2015 16:46:56 -0500 Subject: [PATCH] Replace a double loop over cells and indices by a single loop and the use of cell->active_cell_index(). --- source/grid/grid_refinement.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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(); } -- 2.39.5