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
74 ContextGeometry(Context
const& context, Element
const& element, ElementGeometry
const& elementGeo)
77 , elementGeometry_(&elementGeo)
81 ContextGeometry(Context
const& context, Element
const& element, ElementGeometry&& elementGeo) =
delete;
99 return *elementGeometry_;
103 template <
class C = Context>
104 decltype(
auto) geometry()
const 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 137 return geometry().global(p);
141 Dune::GeometryType
type()
const 143 return context().type();
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>
176 : gridView_(gridView)
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_;
GridView const & gridView() const
Return the GridView this context is bound to.
Definition: ContextGeometry.hpp:183
Definition: ContextGeometry.hpp:161
Definition: AdaptiveGrid.hpp:393
Element const & element() const
Return the bound element (entity of codim 0)
Definition: ContextGeometry.hpp:91
Definition: FieldMatVec.hpp:12
Definition: AdaptBase.hpp:6
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
Geometry const & geometry() const
Return the geometry of the Element.
Definition: ContextGeometry.hpp:195
auto geometryInElement() const
Return the geometry relative to the element geometry. This can be either an identity, or geometryInInside of the intersection.
Definition: ContextGeometry.hpp:114
ContextGeometry(Context const &context, Element const &element, ElementGeometry const &elementGeo)
Constructor. Stores pointer to localContext, element, and geometry.
Definition: ContextGeometry.hpp:74
Context const & context() const
Return the LocalContext, either the element or an intersection.
Definition: ContextGeometry.hpp:85
auto global(LocalCoordinate const &p) const
Coordinate p given in coordinates inside the context, transformed to coordinate in world space...
Definition: ContextGeometry.hpp:135
Wrapper class for element and geometry.
Definition: ContextGeometry.hpp:48
ElementGeometry const & elementGeometry() const
Return the geometry of the Element.
Definition: ContextGeometry.hpp:97
auto coordinateInElement(LocalCoordinate const &p) const
Definition: ContextGeometry.hpp:125
Dune::GeometryType type() const
Return the geometry-type of the local context.
Definition: ContextGeometry.hpp:141
auto integrationElement(LocalCoordinate const &p) const
The integration element of the context geometry.
Definition: ContextGeometry.hpp:148
Element const & element() const
Return the bound element (entity of codim 0)
Definition: ContextGeometry.hpp:189