20#ifndef DUMUX_DISCRETIZATION_PQ3_GEOMETRY_HELPER_HH
21#define DUMUX_DISCRETIZATION_PQ3_GEOMETRY_HELPER_HH
25#include <dune/common/exceptions.hh>
26#include <dune/geometry/type.hh>
27#include <dune/geometry/referenceelements.hh>
28#include <dune/geometry/multilineargeometry.hh>
29#include <dune/common/reservedvector.hh>
48template <
class Gr
idView,
class ScvType,
class ScvfType>
51 using Scalar =
typename GridView::ctype;
52 using GlobalPosition =
typename Dune::FieldVector<Scalar, GridView::dimensionworld>;
53 using ScvCornerStorage =
typename ScvType::Traits::CornerStorage;
54 using ScvfCornerStorage =
typename ScvfType::Traits::CornerStorage;
55 using LocalIndexType =
typename ScvType::Traits::LocalIndexType;
57 using Element =
typename GridView::template Codim<0>::Entity;
58 using Intersection =
typename GridView::Intersection;
60 static constexpr auto dim = GridView::dimension;
61 static constexpr auto dimWorld = GridView::dimensionworld;
69 , boxHelper_(geometry)
75 return getScvCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localScvIdx);
79 template<
class Transformation>
80 static ScvCornerStorage
getScvCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localScvIdx)
82 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
83 const auto numBoxScv = ref.size(dim);
84 if (localScvIdx < numBoxScv)
85 return BoxHelper::getScvCorners(type, trans, localScvIdx);
87 DUNE_THROW(Dune::NotImplemented,
"PQ3 scv corners call for hybrid dofs");
92 const auto numBoxScv = boxHelper_.numScv();
93 if (localScvIdx < numBoxScv)
94 return Dune::GeometryTypes::cube(dim);
96 DUNE_THROW(Dune::NotImplemented,
"PQ3 scv geometry call for hybrid dofs");
102 return getScvfCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localScvfIdx);
106 template<
class Transformation>
107 static ScvfCornerStorage
getScvfCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localScvfIdx)
109 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
110 const auto numBoxScvf = ref.size(dim-1);
111 if (localScvfIdx < numBoxScvf)
112 return BoxHelper::getScvfCorners(type, trans, localScvfIdx);
114 DUNE_THROW(Dune::NotImplemented,
"PQ3 scvf corners call for hybrid dofs");
119 const auto numBoxScvf = boxHelper_.numInteriorScvf();
120 if (localScvfIdx < numBoxScvf)
121 return Dune::GeometryTypes::cube(dim-1);
123 DUNE_THROW(Dune::NotImplemented,
"PQ3 interior scvf geometry type call for hybrid dofs");
129 return boxHelper_.getBoundaryScvfCorners(localFacetIndex, indexInFacet);
134 return Dune::GeometryTypes::cube(dim-1);
137 GlobalPosition
normal(
const ScvfCornerStorage& p,
const std::array<LocalIndexType, 2>& scvPair)
141 GlobalPosition v = geo_.corner(scvPair[1]) - geo_.corner(scvPair[0]);
157 return BoxHelper::numInteriorScvf(type);
163 return Dune::referenceElement<Scalar, dim>(type).size(localFacetIndex, 1, dim);
169 return boxHelper_.numScv();
173 Scalar
scvVolume(
unsigned int localScvIdx,
const ScvCornerStorage& p)
const
178 [&](
unsigned int i){
return p[i]; }
184 const auto numBoxFaces = boxHelper_.numInteriorScvf();
185 if (localScvfIndex < numBoxFaces)
188 static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localScvfIndex, dim-1, 0, dim)),
189 static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localScvfIndex, dim-1, 1, dim))
193 DUNE_THROW(Dune::NotImplemented,
"PQ3 scv pair call for hybrid dofs");
198 const auto numBoxScvf = referenceElement(geo_).size(localFacetIndex, 1, dim);
199 if (localIsScvfIndex < numBoxScvf)
201 const LocalIndexType insideScvIdx
202 =
static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localFacetIndex, 1, localIsScvfIndex, dim));
203 return { insideScvIdx, insideScvIdx };
206 DUNE_THROW(Dune::NotImplemented,
"PQ3 scv boundary pair call for hybrid dofs");
219 const typename Element::Geometry& geo_;
220 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/pq3/geometryhelper.hh:132
std::array< LocalIndexType, 2 > getScvPairForBoundaryScvf(unsigned int localFacetIndex, unsigned int localIsScvfIndex) const
Definition discretization/pq3/geometryhelper.hh:196
bool isOverlappingBoundaryScvf(unsigned int localFacetIndex) const
Definition discretization/pq3/geometryhelper.hh:212
HybridPQ3GeometryHelper(const typename Element::Geometry &geometry)
Definition discretization/pq3/geometryhelper.hh:67
bool isOverlappingScvf(unsigned int localScvfIndex) const
Definition discretization/pq3/geometryhelper.hh:209
ScvfCornerStorage getScvfCorners(unsigned int localScvfIdx) const
Create a vector with the corners of sub control volume faces.
Definition discretization/pq3/geometryhelper.hh:100
bool isOverlappingScv(unsigned int localScvIndex) const
Definition discretization/pq3/geometryhelper.hh:215
ScvCornerStorage getScvCorners(unsigned int localScvIdx) const
Create a vector with the scv corners.
Definition discretization/pq3/geometryhelper.hh:73
GlobalPosition normal(const ScvfCornerStorage &p, const std::array< LocalIndexType, 2 > &scvPair)
Definition discretization/pq3/geometryhelper.hh:137
std::size_t numScv() const
number of sub control volumes (one per vertex)
Definition discretization/pq3/geometryhelper.hh:167
Dune::GeometryType getInteriorScvfGeometryType(unsigned int localScvfIdx) const
Definition discretization/pq3/geometryhelper.hh:117
Dune::GeometryType getScvGeometryType(unsigned int localScvIdx) const
Definition discretization/pq3/geometryhelper.hh:90
ScvfCornerStorage getBoundaryScvfCorners(unsigned int localFacetIndex, unsigned int indexInFacet) const
Create the sub control volume face geometries on the boundary.
Definition discretization/pq3/geometryhelper.hh:127
Scalar scvVolume(unsigned int localScvIdx, const ScvCornerStorage &p) const
get scv volume
Definition discretization/pq3/geometryhelper.hh:173
const Element::Geometry & elementGeometry() const
the wrapped element geometry
Definition discretization/pq3/geometryhelper.hh:151
std::array< LocalIndexType, 2 > getScvPairForScvf(unsigned int localScvfIndex) const
Definition discretization/pq3/geometryhelper.hh:182
PQ3LagrangeDofHelper< GridView > DofHelper
Definition discretization/pq3/geometryhelper.hh:65
static ScvfCornerStorage getScvfCorners(Dune::GeometryType type, Transformation &&trans, unsigned int localScvfIdx)
Create a vector with the corners of sub control volume faces.
Definition discretization/pq3/geometryhelper.hh:107
static auto numInteriorScvf(Dune::GeometryType type)
number of interior sub control volume faces
Definition discretization/pq3/geometryhelper.hh:155
static auto numBoundaryScvf(Dune::GeometryType type, unsigned int localFacetIndex)
number of boundary sub control volume faces for face localFacetIndex
Definition discretization/pq3/geometryhelper.hh:161
static ScvCornerStorage getScvCorners(Dune::GeometryType type, Transformation &&trans, unsigned int localScvIdx)
Create a vector with the scv corners.
Definition discretization/pq3/geometryhelper.hh:80
DOF index and position helper for order-3 Lagrange discretizations.
Definition pq3/dofhelper.hh:51
Helper class constructing the dual grid finite volume geometries for the cvfe discretizazion method.
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
Define some often used mathematical functions.
Lightweight DOF helper for order-3 Lagrange elements.
Normal vector of a sub-control volume face of an element-local dual grid.
Compute the volume of several common geometry types.