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>
38 template<
int mydim,
int cdim >
41 using Type = Dune::ReservedVector< Dune::FieldVector< ct, cdim >, (1<<mydim)>;
47template<Dune::GeometryType::Id gt>
53 static constexpr Dune::GeometryType
type()
54 {
return Dune::GeometryTypes::triangle; }
56 using Key = std::pair<std::uint8_t, std::uint8_t>;
57 static constexpr std::array<std::array<Key, 3>, 3>
keys = {{
67 static constexpr Dune::GeometryType
type()
68 {
return Dune::GeometryTypes::triangle; }
70 using Key = std::pair<std::uint8_t, std::uint8_t>;
71 static constexpr std::array<std::array<Key, 3>, 4>
keys = {{
82 static constexpr Dune::GeometryType
type()
83 {
return Dune::GeometryTypes::tetrahedron; }
85 using Key = std::pair<std::uint8_t, std::uint8_t>;
86 static constexpr std::array<std::array<Key, 4>, 4>
keys = {{
97 static constexpr Dune::GeometryType
type()
98 {
return Dune::GeometryTypes::pyramid; }
100 using Key = std::pair<std::uint8_t, std::uint8_t>;
101 static constexpr std::array<std::array<Key, 5>, 6>
keys = {{
102 {
Key{4, 3},
Key{0, 3},
Key{6, 3},
Key{2, 3},
Key{0, 0} },
103 {
Key{1, 3},
Key{5, 3},
Key{3, 3},
Key{7, 3},
Key{0, 0} },
104 {
Key{4, 3},
Key{5, 3},
Key{0, 3},
Key{1, 3},
Key{0, 0} },
105 {
Key{2, 3},
Key{3, 3},
Key{6, 3},
Key{7, 3},
Key{0, 0} },
106 {
Key{0, 3},
Key{1, 3},
Key{2, 3},
Key{3, 3},
Key{0, 0} },
111template<Dune::GeometryType::Id gt>
117 static constexpr Dune::GeometryType
type()
118 {
return Dune::GeometryTypes::line; }
120 using Key = std::pair<std::uint8_t, std::uint8_t>;
121 static constexpr std::array<std::array<Key, 2>, 3>
keys = {{
131 static constexpr Dune::GeometryType
type()
132 {
return Dune::GeometryTypes::line; }
134 using Key = std::pair<std::uint8_t, std::uint8_t>;
135 static constexpr std::array<std::array<Key, 2>, 4>
keys = {{
146 static constexpr Dune::GeometryType
type()
147 {
return Dune::GeometryTypes::triangle; }
149 using Key = std::pair<std::uint8_t, std::uint8_t>;
150 static constexpr std::array<std::array<Key, 3>, 6>
keys = {{
163 static constexpr Dune::GeometryType
type()
164 {
return Dune::GeometryTypes::triangle; }
166 using Key = std::pair<std::uint8_t, std::uint8_t>;
167 static constexpr std::array<std::array<Key, 3>, 12>
keys = {{
184template<
class S,
class ReferenceElement,
class Transformation,
class KeyArray, std::size_t... I>
185S
keyToCornerStorageImpl(
const ReferenceElement& ref, Transformation&& trans,
const KeyArray& key, std::index_sequence<I...>)
188 return { trans(ref.position(key[I].first, key[I].second))... };
192template<
class S,
class ReferenceElement,
class Transformation,
class T, std::
size_t N,
class Indices = std::make_index_sequence<N>>
193S
keyToCornerStorage(
const ReferenceElement& ref, Transformation&& trans,
const std::array<T, N>& key)
199template<
class S,
int dim,
class ReferenceElement,
class Transformation, std::size_t... ii>
203 return { trans(ref.position(ref.subEntity(i, 1, ii, dim), dim))... };
207template<
class S, std::
size_t numCorners,
int dim,
class ReferenceElement,
class Transformation>
213template<
class IndexType, Dune::GeometryType::Id gt>
216template<
class IndexType>
219 static constexpr std::array<std::array<IndexType, 2>, 3>
pairs = {{
220 {0, 1}, {0, 2}, {1, 2}
224template<
class IndexType>
227 static constexpr std::array<std::array<IndexType, 2>, 4>
pairs = {{
228 {0, 2}, {1, 2}, {0, 3}, {1, 3}
232template<
class IndexType>
235 static constexpr std::array<std::array<IndexType, 2>, 6>
pairs = {{
236 {0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3},
240template<
class IndexType>
243 static constexpr std::array<std::array<IndexType, 2>, 12>
pairs = {{
244 {0, 2}, {1, 2}, {0, 3}, {1, 3}, {0, 4}, {1, 4},
245 {2, 4}, {3, 4}, {0, 5}, {1, 5}, {2, 5}, {3, 5}
255template <
class Gr
idView,
class ScvType,
class ScvfType>
258 using Element =
typename GridView::template Codim<0>::Entity;
260 static constexpr auto dim = GridView::dimension;
261 static constexpr auto dimWorld = GridView::dimensionworld;
263 using ScvCornerStorage =
typename ScvType::Traits::CornerStorage;
264 using LocalIndexType =
typename ScvType::Traits::LocalIndexType;
265 using ScvfCornerStorage =
typename ScvfType::Traits::CornerStorage;
268 using Scalar =
typename GridView::ctype;
269 using GlobalPosition =
typename Dune::FieldVector<Scalar, GridView::dimensionworld>;
281 return getScvCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localFacetIndex);
285 template<
class Transformation>
286 static ScvCornerStorage
getScvCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localFacetIndex)
288 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
289 if (type == Dune::GeometryTypes::triangle)
294 else if (type == Dune::GeometryTypes::quadrilateral)
299 else if (type == Dune::GeometryTypes::tetrahedron)
304 else if (type == Dune::GeometryTypes::hexahedron)
310 DUNE_THROW(Dune::NotImplemented,
"Scv geometries for type " << type);
316 return getScvfCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localEdgeIndex);
320 template<
class Transformation>
321 static ScvfCornerStorage
getScvfCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localEdgeIndex)
323 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
324 if (type == Dune::GeometryTypes::triangle)
329 else if (type == Dune::GeometryTypes::quadrilateral)
334 else if (type == Dune::GeometryTypes::tetrahedron)
339 else if (type == Dune::GeometryTypes::hexahedron)
345 DUNE_THROW(Dune::NotImplemented,
"Scvf geometries for type " << type);
351 return getBoundaryScvfCorners(geo_.type(), [&](
const auto& local){ return geo_.global(local); }, localFacetIndex);
355 template<
class Transformation>
356 static ScvfCornerStorage
getBoundaryScvfCorners(Dune::GeometryType type, Transformation&& trans,
unsigned int localFacetIndex)
358 const auto& ref = Dune::referenceElement<Scalar, dim>(type);
359 if (type == Dune::GeometryTypes::triangle || type == Dune::GeometryTypes::quadrilateral)
361 else if (type == Dune::GeometryTypes::tetrahedron)
363 else if (type == Dune::GeometryTypes::hexahedron)
366 DUNE_THROW(Dune::NotImplemented,
"Boundary scvf geometries for type " << type);
371 return geo_.global(referenceElement(geo_).position(localFacetIndex, 1));
376 const auto type = geo_.type();
377 if (type == Dune::GeometryTypes::triangle)
379 else if (type == Dune::GeometryTypes::quadrilateral)
381 else if (type == Dune::GeometryTypes::tetrahedron)
383 else if (type == Dune::GeometryTypes::hexahedron)
386 DUNE_THROW(Dune::NotImplemented,
"Inside outside scv pairs for type " << type);
392 return referenceElement(geo_).size(2);
398 return referenceElement(geo_).size(1);
401 GlobalPosition
normal(
const ScvfCornerStorage& p,
const std::array<LocalIndexType, 2>& scvPair)
405 const auto ref = referenceElement(geo_);
406 const auto v = facetCenter_(scvPair[1], ref) - facetCenter_(scvPair[0], ref);
419 static Element::Geometry::LocalCoordinate
localScvfCenter(Dune::GeometryType type,
unsigned int localScvfIdx)
431 template<
class RefElement>
432 GlobalPosition facetCenter_(
unsigned int localFacetIndex,
const RefElement& ref)
const
434 return geo_.global(ref.position(localFacetIndex, 1));
437 const typename Element::Geometry& geo_;
Compute the center point of a convex polytope geometry or a random-access container of corner points.
GlobalPosition normal(const ScvfCornerStorage &p, const std::array< LocalIndexType, 2 > &scvPair)
Definition discretization/facecentered/diamond/geometryhelper.hh:401
GlobalPosition facetCenter(unsigned int localFacetIndex) const
Definition discretization/facecentered/diamond/geometryhelper.hh:369
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:314
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:356
std::size_t numInteriorScvf()
number of interior sub control volume faces (number of codim-2 entities)
Definition discretization/facecentered/diamond/geometryhelper.hh:390
std::array< LocalIndexType, 2 > getInsideOutsideScvForScvf(unsigned int localEdgeIndex)
Definition discretization/facecentered/diamond/geometryhelper.hh:374
static Element::Geometry::LocalCoordinate localScvfCenter(Dune::GeometryType type, unsigned int localScvfIdx)
local scvf center
Definition discretization/facecentered/diamond/geometryhelper.hh:419
PQ1NonconformingDofHelper< GridView > DofHelper
Definition discretization/facecentered/diamond/geometryhelper.hh:272
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:279
DiamondGeometryHelper(const typename Element::Geometry &geo)
Definition discretization/facecentered/diamond/geometryhelper.hh:274
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:286
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:321
static Element::Geometry::LocalCoordinate localBoundaryScvfCenter(Dune::GeometryType type, unsigned int localFacetIndex)
local boundary scvf center
Definition discretization/facecentered/diamond/geometryhelper.hh:425
const Element::Geometry & elementGeometry() const
Definition discretization/facecentered/diamond/geometryhelper.hh:415
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:349
std::size_t numScv()
number of sub control volumes (number of codim-1 entities)
Definition discretization/facecentered/diamond/geometryhelper.hh:396
auto scvfUnitNormal(const ElementGeometry &geo, const CornerStorage &corners)
Unit normal of an interior sub-control volume face, up to sign.
Definition scvfnormal.hh:33
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:45
S boundaryCornerStorageImpl(const ReferenceElement &ref, Transformation &&trans, unsigned int i, std::index_sequence< ii... >)
Definition discretization/facecentered/diamond/geometryhelper.hh:200
S keyToCornerStorage(const ReferenceElement &ref, Transformation &&trans, const std::array< T, N > &key)
Definition discretization/facecentered/diamond/geometryhelper.hh:193
S boundaryCornerStorage(const ReferenceElement &ref, Transformation &&trans, unsigned int i)
Definition discretization/facecentered/diamond/geometryhelper.hh:208
S keyToCornerStorageImpl(const ReferenceElement &ref, Transformation &&trans, const KeyArray &key, std::index_sequence< I... >)
Definition discretization/facecentered/diamond/geometryhelper.hh:185
Definition common/pdesolver.hh:24
Normal vector of a sub-control volume face of an element-local dual grid.
static constexpr std::array< std::array< IndexType, 2 >, 4 > pairs
Definition discretization/facecentered/diamond/geometryhelper.hh:227
static constexpr std::array< std::array< IndexType, 2 >, 6 > pairs
Definition discretization/facecentered/diamond/geometryhelper.hh:235
static constexpr std::array< std::array< IndexType, 2 >, 12 > pairs
Definition discretization/facecentered/diamond/geometryhelper.hh:243
static constexpr std::array< std::array< IndexType, 2 >, 3 > pairs
Definition discretization/facecentered/diamond/geometryhelper.hh:219
Definition discretization/facecentered/diamond/geometryhelper.hh:214
static constexpr std::array< std::array< Key, 5 >, 6 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:101
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:97
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:100
static constexpr std::array< std::array< Key, 3 >, 4 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:71
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:67
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:70
static constexpr std::array< std::array< Key, 4 >, 4 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:86
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:85
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:82
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:53
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:56
static constexpr std::array< std::array< Key, 3 >, 3 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:57
Definition discretization/facecentered/diamond/geometryhelper.hh:48
static constexpr std::array< std::array< Key, 3 >, 12 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:167
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:163
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:166
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:131
static constexpr std::array< std::array< Key, 2 >, 4 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:135
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:134
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:149
static constexpr std::array< std::array< Key, 3 >, 6 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:150
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:146
std::pair< std::uint8_t, std::uint8_t > Key
Definition discretization/facecentered/diamond/geometryhelper.hh:120
static constexpr std::array< std::array< Key, 2 >, 3 > keys
Definition discretization/facecentered/diamond/geometryhelper.hh:121
static constexpr Dune::GeometryType type()
Definition discretization/facecentered/diamond/geometryhelper.hh:117
Definition discretization/facecentered/diamond/geometryhelper.hh:112
Definition discretization/facecentered/diamond/geometryhelper.hh:40
Dune::ReservedVector< Dune::FieldVector< ct, cdim >,(1<< mydim)> Type
Definition discretization/facecentered/diamond/geometryhelper.hh:41
Traits for an efficient corner storage for fc diamond method.
Definition discretization/facecentered/diamond/geometryhelper.hh:35