7#ifndef DUNE_FUNCTIONS_COMMON_GEOMETRYINANCESTOR_HH
8#define DUNE_FUNCTIONS_COMMON_GEOMETRYINANCESTOR_HH
12#include <dune/common/iteratorrange.hh>
14namespace Dune::Functions {
37template<
class Element>
40 using GeometryInFather =
typename Element::LocalGeometry;
43 static auto reverse_view(V&& v)
45 return Dune::IteratorRange(v.rbegin(), v.rend());
67 : storedFineElement_(other.storedFineElement_)
68 , storedCoarseElement_(other.storedCoarseElement_)
69 , fineElementPtr_(&storedFineElement_)
70 , coarseElementPtr_(&storedFineElement_)
71 , geometryInFathersVector_(other.geometryInFathersVector_)
75 if (other.fineElementPtr_ != & other.storedFineElement_)
76 fineElementPtr_ = other.fineElementPtr_;
79 if (other.coarseElementPtr_ != & other.storedCoarseElement_)
80 coarseElementPtr_ = fineElementPtr_;
90 : storedFineElement_(other.storedFineElement_)
91 , storedCoarseElement_(other.storedCoarseElement_)
93 , coarseElementPtr_(&storedFineElement_)
94 , geometryInFathersVector_(other.geometryInFathersVector_)
98 if (other.coarseElementPtr_ != & other.storedCoarseElement_)
99 coarseElementPtr_ = fineElementPtr_;
118 requires (std::is_invocable_r_v<bool,F,Element>)
122 geometryInFathersVector_.clear();
123 coarseElementPtr_ = fineElementPtr_;
124 while (includeFather(*coarseElementPtr_))
126 geometryInFathersVector_.push_back(coarseElementPtr_->geometryInFather());
127 storedCoarseElement_ = coarseElementPtr_->father();
128 coarseElementPtr_ = &storedCoarseElement_;
149 requires (std::is_invocable_r_v<bool,F,Element>)
153 bind(storedFineElement_, includeFather);
159 return *fineElementPtr_;
165 return *coarseElementPtr_;
171 for (
const auto& g : geometryInFathersVector_)
181 for (
const auto& g : reverse_view(geometryInFathersVector_))
187 Element storedFineElement_;
188 Element storedCoarseElement_;
189 const Element* fineElementPtr_ =
nullptr;
190 const Element* coarseElementPtr_ =
nullptr;
191 std::vector<GeometryInFather> geometryInFathersVector_;
A geometry embedding a descendent element into an ancestor.
Definition: geometryinancestor.hh:39
GeometryInAncestor(const GeometryInAncestor &other, const Element &fineElement)
Copy construction setting an external fine element.
Definition: geometryinancestor.hh:89
const Element & fineElement() const
Return the fine element.
Definition: geometryinancestor.hh:157
GlobalCoordinate global(LocalCoordinate x) const
Map local coordinate in fine element into coarse element.
Definition: geometryinancestor.hh:169
const Element & bind(const Element &fineElement, F &&includeFather)
Bind this GeometryInAncestor to a fine element and search coarse element.
Definition: geometryinancestor.hh:119
const Element & coarseElement() const
Return the coarse element.
Definition: geometryinancestor.hh:163
GeometryInAncestor(const GeometryInAncestor &other)
Copy constructor.
Definition: geometryinancestor.hh:66
LocalCoordinate local(GlobalCoordinate x) const
Map local coordinate in coarse element into fine element.
Definition: geometryinancestor.hh:177
typename Element::Geometry::LocalCoordinate LocalCoordinate
Type of local coordinate (local within fine element)
Definition: geometryinancestor.hh:51
typename Element::Geometry::LocalCoordinate GlobalCoordinate
Type of global coordinate (local within coarse element)
Definition: geometryinancestor.hh:54
const Element & bind(Element &&fineElement, F &&includeFather)
Bind this GeometryInAncestor to a fine element and search coarse element.
Definition: geometryinancestor.hh:150