From a665c1291749aa11d77ad41bf8a86ed5457b99d6 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 28 May 1998 11:40:57 +0000 Subject: [PATCH] Cleanup. git-svn-id: https://svn.dealii.org/trunk@370 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/grid/tria.cc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 62ef6de991..0bd077b5d4 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -1893,11 +1893,15 @@ void Triangulation::refine_fixed_fraction (const dVector &criteria, // number of cells to be sorted per part const unsigned cells_per_part = static_cast(fraction_of_error * criteria.size() / n_sorting_parts); + // let tmp be the cellwise square of the + // error, which is what we have to sum + // up and compare with + // #fraction_of_error*total_error#. dVector tmp(criteria); transform (tmp.begin(), tmp.end(), tmp.begin(), sqr); + const double total_error = tmp.l1_norm(); dVector partial_sums(criteria.size()); - const double total_error = sqr(criteria.l2_norm()); for (unsigned int part=0; part::refine_fixed_fraction (const dVector &criteria, tmp.begin()+(part+1)*cells_per_part, tmp.end(), greater()); + // compute partial sum of the range + // as yet sorted. In principle it + // would be sufficient to only sum up + // the newly sorted part and give the + // partial sum an initial value equal + // to the previously last partial sum, + // but at present I do not know how + // to do so in an easy way. Think + // about it and fix it if you want! + // (This way doesn't eat up much + // computing time anyway, much less + // than the sorting, so I don't care + // about fixing this myself.) partial_sum (tmp.begin(), tmp.begin()+(part+1)*cells_per_part, partial_sums.begin()); @@ -1919,7 +1936,7 @@ void Triangulation::refine_fixed_fraction (const dVector &criteria, // fraction of the error. We only // need to search the newly created //region - dVector::const_iterator threshold_ptr + const dVector::const_iterator threshold_ptr = lower_bound (partial_sums.begin()+part*cells_per_part, partial_sums.begin()+(part+1)*cells_per_part, fraction_of_error*total_error); @@ -1932,6 +1949,8 @@ void Triangulation::refine_fixed_fraction (const dVector &criteria, refine (criteria, sqrt(*threshold_ptr)); else refine (criteria, + // revert partial sum into + // a single value sqrt(*threshold_ptr - *(threshold_ptr-1))); return; }; -- 2.39.5