From b760a5b3a16ff51469ece8ae9d481ba187ea5977 Mon Sep 17 00:00:00 2001 From: Markus Wolff <markus.wolff@twt-gmbh.de> Date: Mon, 19 Mar 2012 07:56:40 +0000 Subject: [PATCH] stricter rules for coarsening in adaptive decoupled models - allow coarsening only if all leaf cells of a father element (new coarser element) are marked for coarsening - additionally: added refine and coarsen thresholds as parameter-properties git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@8028 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/decoupled/common/gridadapt.hh | 19 +++++++++++++++++++ dumux/decoupled/common/gridadaptproperties.hh | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/dumux/decoupled/common/gridadapt.hh b/dumux/decoupled/common/gridadapt.hh index 3bcc2645ed..590b144b2d 100644 --- a/dumux/decoupled/common/gridadapt.hh +++ b/dumux/decoupled/common/gridadapt.hh @@ -147,6 +147,9 @@ public: */ int markElements() { + std::map<int, int> coarsenMarker; + const typename Grid::Traits::LocalIdSet& idSet(problem_.grid().localIdSet()); + for (LeafIterator eIt = problem_.gridView().template begin<0>(); eIt!=problem_.gridView().template end<0>(); ++eIt) { @@ -160,6 +163,19 @@ public: // this also refines the neighbor elements checkNeighborsRefine_(entity); } + if (adaptionIndicator_.coarsen(*eIt) && eIt->hasFather()) + { + int idx = idSet.id(*(eIt->father())); + std::map<int, int>::iterator it = coarsenMarker.find(idx); + if (it != coarsenMarker.end()) + { + it->second++; + } + else + { + coarsenMarker[idx] = 1; + } + } } // coarsen for (LeafIterator eIt = problem_.gridView().template begin<0>(); @@ -167,6 +183,8 @@ public: { if (adaptionIndicator_.coarsen(*eIt) && eIt->level() > levelMin_ && problem_.grid().getMark(*eIt) == 0) { + if (coarsenMarker[idSet.id(*(eIt->father()))] == eIt->geometry().corners()) + { // check if coarsening is possible bool coarsenPossible = true; LeafIntersectionIterator isend = problem_.gridView().iend(*eIt); @@ -186,6 +204,7 @@ public: problem_.grid().mark( -1, *eIt ); ++coarsened_; } + } } } diff --git a/dumux/decoupled/common/gridadaptproperties.hh b/dumux/decoupled/common/gridadaptproperties.hh index cd8e874041..08af9109cd 100644 --- a/dumux/decoupled/common/gridadaptproperties.hh +++ b/dumux/decoupled/common/gridadaptproperties.hh @@ -57,6 +57,12 @@ NEW_PROP_TAG(RefineTolerance); //! Tolerance for coarsening NEW_PROP_TAG(CoarsenTolerance); +//! Tolerance for refinement +NEW_PROP_TAG(RefineThreshold); + +//! Tolerance for coarsening +NEW_PROP_TAG(CoarsenThreshold); + //no adaptive grid SET_BOOL_PROP(GridAdaptTypeTag, AdaptiveGrid, false); @@ -65,6 +71,8 @@ SET_INT_PROP(GridAdaptTypeTag, MinLevel, 0); SET_INT_PROP(GridAdaptTypeTag, MaxLevel, 1); SET_SCALAR_PROP(GridAdaptTypeTag, RefineTolerance, 0.05); SET_SCALAR_PROP(GridAdaptTypeTag, CoarsenTolerance, 0.001); +SET_SCALAR_PROP(GridAdaptTypeTag, RefineThreshold, 0.0); +SET_SCALAR_PROP(GridAdaptTypeTag, CoarsenThreshold, 0.0); } // namespace Properties } // namespace Dumux -- GitLab