26#ifndef DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
27#define DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
30#include <dune/geometry/type.hh>
31#include <dune/localfunctions/lagrange/pqkfactory.hh>
47template<
class GG,
bool enableGr
idGeometryCache>
54 using GridView =
typename GG::GridView;
55 static constexpr int dim = GridView::dimension;
56 static constexpr int dimWorld = GridView::dimensionworld;
59 using CoordScalar =
typename GridView::ctype;
60 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
63 using Element =
typename GridView::template Codim<0>::Entity;
71 static constexpr std::size_t maxNumElementScvs = (1<<dim);
75 : gridGeometryPtr_(&gridGeometry) {}
80 return gridGeometry().scvs(eIdx_)[scvIdx];
86 return gridGeometry().scvfs(eIdx_)[scvfIdx];
94 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
97 const auto& g = fvGeometry.gridGeometry();
98 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
99 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
107 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
110 const auto& g = fvGeometry.gridGeometry();
111 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
112 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
118 return gridGeometry().feCache().get(element_->type()).localBasis();
124 return gridGeometry().scvs(eIdx_).size();
130 return gridGeometry().scvfs(eIdx_).size();
138 this->bindElement(element);
148 eIdx_ = gridGeometry().elementMapper().index(element);
153 {
return static_cast<bool>(element_); }
157 {
return *element_; }
161 {
return *gridGeometryPtr_; }
165 {
return gridGeometry().hasBoundaryScvf(eIdx_); }
168 const GridGeometry* gridGeometryPtr_;
171 std::optional<Element> element_;
178 using GridView =
typename GG::GridView;
179 static constexpr int dim = GridView::dimension;
180 static constexpr int dimWorld = GridView::dimensionworld;
183 using CoordScalar =
typename GridView::ctype;
184 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
187 typename GG::SubControlVolume,
188 typename GG::SubControlVolumeFace>;
191 using Element =
typename GridView::template Codim<0>::Entity;
199 static constexpr std::size_t maxNumElementScvs = (1<<dim);
203 : gridGeometryPtr_(&gridGeometry) {}
208 return scvs_[scvIdx];
214 return scvfs_[scvfIdx];
222 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
225 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
226 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
234 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
237 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
238 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
244 return gridGeometry().feCache().get(element_->type()).localBasis();
256 return scvfs_.size();
264 this->bindElement(element);
273 eIdx_ = gridGeometry().elementMapper().index(element);
274 makeElementGeometries_();
279 {
return static_cast<bool>(element_); }
283 {
return *element_; }
287 {
return *gridGeometryPtr_; }
291 {
return hasBoundaryScvf_; }
295 void makeElementGeometries_()
297 hasBoundaryScvf_ =
false;
300 const auto& element = *element_;
301 const auto elementGeometry = element.geometry();
302 const auto refElement = referenceElement(elementGeometry);
305 GeometryHelper geometryHelper(elementGeometry);
308 scvs_.resize(elementGeometry.corners());
309 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
312 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
315 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
322 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
323 scvfs_.resize(numInnerScvf);
325 LocalIndexType scvfLocalIdx = 0;
326 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
329 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
330 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
332 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
336 std::move(localScvIndices),
341 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
343 if (intersection.boundary() && !intersection.neighbor())
345 const auto isGeometry = intersection.geometry();
346 hasBoundaryScvf_ =
true;
348 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
351 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(refElement.subEntity(intersection.indexInInside(), 1, isScvfLocalIdx, dim));
352 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
354 scvfs_.emplace_back(geometryHelper,
359 std::move(localScvIndices),
371 std::optional<Element> element_;
374 const GridGeometry* gridGeometryPtr_;
377 std::vector<SubControlVolume> scvs_;
378 std::vector<SubControlVolumeFace> scvfs_;
380 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:48
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/box/fvelementgeometry.hh:152
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/box/fvelementgeometry.hh:116
void bindElement(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:144
const Element & element() const
The bound element.
Definition: discretization/box/fvelementgeometry.hh:156
BoxFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/box/fvelementgeometry.hh:74
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:95
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/box/fvelementgeometry.hh:122
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/box/fvelementgeometry.hh:78
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/box/fvelementgeometry.hh:128
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/box/fvelementgeometry.hh:65
const GridGeometry & gridGeometry() const
The grid geometry we are a restriction of.
Definition: discretization/box/fvelementgeometry.hh:160
void bind(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:136
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/box/fvelementgeometry.hh:164
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:108
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/box/fvelementgeometry.hh:67
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/box/fvelementgeometry.hh:84
typename GridView::template Codim< 0 >::Entity Element
export the element type
Definition: discretization/box/fvelementgeometry.hh:63
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/box/fvelementgeometry.hh:69
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/box/fvelementgeometry.hh:278
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/box/fvelementgeometry.hh:254
BoxFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/box/fvelementgeometry.hh:202
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/box/fvelementgeometry.hh:197
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/box/fvelementgeometry.hh:290
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:223
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/box/fvelementgeometry.hh:248
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/box/fvelementgeometry.hh:212
const GridGeometry & gridGeometry() const
The grid geometry we are a restriction of.
Definition: discretization/box/fvelementgeometry.hh:286
typename GridView::template Codim< 0 >::Entity Element
export the element type
Definition: discretization/box/fvelementgeometry.hh:191
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:235
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/box/fvelementgeometry.hh:242
const Element & element() const
The bound element.
Definition: discretization/box/fvelementgeometry.hh:282
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/box/fvelementgeometry.hh:206
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/box/fvelementgeometry.hh:195
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/box/fvelementgeometry.hh:193
void bind(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:262
void bindElement(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:270