73 std::shared_ptr<const GridGeometry> gridGeometry,
74 std::shared_ptr<const GridVariables> gridVariables)
76 , gridGeometry_(gridGeometry)
77 , gridVariables_(gridVariables)
80 , refineAtDirichletBC_(
getParamFromGroup<bool>(problem->paramGroup(),
"Adaptive.RefineAtDirichletBC", true))
81 , refineAtFluxBC_(
getParamFromGroup<bool>(problem->paramGroup(),
"Adaptive.RefineAtFluxBC", true))
82 , refineAtSource_(
getParamFromGroup<bool>(problem->paramGroup(),
"Adaptive.RefineAtSource", true))
83 , eps_(
getParamFromGroup<Scalar>(problem->paramGroup(),
"Adaptive.BCRefinementThreshold", 1e-10))
144 indicatorVector_.assign(gridGeometry_->gridView().size(0),
false);
146 for (
const auto& element : elements(gridGeometry_->gridView()))
148 const auto eIdx = gridGeometry_->elementMapper().index(element);
151 if (element.level() < minLevel_)
153 indicatorVector_[eIdx] =
true;
158 if (!refineAtSource_ && !refineAtFluxBC_ && !refineAtDirichletBC_)
162 if (element.level() == maxLevel_)
166 auto fvGeometry =
localView(*gridGeometry_);
167 fvGeometry.bind(element);
169 auto elemVolVars =
localView(gridVariables_->curGridVolVars());
170 elemVolVars.bind(element, fvGeometry, sol);
173 auto elemFluxVarsCache =
localView(gridVariables_->gridFluxVarsCache());
174 elemFluxVarsCache.bind(element, fvGeometry, elemVolVars);
179 for (
const auto& scv : scvs(fvGeometry))
181 auto source = problem_->source(element, fvGeometry, elemVolVars, scv);
182 auto pointSource = problem_->scvPointSources(element, fvGeometry, elemVolVars, scv);
183 if (source.infinity_norm() + pointSource.infinity_norm() > eps_)
185 indicatorVector_[eIdx] =
true;
192 if (!indicatorVector_[eIdx]
193 && element.hasBoundaryIntersections()
194 && (refineAtDirichletBC_ || refineAtFluxBC_))
199 for (
const auto& scvf : scvfs(fvGeometry))
202 if (!scvf.boundary())
205 const auto bcTypes = problem_->boundaryTypes(element, scvf);
207 if(bcTypes.hasOnlyDirichlet() && refineAtDirichletBC_)
209 indicatorVector_[eIdx] =
true;
214 else if(refineAtFluxBC_)
216 const auto fluxes = problem_->neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
217 if (fluxes.infinity_norm() > eps_)
219 indicatorVector_[eIdx] =
true;
229 std::vector<BoundaryTypes> bcTypes(fvGeometry.numScv());
232 for (
const auto& scv : scvs(fvGeometry))
234 bcTypes[scv.localDofIndex()] = problem_->boundaryTypes(element, scv);
235 if (refineAtDirichletBC_ && bcTypes[scv.localDofIndex()].hasDirichlet())
237 indicatorVector_[eIdx] =
true;
243 if (!indicatorVector_[eIdx] && refineAtFluxBC_)
245 for (
const auto& scvf : scvfs(fvGeometry))
248 if (scvf.boundary() && bcTypes[scvf.insideScvIdx()].hasNeumann())
250 const auto fluxes = problem_->neumann(element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
251 if (fluxes.infinity_norm() > eps_)
253 indicatorVector_[eIdx] =
true;