6#include <dune/common/typetraits.hh>
7#include <dune/geometry/referenceelement.hh>
8#include <dune/geometry/type.hh>
14 template <
class E,
class = std::
void_t<>>
22 struct ContextTypes<I, std::void_t<decltype(std::declval<I>().inside())>>
24 using Entity =
typename I::Entity;
30 using type =
typename Tag::type;
47 template <
class ContextType>
51 using IsIntersection = std::void_t<typename I::Entity, typename I::Geometry, typename I::LocalGeometry>;
54 using IsElement = std::void_t<typename E::Geometry, typename E::EntitySeed, typename E::LocalGeometry, typename E::HierarchicIterator>;
57 using Context = ContextType;
58 using Geometry =
typename Context::Geometry;
59 using LocalCoordinate =
typename Geometry::LocalCoordinate;
61 using Element =
typename Impl::ContextTypes<Context>::Entity;
62 using ElementGeometry =
typename Element::Geometry;
63 using ElementCoordinate =
typename ElementGeometry::LocalCoordinate;
66 static constexpr bool isEntity = Dune::Std::is_detected_v<IsElement,C>;
69 dim = ElementGeometry::mydimension,
70 dow = ElementGeometry::coorddimension
77 , elementGeometry_(&elementGeo)
99 return *elementGeometry_;
103 template <
class C = Context>
106 if constexpr(isEntity<C>)
107 return *elementGeometry_;
109 return context_->geometry();
113 template <
class C = Context>
116 if constexpr(isEntity<C>)
117 return Dune::referenceElement(*element_).geometry();
119 return context_->geometryInInside();
124 template <
class C = Context>
127 if constexpr(isEntity<C>)
130 return context_->geometryInInside().global(p);
134 template <
class C = Context>
135 auto global(LocalCoordinate
const& p)
const
141 Dune::GeometryType
type()
const
147 template <
class C = Context>
150 return geometry().integrationElement(p);
154 Context
const* context_;
155 Element
const* element_;
156 ElementGeometry
const* elementGeometry_;
165 using Element =
typename GV::template Codim<0>::Entity;
166 using Geometry =
typename Element::Geometry;
169 dim = GridView::dimension,
170 dow = GridView::dimensionworld
174 template <
class E,
class G>
177 , element_(Dune::wrap_or_move(FWD(
element)))
178 , geometry_(Dune::wrap_or_move(FWD(
geometry)))
202 std::shared_ptr<Element const> element_;
203 std::shared_ptr<Geometry const> geometry_;
Definition: ContextGeometry.hpp:162
GridView const & gridView() const
Return the GridView this context is bound to.
Definition: ContextGeometry.hpp:183
Geometry const & geometry() const
Return the geometry of the Element.
Definition: ContextGeometry.hpp:195
Element const & element() const
Return the bound element (entity of codim 0)
Definition: ContextGeometry.hpp:189
GlobalContext(GV const &gridView, E &&element, G &&geometry)
Constructor. Stores a copy of gridView and a pointer to element and geometry.
Definition: ContextGeometry.hpp:175
Wrapper class for element and geometry.
Definition: ContextGeometry.hpp:49
auto geometryInElement() const
Return the geometry relative to the element geometry. This can be either an identity,...
Definition: ContextGeometry.hpp:114
Dune::GeometryType type() const
Return the geometry-type of the local context.
Definition: ContextGeometry.hpp:141
Context const & context() const
Return the LocalContext, either the element or an intersection.
Definition: ContextGeometry.hpp:85
Element const & element() const
Return the bound element (entity of codim 0)
Definition: ContextGeometry.hpp:91
auto global(LocalCoordinate const &p) const
Coordinate p given in coordinates inside the context, transformed to coordinate in world space.
Definition: ContextGeometry.hpp:135
ContextGeometry(Context const &context, Element const &element, ElementGeometry const &elementGeo)
Constructor. Stores pointer to localContext, element, and geometry.
Definition: ContextGeometry.hpp:74
auto integrationElement(LocalCoordinate const &p) const
The integration element of the context geometry.
Definition: ContextGeometry.hpp:148
decltype(auto) geometry() const
Return the geometry of the Context.
Definition: ContextGeometry.hpp:104
ElementGeometry const & elementGeometry() const
Return the geometry of the Element.
Definition: ContextGeometry.hpp:97
auto coordinateInElement(LocalCoordinate const &p) const
Definition: ContextGeometry.hpp:125