13#ifndef DUMUX_DISCRETIZATION_PQ2_GEOMETRY_HELPER_HH
14#define DUMUX_DISCRETIZATION_PQ2_GEOMETRY_HELPER_HH
19#include <dune/common/exceptions.hh>
21#include <dune/geometry/type.hh>
22#include <dune/geometry/referenceelements.hh>
23#include <dune/geometry/multilineargeometry.hh>
24#include <dune/common/reservedvector.hh>
41 template<
int mydim,
int cdim >
44 using Type = Dune::ReservedVector< Dune::FieldVector< ct, cdim >, (1<<mydim)>;
53template <
class Gr
idView,
class ScvType,
class ScvfType>
56 using Scalar =
typename GridView::ctype;
57 using GlobalPosition =
typename Dune::FieldVector<Scalar, GridView::dimensionworld>;
58 using ScvCornerStorage =
typename ScvType::Traits::CornerStorage;
59 using ScvfCornerStorage =
typename ScvfType::Traits::CornerStorage;
60 using LocalIndexType =
typename ScvType::Traits::LocalIndexType;
62 using Element =
typename GridView::template Codim<0>::Entity;
63 using Intersection =
typename GridView::Intersection;
65 static constexpr auto dim = GridView::dimension;
66 static constexpr auto dimWorld = GridView::dimensionworld;
74 , boxHelper_(geometry)
80 return getScvCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localScvIdx);
84 template<
class Transformation>
85 static ScvCornerStorage
getScvCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localScvIdx)
88 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
89 const auto numBoxScv = ref.size(dim);
91 if (localScvIdx < numBoxScv)
92 return BoxHelper::getScvCorners(type, trans, localScvIdx);
94 DUNE_THROW(Dune::NotImplemented,
"PQ2 scv corners call for hybrid dofs");
100 const auto numBoxScv = boxHelper_.numScv();
102 if (localScvIdx < numBoxScv)
103 return Dune::GeometryTypes::cube(dim);
105 DUNE_THROW(Dune::NotImplemented,
"PQ2 scv geometry call for hybrid dofs");
111 return getScvfCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localScvfIdx);
115 template<
class Transformation>
116 static ScvfCornerStorage
getScvfCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localScvfIdx)
119 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
120 const auto numBoxScvf = ref.size(dim-1);
122 if (localScvfIdx < numBoxScvf)
123 return BoxHelper::getScvfCorners(type, trans, localScvfIdx);
125 DUNE_THROW(Dune::NotImplemented,
"PQ2 scvf corners call for hybrid dofs");
130 const auto numBoxScvf = boxHelper_.numInteriorScvf();
131 if (localScvfIdx < numBoxScvf)
132 return Dune::GeometryTypes::cube(dim-1);
134 DUNE_THROW(Dune::NotImplemented,
"PQ2 interior scvf geometry type call for hybrid dofs");
139 unsigned int indexInFacet)
const
141 return boxHelper_.getBoundaryScvfCorners(localFacetIndex, indexInFacet);
146 return Dune::GeometryTypes::cube(dim-1);
149 template<
int d = dimWorld, std::enable_if_t<(d==3),
int> = 0>
150 GlobalPosition
normal(
const ScvfCornerStorage& p,
const std::array<LocalIndexType, 2>& scvPair)
155 GlobalPosition v = geo_.corner(scvPair[1]) - geo_.corner(scvPair[0]);
164 template<
int d = dimWorld, std::enable_if_t<(d==2),
int> = 0>
165 GlobalPosition
normal(
const ScvfCornerStorage& p,
const std::array<LocalIndexType, 2>& scvPair)
168 const auto t = p[1] - p[0];
169 GlobalPosition
normal({-t[1], t[0]});
172 GlobalPosition v = geo_.corner(scvPair[1]) - geo_.corner(scvPair[0]);
188 return BoxHelper::numInteriorScvf(type);
194 return Dune::referenceElement<Scalar, dim>(type).size(localFacetIndex, 1, dim);
200 return boxHelper_.numScv();
204 Scalar
scvVolume(
unsigned int localScvIdx,
const ScvCornerStorage& p)
const
210 [&](
unsigned int i){
return p[i]; }
216 const auto numBoxFaces = boxHelper_.numInteriorScvf();
217 if (localScvfIndex < numBoxFaces)
220 static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localScvfIndex, dim-1, 0, dim)),
221 static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localScvfIndex, dim-1, 1, dim))
225 DUNE_THROW(Dune::NotImplemented,
"PQ2 scv pair call for hybrid dofs");
230 const auto numBoxScvf = referenceElement(geo_).size(localFacetIndex, 1, dim);
231 if (localIsScvfIndex < numBoxScvf)
233 const LocalIndexType insideScvIdx
234 =
static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localFacetIndex, 1, localIsScvfIndex, dim));
235 return { insideScvIdx, insideScvIdx };
238 DUNE_THROW(Dune::NotImplemented,
"PQ2 scv boundary pair call for hybrid dofs");
253 const typename Element::Geometry& geo_;
254 BoxHelper boxHelper_;
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Create sub control volumes and sub control volume face geometries.
Definition boxgeometryhelper.hh:261
Dune::GeometryType getBoundaryScvfGeometryType(unsigned int localScvfIdx) const
Definition discretization/pq2/geometryhelper.hh:144
std::size_t numScv() const
number of sub control volumes (number of codim-1 entities)
Definition discretization/pq2/geometryhelper.hh:198
bool isOverlappingBoundaryScvf(unsigned int localFacetIndex) const
Definition discretization/pq2/geometryhelper.hh:245
ScvfCornerStorage getScvfCorners(unsigned int localScvfIdx) const
Create a vector with the corners of sub control volume faces.
Definition discretization/pq2/geometryhelper.hh:109
bool isOverlappingScvf(unsigned int localScvfIndex) const
Definition discretization/pq2/geometryhelper.hh:242
std::array< LocalIndexType, 2 > getScvPairForBoundaryScvf(unsigned int localFacetIndex, unsigned int localIsScvfIndex) const
Definition discretization/pq2/geometryhelper.hh:228
ScvCornerStorage getScvCorners(unsigned int localScvIdx) const
Create a vector with the scv corners.
Definition discretization/pq2/geometryhelper.hh:78
const Element::Geometry & elementGeometry() const
the wrapped element geometry
Definition discretization/pq2/geometryhelper.hh:182
std::array< LocalIndexType, 2 > getScvPairForScvf(unsigned int localScvfIndex) const
Definition discretization/pq2/geometryhelper.hh:214
static auto numInteriorScvf(Dune::GeometryType type)
number of interior sub control volume faces
Definition discretization/pq2/geometryhelper.hh:186
ScvfCornerStorage getBoundaryScvfCorners(unsigned int localFacetIndex, unsigned int indexInFacet) const
Create the sub control volume face geometries on the boundary.
Definition discretization/pq2/geometryhelper.hh:138
Scalar scvVolume(unsigned int localScvIdx, const ScvCornerStorage &p) const
get scv volume
Definition discretization/pq2/geometryhelper.hh:204
static auto numBoundaryScvf(Dune::GeometryType type, unsigned int localFacetIndex)
number of boundary sub control volume faces for face localFacetIndex
Definition discretization/pq2/geometryhelper.hh:192
Dumux::PQ2LagrangeDofHelper< GridView > DofHelper
Definition discretization/pq2/geometryhelper.hh:70
Dune::GeometryType getInteriorScvfGeometryType(unsigned int localScvfIdx) const
Definition discretization/pq2/geometryhelper.hh:128
Dune::GeometryType getScvGeometryType(unsigned int localScvIdx) const
Definition discretization/pq2/geometryhelper.hh:97
GlobalPosition normal(const ScvfCornerStorage &p, const std::array< LocalIndexType, 2 > &scvPair)
Definition discretization/pq2/geometryhelper.hh:150
bool isOverlappingScv(unsigned int localScvIndex) const
Definition discretization/pq2/geometryhelper.hh:249
HybridPQ2GeometryHelper(const typename Element::Geometry &geometry)
Definition discretization/pq2/geometryhelper.hh:72
static ScvfCornerStorage getScvfCorners(Dune::GeometryType type, Transformation &&trans, unsigned int localScvfIdx)
Create a vector with the corners of sub control volume faces.
Definition discretization/pq2/geometryhelper.hh:116
static ScvCornerStorage getScvCorners(Dune::GeometryType type, Transformation &&trans, unsigned int localScvIdx)
Create a vector with the scv corners.
Definition discretization/pq2/geometryhelper.hh:85
Dune::FieldVector< Scalar, 3 > crossProduct(const Dune::FieldVector< Scalar, 3 > &vec1, const Dune::FieldVector< Scalar, 3 > &vec2)
Cross product of two vectors in three-dimensional Euclidean space.
Definition math.hh:671
auto convexPolytopeVolume(Dune::GeometryType type, const CornerF &c)
Compute the volume of several common geometry types.
Definition volume.hh:41
Class representing dofs on elements for control-volume finite element schemes.
Define some often used mathematical functions.
Lightweight DOF helper for order-2 Lagrange elements.
DOF index and position helper for order-2 Lagrange discretizations.
Definition pq2/dofhelper.hh:36
Definition discretization/pq2/geometryhelper.hh:43
Dune::ReservedVector< Dune::FieldVector< ct, cdim >,(1<< mydim)> Type
Definition discretization/pq2/geometryhelper.hh:44
Traits for an efficient corner storage for the PQ2 method.
Definition discretization/pq2/geometryhelper.hh:38
Compute the volume of several common geometry types.