26#ifndef DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
27#define DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
29#include <dune/geometry/type.hh>
30#include <dune/geometry/referenceelements.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 Element =
typename GridView::template Codim<0>::Entity;
60 using CoordScalar =
typename GridView::ctype;
61 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
62 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
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(elemGeometryType_).localBasis();
124 return gridGeometry().scvs(eIdx_).size();
130 return gridGeometry().scvfs(eIdx_).size();
136 void bind(
const Element& element)
138 this->bindElement(element);
146 elemGeometryType_ = element.type();
147 eIdx_ = gridGeometry().elementMapper().index(element);
152 {
return *gridGeometryPtr_; }
156 {
return gridGeometry().hasBoundaryScvf(eIdx_); }
159 Dune::GeometryType elemGeometryType_;
160 const GridGeometry* gridGeometryPtr_;
169 using GridView =
typename GG::GridView;
170 static constexpr int dim = GridView::dimension;
171 static constexpr int dimWorld = GridView::dimensionworld;
174 using Element =
typename GridView::template Codim<0>::Entity;
175 using CoordScalar =
typename GridView::ctype;
176 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
177 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
180 typename GG::SubControlVolume,
181 typename GG::SubControlVolumeFace>;
190 static constexpr std::size_t maxNumElementScvs = (1<<dim);
194 : gridGeometryPtr_(&gridGeometry) {}
199 return scvs_[scvIdx];
205 return scvfs_[scvfIdx];
213 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
216 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
217 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
225 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
228 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
229 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
235 return gridGeometry().feCache().get(elemGeometryType_).localBasis();
247 return scvfs_.size();
253 void bind(
const Element& element)
255 this->bindElement(element);
263 eIdx_ = gridGeometry().elementMapper().index(element);
264 makeElementGeometries(element);
269 {
return *gridGeometryPtr_; }
273 {
return hasBoundaryScvf_; }
277 void makeElementGeometries(
const Element& element)
279 hasBoundaryScvf_ =
false;
282 auto elementGeometry = element.geometry();
283 elemGeometryType_ = elementGeometry.type();
284 const auto referenceElement = ReferenceElements::general(elemGeometryType_);
287 GeometryHelper geometryHelper(elementGeometry);
290 scvs_.resize(elementGeometry.corners());
291 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
294 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
297 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
304 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
305 scvfs_.resize(numInnerScvf);
307 LocalIndexType scvfLocalIdx = 0;
308 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
311 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
312 static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
314 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
318 std::move(localScvIndices),
323 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
325 if (intersection.boundary() && !intersection.neighbor())
327 const auto isGeometry = intersection.geometry();
328 hasBoundaryScvf_ =
true;
330 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
333 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(referenceElement.subEntity(intersection.indexInInside(), 1, isScvfLocalIdx, dim));
334 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
336 scvfs_.emplace_back(geometryHelper,
341 std::move(localScvIndices),
352 Dune::GeometryType elemGeometryType_;
356 const GridGeometry* gridGeometryPtr_;
359 std::vector<SubControlVolume> scvs_;
360 std::vector<SubControlVolumeFace> scvfs_;
362 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:37
Base class for the finite volume geometry vector for box models This builds up the sub control volume...
Definition: discretization/box/fvelementgeometry.hh:48
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
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:151
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:155
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
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/box/fvelementgeometry.hh:69
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/box/fvelementgeometry.hh:245
BoxFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/box/fvelementgeometry.hh:193
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/box/fvelementgeometry.hh:188
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/box/fvelementgeometry.hh:272
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:214
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/box/fvelementgeometry.hh:239
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/box/fvelementgeometry.hh:203
const GridGeometry & gridGeometry() const
The grid geometry we are a restriction of.
Definition: discretization/box/fvelementgeometry.hh:268
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:226
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/box/fvelementgeometry.hh:233
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/box/fvelementgeometry.hh:197
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/box/fvelementgeometry.hh:186
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/box/fvelementgeometry.hh:184
void bind(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:253
void bindElement(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:261