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>
51template <
class Gr
idView,
class ScvType,
class ScvfType>
54 using Scalar =
typename GridView::ctype;
55 using GlobalPosition =
typename Dune::FieldVector<Scalar, GridView::dimensionworld>;
56 using ScvCornerStorage =
typename ScvType::Traits::CornerStorage;
57 using ScvfCornerStorage =
typename ScvfType::Traits::CornerStorage;
58 using LocalIndexType =
typename ScvType::Traits::LocalIndexType;
60 using Element =
typename GridView::template Codim<0>::Entity;
61 using Intersection =
typename GridView::Intersection;
63 static constexpr auto dim = GridView::dimension;
64 static constexpr auto dimWorld = GridView::dimensionworld;
72 , boxHelper_(geometry)
78 return getScvCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localScvIdx);
82 template<
class Transformation>
83 static ScvCornerStorage
getScvCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localScvIdx)
85 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
86 const auto numBoxScv = ref.size(dim);
87 if (localScvIdx < numBoxScv)
88 return BoxHelper::getScvCorners(type, trans, localScvIdx);
90 DUNE_THROW(Dune::NotImplemented,
"PQ3 scv corners call for hybrid dofs");
95 const auto numBoxScv = boxHelper_.numScv();
96 if (localScvIdx < numBoxScv)
97 return Dune::GeometryTypes::cube(dim);
99 DUNE_THROW(Dune::NotImplemented,
"PQ3 scv geometry call for hybrid dofs");
105 return getScvfCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localScvfIdx);
109 template<
class Transformation>
110 static ScvfCornerStorage
getScvfCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localScvfIdx)
112 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
113 const auto numBoxScvf = ref.size(dim-1);
114 if (localScvfIdx < numBoxScvf)
115 return BoxHelper::getScvfCorners(type, trans, localScvfIdx);
117 DUNE_THROW(Dune::NotImplemented,
"PQ3 scvf corners call for hybrid dofs");
122 const auto numBoxScvf = boxHelper_.numInteriorScvf();
123 if (localScvfIdx < numBoxScvf)
124 return Dune::GeometryTypes::cube(dim-1);
126 DUNE_THROW(Dune::NotImplemented,
"PQ3 interior scvf geometry type call for hybrid dofs");
132 return boxHelper_.getBoundaryScvfCorners(localFacetIndex, indexInFacet);
137 return Dune::GeometryTypes::cube(dim-1);
140 template<
int d = dimWorld, std::enable_if_t<(d==3),
int> = 0>
141 GlobalPosition
normal(
const ScvfCornerStorage& p,
const std::array<LocalIndexType, 2>& scvPair)
146 GlobalPosition v = geo_.corner(scvPair[1]) - geo_.corner(scvPair[0]);
155 template<
int d = dimWorld, std::enable_if_t<(d==2),
int> = 0>
156 GlobalPosition
normal(
const ScvfCornerStorage& p,
const std::array<LocalIndexType, 2>& scvPair)
158 const auto t = p[1] - p[0];
159 GlobalPosition
normal({-t[1], t[0]});
162 GlobalPosition v = geo_.corner(scvPair[1]) - geo_.corner(scvPair[0]);
178 return BoxHelper::numInteriorScvf(type);
184 return Dune::referenceElement<Scalar, dim>(type).size(localFacetIndex, 1, dim);
190 return boxHelper_.numScv();
194 Scalar
scvVolume(
unsigned int localScvIdx,
const ScvCornerStorage& p)
const
199 [&](
unsigned int i){
return p[i]; }
205 const auto numBoxFaces = boxHelper_.numInteriorScvf();
206 if (localScvfIndex < numBoxFaces)
209 static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localScvfIndex, dim-1, 0, dim)),
210 static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localScvfIndex, dim-1, 1, dim))
214 DUNE_THROW(Dune::NotImplemented,
"PQ3 scv pair call for hybrid dofs");
219 const auto numBoxScvf = referenceElement(geo_).size(localFacetIndex, 1, dim);
220 if (localIsScvfIndex < numBoxScvf)
222 const LocalIndexType insideScvIdx
223 =
static_cast<LocalIndexType
>(referenceElement(geo_).subEntity(localFacetIndex, 1, localIsScvfIndex, dim));
224 return { insideScvIdx, insideScvIdx };
227 DUNE_THROW(Dune::NotImplemented,
"PQ3 scv boundary pair call for hybrid dofs");
240 const typename Element::Geometry& geo_;
241 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/pq3/geometryhelper.hh:135
std::array< LocalIndexType, 2 > getScvPairForBoundaryScvf(unsigned int localFacetIndex, unsigned int localIsScvfIndex) const
Definition discretization/pq3/geometryhelper.hh:217
bool isOverlappingBoundaryScvf(unsigned int localFacetIndex) const
Definition discretization/pq3/geometryhelper.hh:233
HybridPQ3GeometryHelper(const typename Element::Geometry &geometry)
Definition discretization/pq3/geometryhelper.hh:70
bool isOverlappingScvf(unsigned int localScvfIndex) const
Definition discretization/pq3/geometryhelper.hh:230
ScvfCornerStorage getScvfCorners(unsigned int localScvfIdx) const
Create a vector with the corners of sub control volume faces.
Definition discretization/pq3/geometryhelper.hh:103
bool isOverlappingScv(unsigned int localScvIndex) const
Definition discretization/pq3/geometryhelper.hh:236
ScvCornerStorage getScvCorners(unsigned int localScvIdx) const
Create a vector with the scv corners.
Definition discretization/pq3/geometryhelper.hh:76
GlobalPosition normal(const ScvfCornerStorage &p, const std::array< LocalIndexType, 2 > &scvPair)
Definition discretization/pq3/geometryhelper.hh:141
std::size_t numScv() const
number of sub control volumes (one per vertex)
Definition discretization/pq3/geometryhelper.hh:188
Dune::GeometryType getInteriorScvfGeometryType(unsigned int localScvfIdx) const
Definition discretization/pq3/geometryhelper.hh:120
Dune::GeometryType getScvGeometryType(unsigned int localScvIdx) const
Definition discretization/pq3/geometryhelper.hh:93
ScvfCornerStorage getBoundaryScvfCorners(unsigned int localFacetIndex, unsigned int indexInFacet) const
Create the sub control volume face geometries on the boundary.
Definition discretization/pq3/geometryhelper.hh:130
Scalar scvVolume(unsigned int localScvIdx, const ScvCornerStorage &p) const
get scv volume
Definition discretization/pq3/geometryhelper.hh:194
const Element::Geometry & elementGeometry() const
the wrapped element geometry
Definition discretization/pq3/geometryhelper.hh:172
std::array< LocalIndexType, 2 > getScvPairForScvf(unsigned int localScvfIndex) const
Definition discretization/pq3/geometryhelper.hh:203
PQ3LagrangeDofHelper< GridView > DofHelper
Definition discretization/pq3/geometryhelper.hh:68
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:110
static auto numInteriorScvf(Dune::GeometryType type)
number of interior sub control volume faces
Definition discretization/pq3/geometryhelper.hh:176
static auto numBoundaryScvf(Dune::GeometryType type, unsigned int localFacetIndex)
number of boundary sub control volume faces for face localFacetIndex
Definition discretization/pq3/geometryhelper.hh:182
static ScvCornerStorage getScvCorners(Dune::GeometryType type, Transformation &&trans, unsigned int localScvIdx)
Create a vector with the scv corners.
Definition discretization/pq3/geometryhelper.hh:83
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.
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
Define some often used mathematical functions.
Lightweight DOF helper for order-3 Lagrange elements.
Compute the volume of several common geometry types.