From: Wolfgang Bangerth Date: Thu, 7 May 1998 18:07:39 +0000 (+0000) Subject: Add additional refinement strategy. X-Git-Tag: v8.0.0~22987 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c949542a42642c8a2e4a298fc98d826588024e0;p=dealii.git Add additional refinement strategy. git-svn-id: https://svn.dealii.org/trunk@267 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 70019f75d2..ea56ce65ce 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -1747,6 +1748,10 @@ void Triangulation::refine (const dVector &criteria, template void Triangulation::refine_fixed_number (const dVector &criteria, const double fraction) { + // correct number of cells is + // checked in #refine# + Assert ((fraction>0) && (fraction<=1), ExcInvalidParameterValue()); + dVector tmp(criteria); nth_element (tmp.begin(), tmp.begin()+static_cast(fraction*tmp.size()), @@ -1758,6 +1763,75 @@ void Triangulation::refine_fixed_number (const dVector &criteria, }; +inline +double sqr(double a) { + return a*a; +}; + + +template +void Triangulation::refine_fixed_fraction (const dVector &criteria, + const double fraction_of_error, + const unsigned int n_sorting_parts) { + // correct number of cells is + // checked in #refine# + Assert ((fraction_of_error>0) && (fraction_of_error<=1), + ExcInvalidParameterValue()); + + // number of cells to be sorted per part + const unsigned cells_per_part + = static_cast(fraction_of_error * criteria.size() / n_sorting_parts); + dVector tmp(criteria); + transform (tmp.begin(), tmp.end(), tmp.begin(), sqr); + + dVector partial_sums(criteria.size()); + const double total_error = sqr(criteria.l2_norm()); + for (unsigned int part=0; part()); + partial_sum (tmp.begin(), + tmp.begin()+(part+1)*cells_per_part, + partial_sums.begin()); + + // check whether the sorted + // region already is enough + if (*(partial_sums.begin()+(part+1)*cells_per_part-1) >= + (fraction_of_error*total_error)) + { + // find first entry in the partial + // sum which is greater than the + // fraction of the error. We only + // need to search the newly created + //region + 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); + Assert (threshold_ptr::execute_refinement () {