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>;
70 using FVGridGeometry [[deprecated (
"Use GridGeometry instead. Will be removed after 3.1!")]]=
GridGeometry;
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(elemGeometryType_).localBasis();
137 void bind(
const Element& element)
147 elemGeometryType_ = element.type();
152 [[deprecated (
"Use gridGeometry() instead. fvGridGeometry() will be removed after 3.1!")]]
156 {
return *gridGeometryPtr_; }
163 Dune::GeometryType elemGeometryType_;
164 const GridGeometry* gridGeometryPtr_;
173 using GridView =
typename GG::GridView;
174 static constexpr int dim = GridView::dimension;
175 static constexpr int dimWorld = GridView::dimensionworld;
178 using Element =
typename GridView::template Codim<0>::Entity;
179 using CoordScalar =
typename GridView::ctype;
180 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
181 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
184 typename GG::SubControlVolume,
185 typename GG::SubControlVolumeFace>;
193 using FVGridGeometry [[deprecated (
"Use GridGeometry instead. Will be removed after 3.1!")]]=
GridGeometry;
204 return scvs_[scvIdx];
210 return scvfs_[scvfIdx];
218 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
221 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
222 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
230 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
233 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
234 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
240 return gridGeometry().feCache().get(elemGeometryType_).localBasis();
252 return scvfs_.size();
258 void bind(
const Element& element)
269 makeElementGeometries(element);
273 [[deprecated (
"Use gridGeometry() instead. fvGridGeometry() will be removed after 3.1!")]]
277 {
return *gridGeometryPtr_; }
281 {
return hasBoundaryScvf_; }
285 void makeElementGeometries(
const Element& element)
287 hasBoundaryScvf_ =
false;
290 auto elementGeometry = element.geometry();
291 elemGeometryType_ = elementGeometry.type();
292 const auto referenceElement = ReferenceElements::general(elemGeometryType_);
295 GeometryHelper geometryHelper(elementGeometry);
298 scvs_.resize(elementGeometry.corners());
299 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
302 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
305 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
312 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
313 scvfs_.resize(numInnerScvf);
315 LocalIndexType scvfLocalIdx = 0;
316 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
319 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
320 static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
322 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
326 std::move(localScvIndices),
331 for (
const auto& intersection :
intersections(gridGeometry().gridView(), element))
333 if (intersection.boundary() && !intersection.neighbor())
335 const auto isGeometry = intersection.geometry();
336 hasBoundaryScvf_ =
true;
338 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
341 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(referenceElement.subEntity(intersection.indexInInside(), 1, isScvfLocalIdx, dim));
342 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
344 scvfs_.emplace_back(geometryHelper,
349 std::move(localScvIndices),
360 Dune::GeometryType elemGeometryType_;
364 const GridGeometry* gridGeometryPtr_;
367 std::vector<SubControlVolume> scvs_;
368 std::vector<SubControlVolumeFace> scvfs_;
370 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.
Dune::IteratorRange< typename MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper >::Intersections::const_iterator > intersections(const MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper > &glue)
Range generator to iterate with range-based for loops over all intersections as follows: for (const a...
Definition glue.hh:62
make the local view function available whenever we use the grid geometry
Definition adapt.hh:29
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:117
void bindElement(const Element &element)
Definition discretization/box/fvelementgeometry.hh:145
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:65
const GridGeometry & gridGeometry() const
Definition discretization/box/fvelementgeometry.hh:155
const GridGeometry & fvGridGeometry() const
The global finite volume geometry we are a restriction of.
Definition discretization/box/fvelementgeometry.hh:153
void bind(const Element &element)
Definition discretization/box/fvelementgeometry.hh:137
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition discretization/box/fvelementgeometry.hh:159
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFVElementGeometry &fvGeometry)
Definition discretization/box/fvelementgeometry.hh:109
static constexpr std::size_t maxNumElementScvs
the maximum number of scvs per element (2^dim for cubes)
Definition discretization/box/fvelementgeometry.hh:72
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:85
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:250
BoxFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition discretization/box/fvelementgeometry.hh:198
GG GridGeometry
export type of finite volume grid geometry
Definition discretization/box/fvelementgeometry.hh:192
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition discretization/box/fvelementgeometry.hh:280
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFVElementGeometry &fvGeometry)
Definition discretization/box/fvelementgeometry.hh:219
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/box/fvelementgeometry.hh:244
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition discretization/box/fvelementgeometry.hh:208
const GridGeometry & gridGeometry() const
Definition discretization/box/fvelementgeometry.hh:276
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFVElementGeometry &fvGeometry)
Definition discretization/box/fvelementgeometry.hh:231
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition discretization/box/fvelementgeometry.hh:238
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition discretization/box/fvelementgeometry.hh:202
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition discretization/box/fvelementgeometry.hh:190
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition discretization/box/fvelementgeometry.hh:188
void bind(const Element &element)
Definition discretization/box/fvelementgeometry.hh:258
static constexpr std::size_t maxNumElementScvs
the maximum number of scvs per element (2^dim for cubes)
Definition discretization/box/fvelementgeometry.hh:195
const GridGeometry & fvGridGeometry() const
The global finite volume geometry we are a restriction of.
Definition discretization/box/fvelementgeometry.hh:274
void bindElement(const Element &element)
Definition discretization/box/fvelementgeometry.hh:266