29#ifndef DUMUX_POROUSMEDIUMFLOW_BOXDFM_FV_ELEMENT_GEOMETRY_HH
30#define DUMUX_POROUSMEDIUMFLOW_BOXDFM_FV_ELEMENT_GEOMETRY_HH
32#include <dune/common/version.hh>
33#include <dune/geometry/type.hh>
34#include <dune/geometry/referenceelements.hh>
35#include <dune/localfunctions/lagrange/pqkfactory.hh>
51template<
class GG,
bool enableGr
idGeometryCache>
58 using GridView =
typename GG::GridView;
59 static constexpr int dim = GridView::dimension;
60 static constexpr int dimWorld = GridView::dimensionworld;
61 using GridIndexType =
typename GridView::IndexSet::IndexType;
62 using Element =
typename GridView::template Codim<0>::Entity;
63 using CoordScalar =
typename GridView::ctype;
64 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
65 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
78 static constexpr std::size_t maxNumElementScvs = (1<<dim)*3;
82 : gridGeometryPtr_(&gridGeometry) {}
86 {
return gridGeometry().scvs(eIdx_)[scvIdx]; }
90 {
return gridGeometry().scvfs(eIdx_)[scvfIdx]; }
100 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
103 const auto& g = fvGeometry.gridGeometry();
104 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
105 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
116 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
119 const auto& g = fvGeometry.gridGeometry();
120 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
121 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
126 {
return gridGeometry().feCache().get(elemGeometryType_).localBasis(); }
130 {
return gridGeometry().scvs(eIdx_).size(); }
134 {
return gridGeometry().scvfs(eIdx_).size(); }
138 void bind(
const Element& element)
140 this->bindElement(element);
151 elemGeometryType_ = element.type();
152 eIdx_ = gridGeometry().elementMapper().index(element);
156 [[deprecated(
"Use gridGeometry() instead. fvGridGeometry() will be removed after 3.1!")]]
158 {
return *gridGeometryPtr_; }
162 {
return *gridGeometryPtr_; }
165 Dune::GeometryType elemGeometryType_;
166 const GridGeometry* gridGeometryPtr_;
174 using GridView =
typename GG::GridView;
175 static constexpr int dim = GridView::dimension;
176 static constexpr int dimWorld = GridView::dimensionworld;
178 using GridIndexType =
typename GridView::IndexSet::IndexType;
179 using Element =
typename GridView::template Codim<0>::Entity;
181 using CoordScalar =
typename GridView::ctype;
182 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
183 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
184 using FaceReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim-1>;
187 typename GG::SubControlVolume,
188 typename GG::SubControlVolumeFace>;
200 static constexpr std::size_t maxNumElementScvs = (1<<dim)*3;
204 : gridGeometryPtr_(&gridGeometry) {}
208 {
return scvs_[scvIdx]; }
212 {
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());
237 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
240 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
241 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
246 {
return gridGeometry().feCache().get(elemGeometryType_).localBasis(); }
250 {
return scvs_.size(); }
254 {
return scvfs_.size(); }
258 void bind(
const Element& element)
260 this->bindElement(element);
271 eIdx_ = gridGeometry().elementMapper().index(element);
272 makeElementGeometries(element);
276 [[deprecated(
"Use gridGeometry() instead. fvGridGeometry() will be removed after 3.1!")]]
278 {
return *gridGeometryPtr_; }
282 {
return *gridGeometryPtr_; }
286 void makeElementGeometries(
const Element& element)
288 auto eIdx = gridGeometry().elementMapper().index(element);
291 auto elementGeometry = element.geometry();
292 elemGeometryType_ = elementGeometry.type();
293 const auto referenceElement = ReferenceElements::general(elemGeometryType_);
296 GeometryHelper geometryHelper(elementGeometry);
299 scvs_.resize(elementGeometry.corners());
300 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
301 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
304 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
307 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
314 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
315 scvfs_.resize(numInnerScvf);
317 unsigned int scvfLocalIdx = 0;
318 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
321 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
322 static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
324 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
328 std::move(localScvIndices));
342 LocalIndexType scvLocalIdx = element.subEntities(dim);
343 for (
const auto& intersection :
intersections(gridGeometry().gridView(), element))
346 const auto& isGeometry = intersection.geometry();
347 const auto numCorners = isGeometry.corners();
348 const auto idxInInside = intersection.indexInInside();
350 std::vector<GridIndexType> isVertexIndices(numCorners);
351 for (
unsigned int vIdxLocal = 0; vIdxLocal < numCorners; ++vIdxLocal)
352 isVertexIndices[vIdxLocal] = gridGeometry().vertexMapper().subIndex(element,
353 referenceElement.subEntity(idxInInside, 1, vIdxLocal, dim),
356 if (intersection.boundary())
358 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < numCorners; ++isScvfLocalIdx)
361 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(referenceElement.subEntity(idxInInside, 1, isScvfLocalIdx, dim));
362 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
364 scvfs_.emplace_back(geometryHelper,
369 std::move(localScvIndices));
377 if (this->gridGeometry().isOnFracture(element, intersection))
380 const auto curNumScvs = scvs_.size();
381 scvs_.reserve(curNumScvs+numCorners);
382 for (
unsigned int vIdxLocal = 0; vIdxLocal < numCorners; ++vIdxLocal)
383 scvs_.emplace_back(geometryHelper,
387 static_cast<LocalIndexType
>(referenceElement.subEntity(idxInInside, 1, vIdxLocal, dim)),
391 isVertexIndices[vIdxLocal]);
396 const auto& faceReferenceElement = FaceReferenceElements::general(isGeometry.type());
397 for (
unsigned int edgeIdx = 0; edgeIdx < faceReferenceElement.size(1); ++edgeIdx)
400 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(faceReferenceElement.subEntity(edgeIdx, 1, 0, dim-1)),
401 static_cast<LocalIndexType
>(faceReferenceElement.subEntity(edgeIdx, 1, 1, dim-1))});
404 std::for_each( localScvIndices.begin(),
405 localScvIndices.end(),
406 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
409 scvfs_.emplace_back(geometryHelper,
414 std::move(localScvIndices),
415 intersection.boundary());
423 std::vector<LocalIndexType> localScvIndices({0, 1});
426 std::for_each( localScvIndices.begin(),
427 localScvIndices.end(),
428 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
431 scvfs_.emplace_back(geometryHelper,
436 std::move(localScvIndices),
437 intersection.boundary());
444 Dune::GeometryType elemGeometryType_;
448 const GridGeometry* gridGeometryPtr_;
457 std::vector<SubControlVolume> scvs_;
458 std::vector<SubControlVolumeFace> scvfs_;
Class providing iterators over sub control volumes and sub control volume faces of an element.
Helper class constructing the dual grid finite volume geometries for the box discrete fracture model.
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
Base class for the finite volume geometry vector for box discrete fracture model.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:52
typename GG::SubControlVolumeFace SubControlVolumeFace
Export type of subcontrol volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:70
std::size_t numScv() const
The total number of sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:129
void bind(const Element &element)
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:138
void bindElement(const Element &element)
Binding of an element, has to be called before using the fvgeometries.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:149
const SubControlVolumeFace & scvf(std::size_t scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:89
GG GridGeometry
Export type of finite volume grid geometry.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:72
BoxDfmFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:81
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:133
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:125
typename GG::SubControlVolume SubControlVolume
Export type of subcontrol volume.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:68
const SubControlVolume & scv(std::size_t scvIdx) const
Get a sub control volume with a local scv index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:85
const GridGeometry & fvGridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:157
GridGeometry FVGridGeometry
Export type of finite volume grid geometry.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:74
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:101
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:161
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:117
void bindElement(const Element &element)
Binding of an element, has to be called before using the fvgeometries.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:269
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:245
const SubControlVolumeFace & scvf(std::size_t scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:211
GridGeometry FVGridGeometry
export type of finite volume grid geometry
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:197
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:281
void bind(const Element &element)
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:258
const GridGeometry & fvGridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:277
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:253
BoxDfmFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:203
std::size_t numScv() const
The total number of sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:249
const SubControlVolume & scv(std::size_t scvIdx) const
Get a sub control volume with a local scv index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:207
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:223
GG GridGeometry
Export type of finite volume grid geometry.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:195
typename GG::SubControlVolumeFace SubControlVolumeFace
Export type of subcontrol volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:193
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:238
typename GG::SubControlVolume SubControlVolume
Export type of subcontrol volume.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:191
Create sub control volumes and sub control volume face geometries.
Definition: geometryhelper.hh:35