6 #include <dune/common/typetraits.hh> 7 #include <dune/geometry/type.hh> 13 template <
class E,
class = std::
void_t<>>
17 using LocalGeometry =
typename E::Geometry;
22 struct ContextTypes<I,
std::void_t<decltype(std::declval<I>().inside())>>
24 using Entity =
typename I::Entity;
25 using LocalGeometry =
typename I::LocalGeometry;
45 using ContextType = Impl::ContextTypes<LC>;
48 using LocalContext = LC;
49 using Element =
typename ContextType::Entity;
50 using Geometry =
typename Element::Geometry;
51 using LocalGeometry =
typename ContextType::LocalGeometry;
53 using IsEntity = std::is_same<Element, LocalContext>;
56 dim = Geometry::mydimension,
57 dow = Geometry::coorddimension
61 ContextGeometry(LC
const& localContext, Element
const& element, Geometry
const& geometry)
62 : localContext_(&localContext)
64 , geometry_(&geometry)
68 ContextGeometry(LC
const& localContext, Element
const& element, Geometry&& geometry) =
delete;
80 return *localContext_;
92 return localGeometry_impl(IsEntity{});
99 template <
class Coordinate>
100 decltype(
auto) local(Coordinate const& p)
const 102 return local_impl(p, IsEntity{});
106 template <
class Coordinate>
107 decltype(
auto) global(Coordinate const& p)
const 109 return geometry_->global(p);
113 Dune::GeometryType
type()
const 115 return localContext_->type();
120 template <
class Coordinate>
123 return localGeometry().integrationElement(p);
129 template <
class Coordinate>
130 Coordinate
const& local_impl(Coordinate
const& p, std::true_type)
const 136 template <
class Coordinate>
137 auto local_impl(Coordinate
const& p, std::false_type)
const 139 return localGeometry().global(p);
143 Geometry
const& localGeometry_impl(std::true_type)
const 149 LocalGeometry
const& localGeometry_impl(std::false_type)
const 152 localGeometry_.emplace(localContext_->geometryInInside());
154 return *localGeometry_;
158 LocalContext
const* localContext_;
159 Element
const* element_;
160 Geometry
const* geometry_;
163 mutable std::optional<LocalGeometry> localGeometry_;
172 using Element =
typename GV::template Codim<0>::Entity;
173 using Geometry =
typename Element::Geometry;
176 dim = GridView::dimension,
177 dow = GridView::dimensionworld
181 template <
class E,
class G>
183 : gridView_(gridView)
184 , element_(
Dune::wrap_or_move(FWD(element)))
185 , geometry_(
Dune::wrap_or_move(FWD(geometry)))
209 std::shared_ptr<Element const> element_;
210 std::shared_ptr<Geometry const> geometry_;
LocalGeometry const & localGeometry() const
Return the geometry of the element, or geometryInInside of the intersection.
Definition: ContextGeometry.hpp:90
GridView const & gridView() const
Return the GridView this context is bound to.
Definition: ContextGeometry.hpp:190
Definition: ContextGeometry.hpp:168
Definition: AdaptiveGrid.hpp:373
Element const & element() const
Return the bound element (entity of codim 0)
Definition: ContextGeometry.hpp:72
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:182
Geometry const & geometry() const
Return the geometry of the Element.
Definition: ContextGeometry.hpp:202
auto integrationElement(Coordinate const &p) const
Definition: ContextGeometry.hpp:121
Geometry const & geometry() const
Return the geometry of the Element.
Definition: ContextGeometry.hpp:84
Wrapper class for element and geometry.
Definition: ContextGeometry.hpp:43
LocalContext const & localContext() const
Return the LocalContext, either the element or an intersection.
Definition: ContextGeometry.hpp:78
Dune::GeometryType type() const
Return the geometry-type of the localContext.
Definition: ContextGeometry.hpp:113
Element const & element() const
Return the bound element (entity of codim 0)
Definition: ContextGeometry.hpp:196
ContextGeometry(LC const &localContext, Element const &element, Geometry const &geometry)
Constructor. Stores pointer to localContext, element, and geometry.
Definition: ContextGeometry.hpp:61