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>
42 template<
int mydim,
int cdim >
45 using Type = Dune::ReservedVector< Dune::FieldVector< ct, cdim >, (1<<mydim)>;
54template <
class Gr
idView,
class ScvType,
class ScvfType>
57 using Scalar =
typename GridView::ctype;
58 using GlobalPosition =
typename Dune::FieldVector<Scalar, GridView::dimensionworld>;
59 using ScvCornerStorage =
typename ScvType::Traits::CornerStorage;
60 using ScvfCornerStorage =
typename ScvfType::Traits::CornerStorage;
61 using LocalIndexType =
typename ScvType::Traits::LocalIndexType;
63 using Element =
typename GridView::template Codim<0>::Entity;
64 using Intersection =
typename GridView::Intersection;
66 static constexpr auto dim = GridView::dimension;
67 static constexpr auto dimWorld = GridView::dimensionworld;
75 , boxHelper_(geometry)
81 return getScvCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localScvIdx);
85 template<
class Transformation>
86 static ScvCornerStorage
getScvCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localScvIdx)
89 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
90 const auto numBoxScv = ref.size(dim);
92 if (localScvIdx < numBoxScv)
93 return BoxHelper::getScvCorners(type, trans, localScvIdx);
95 DUNE_THROW(Dune::NotImplemented,
"PQ2 scv corners call for hybrid dofs");
101 const auto numBoxScv = boxHelper_.numScv();
103 if (localScvIdx < numBoxScv)
104 return Dune::GeometryTypes::cube(dim);
106 DUNE_THROW(Dune::NotImplemented,
"PQ2 scv geometry call for hybrid dofs");
112 return getScvfCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localScvfIdx);
116 template<
class Transformation>
117 static ScvfCornerStorage
getScvfCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localScvfIdx)
120 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
121 const auto numBoxScvf = ref.size(dim-1);
123 if (localScvfIdx < numBoxScvf)
124 return BoxHelper::getScvfCorners(type, trans, localScvfIdx);
126 DUNE_THROW(Dune::NotImplemented,
"PQ2 scvf corners call for hybrid dofs");
131 const auto numBoxScvf = boxHelper_.numInteriorScvf();
132 if (localScvfIdx < numBoxScvf)
133 return Dune::GeometryTypes::cube(dim-1);
135 DUNE_THROW(Dune::NotImplemented,
"PQ2 interior scvf geometry type call for hybrid dofs");
140 unsigned int indexInFacet)
const
142 return boxHelper_.getBoundaryScvfCorners(localFacetIndex, indexInFacet);
147 return Dune::GeometryTypes::cube(dim-1);
150 GlobalPosition
normal(
const ScvfCornerStorage& p,
const std::array<LocalIndexType, 2>& scvPair)
154 GlobalPosition v = geo_.corner(scvPair[1]) - geo_.corner(scvPair[0]);
170 return BoxHelper::numInteriorScvf(type);
176 return Dune::referenceElement<Scalar, dim>(type).size(localFacetIndex, 1, dim);
182 return boxHelper_.numScv();
186 Scalar
scvVolume(
unsigned int localScvIdx,
const ScvCornerStorage& p)
const
192 [&](
unsigned int i){
return p[i]; }
198 const auto numBoxFaces = boxHelper_.numInteriorScvf();
199 if (localScvfIndex < numBoxFaces)
202 static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localScvfIndex, dim-1, 0, dim)),
203 static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localScvfIndex, dim-1, 1, dim))
207 DUNE_THROW(Dune::NotImplemented,
"PQ2 scv pair call for hybrid dofs");
212 const auto numBoxScvf = referenceElement(geo_).size(localFacetIndex, 1, dim);
213 if (localIsScvfIndex < numBoxScvf)
215 const LocalIndexType insideScvIdx
216 =
static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localFacetIndex, 1, localIsScvfIndex, dim));
217 return { insideScvIdx, insideScvIdx };
220 DUNE_THROW(Dune::NotImplemented,
"PQ2 scv boundary pair call for hybrid dofs");
235 const typename Element::Geometry& geo_;
236 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:262
Dune::GeometryType getBoundaryScvfGeometryType(unsigned int localScvfIdx) const
Definition discretization/pq2/geometryhelper.hh:145
std::size_t numScv() const
number of sub control volumes (number of codim-1 entities)
Definition discretization/pq2/geometryhelper.hh:180
bool isOverlappingBoundaryScvf(unsigned int localFacetIndex) const
Definition discretization/pq2/geometryhelper.hh:227
ScvfCornerStorage getScvfCorners(unsigned int localScvfIdx) const
Create a vector with the corners of sub control volume faces.
Definition discretization/pq2/geometryhelper.hh:110
bool isOverlappingScvf(unsigned int localScvfIndex) const
Definition discretization/pq2/geometryhelper.hh:224
std::array< LocalIndexType, 2 > getScvPairForBoundaryScvf(unsigned int localFacetIndex, unsigned int localIsScvfIndex) const
Definition discretization/pq2/geometryhelper.hh:210
ScvCornerStorage getScvCorners(unsigned int localScvIdx) const
Create a vector with the scv corners.
Definition discretization/pq2/geometryhelper.hh:79
const Element::Geometry & elementGeometry() const
the wrapped element geometry
Definition discretization/pq2/geometryhelper.hh:164
std::array< LocalIndexType, 2 > getScvPairForScvf(unsigned int localScvfIndex) const
Definition discretization/pq2/geometryhelper.hh:196
static auto numInteriorScvf(Dune::GeometryType type)
number of interior sub control volume faces
Definition discretization/pq2/geometryhelper.hh:168
ScvfCornerStorage getBoundaryScvfCorners(unsigned int localFacetIndex, unsigned int indexInFacet) const
Create the sub control volume face geometries on the boundary.
Definition discretization/pq2/geometryhelper.hh:139
Scalar scvVolume(unsigned int localScvIdx, const ScvCornerStorage &p) const
get scv volume
Definition discretization/pq2/geometryhelper.hh:186
static auto numBoundaryScvf(Dune::GeometryType type, unsigned int localFacetIndex)
number of boundary sub control volume faces for face localFacetIndex
Definition discretization/pq2/geometryhelper.hh:174
Dumux::PQ2LagrangeDofHelper< GridView > DofHelper
Definition discretization/pq2/geometryhelper.hh:71
GlobalPosition normal(const ScvfCornerStorage &p, const std::array< LocalIndexType, 2 > &scvPair)
Definition discretization/pq2/geometryhelper.hh:150
Dune::GeometryType getInteriorScvfGeometryType(unsigned int localScvfIdx) const
Definition discretization/pq2/geometryhelper.hh:129
Dune::GeometryType getScvGeometryType(unsigned int localScvIdx) const
Definition discretization/pq2/geometryhelper.hh:98
bool isOverlappingScv(unsigned int localScvIndex) const
Definition discretization/pq2/geometryhelper.hh:231
HybridPQ2GeometryHelper(const typename Element::Geometry &geometry)
Definition discretization/pq2/geometryhelper.hh:73
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:117
static ScvCornerStorage getScvCorners(Dune::GeometryType type, Transformation &&trans, unsigned int localScvIdx)
Create a vector with the scv corners.
Definition discretization/pq2/geometryhelper.hh:86
auto scvfUnitNormal(const ElementGeometry &geo, const CornerStorage &corners)
Unit normal of an interior sub-control volume face, up to sign.
Definition scvfnormal.hh:33
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.
Normal vector of a sub-control volume face of an element-local dual grid.
DOF index and position helper for order-2 Lagrange discretizations.
Definition pq2/dofhelper.hh:36
Definition discretization/pq2/geometryhelper.hh:44
Dune::ReservedVector< Dune::FieldVector< ct, cdim >,(1<< mydim)> Type
Definition discretization/pq2/geometryhelper.hh:45
Traits for an efficient corner storage for the PQ2 method.
Definition discretization/pq2/geometryhelper.hh:39
Compute the volume of several common geometry types.