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/localfunctions/lagrange/pqkfactory.hh>
46template<
class GG,
bool enableGr
idGeometryCache>
53 using GridView =
typename GG::GridView;
54 static constexpr int dim = GridView::dimension;
55 static constexpr int dimWorld = GridView::dimensionworld;
58 using CoordScalar =
typename GridView::ctype;
59 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
62 using Element =
typename GridView::template Codim<0>::Entity;
70 static constexpr std::size_t maxNumElementScvs = (1<<dim);
74 : gridGeometryPtr_(&gridGeometry) {}
79 return gridGeometry().scvs(eIdx_)[scvIdx];
85 return gridGeometry().scvfs(eIdx_)[scvfIdx];
93 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
96 const auto& g = fvGeometry.gridGeometry();
97 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
98 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
106 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
109 const auto& g = fvGeometry.gridGeometry();
110 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
111 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
117 return gridGeometry().feCache().get(elemGeometryType_).localBasis();
123 return gridGeometry().scvs(eIdx_).size();
129 return gridGeometry().scvfs(eIdx_).size();
137 this->bindElement(element);
145 elemGeometryType_ = element.type();
146 eIdx_ = gridGeometry().elementMapper().index(element);
151 {
return *gridGeometryPtr_; }
155 {
return gridGeometry().hasBoundaryScvf(eIdx_); }
158 Dune::GeometryType elemGeometryType_;
159 const GridGeometry* gridGeometryPtr_;
168 using GridView =
typename GG::GridView;
169 static constexpr int dim = GridView::dimension;
170 static constexpr int dimWorld = GridView::dimensionworld;
173 using CoordScalar =
typename GridView::ctype;
174 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
177 typename GG::SubControlVolume,
178 typename GG::SubControlVolumeFace>;
181 using Element =
typename GridView::template Codim<0>::Entity;
189 static constexpr std::size_t maxNumElementScvs = (1<<dim);
193 : gridGeometryPtr_(&gridGeometry) {}
198 return scvs_[scvIdx];
204 return scvfs_[scvfIdx];
212 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
215 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
216 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
224 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
227 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
228 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
234 return gridGeometry().feCache().get(elemGeometryType_).localBasis();
246 return scvfs_.size();
254 this->bindElement(element);
262 eIdx_ = gridGeometry().elementMapper().index(element);
263 makeElementGeometries(element);
268 {
return *gridGeometryPtr_; }
272 {
return hasBoundaryScvf_; }
276 void makeElementGeometries(
const Element& element)
278 hasBoundaryScvf_ =
false;
281 auto elementGeometry = element.geometry();
282 elemGeometryType_ = elementGeometry.type();
283 const auto refElement = referenceElement(elementGeometry);
286 GeometryHelper geometryHelper(elementGeometry);
289 scvs_.resize(elementGeometry.corners());
290 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
293 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
296 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
303 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
304 scvfs_.resize(numInnerScvf);
306 LocalIndexType scvfLocalIdx = 0;
307 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
310 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
311 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
313 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
317 std::move(localScvIndices),
322 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
324 if (intersection.boundary() && !intersection.neighbor())
326 const auto isGeometry = intersection.geometry();
327 hasBoundaryScvf_ =
true;
329 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
332 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(refElement.subEntity(intersection.indexInInside(), 1, isScvfLocalIdx, dim));
333 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
335 scvfs_.emplace_back(geometryHelper,
340 std::move(localScvIndices),
351 Dune::GeometryType elemGeometryType_;
355 const GridGeometry* gridGeometryPtr_;
358 std::vector<SubControlVolume> scvs_;
359 std::vector<SubControlVolumeFace> scvfs_;
361 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:47
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/box/fvelementgeometry.hh:115
void bindElement(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:143
BoxFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/box/fvelementgeometry.hh:73
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:94
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/box/fvelementgeometry.hh:121
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/box/fvelementgeometry.hh:77
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/box/fvelementgeometry.hh:127
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/box/fvelementgeometry.hh:64
const GridGeometry & gridGeometry() const
The grid geometry we are a restriction of.
Definition: discretization/box/fvelementgeometry.hh:150
void bind(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:135
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/box/fvelementgeometry.hh:154
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:107
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/box/fvelementgeometry.hh:66
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/box/fvelementgeometry.hh:83
typename GridView::template Codim< 0 >::Entity Element
export the element type
Definition: discretization/box/fvelementgeometry.hh:62
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/box/fvelementgeometry.hh:68
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/box/fvelementgeometry.hh:244
BoxFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/box/fvelementgeometry.hh:192
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/box/fvelementgeometry.hh:187
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/box/fvelementgeometry.hh:271
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:213
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/box/fvelementgeometry.hh:238
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/box/fvelementgeometry.hh:202
const GridGeometry & gridGeometry() const
The grid geometry we are a restriction of.
Definition: discretization/box/fvelementgeometry.hh:267
typename GridView::template Codim< 0 >::Entity Element
export the element type
Definition: discretization/box/fvelementgeometry.hh:181
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFVElementGeometry &fvGeometry)
Definition: discretization/box/fvelementgeometry.hh:225
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/box/fvelementgeometry.hh:232
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/box/fvelementgeometry.hh:196
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/box/fvelementgeometry.hh:185
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/box/fvelementgeometry.hh:183
void bind(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:252
void bindElement(const Element &element)
Definition: discretization/box/fvelementgeometry.hh:260