12#ifndef DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_FV_ELEMENT_GEOMETRY_HH
13#define DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_FV_ELEMENT_GEOMETRY_HH
20#include <dune/common/reservedvector.hh>
21#include <dune/common/iteratorrange.hh>
37template<
class GG,
bool cachingEnabled>
48 using GridView =
typename GG::GridView;
51 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
52 using GGCache =
typename GG::Cache;
53 using GeometryHelper =
typename GGCache::GeometryHelper;
56 typename GridView::template Codim<0>::Entity::Geometry::LocalCoordinate,
57 typename GridView::template Codim<0>::Entity::Geometry::GlobalCoordinate
65 using Element =
typename GridView::template Codim<0>::Entity;
73 static constexpr std::size_t maxNumElementScvs = 2*GridView::dimension;
81 {
return ggCache_->scvs(eIdx_)[scvIdx]; }
85 {
return ggCache_->scvf(eIdx_)[scvfIdx]; }
95 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
96 const auto& s = fvGeometry.ggCache_->scvs(fvGeometry.eIdx_);
97 return Dune::IteratorRange<Iter>(s.begin(), s.end());
108 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
109 const auto& s = fvGeometry.ggCache_->scvfs(fvGeometry.eIdx_);
110 return Dune::IteratorRange<Iter>(s.begin(), s.end());
116 return gridGeometry().feCache().get(element().type()).localBasis();
128 return ggCache_->scvs(eIdx_).size();
134 return ggCache_->scvfs(eIdx_).size();
139 {
return ggCache_->hasBoundaryScvf(eIdx_); }
143 {
return hasBoundaryScvf(); }
147 {
return ggCache_->boundaryFaces(eIdx_)[bfIdx]; }
150 friend inline std::ranges::view
auto
153 const auto& v = fvGeometry.ggCache_->boundaryFaces(fvGeometry.eIdx_);
154 return std::ranges::views::all(v);
164 this->bindElement(element);
165 return std::move(*
this);
170 this->bindElement(element);
180 this->bindElement(element);
181 return std::move(*
this);
188 elementGeometry_.emplace(element.geometry());
189 eIdx_ = gridGeometry().elementMapper().index(element);
194 {
return static_cast<bool>(element_); }
198 {
return *element_; }
202 {
return *elementGeometry_; }
206 {
return ggCache_->gridGeometry(); }
216 return scvf.insideScvIdx();
224 SubControlVolume::Traits::geometryType((*elementGeometry_).type()),
225 GeometryHelper(*elementGeometry_).getScvCorners(scv.indexInElement())
236 const auto localFacetIndex = scvf.insideScvIdx();
238 referenceElement(*elementGeometry_).type(localFacetIndex, 1),
239 GeometryHelper(*elementGeometry_).getBoundaryScvfCorners(localFacetIndex)
245 SubControlVolumeFace::Traits::interiorGeometryType((*elementGeometry_).type()),
246 GeometryHelper(*elementGeometry_).getScvfCorners(scvf.index())
255 const auto& elemGeo = elementGeometry();
256 const auto faceGeoInRef = referenceElement(elemGeo).template geometry<1>(boundaryFace.intersectionIndex());
257 typename BoundaryFace::Traits::CornerStorage corners;
258 for (
int i = 0; i < faceGeoInRef.corners(); ++i)
259 corners.push_back(elemGeo.global(faceGeoInRef.corner(i)));
260 return { faceGeoInRef.type(), corners };
267 const auto localDofIdx = boundaryFace.intersectionIndex();
269 static_cast<LocalIndexType
>(localDofIdx),
270 static_cast<GridIndexType
>(fvGeometry.scv(localDofIdx).dofIndex()),
271 static_cast<GridIndexType
>(fvGeometry.elementIndex())
278 const auto type = fvGeometry.element().type();
279 const auto& localKey = fvGeometry.gridGeometry().feCache().get(type).localCoefficients().localKey(scv.localDofIndex());
285 template<
class LocalDof>
288 const auto type = fvGeometry.element().type();
289 const auto& localKey = fvGeometry.gridGeometry().feCache().get(type).localCoefficients().localKey(localDof.index());
290 const auto& localPos = GeometryHelper::localDofPosition(type, localKey);
300 [&] (
const typename Element::Geometry::GlobalCoordinate& pos) {
return fvGeometry.elementGeometry().local(pos); },
309 { scvf.
unitOuterNormal(), scvf.index(), fvGeometry.elementGeometry().local(scvf.ipGlobal()), scvf.ipGlobal() };
313 std::optional<Element> element_;
314 std::optional<typename Element::Geometry> elementGeometry_;
316 const GGCache* ggCache_;
An interpolation point related to a face of an element.
Definition: cvfe/interpolationpointdata.hh:109
const GlobalPosition & unitOuterNormal() const
The unit outer normal vector at the quadrature point.
Definition: cvfe/interpolationpointdata.hh:123
An interpolation point related to an element that includes global and local positions.
Definition: cvfe/interpolationpointdata.hh:31
An interpolation point related to a global position of an element, giving its local positions by a ma...
Definition: cvfe/interpolationpointdata.hh:82
A local degree of freedom from an element perspective.
Definition: localdof.hh:27
An interpolation point related to a localDof of an element, giving its global and local positions.
Definition: cvfe/interpolationpointdata.hh:60
LocalIndex localDofIndex() const
The local index of the corresponding dof.
Definition: cvfe/interpolationpointdata.hh:69
Element-wise grid geometry (local view)
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:46
friend auto scvs(const FaceCenteredDiamondFVElementGeometry &fvGeometry)
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:93
void bindElement(const Element &element) &
Bind only element-local.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:185
const GridGeometry & gridGeometry() const
The grid geometry we are a restriction of.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:205
const Element & element() const
The bound element.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:197
typename GG::ScvQuadratureRule ScvQuadratureRule
the quadrature rule type for scvs
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:68
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume face
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:62
friend auto ipData(const FaceCenteredDiamondFVElementGeometry &fvGeometry, const LocalDof &localDof)
Interpolation point data for a localDof.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:286
std::size_t intersectionIndex(const SubControlVolumeFace &scvf) const
The intersection index the scvf belongs to.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:213
const Element::Geometry & elementGeometry() const
The bound element geometry.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:201
friend auto ipData(const FaceCenteredDiamondFVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf)
Interpolation point data for scvf.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:306
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:138
typename GG::SubControlVolumeFace SubControlVolumeFace
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:63
typename GG::ScvfQuadratureRule ScvfQuadratureRule
the quadrature rule type for scvfs
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:70
bool hasBoundaryFaces() const
Returns whether the element has boundary faces.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:142
friend auto ipData(const FaceCenteredDiamondFVElementGeometry &fvGeometry, const SubControlVolume &scv)
Interpolation point data for an scv.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:276
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:193
const BoundaryFace & boundaryFace(LocalIndexType bfIdx) const
Get a boundary face with a local boundary face index.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:146
std::size_t numScvf() const
number of sub control volumes in this fv element geometry
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:132
friend auto scvfs(const FaceCenteredDiamondFVElementGeometry &fvGeometry)
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:106
std::size_t elementIndex() const
The bound element index.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:209
GG GridGeometry
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:66
friend auto ipData(const FaceCenteredDiamondFVElementGeometry &fvGeometry, const typename Element::Geometry::GlobalCoordinate &globalPos)
Interpolation point data for a global position.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:296
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:84
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:80
typename GridView::template Codim< 0 >::Entity Element
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:65
friend auto localDofs(const FaceCenteredDiamondFVElementGeometry &fvGeometry, const BoundaryFace &boundaryFace)
an iterator over all local dofs related to a boundary face
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:264
typename GG::BoundaryFace BoundaryFace
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:64
BoundaryFace::Traits::Geometry geometry(const BoundaryFace &boundaryFace) const
Geometry of a boundary face.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:252
FaceCenteredDiamondFVElementGeometry bind(const Element &element) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:162
std::size_t numScv() const
number of sub control volumes in this fv element geometry
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:126
std::size_t numLocalDofs() const
The total number of element-local dofs.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:120
FaceCenteredDiamondFVElementGeometry(const GGCache &ggCache)
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:75
friend std::ranges::view auto boundaryFaces(const FaceCenteredDiamondFVElementGeometry &fvGeometry)
iterator range for boundary faces
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:151
void bind(const Element &element) &
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:168
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:114
SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace &scvf) const
Geometry of a sub control volume face.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:230
SubControlVolume::Traits::Geometry geometry(const SubControlVolume &scv) const
Geometry of a sub control volume.
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:220
FaceCenteredDiamondFVElementGeometry bindElement(const Element &element) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:178
Element-wise grid geometry (local view)
Definition: discretization/facecentered/diamond/fvelementgeometry.hh:38
Classes representing interpolation point data for control-volume finite element schemes.
Quadrature rules over sub-control volumes and sub-control volume faces.
Class providing iterators over sub control volumes and sub control volume faces of an element.
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:29