34 #ifndef __H__UG_DISC__ERROR_ELEM_MARKING_STRATEGY__
35 #define __H__UG_DISC__ERROR_ELEM_MARKING_STRATEGY__
47 template <
typename TDomain>
class IElementMarkingStrategy;
52 template <
typename TDomain>
80 pMG->template attach_to_dv<elem_type>(
m_aError, -1.0);
123 template <
typename TDomain>
166 template <
typename TDomain>
188 template <
typename TDomain>
193 MarkElementsForRefinement<typename base_type::elem_type>(aaError, refiner, dd, m_tol, m_max_level);
199 template <
typename TDomain>
223 template <
typename TDomain>
234 if (errTotal <= m_tol || dd->multi_grid()->num_levels() > m_max_level)
239 const_iterator iter = dd->template begin<typename base_type::elem_type>();
240 const_iterator iterEnd = dd->template end<typename base_type::elem_type>();
243 for (; iter != iterEnd; ++iter)
250 template <
typename TDomain>
280 template <
typename TDomain>
285 MarkElementsForCoarsening<typename base_type::elem_type>(aaError, refiner, dd, m_tol, m_safety, m_minLvl);
290 template<
class TElem>
295 std::vector<double> &etaSq)
300 for (iter = iterBegin; iter != iterEnd; ++iter)
302 const double elemErrSq = aaError[*iter];
306 if (elemErrSq < 0)
continue;
308 etaSq[i++] = elemErrSq;
309 localErrSq += elemErrSq;
313 std::sort (etaSq.begin(), etaSq.end(), std::greater<double>());
320 template<
class TElem>
325 std::vector< std::pair<double, TElem*> > &etaSqList)
333 for (iter = iterBegin; iter != iterEnd; ++iter)
335 const double elemErrSq = aaError[*iter];
339 if (elemErrSq < 0)
continue;
341 etaSqList[i++] = std::make_pair<>(elemErrSq, *iter);
342 localErrSq += elemErrSq;
346 std::sort (etaSqList.begin(), etaSqList.end());
354 template <
typename TDomain>
376 std::vector<std::pair<number, int> >::iterator beginFirst,
377 std::vector<std::pair<number, int> >::iterator beginSecond,
378 std::vector<std::pair<number, int> >::iterator end
389 template <
typename TDomain>
406 template <
typename TDomain>
409 std::vector<std::pair<number, int> >::iterator beginFirst,
410 std::vector<std::pair<number, int> >::iterator beginSecond,
411 std::vector<std::pair<number, int> >::iterator end
414 const size_t nVal = std::distance(beginFirst, end);
415 std::vector<std::pair<number, int> > sorted;
416 sorted.reserve(nVal);
418 std::vector<std::pair<number, int> >::iterator it1 = beginFirst;
419 std::vector<std::pair<number, int> >::iterator it2 = beginSecond;
420 while (it1 != beginSecond && it2 != end)
422 if (it1->first > it2->first)
424 sorted.push_back(*it1);
429 sorted.push_back(*it2);
434 for (; it1 != beginSecond; ++it1)
435 sorted.push_back(*it1);
436 for (; it2 != end; ++it2)
437 sorted.push_back(*it2);
440 for (it1 = beginFirst; it1 != end; ++it1, ++i)
446 template <
typename TDomain>
458 const_iterator iter = dd->template begin<TElem>();
459 const const_iterator iterEnd = dd->template end<TElem>();
460 std::vector<TElem*> elemVec;
462 for (; iter != iterEnd; ++iter)
466 if (aaErrorSq[elem] < 0)
469 if (aaErrorSq[elem] != aaErrorSq[elem])
475 locError += aaErrorSq[elem];
477 if (dd->multi_grid()->get_level(elem) < m_max_level)
478 elemVec.push_back(elem);
480 const size_t nLocalElem = elemVec.size();
484 std::sort(elemVec.begin(), elemVec.end(), eeSort);
487 std::vector<number> etaSq(nLocalElem);
488 for (
size_t i = 0; i < nLocalElem; ++i)
489 etaSq[i] = aaErrorSq[elemVec[i]];
499 UG_LOGN(
" +++ Element errors: sumEtaSq = " << globError <<
".");
504 std::vector<number> rcvBuf;
505 std::vector<int> vSizes;
506 pc.
gatherv(rcvBuf, etaSq, rootProc, &vSizes);
509 std::vector<int> nRefineElems;
510 size_t globNumRefineElems = 0;
515 std::vector<size_t> vOffsets(nProcs, 0);
516 const size_t nGlobElem = rcvBuf.size();
517 std::vector<std::pair<number, int> > vGlobErrors(nGlobElem);
519 for (
int p = 0;
p < nProcs; ++
p)
521 const size_t szp = vSizes[
p];
522 for (
size_t i = 0; i < szp; ++i, ++e)
524 vGlobErrors[e].first = rcvBuf[e];
525 vGlobErrors[e].second =
p;
533 std::vector<number> tmp;
541 const size_t nMerge = nProcs / std::min(nLists, (
size_t) nProcs);
542 for (
size_t m = 0; m < nMerge; ++m)
544 std::vector<std::pair<number, int> >::iterator beginFirst =
545 vGlobErrors.begin() + vOffsets[m*nLists];
546 std::vector<std::pair<number, int> >::iterator beginSecond =
547 vGlobErrors.begin() + vOffsets[m*nLists + nLists/2];
548 std::vector<std::pair<number, int> >::iterator endSecond =
549 (m+1)*nLists < (
size_t) nProcs ? vGlobErrors.begin() + vOffsets[(m+1)*nLists] : vGlobErrors.end();
551 merge_sorted_lists(beginFirst, beginSecond, endSecond);
554 if (nLists >= (
size_t) nProcs)
557 nLists = nLists << 1;
561 const number requiredReduction = globError > m_tol ? globError - m_safety*m_tol : 0.0;
563 nRefineElems.resize(nProcs, 0);
564 for (; red < requiredReduction && globNumRefineElems < nGlobElem; ++globNumRefineElems)
566 red += (1.0-m_expRedFac) * vGlobErrors[globNumRefineElems].first;
567 ++nRefineElems[vGlobErrors[globNumRefineElems].second];
575 pc.
broadcast(globNumRefineElems, rootProc);
578 UG_COND_THROW((
size_t) nRefElems > nLocalElem,
"More elements supposedly need refinement here ("
579 << nRefElems <<
") than are refineable (" << nLocalElem <<
").");
580 for (
size_t i = 0; i < (size_t) nRefElems; ++i)
583 if (globNumRefineElems)
585 UG_LOGN(
" +++ Marked for refinement: " << globNumRefineElems <<
" elements");
589 UG_LOGN(
" +++ No refinement necessary.");
598 const number requiredReduction = locError - m_safety*m_tol;
599 UG_LOGN(
" +++ Element errors: sumEtaSq = " << locError <<
".");
602 for (; red < requiredReduction && i < nLocalElem; ++i)
604 red += m_expRedFac * etaSq[i];
609 UG_LOGN(
" +++ Marked for refinement: " << i <<
" elements.");
613 UG_LOGN(
" +++ No refinement necessary.");
625 template <
typename TDomain>
653 template <
typename TDomain>
663 number minElemErr, minElemErrLocal;
664 number maxElemErr, maxElemErrLocal;
665 number errTotal, errLocal;
666 size_t numElem, numElemLocal;
668 ComputeMinMax(aaErrorSq, dd, minElemErr, maxElemErr, errTotal, numElem,
669 minElemErrLocal, maxElemErrLocal, errLocal, numElemLocal);
671 this->m_latest_error = sqrt(errTotal);
672 this->m_latest_error_per_elem_max = maxElemErr;
673 this->m_latest_error_per_elem_min = minElemErr;
677 const const_iterator iterEnd = dd->template end<TElem>();
680 const size_t ndiscard = (size_t) (numElemLocal*m_eps);
681 UG_LOG(
" +++ MaximumMarking: Found max "<< maxElemErr <<
", ndiscard="<<ndiscard<<
".\n");
683 if (numElemLocal > 0)
686 std::vector<double> etaSq;
687 etaSq.resize(numElemLocal);
688 CreateListOfElemWeights<TElem>(aaErrorSq,dd->template begin<TElem>(), iterEnd, etaSq);
689 UG_ASSERT(numElemLocal==etaSq.size(),
"Huhh: number of elements does not match!");
690 UG_ASSERT(numElemLocal > ndiscard,
"Huhh: number of elements does not match!");
691 maxElemErr = etaSq[ndiscard];
699 number maxElemErrLocal = maxElemErr;
701 UG_LOG(
" +++ Maximum for refinement: " << maxElemErr <<
".\n");
704 UG_LOG(
" +++ Skipping " << ndiscard <<
" elements; new (parallel) max." << maxElemErr <<
".\n");
708 const number top_threshold = maxElemErr*m_theta;
709 const number bot_threshold = maxElemErr*m_theta_min;
710 UG_LOG(
" +++ Refining elements, if error > " << maxElemErr <<
"*" << m_theta <<
711 " = " << top_threshold <<
".\n");
712 UG_LOG(
" +++ Coarsening elements, if error < " << maxElemErr <<
"*" << m_theta_min <<
713 " = " << bot_threshold <<
".\n");
716 std::size_t numMarkedRefine = 0;
717 std::size_t numMarkedCoarse = 0;
720 for (iter = dd->template begin<TElem>(); iter != iterEnd; ++iter)
727 if (aaErrorSq[elem] < 0)
continue;
730 if ((aaErrorSq[elem] > top_threshold) && (dd->multi_grid()->get_level(elem) <= m_max_level))
737 if ((aaErrorSq[elem] < bot_threshold) && (dd->multi_grid()->get_level(elem) >= m_min_level))
748 std::size_t numMarkedRefineLocal = numMarkedRefine;
750 UG_LOG(
" +++ MaximumMarking: Marked for refinement: " << numMarkedRefine <<
" ("<< numMarkedRefineLocal <<
") elements.\n");
754 {
UG_LOG(
" +++ MaximumMarking: refinement: " << numMarkedRefine <<
", coarsening" << numMarkedCoarse <<
" elements.\n") }
763 template <
typename TDomain>
784 template <
typename TDomain>
791 typedef typename std::pair<double, TElem*> TPair;
792 typedef typename std::vector<TPair> TPairVector;
795 number minElemErrSq, minElemErrSqLocal;
796 number maxElemErrSq, maxElemErrSqLocal;
797 number errSqTotal, errSqLocal;
798 size_t numElem, numElemLocal;
800 size_t numCoarsened=0;
803 ComputeMinMax(aaErrorSq, dd, minElemErrSq, maxElemErrSq, errSqTotal, numElem,
804 minElemErrSqLocal, maxElemErrSqLocal, errSqLocal, numElemLocal);
806 this->m_latest_error = sqrt(errSqTotal);
807 this->m_latest_error_per_elem_max = maxElemErrSq;
808 this->m_latest_error_per_elem_min = minElemErrSq;
812 if (numElemLocal > 0)
815 TPairVector etaSqVec;
816 etaSqVec.resize(numElemLocal);
817 CreateSortedListOfElems<TElem>(aaErrorSq,dd->template begin<TElem>(), dd->template end<TElem>(), etaSqVec);
820 UG_ASSERT(numElemLocal==etaSqVec.size(),
"Huhh: number of elements does not match!");
824 const double mySumSq = errSqLocal*m_theta;
825 double localSumSq = 0.0;
827 typename TPairVector::const_iterator iterEnd = etaSqVec.end();
829 for (
typename TPairVector::iterator iter = etaSqVec.begin();
830 (iter != iterEnd) && (localSumSq < mySumSq); ++iter)
833 localSumSq += iter->first;
834 if (localSumSq < mySumSq) {
840 UG_LOG(
" +++ APosterioriCoarsening: localSumSq = "<< localSumSq <<
" >" << mySumSq << std::endl);
853 std::size_t numCoarsenedLocal = numCoarsened;
855 UG_LOG(
" +++ APosterioriCoarsening: Marked for coarsening: " << numCoarsened <<
" ("<< numCoarsenedLocal <<
") elements.\n");
859 {
UG_LOG(
" +++ APosterioriCoarsening: coarsening" << numCoarsened <<
" elements.\n") }
867 template <
typename TDomain>
892 template <
typename TDomain>
901 number minElemErr, minElemErrLocal;
902 number maxElemErr, maxElemErrLocal;
903 number errTotal= 0.0, errLocal= 0.0;
904 size_t numElem= 0, numElemLocal;
907 ComputeMinMax(aaErrorSq, dd, minElemErr, maxElemErr, errTotal, numElem,
908 minElemErrLocal, maxElemErrLocal, errLocal, numElemLocal);
911 const const_iterator iterEnd = dd->template end<TElem>();
915 std::vector<double> etaSq;
916 etaSq.resize(numElemLocal);
917 CreateListOfElemWeights<TElem>(aaErrorSq,dd->template begin<TElem>(), iterEnd, etaSq);
918 UG_ASSERT(numElemLocal==etaSq.size(),
"Huhh: number of elements does not match!");
921 UG_ASSERT( ((m_theta_top>=0.0) && (m_theta_top<=1.0)),
"Huhh: m_theta_top invalid!");
922 UG_ASSERT( ((m_theta_bot>=0.0) && (m_theta_bot<=1.0)),
"Huhh: m_theta_top invalid!");
923 UG_ASSERT( (m_theta_top>m_theta_bot),
"Huhh: m_theta_top invalid!");
927 typename std::vector<double>::const_iterator top = etaSq.begin();
929 (sumSq<m_theta_top*errLocal) && (top !=(etaSq.end()-1));
930 ++top) { sumSq += *top; }
931 number top_threshold = (top != etaSq.begin()) ? (*top + *(top-1))/2.0 : *top;
934 typename std::vector<double>::const_iterator bot = etaSq.end()-1;
936 (sumSq<m_theta_bot*errLocal) && (bot !=etaSq.begin() );
937 --bot) { sumSq += *bot; }
938 number bot_threshold = (bot != (etaSq.end()-1)) ? (*bot + *(bot+1))/2.0 : 0.0;
940 UG_LOG(
" +++ error = "<< errLocal << std::endl);
941 UG_LOG(
" +++ top_threshold= "<< top_threshold <<
"( "<< top - etaSq.begin() <<
" cells)" << std::endl);
942 UG_LOG(
" +++ bot_threshold= "<< bot_threshold <<
"( "<< etaSq.end()-bot <<
" cells)" << std::endl);
945 size_t numMarkedRefine = 0;
946 size_t numMarkedCoarse = 0;
947 for (iter = dd->template begin<TElem>(); iter != iterEnd; ++iter)
950 const double elemErr = aaErrorSq[*iter];
951 if (elemErr < 0)
continue;
953 if (elemErr > top_threshold)
959 if (elemErr < bot_threshold)
968 UG_LOG(
" +++ EquilibrationMarkingStrategy: Marked for refinement: "<< numMarkedRefine <<
", " << numMarkedCoarse <<
" elements.\n");
975 template <
typename TDomain>
994 template <
typename TDomain>
1004 number minElemErr, minElemErrLocal;
1005 number maxElemErr, maxElemErrLocal;
1006 number errTotal, errLocal;
1007 size_t numElem, numElemLocal;
1009 ComputeMinMax(aaError2, dd, minElemErr, maxElemErr, errTotal, numElem,
1010 minElemErrLocal, maxElemErrLocal, errLocal, numElemLocal);
1012 this->m_latest_error = sqrt(errTotal);
1013 this->m_latest_error_per_elem_max = maxElemErr;
1014 this->m_latest_error_per_elem_min = minElemErr;
1017 number elemMean = errTotal / numElem;
1019 UG_LOG(
" +++ VarianceMarking: Mean error : " << elemMean <<
" on "<< numElem <<
" elements.\n");
1022 const_iterator iter;
1023 const const_iterator iterEnd = dd->template end<TElem>();
1026 for (iter = dd->template begin<TElem>(); iter != iterEnd; ++iter)
1028 TElem* elem = *iter;
1029 number elemError = aaError2[elem];
1031 if (elemError < 0)
continue;
1032 elemVar += (elemMean-elemError) * (elemMean-elemError);
1041 number elemVarLocal = elemVar;
1046 UG_LOG(
" +++ VarianceMarking: Est. variance (1) : " << elemVar <<
" on "<< numElem <<
" elements.\n");
1049 elemVar /= (numElem-1.0);
1050 UG_LOG(
" +++ VarianceMarking: Est. variance (2): " << elemVar <<
" on "<< numElem <<
" elements.\n");
1054 const number sigma = sqrt(elemVar);
1055 const number maxError = elemMean + sigma*m_width;
1056 UG_LOG(
" +++ Refining elements if error greater " << sigma <<
"*" << m_width <<
" + "<< elemMean <<
1057 " = " << maxError <<
".\n");
1061 const number minErrToRefine = maxError*m_theta;
1062 UG_LOG(
" +++ Refining elements if error greater " << maxError <<
"*" << m_theta <<
1063 " = " << minErrToRefine <<
".\n");
1066 std::size_t numMarkedRefine = 0;
1069 for (iter = dd->template begin<TElem>(); iter != iterEnd; ++iter)
1072 TElem* elem = *iter;
1076 if (aaError2[elem] < 0)
continue;
1079 if (aaError2[elem] >= minErrToRefine)
1080 if (dd->multi_grid()->get_level(elem) <= m_max_level)
1091 std::size_t numMarkedRefineLocal = numMarkedRefine;
1093 UG_LOG(
" +++ MaximumMarking: Marked for refinement: " << numMarkedRefine <<
" ("<< numMarkedRefineLocal <<
") elements.\n");
1096 UG_LOG(
" +++ MaximumMarking: Marked for refinement: " << numMarkedRefine <<
" elements.\n");
1109 template <
typename TDomain>
1144 template <
typename TDomain>
1154 number minElemErr, minElemErrLocal;
1155 number maxElemErr, maxElemErrLocal;
1156 number errSum, errTotalSq, errLocal;
1157 size_t numElem, numElemLocal;
1159 const number elemMean =
ComputeAvg(aaError2, dd, minElemErr, maxElemErr, errSum, errTotalSq, numElem,
1160 minElemErrLocal, maxElemErrLocal, errLocal, numElemLocal);
1163 this->m_latest_error = sqrt(errTotalSq);
1164 this->m_latest_error_per_elem_max = maxElemErr;
1165 this->m_latest_error_per_elem_min = minElemErr;
1167 UG_LOG(
" +++ VarianceMarkingEta: error : "<< this->m_latest_error <<
" (meanEta : " << elemMean <<
" on "<< numElem <<
" elements).\n");
1170 const_iterator iter;
1171 const const_iterator iterEnd = dd->template end<TElem>();
1174 for (iter = dd->template begin<TElem>(); iter != iterEnd; ++iter)
1176 TElem* elem = *iter;
1178 if (aaError2[elem] < 0)
continue;
1180 number elemError = sqrt(aaError2[elem]);
1182 elemVar += (elemMean-elemError) * (elemMean-elemError);
1185 UG_LOG(
" +++ VarianceMarkingEta: Est. variance (1) : " << (elemVar / (numElem -1.0)) <<
" on "<< numElem <<
" elements.\n");
1190 number elemVarLocal = elemVar;
1195 elemVar /= (numElem-1.0);
1196 UG_LOG(
" +++ VarianceMarkingEta: Est. variance (2): " << elemVar <<
" on "<< numElem <<
" elements.\n");
1200 const number sigma = sqrt(elemVar);
1201 const number maxError = elemMean + sigma*m_width;
1202 UG_LOG(
" +++ Refining elements if error > " << elemMean <<
" + "<< sigma <<
"*" << m_width <<
1203 " = " << maxError <<
".\n");
1205 const number elemErrorRefine = maxError*m_theta;
1206 UG_LOG(
" +++ Refining elements if error > " << maxError <<
"*" << m_theta <<
1207 " = " << elemErrorRefine <<
".\n");
1214 const number elemErrorCoarsen = elemMean*m_theta_coarse;
1215 UG_LOG(
" +++ Coarsening elements if error < " << elemMean <<
"*" << m_theta_coarse <<
1216 " = " << elemErrorCoarsen <<
".\n");
1221 std::size_t numMarkedRefine = 0;
1222 std::size_t numMarkedCoarsen = 0;
1225 for (iter = dd->template begin<TElem>(); iter != iterEnd; ++iter)
1228 TElem* elem = *iter;
1232 if (aaError2[elem] < 0)
continue;
1234 const number elemError = sqrt(aaError2[elem]);
1237 if ((elemError >= elemErrorRefine) && (dd->multi_grid()->get_level(elem) <= m_max_level))
1244 if ((elemError < elemErrorCoarsen) && (dd->multi_grid()->get_level(elem) >= m_min_level))
1256 std::size_t numMarkedRefineLocal = numMarkedRefine;
1258 UG_LOG(
" +++ VarianceMarkingEta: Marked for refinement: " << numMarkedRefine <<
" ("<< numMarkedRefineLocal <<
") elements.\n");
1262 UG_LOG(
" +++ VarianceMarkingEta: Marked for refinement: " << numMarkedRefine <<
" elements.\n");
1263 UG_LOG(
" +++ VarianceMarkingEta: Marked for coarsening: " << numMarkedCoarsen <<
" elements.\n");
1270 template <
typename TDomain>
1287 template <
typename TDomain>
1297 number minElemErr, minElemErrLocal;
1298 number maxElemErrSq, maxElemErrLocal;
1299 number errTotalSq, errLocal;
1300 size_t numElem, numElemLocal;
1302 ComputeMinMax(aaError, dd, minElemErr, maxElemErrSq, errTotalSq, numElem,
1303 minElemErrLocal, maxElemErrLocal, errLocal, numElemLocal);
1307 number avgElemErr = errTotalSq / numElem;
1308 UG_LOG(
" +++ Global max: "<< maxElemErrSq <<
", Global min: "<< minElemErr <<
".\n");
1309 UG_LOG(
" +++ MeanValueMarking: Mean value : " << avgElemErr <<
" (Global error sum: "<<errTotalSq<<
" on "<< numElem <<
" elements).\n");
1312 const number minThetaErrToRefine = maxElemErrSq*m_theta;
1313 const number minFactorAvgErrToRefine = avgElemErr*m_factor;
1314 UG_LOG(
" +++ MeanValueMarking: Min theta error : "<<minThetaErrToRefine<<
" (Global Max Error: " << maxElemErrSq<<
" for theta: "<<m_theta<<
").\n");
1315 UG_LOG(
" +++ MeanValueMarking: Min factor avg error : "<<minFactorAvgErrToRefine<<
" (Global Avg Error: " << avgElemErr<<
" for factor: "<<m_factor<<
").\n");
1317 const number minErrToRefine = std::min(minThetaErrToRefine, minFactorAvgErrToRefine);
1318 UG_LOG(
" +++ MeanValueMarking: Refining if error >= : "<<minErrToRefine<<
".\n");
1322 std::size_t numMarkedRefine = 0;
1325 const_iterator iter;
1326 const const_iterator iterEnd = dd->template end<TElem>();
1327 for (iter = dd->template begin<TElem>(); iter != iterEnd; ++iter)
1330 TElem* elem = *iter;
1334 if (aaError[elem] < 0)
continue;
1337 if (aaError[elem] >= minErrToRefine)
1348 std::size_t numMarkedRefineLocal = numMarkedRefine;
1350 UG_LOG(
" +++ MeanValueMarking: Marked for refinement: " << numMarkedRefine <<
" ("<< numMarkedRefineLocal <<
") elements.\n");
1353 UG_LOG(
" +++ MeanValueMarking: Marked for refinement: " << numMarkedRefine <<
" elements.\n");
1365 template <
typename TDomain>
1382 template <
typename TDomain>
1391 const const_iterator iterEnd = dd->template end<TElem>();
1393 number lowerBound = m_eta*m_eta;
1397 size_t numMarkedRefine = 0;
1398 for (const_iterator iter = dd->template begin<TElem>(); iter != iterEnd; ++iter)
1401 TElem* elem = *iter;
1402 const number elemError = aaError[elem];
1405 if (elemError < 0)
continue;
1406 errTotal += elemError;
1409 if ((elemError >= lowerBound) && (dd->multi_grid()->get_level(elem) <= m_max_level))
1422 std::size_t numMarkedRefineLocal = numMarkedRefine;
1423 number errLocal = errTotal;
1429 this->m_latest_error = sqrt(errTotal);
1431 UG_LOG(
" +++ AbsoluteMarking: Error**2 = "<<errTotal <<
"; marked "<< numMarkedRefine <<
" elements for refinement "<<std::endl);
1438 template <
typename TDomain,
typename TAlgebra>
1442 refiner.
mark(spDD->begin<TElem>(), spDD->end<TElem>(),
RM_COARSEN);
Definition: smart_pointer.h:296
bool invalid() const
returns true if the pointer is invalid, false if not.
Definition: smart_pointer.h:212
Definition: pcl_process_communicator.h:70
void gatherv(const void *sendBuf, int sendCount, DataType sendType, void *recBuf, int *recCounts, int *displs, DataType recType, int root) const
performs MPI_Gatherv on the processes of the communicator.
Definition: pcl_process_communicator.cpp:406
void allreduce(const void *sendBuf, void *recBuf, int count, DataType type, ReduceOperation op) const
performs MPI_Allreduce on the processes of the communicator.
Definition: pcl_process_communicator.cpp:318
void scatter(const void *sendBuf, int sendCount, DataType sendType, void *recBuf, int recCount, DataType recType, int root) const
performs MPI_Scatter on the processes of the communicator
Definition: pcl_process_communicator.cpp:392
void broadcast(void *v, size_t size, DataType type, int root=0) const
Definition: pcl_process_communicator.cpp:685
Definition: error_elem_marking_strategy.h:764
APosterioriCoarsening(number theta=0.1)
Definition: error_elem_marking_strategy.h:768
void set_max_level(int lvl)
Definition: error_elem_marking_strategy.h:773
void mark(typename base_type::elem_accessor_type &aaErrorSq, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:785
void set_min_level(int lvl)
Definition: error_elem_marking_strategy.h:774
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:767
number m_theta
Definition: error_elem_marking_strategy.h:778
int m_min_level
Definition: error_elem_marking_strategy.h:779
int m_max_level
Definition: error_elem_marking_strategy.h:779
marks elements above an absolute threshold (based on S. Reiter's idea)
Definition: error_elem_marking_strategy.h:1366
int m_max_level
Definition: error_elem_marking_strategy.h:1379
number m_eta
Definition: error_elem_marking_strategy.h:1378
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:1369
void mark(typename base_type::elem_accessor_type &aaError, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:1383
AbsoluteMarking(number eta)
Definition: error_elem_marking_strategy.h:1370
marks elements above a certain fraction of the maximum
Definition: error_elem_marking_strategy.h:868
number m_theta_top
Definition: error_elem_marking_strategy.h:883
EquilibrationMarkingStrategy(number theta_top=0.9)
Definition: error_elem_marking_strategy.h:872
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:871
void mark(typename base_type::elem_accessor_type &aaErrorSq, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:893
EquilibrationMarkingStrategy(number theta_top, number theta_bot)
Definition: error_elem_marking_strategy.h:874
number m_theta_bot
Definition: error_elem_marking_strategy.h:884
Definition: error_elem_marking_strategy.h:356
number m_expRedFac
Definition: error_elem_marking_strategy.h:385
void merge_sorted_lists(std::vector< std::pair< number, int > >::iterator beginFirst, std::vector< std::pair< number, int > >::iterator beginSecond, std::vector< std::pair< number, int > >::iterator end)
Definition: error_elem_marking_strategy.h:408
int m_max_level
Definition: error_elem_marking_strategy.h:383
void set_expected_reduction_factor(number expectedReductionFactor)
Definition: error_elem_marking_strategy.h:367
number m_tol
Definition: error_elem_marking_strategy.h:382
void set_safety_factor(number safetyFactor)
Definition: error_elem_marking_strategy.h:366
void set_max_level(int max_level)
Definition: error_elem_marking_strategy.h:365
void mark(typename base_type::elem_accessor_type &aaError, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:448
ExpectedErrorMarkingStrategy(number tol, int max_level, number safetyFactor, number expectedReductionFactor)
Definition: error_elem_marking_strategy.h:361
void set_tolerance(number tol)
Definition: error_elem_marking_strategy.h:364
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:359
number m_safety
Definition: error_elem_marking_strategy.h:384
mark everything if error too high and refinement allowed
Definition: error_elem_marking_strategy.h:201
number m_tol
Definition: error_elem_marking_strategy.h:219
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:204
size_t m_max_level
Definition: error_elem_marking_strategy.h:220
GlobalMarking(number tol, size_t max_level)
Definition: error_elem_marking_strategy.h:206
void set_tolerance(number tol)
Definition: error_elem_marking_strategy.h:209
void set_max_level(size_t max_level)
Definition: error_elem_marking_strategy.h:210
void mark(typename base_type::elem_accessor_type &aaError, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:224
the generic attachment-accessor for access to grids attachment pipes.
Definition: grid.h:182
represents numerical solutions on a grid using an algebraic vector
Definition: grid_function.h:121
SmartPtr< DoFDistribution > dof_distribution()
Definition: grid_function.h:236
Abstract base class for element marking (in adaptive refinement)
Definition: error_elem_marking_strategy.h:125
static const int dim
world dimension
Definition: error_elem_marking_strategy.h:128
IElementMarkingStrategy()
Definition: error_elem_marking_strategy.h:134
virtual void mark(elem_accessor_type &aaError, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)=0
DEPRECATED:
void mark(IMultigridElementIndicators< TDomain > &mgElemIndicators, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
This function marks all elements.
Definition: error_elem_marking_strategy.h:141
Grid::AttachmentAccessor< elem_type, ug::Attachment< number > > elem_accessor_type
Definition: error_elem_marking_strategy.h:132
domain_traits< dim >::element_type elem_type
element type to be marked
Definition: error_elem_marking_strategy.h:131
number m_latest_error
Definition: error_elem_marking_strategy.h:155
number m_latest_error_per_elem_max
Definition: error_elem_marking_strategy.h:156
number global_estimated_error_per_elem_max() const
Definition: error_elem_marking_strategy.h:161
virtual ~IElementMarkingStrategy()
Definition: error_elem_marking_strategy.h:137
number global_estimated_error_per_elem_min() const
Definition: error_elem_marking_strategy.h:162
number m_latest_error_per_elem_min
Definition: error_elem_marking_strategy.h:157
number global_estimated_error() const
Definition: error_elem_marking_strategy.h:160
This class encapsulates the multi-grid attachments for error estimation.
Definition: error_elem_marking_strategy.h:54
Attachment< number > error_attachment_type
Definition: error_elem_marking_strategy.h:60
static const int dim
world dimension
Definition: error_elem_marking_strategy.h:57
domain_traits< dim >::element_type elem_type
Definition: error_elem_marking_strategy.h:59
IMultigridElementIndicators()
CTOR.
Definition: error_elem_marking_strategy.h:64
SmartPtr< MultiGrid > m_pMG
Definition: error_elem_marking_strategy.h:112
attachment_accessor_type & errors()
Definition: error_elem_marking_strategy.h:108
attachment_accessor_type m_aaError
Definition: error_elem_marking_strategy.h:114
const number & error(typename attachment_accessor_type::atraits::ConstElemPtr pElem) const
returns error indicator value
Definition: error_elem_marking_strategy.h:99
~IMultigridElementIndicators()
DTOR.
Definition: error_elem_marking_strategy.h:67
error_attachment_type m_aError
Definition: error_elem_marking_strategy.h:113
void attach_indicators(SmartPtr< MultiGrid > pMG)
Attach error indicator to multigrid.
Definition: error_elem_marking_strategy.h:73
MultiGrid::AttachmentAccessor< elem_type, error_attachment_type > attachment_accessor_type
Definition: error_elem_marking_strategy.h:61
void detach_indicators()
Detach error indicator from multigrid.
Definition: error_elem_marking_strategy.h:86
number & error(typename attachment_accessor_type::atraits::ConstElemPtr pElem)
returns error indicator value
Definition: error_elem_marking_strategy.h:95
The refiner interface allows to mark elements for refinement and to call refine.
Definition: refiner_interface.h:67
bool coarsen()
Performs coarsening on the elements marked RM_COARSEN.
Definition: refiner_interface.cpp:162
virtual bool mark(Vertex *v, RefinementMark refMark=RM_REFINE)
Marks an element for refinement. Default implementation is empty.
Definition: refiner_interface.h:103
virtual Grid * grid()=0
Returns the grid associated with the refiner.
Definition: error_elem_marking_strategy.h:626
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:629
int m_max_level
Definition: error_elem_marking_strategy.h:648
void set_max_level(int lvl)
Definition: error_elem_marking_strategy.h:641
int m_min_level
Definition: error_elem_marking_strategy.h:648
MaximumMarking(number theta_max, number theta_min, number eps)
Definition: error_elem_marking_strategy.h:634
MaximumMarking(number theta=1.0)
Definition: error_elem_marking_strategy.h:630
number m_eps
Definition: error_elem_marking_strategy.h:647
number m_theta_min
Definition: error_elem_marking_strategy.h:646
MaximumMarking(number theta, number eps)
Definition: error_elem_marking_strategy.h:632
void mark(typename base_type::elem_accessor_type &aaErrorSq, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:654
void set_min_level(int lvl)
Definition: error_elem_marking_strategy.h:642
number m_theta
Definition: error_elem_marking_strategy.h:646
Definition: error_elem_marking_strategy.h:1271
number m_factor
Definition: error_elem_marking_strategy.h:1284
MeanValueMarking(number theta, number factor)
Definition: error_elem_marking_strategy.h:1275
void mark(typename base_type::elem_accessor_type &aaError, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:1288
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:1274
number m_theta
Definition: error_elem_marking_strategy.h:1283
M. Breit's standard coarsening strategy.
Definition: error_elem_marking_strategy.h:252
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:255
number m_tol
Definition: error_elem_marking_strategy.h:275
StdCoarseningMarkingStrategy(number tol, number safety, int minLvl)
Definition: error_elem_marking_strategy.h:263
number m_safety
Definition: error_elem_marking_strategy.h:276
StdCoarseningMarkingStrategy(number tol)
Definition: error_elem_marking_strategy.h:257
int m_minLvl
Definition: error_elem_marking_strategy.h:277
void set_safety_factor(number safety)
Definition: error_elem_marking_strategy.h:267
void set_tolerance(number tol)
Definition: error_elem_marking_strategy.h:266
StdCoarseningMarkingStrategy(number tol, number safety)
Definition: error_elem_marking_strategy.h:260
void mark(typename base_type::elem_accessor_type &aaError, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:281
M. Breit's standard refinement strategy.
Definition: error_elem_marking_strategy.h:168
StdRefinementMarkingStrategy(number tol, int max_level)
Definition: error_elem_marking_strategy.h:173
int m_max_level
Definition: error_elem_marking_strategy.h:185
void set_tolerance(number tol)
Definition: error_elem_marking_strategy.h:176
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:171
number m_tol
Definition: error_elem_marking_strategy.h:184
void set_max_level(int max_level)
Definition: error_elem_marking_strategy.h:177
void mark(typename base_type::elem_accessor_type &aaError, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:189
Const iterator to traverse the surface of a multi-grid hierarchy.
Definition: surface_view.h:237
Marks elements above a certain threshold for refinement.
Definition: error_elem_marking_strategy.h:1110
VarianceMarkingEta(number theta, number width)
Definition: error_elem_marking_strategy.h:1117
number m_theta_coarse
Definition: error_elem_marking_strategy.h:1140
void init_coarsening(number theta, int min_level)
Definition: error_elem_marking_strategy.h:1127
VarianceMarkingEta(number theta)
Definition: error_elem_marking_strategy.h:1114
number m_width
Definition: error_elem_marking_strategy.h:1137
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:1113
number m_theta
Definition: error_elem_marking_strategy.h:1136
VarianceMarkingEta(number theta, number width, number theta_coarse)
Definition: error_elem_marking_strategy.h:1120
void mark(typename base_type::elem_accessor_type &aaError2, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:1145
void init_refinement(number theta, int max_level)
Definition: error_elem_marking_strategy.h:1124
int m_min_level
Definition: error_elem_marking_strategy.h:1141
int m_max_level
Definition: error_elem_marking_strategy.h:1138
Definition: error_elem_marking_strategy.h:976
int m_max_level
Definition: error_elem_marking_strategy.h:991
number m_width
Definition: error_elem_marking_strategy.h:990
VarianceMarking(number theta)
Definition: error_elem_marking_strategy.h:980
void mark(typename base_type::elem_accessor_type &aaError2, IRefiner &refiner, ConstSmartPtr< DoFDistribution > dd)
DEPRECATED:
Definition: error_elem_marking_strategy.h:995
number m_theta
Definition: error_elem_marking_strategy.h:989
VarianceMarking(number theta, number width)
Definition: error_elem_marking_strategy.h:981
IElementMarkingStrategy< TDomain > base_type
Definition: error_elem_marking_strategy.h:979
const void * ConstElemPtr
Definition: attachment_pipe.h:309
std::string ElementDebugInfo(const Grid &grid, GridObject *e)
Returns a string containing information on the given element.
Definition: debug_util.cpp:991
@ RM_COARSEN
the element is coarsened (only valid for adaptive multi-grid refinement)
Definition: refiner_interface.h:56
@ RM_REFINE
DEPRECATED. Use RM_FULL instead.
Definition: refiner_interface.h:55
#define PCL_RO_SUM
Definition: pcl_methods.h:63
int ProcRank()
returns the rank of the process
Definition: pcl_base.cpp:83
#define PCL_RO_MAX
Definition: pcl_methods.h:61
int NumProcs()
returns the number of processes
Definition: pcl_base.cpp:91
#define PCL_DT_INT
Definition: pcl_datatype.h:51
T * GetDataPtr(std::vector< T > &v)
Returns a pointer to the array which is managed by the std::vector.
Definition: vector_util.h:51
#define UG_LOG_ALL_PROCS(msg)
Definition: log.h:371
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_LOG(msg)
Definition: log.h:367
#define UG_LOGN(msg)
Definition: log.h:369
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
double number
Definition: types.h:124
void ComputeMinMax(MultiGrid::AttachmentAccessor< TElem, ug::Attachment< number > > &aaError, ConstSmartPtr< DoFDistribution > dd, number &min, number &max, number &totalErr, size_t &numElem, number &minLocal, number &maxLocal, number &totalErrLocal, size_t &numElemLocal)
helper function that computes min/max and total of error indicators
Definition: error_indicator_util.h:135
number CreateListOfElemWeights(Grid::AttachmentAccessor< TElem, ug::Attachment< number > > &aaError, typename DoFDistribution::traits< TElem >::const_iterator iterBegin, const typename DoFDistribution::traits< TElem >::const_iterator iterEnd, std::vector< double > &etaSq)
Definition: error_elem_marking_strategy.h:291
number CreateSortedListOfElems(Grid::AttachmentAccessor< TElem, ug::Attachment< number > > &aaError, typename DoFDistribution::traits< TElem >::const_iterator iterBegin, const typename DoFDistribution::traits< TElem >::const_iterator iterEnd, std::vector< std::pair< double, TElem * > > &etaSqList)
Definition: error_elem_marking_strategy.h:321
number ComputeAvg(MultiGrid::AttachmentAccessor< TElem, ug::Attachment< number > > &aaError2, ConstSmartPtr< DoFDistribution > dd, number &min, number &max, number &sum, number &errSq, size_t &numElem, number &minLocal, number &maxLocal, number &sumLocal, size_t &numElemLocal)
helper function that computes min/max and total of error indicators
Definition: error_indicator_util.h:54
void MarkForCoarsenening_SurfaceLayer(const GridFunction< TDomain, TAlgebra > &u, IRefiner &refiner)
Mark surface layer for coarsening.
Definition: error_elem_marking_strategy.h:1439
void ComputeMinMaxTotal(MultiGrid::AttachmentAccessor< TElem, ug::Attachment< number > > &aaError2, ConstSmartPtr< DoFDistribution > dd, number &min, number &max, number &totalErr, size_t &numElem)
helper function that computes min/max and total of error indicators
Definition: error_indicator_util.h:196
Definition: error_elem_marking_strategy.h:391
Grid::AttachmentAccessor< elem_type, ug::Attachment< number > > error_accessor_type
Definition: error_elem_marking_strategy.h:393
const error_accessor_type & m_aaErr
Definition: error_elem_marking_strategy.h:402
ElemErrorSortDesc(const error_accessor_type &aaErr)
Definition: error_elem_marking_strategy.h:394
domain_traits< TDomain::dim >::element_type elem_type
Definition: error_elem_marking_strategy.h:392
bool operator()(const elem_type *elem1, const elem_type *elem2)
Definition: error_elem_marking_strategy.h:397
Definition: domain_traits.h:53