26#ifndef DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
27#define DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
31#include <dune/geometry/type.hh>
32#include <dune/localfunctions/lagrange/pqkfactory.hh>
48template<
class GG,
bool enableGr
idGeometryCache>
55 using GridView =
typename GG::GridView;
56 static constexpr int dim = GridView::dimension;
57 static constexpr int dimWorld = GridView::dimensionworld;
60 using CoordScalar =
typename GridView::ctype;
61 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
64 using Element =
typename GridView::template Codim<0>::Entity;
72 static constexpr std::size_t maxNumElementScvs = (1<<dim);
76 : gridGeometryPtr_(&gridGeometry) {}
81 return gridGeometry().scvs(eIdx_)[scvIdx];
87 return gridGeometry().scvfs(eIdx_)[scvfIdx];
95 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
98 const auto& g = fvGeometry.gridGeometry();
99 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
100 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
108 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
111 const auto& g = fvGeometry.gridGeometry();
112 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
113 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
119 return gridGeometry().feCache().get(element_->type()).localBasis();
125 return gridGeometry().scvs(eIdx_).size();
131 return gridGeometry().scvfs(eIdx_).size();
141 this->bindElement(element);
142 return std::move(*
this);
149 { this->bindElement(element); }
158 this->bindElement(element);
159 return std::move(*
this);
169 eIdx_ = gridGeometry().elementMapper().index(element);
174 {
return static_cast<bool>(element_); }
178 {
return *element_; }
182 {
return *gridGeometryPtr_; }
186 {
return gridGeometry().hasBoundaryScvf(eIdx_); }
189 const GridGeometry* gridGeometryPtr_;
192 std::optional<Element> element_;
199 using GridView =
typename GG::GridView;
200 static constexpr int dim = GridView::dimension;
201 static constexpr int dimWorld = GridView::dimensionworld;
204 using CoordScalar =
typename GridView::ctype;
205 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
208 typename GG::SubControlVolume,
209 typename GG::SubControlVolumeFace>;
212 using Element =
typename GridView::template Codim<0>::Entity;
220 static constexpr std::size_t maxNumElementScvs = (1<<dim);
224 : gridGeometryPtr_(&gridGeometry) {}
229 return scvs_[scvIdx];
235 return scvfs_[scvfIdx];
243 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
246 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
247 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
255 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
258 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
259 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
265 return gridGeometry().feCache().get(element_->type()).localBasis();
277 return scvfs_.size();
287 this->bindElement(element);
288 return std::move(*
this);
295 { this->bindElement(element); }
304 this->bindElement(element);
305 return std::move(*
this);
314 eIdx_ = gridGeometry().elementMapper().index(element);
315 makeElementGeometries_();
320 {
return static_cast<bool>(element_); }
324 {
return *element_; }
328 {
return *gridGeometryPtr_; }
332 {
return hasBoundaryScvf_; }
336 void makeElementGeometries_()
338 hasBoundaryScvf_ =
false;
341 const auto& element = *element_;
342 const auto elementGeometry = element.geometry();
343 const auto refElement = referenceElement(elementGeometry);
346 GeometryHelper geometryHelper(elementGeometry);
349 scvs_.resize(elementGeometry.corners());
350 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
353 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
356 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
363 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
364 scvfs_.resize(numInnerScvf);
366 LocalIndexType scvfLocalIdx = 0;
367 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
370 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
371 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
373 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
377 std::move(localScvIndices),
382 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
384 if (intersection.boundary() && !intersection.neighbor())
386 const auto isGeometry = intersection.geometry();
387 hasBoundaryScvf_ =
true;
389 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
392 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(refElement.subEntity(intersection.indexInInside(), 1, isScvfLocalIdx, dim));
393 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
395 scvfs_.emplace_back(geometryHelper,
400 std::move(localScvIndices),
412 std::optional<Element> element_;
415 const GridGeometry* gridGeometryPtr_;
418 std::vector<SubControlVolume> scvs_;
419 std::vector<SubControlVolumeFace> scvfs_;
421 bool hasBoundaryScvf_ =
false;
Defines the index types used for grid and local indices.
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Class providing iterators over sub control volumes and sub control volume faces of an element.
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
unsigned int LocalIndex
Definition: indextraits.hh:40
Create sub control volumes and sub control volume face geometries.
Definition: boxgeometryhelper.hh:36
Base class for the finite volume geometry vector for box models This builds up the sub control volume...
Definition: discretization/box/fvelementgeometry.hh:49
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/box/fvelementgeometry.hh:173
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/box/fvelementgeometry.hh:117
BoxFVElementGeometry 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/box/fvelementgeometry.hh:156
const Element & element() const
The bound element.
Definition: discretization/box/fvelementgeometry.hh:177
BoxFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/box/fvelementgeometry.hh:75
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:96
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/box/fvelementgeometry.hh:123
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/box/fvelementgeometry.hh:79
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/box/fvelementgeometry.hh:129
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/box/fvelementgeometry.hh:66
const GridGeometry & gridGeometry() const
The grid geometry we are a restriction of.
Definition: discretization/box/fvelementgeometry.hh:181
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/box/fvelementgeometry.hh:185
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:109
void bind(const Element &element) &
Definition: discretization/box/fvelementgeometry.hh:148
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/box/fvelementgeometry.hh:68
void bindElement(const Element &element) &
Definition: discretization/box/fvelementgeometry.hh:165
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/box/fvelementgeometry.hh:85
BoxFVElementGeometry 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/box/fvelementgeometry.hh:139
typename GridView::template Codim< 0 >::Entity Element
export the element type
Definition: discretization/box/fvelementgeometry.hh:64
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/box/fvelementgeometry.hh:70
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/box/fvelementgeometry.hh:319
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/box/fvelementgeometry.hh:275
BoxFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/box/fvelementgeometry.hh:223
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/box/fvelementgeometry.hh:218
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/box/fvelementgeometry.hh:331
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:244
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/box/fvelementgeometry.hh:269
void bindElement(const Element &element) &
Definition: discretization/box/fvelementgeometry.hh:311
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/box/fvelementgeometry.hh:233
const GridGeometry & gridGeometry() const
The grid geometry we are a restriction of.
Definition: discretization/box/fvelementgeometry.hh:327
typename GridView::template Codim< 0 >::Entity Element
export the element type
Definition: discretization/box/fvelementgeometry.hh:212
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:256
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/box/fvelementgeometry.hh:263
const Element & element() const
The bound element.
Definition: discretization/box/fvelementgeometry.hh:323
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/box/fvelementgeometry.hh:227
BoxFVElementGeometry 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/box/fvelementgeometry.hh:285
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/box/fvelementgeometry.hh:216
BoxFVElementGeometry 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/box/fvelementgeometry.hh:302
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/box/fvelementgeometry.hh:214
void bind(const Element &element) &
Definition: discretization/box/fvelementgeometry.hh:294