12#ifndef DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_GEOMETRY_HELPER_HH
13#define DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_GEOMETRY_HELPER_HH
18#include <dune/common/reservedvector.hh>
19#include <dune/common/fvector.hh>
20#include <dune/geometry/multilineargeometry.hh>
21#include <dune/geometry/type.hh>
37 template<
int mydim,
int cdim >
40 using Type = Dune::ReservedVector< Dune::FieldVector< ct, cdim >, (1<<mydim)>;
46template<Dune::GeometryType::Id gt>
52 static constexpr Dune::GeometryType
type()
53 {
return Dune::GeometryTypes::triangle; }
55 using Key = std::pair<std::uint8_t, std::uint8_t>;
56 static constexpr std::array<std::array<Key, 3>, 3>
keys = {{
66 static constexpr Dune::GeometryType
type()
67 {
return Dune::GeometryTypes::triangle; }
69 using Key = std::pair<std::uint8_t, std::uint8_t>;
70 static constexpr std::array<std::array<Key, 3>, 4>
keys = {{
81 static constexpr Dune::GeometryType
type()
82 {
return Dune::GeometryTypes::tetrahedron; }
84 using Key = std::pair<std::uint8_t, std::uint8_t>;
85 static constexpr std::array<std::array<Key, 4>, 4>
keys = {{
96 static constexpr Dune::GeometryType
type()
97 {
return Dune::GeometryTypes::pyramid; }
99 using Key = std::pair<std::uint8_t, std::uint8_t>;
100 static constexpr std::array<std::array<Key, 5>, 6>
keys = {{
101 {
Key{4, 3},
Key{0, 3},
Key{6, 3},
Key{2, 3},
Key{0, 0} },
102 {
Key{1, 3},
Key{5, 3},
Key{3, 3},
Key{7, 3},
Key{0, 0} },
103 {
Key{4, 3},
Key{5, 3},
Key{0, 3},
Key{1, 3},
Key{0, 0} },
104 {
Key{2, 3},
Key{3, 3},
Key{6, 3},
Key{7, 3},
Key{0, 0} },
105 {
Key{0, 3},
Key{1, 3},
Key{2, 3},
Key{3, 3},
Key{0, 0} },
110template<Dune::GeometryType::Id gt>
116 static constexpr Dune::GeometryType
type()
117 {
return Dune::GeometryTypes::line; }
119 using Key = std::pair<std::uint8_t, std::uint8_t>;
120 static constexpr std::array<std::array<Key, 2>, 3>
keys = {{
130 static constexpr Dune::GeometryType
type()
131 {
return Dune::GeometryTypes::line; }
133 using Key = std::pair<std::uint8_t, std::uint8_t>;
134 static constexpr std::array<std::array<Key, 2>, 4>
keys = {{
145 static constexpr Dune::GeometryType
type()
146 {
return Dune::GeometryTypes::triangle; }
148 using Key = std::pair<std::uint8_t, std::uint8_t>;
149 static constexpr std::array<std::array<Key, 3>, 6>
keys = {{
162 static constexpr Dune::GeometryType
type()
163 {
return Dune::GeometryTypes::triangle; }
165 using Key = std::pair<std::uint8_t, std::uint8_t>;
166 static constexpr std::array<std::array<Key, 3>, 12>
keys = {{
183template<
class S,
class ReferenceElement,
class Transformation,
class KeyArray, std::size_t... I>
184S
keyToCornerStorageImpl(
const ReferenceElement& ref, Transformation&& trans,
const KeyArray& key, std::index_sequence<I...>)
187 return { trans(ref.position(key[I].first, key[I].second))... };
191template<
class S,
class ReferenceElement,
class Transformation,
class T, std::
size_t N,
class Indices = std::make_index_sequence<N>>
192S
keyToCornerStorage(
const ReferenceElement& ref, Transformation&& trans,
const std::array<T, N>& key)
198template<
class S,
int dim,
class ReferenceElement,
class Transformation, std::size_t... ii>
202 return { trans(ref.position(ref.subEntity(i, 1, ii, dim), dim))... };
206template<
class S, std::
size_t numCorners,
int dim,
class ReferenceElement,
class Transformation>
212template<
class IndexType, Dune::GeometryType::Id gt>
215template<
class IndexType>
218 static constexpr std::array<std::array<IndexType, 2>, 3>
pairs = {{
219 {0, 1}, {0, 2}, {1, 2}
223template<
class IndexType>
226 static constexpr std::array<std::array<IndexType, 2>, 4>
pairs = {{
227 {0, 2}, {1, 2}, {0, 3}, {1, 3}
231template<
class IndexType>
234 static constexpr std::array<std::array<IndexType, 2>, 6>
pairs = {{
235 {0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3},
239template<
class IndexType>
242 static constexpr std::array<std::array<IndexType, 2>, 12>
pairs = {{
243 {0, 2}, {1, 2}, {0, 3}, {1, 3}, {0, 4}, {1, 4},
244 {2, 4}, {3, 4}, {0, 5}, {1, 5}, {2, 5}, {3, 5}
254template <
class Gr
idView,
class ScvType,
class ScvfType>
257 using Element =
typename GridView::template Codim<0>::Entity;
259 static constexpr auto dim = GridView::dimension;
260 static constexpr auto dimWorld = GridView::dimensionworld;
262 using ScvCornerStorage =
typename ScvType::Traits::CornerStorage;
263 using LocalIndexType =
typename ScvType::Traits::LocalIndexType;
264 using ScvfCornerStorage =
typename ScvfType::Traits::CornerStorage;
267 using Scalar =
typename GridView::ctype;
268 using GlobalPosition =
typename Dune::FieldVector<Scalar, GridView::dimensionworld>;
280 return getScvCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localFacetIndex);
284 template<
class Transformation>
285 static ScvCornerStorage
getScvCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localFacetIndex)
287 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
288 if (type == Dune::GeometryTypes::triangle)
293 else if (type == Dune::GeometryTypes::quadrilateral)
298 else if (type == Dune::GeometryTypes::tetrahedron)
303 else if (type == Dune::GeometryTypes::hexahedron)
309 DUNE_THROW(Dune::NotImplemented,
"Scv geometries for type " << type);
315 return getScvfCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localEdgeIndex);
319 template<
class Transformation>
320 static ScvfCornerStorage
getScvfCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localEdgeIndex)
322 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
323 if (type == Dune::GeometryTypes::triangle)
328 else if (type == Dune::GeometryTypes::quadrilateral)
333 else if (type == Dune::GeometryTypes::tetrahedron)
338 else if (type == Dune::GeometryTypes::hexahedron)
344 DUNE_THROW(Dune::NotImplemented,
"Scvf geometries for type " << type);
350 return getBoundaryScvfCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localFacetIndex);
354 template<
class Transformation>
355 static ScvfCornerStorage
getBoundaryScvfCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localFacetIndex)
357 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
358 if (type == Dune::GeometryTypes::triangle || type == Dune::GeometryTypes::quadrilateral)
360 else if (type == Dune::GeometryTypes::tetrahedron)
362 else if (type == Dune::GeometryTypes::hexahedron)
365 DUNE_THROW(Dune::NotImplemented,
"Boundary scvf geometries for type " << type);
370 return geo_.global(referenceElement(geo_).position(localFacetIndex, 1));
375 const auto type = geo_.type();
376 if (type == Dune::GeometryTypes::triangle)
378 else if (type == Dune::GeometryTypes::quadrilateral)
380 else if (type == Dune::GeometryTypes::tetrahedron)
382 else if (type == Dune::GeometryTypes::hexahedron)
385 DUNE_THROW(Dune::NotImplemented,
"Inside outside scv pairs for type " << type);
391 return referenceElement(geo_).size(2);
397 return referenceElement(geo_).size(1);
400 template<
int d = dimWorld, std::enable_if_t<(d==3),
int> = 0>
401 GlobalPosition
normal(
const ScvfCornerStorage& p,
const std::array<LocalIndexType, 2>& scvPair)
406 const auto ref = referenceElement(geo_);
407 const auto v = facetCenter_(scvPair[1], ref) - facetCenter_(scvPair[0], ref);
416 template<
int d = dimWorld, std::enable_if_t<(d==2),
int> = 0>
417 GlobalPosition
normal(
const ScvfCornerStorage& p,
const std::array<LocalIndexType, 2>& scvPair)
420 const auto t = p[1] - p[0];
421 GlobalPosition
normal({-t[1], t[0]});
424 const auto ref = referenceElement(geo_);
425 const auto v = facetCenter_(scvPair[1], ref) - facetCenter_(scvPair[0], ref);
438 static Element::Geometry::LocalCoordinate
localScvfCenter(Dune::GeometryType type,
unsigned int localScvfIdx)
450 template<
class RefElement>
451 GlobalPosition facetCenter_(
unsigned int localFacetIndex,
const RefElement& ref)
const
453 return geo_.global(ref.position(localFacetIndex, 1));
456 const typename Element::Geometry& geo_;
Compute the center point of a convex polytope geometry or a random-access container of corner points.
GlobalPosition facetCenter(unsigned int localFacetIndex) const
Definition discretization/facecentered/diamond/geometryhelper.hh:368
ScvfCornerStorage getScvfCorners(unsigned int localEdgeIndex) const
Create a corner storage with the scvf corners for a given edge (codim-2) index.
Definition discretization/facecentered/diamond/geometryhelper.hh:313
static ScvfCornerStorage getBoundaryScvfCorners(Dune::GeometryType type, Transformation &&trans, unsigned int localFacetIndex)
Create the sub control volume face geometries on the boundary for a given face index.
Definition discretization/facecentered/diamond/geometryhelper.hh:355
std::size_t numInteriorScvf()
number of interior sub control volume faces (number of codim-2 entities)
Definition discretization/facecentered/diamond/geometryhelper.hh:389
std::array< LocalIndexType, 2 > getInsideOutsideScvForScvf(unsigned int localEdgeIndex)
Definition discretization/facecentered/diamond/geometryhelper.hh:373
static Element::Geometry::LocalCoordinate localScvfCenter(Dune::GeometryType type, unsigned int localScvfIdx)
local scvf center
Definition discretization/facecentered/diamond/geometryhelper.hh:438
PQ1NonconformingDofHelper< GridView > DofHelper
Definition discretization/facecentered/diamond/geometryhelper.hh:271
ScvCornerStorage getScvCorners(unsigned int localFacetIndex) const
Create a corner storage with the scv corners for a given face (codim-1) index.
Definition discretization/facecentered/diamond/geometryhelper.hh:278
DiamondGeometryHelper(const typename Element::Geometry &geo)
Definition discretization/facecentered/diamond/geometryhelper.hh:273
static ScvCornerStorage getScvCorners(Dune::GeometryType type, Transformation &&trans, unsigned int localFacetIndex)
Create a corner storage with the scv corners for a given face (codim-1) index.
Definition discretization/facecentered/diamond/geometryhelper.hh:285
static ScvfCornerStorage getScvfCorners(Dune::GeometryType type, Transformation &&trans, unsigned int localEdgeIndex)
Create a corner storage with the scvf corners for a given edge (codim-2) index.
Definition discretization/facecentered/diamond/geometryhelper.hh:320
GlobalPosition normal(const ScvfCornerStorage &p, const std::array< LocalIndexType, 2 > &scvPair)
Definition discretization/facecentered/diamond/geometryhelper.hh:401
static Element::Geometry::LocalCoordinate localBoundaryScvfCenter(Dune::GeometryType type, unsigned int localFacetIndex)
local boundary scvf center
Definition discretization/facecentered/diamond/geometryhelper.hh:444
const Element::Geometry & elementGeometry() const
Definition discretization/facecentered/diamond/geometryhelper.hh:434
ScvfCornerStorage getBoundaryScvfCorners(unsigned int localFacetIndex) const
Create the sub control volume face geometries on the boundary for a given face index.
Definition discretization/facecentered/diamond/geometryhelper.hh:348
std::size_t numScv()
number of sub control volumes (number of codim-1 entities)
Definition discretization/facecentered/diamond/geometryhelper.hh:395
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
Corners::value_type center(const Corners &corners)
The center of a given list of corners.
Definition center.hh:24
Class representing dofs on elements for control-volume finite element schemes.
Define some often used mathematical functions.
Definition discretization/facecentered/diamond/geometryhelper.hh:44
S boundaryCornerStorageImpl(const ReferenceElement &ref, Transformation &&trans, unsigned int i, std::index_sequence< ii... >)
Definition discretization/facecentered/diamond/geometryhelper.hh:199
S keyToCornerStorage(const ReferenceElement &ref, Transformation &&trans, const std::array< T, N > &key)
Definition discretization/facecentered/diamond/geometryhelper.hh:192
S boundaryCornerStorage(const ReferenceElement &ref, Transformation &&trans, unsigned int i)
Definition discretization/facecentered/diamond/geometryhelper.hh:207
S keyToCornerStorageImpl(const ReferenceElement &ref, Transformation &&trans, const KeyArray &key, std::index_sequence< I... >)
Definition discretization/facecentered/diamond/geometryhelper.hh:184
Definition common/pdesolver.hh:24
static constexpr std::array< std::array< IndexType, 2 >, 4 > pairs
Definition discretization/facecentered/diamond/geometryhelper.hh:226
static constexpr std::array< std::array< IndexType, 2 >, 6 > pairs
Definition discretization/facecentered/diamond/geometryhelper.hh:234
static constexpr std::array< std::array< IndexType, 2 >, 12 > pairs
Definition discretization/facecentered/diamond/geometryhelper.hh:242
static constexpr std::array< std::array< IndexType, 2 >, 3 > pairs
Definition discretization/facecentered/diamond/geometryhelper.hh:218
Definition discretization/facecentered/diamond/geometryhelper.hh:213
static constexpr std::array< std::array< Key, 5 >, 6 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:100
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:96
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:99
static constexpr std::array< std::array< Key, 3 >, 4 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:70
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:66
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:69
static constexpr std::array< std::array< Key, 4 >, 4 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:85
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:84
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:81
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:52
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:55
static constexpr std::array< std::array< Key, 3 >, 3 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:56
Definition discretization/facecentered/diamond/geometryhelper.hh:47
static constexpr std::array< std::array< Key, 3 >, 12 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:166
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:162
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:165
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:130
static constexpr std::array< std::array< Key, 2 >, 4 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:134
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:133
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:148
static constexpr std::array< std::array< Key, 3 >, 6 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:149
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:145
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:119
static constexpr std::array< std::array< Key, 2 >, 3 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:120
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:116
Definition discretization/facecentered/diamond/geometryhelper.hh:111
Definition discretization/facecentered/diamond/geometryhelper.hh:39
Dune::ReservedVector< Dune::FieldVector< ct, cdim >,(1<< mydim)> Type
Definition discretization/facecentered/diamond/geometryhelper.hh:40
Traits for an efficient corner storage for fc diamond method.
Definition discretization/facecentered/diamond/geometryhelper.hh:34