6#include <dune/common/referencehelper.hh>
7#include <dune/functions/gridfunctions/gridviewentityset.hh>
9#include <amdis/common/TypeTraits.hpp>
10#include <amdis/Output.hpp>
28template <
class GV,
class GF>
29class [[deprecated(
"Use Dune::Functions::FineFunctionOnCoarseGridView instead")]]
34 using EntitySet = Dune::Functions::GridViewEntitySet<GV,0>;
37 using Domain =
typename EntitySet::GlobalCoordinate;
40 using Range = std::invoke_result_t<GF, Domain>;
46 using Element =
typename EntitySet::Element;
48 using Grid =
typename GV::Grid;
49 using Geometry =
typename Element::Geometry;
51 template <
class ES,
class LF>
59 using Mapping = std::function<Domain(Domain
const&)>;
61 typename Element::HierarchicIterator it;
68 : entitySet_(entitySet)
74 : entitySet_(entitySet)
75 , localFct_(std::move(localFct))
85 void bind(Element
const& element)
87 element_.emplace(element);
90 if (entitySet_.contains(*element_)) {
91 localFct_.bind(*element_);
95 test_exit_dbg(!element_->isLeaf(),
"Element is leaf. Cannot traverse its children.");
96 for (
auto it = element_->hbegin(maxLevel_); it != element_->hend(maxLevel_); ++it) {
97 if (entitySet_.contains(*it))
98 childs_.emplace_back(
ChildElement{.it=it, .local=makeMapping(*element_,*it)});
101 test_exit_dbg(!childs_.empty(),
"No child element in entitySet found!");
123 typename Grid::ctype
const checkInsideTolerance = std::sqrt(std::numeric_limits<typename Grid::ctype>::epsilon());
124 for (
auto const& child : childs_) {
125 auto refElem = referenceElement(*child.it);
126 auto local = child.local(x);
127 auto refTypeId = refElem.type().id();
128 bool isInside = Dune::Geo::Impl::checkInside(refTypeId, Geometry::mydimension, local, checkInsideTolerance);
130 localFct_.bind(*child.it);
131 return localFct_(local);
135 error_exit(
"No child element with x in child found!");
147 template <
class LF_ = LF>
152 entitySet_, derivative(localFct_)};
164 Mapping map = [](
Domain const& x) {
return x; };
165 while (coarse != fine && fine.hasFather()) {
166 map = [map, geo=fine.geometryInFather()](Domain
const& x) {
167 return map(geo.local(x));
169 fine = fine.father();
175 ES
const& entitySet_;
176 mutable LF localFct_;
178 std::optional<Element> element_;
180 std::vector<ChildElement> childs_;
190 : gridView_{gridView}
191 , entitySet_{gridView}
196 : gridView_{gridView}
197 , entitySet_{gridView}
198 , gridFct_{std::move(gridFct)}
208 template <
class GF_ = GF>
211 TYPEOF(derivative(Dune::resolveRef(std::declval<GF_ const&>())))>
213 return {gridView_, derivative(Dune::resolveRef(gridFct_))};
219 using LF = TYPEOF(localFunction(Dune::resolveRef(gridFct_)));
221 return LocalFunction{gridFct_.entitySet(),
222 localFunction(Dune::resolveRef(gridFct_)),
223 gridView_.grid().maxLevel()};
234 EntitySet entitySet_;
Definition CoarsenedGridFunction.hpp:53
auto makeDerivative() const -> CoarsenedLocalFunction< ES, TYPEOF(derivative(std::declval< LF_ const & >()))>
Construct a derivative by wrapping the derivative of the wrapped local-function.
Definition CoarsenedGridFunction.hpp:148
bool bound() const
Check whether the LocalFunction is bound to an element.
Definition CoarsenedGridFunction.hpp:111
Range operator()(Domain const &x) const
Evaluate LocalFunction at bound element.
Definition CoarsenedGridFunction.hpp:117
void bind(Element const &element)
Bind the wrapped local-function to grid element.
Definition CoarsenedGridFunction.hpp:85
CoarsenedLocalFunction(ES const &entitySet, LF const &localFct, int maxLevel)
Constructor. Stores the localFct by value.
Definition CoarsenedGridFunction.hpp:67
Element const & localContext() const
Return the element this LocalFunction is bound to.
Definition CoarsenedGridFunction.hpp:140
void unbind()
Unbind the wrapped local-function.
Definition CoarsenedGridFunction.hpp:105
A grid function defining data on a coarser entity level than it can be bound to.
Definition CoarsenedGridFunction.hpp:31
std::invoke_result_t< GF, Domain > Range
The result type of the function.
Definition CoarsenedGridFunction.hpp:40
auto makeDerivative() const -> CoarsenedGridFunction< GV, TYPEOF(derivative(Dune::resolveRef(std::declval< GF_ const & >())))>
Construct a derivative by wrapping the derivative of the wrapped grid-function.
Definition CoarsenedGridFunction.hpp:209
typename EntitySet::GlobalCoordinate Domain
The global coordinates.
Definition CoarsenedGridFunction.hpp:37
Range operator()(Domain const &x) const
Evaluate the wrapped grid-function.
Definition CoarsenedGridFunction.hpp:202
typename EntitySet::Element Element
Type of the grid element the LocalFunction can be bound to.
Definition CoarsenedGridFunction.hpp:46
auto makeLocalFunction() const
Construct local function from a DiscreteGlobalBasisFunction.
Definition CoarsenedGridFunction.hpp:217
EntitySet const & entitySet() const
Get associated EntitySet.
Definition CoarsenedGridFunction.hpp:227
typename EntitySet::LocalCoordinate LocalDomain
The local coordinates.
Definition CoarsenedGridFunction.hpp:43
CoarsenedGridFunction(GV const &gridView, GF const &gridFct)
Constructor.
Definition CoarsenedGridFunction.hpp:189
Dune::Functions::GridViewEntitySet< GV, 0 > EntitySet
The set of entities this function can be evaluated on.
Definition CoarsenedGridFunction.hpp:34
Definition CoarsenedGridFunction.hpp:60