29#ifndef DUMUX_POROUSMEDIUMFLOW_BOXDFM_FV_ELEMENT_GEOMETRY_HH
30#define DUMUX_POROUSMEDIUMFLOW_BOXDFM_FV_ELEMENT_GEOMETRY_HH
35#include <dune/common/version.hh>
36#include <dune/geometry/type.hh>
37#include <dune/localfunctions/lagrange/pqkfactory.hh>
53template<
class GG,
bool enableGr
idGeometryCache>
60 using GridView =
typename GG::GridView;
61 static constexpr int dim = GridView::dimension;
62 static constexpr int dimWorld = GridView::dimensionworld;
63 using GridIndexType =
typename GridView::IndexSet::IndexType;
64 using CoordScalar =
typename GridView::ctype;
65 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
68 using Element =
typename GridView::template Codim<0>::Entity;
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(element_->type()).localBasis(); }
130 {
return gridGeometry().scvs(eIdx_).size(); }
134 {
return gridGeometry().scvfs(eIdx_).size(); }
143 this->bindElement(element);
144 return std::move(*
this);
150 { this->bindElement(element); }
159 this->bindElement(element);
160 return std::move(*
this);
172 eIdx_ = gridGeometry().elementMapper().index(element);
177 {
return *gridGeometryPtr_; }
181 {
return static_cast<bool>(element_); }
185 {
return *element_; }
188 const GridGeometry* gridGeometryPtr_;
190 std::optional<Element> element_;
198 using GridView =
typename GG::GridView;
199 static constexpr int dim = GridView::dimension;
200 static constexpr int dimWorld = GridView::dimensionworld;
202 using GridIndexType =
typename GridView::IndexSet::IndexType;
204 using CoordScalar =
typename GridView::ctype;
205 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
207 typename GG::SubControlVolume,
208 typename GG::SubControlVolumeFace>;
211 using Element =
typename GridView::template Codim<0>::Entity;
220 static constexpr std::size_t maxNumElementScvs = (1<<dim)*3;
224 : gridGeometryPtr_(&gridGeometry) {}
228 {
return scvs_[scvIdx]; }
232 {
return scvfs_[scvfIdx]; }
242 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
245 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
246 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
257 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
260 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
261 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
266 {
return gridGeometry().feCache().get(element_->type()).localBasis(); }
270 {
return scvs_.size(); }
274 {
return scvfs_.size(); }
283 this->bindElement(element);
284 return std::move(*
this);
294 { this->bindElement(element); }
303 this->bindElement(element);
304 return std::move(*
this);
314 eIdx_ = gridGeometry().elementMapper().index(element);
315 makeElementGeometries_();
320 {
return *gridGeometryPtr_; }
324 {
return static_cast<bool>(element_); }
328 {
return *element_; }
332 void makeElementGeometries_()
335 const auto& element = *element_;
336 const auto elementGeometry = element.geometry();
337 const auto refElement = referenceElement(element);
340 GeometryHelper geometryHelper(elementGeometry);
343 scvs_.resize(elementGeometry.corners());
344 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
345 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
348 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
351 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
358 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
359 scvfs_.resize(numInnerScvf);
361 unsigned int scvfLocalIdx = 0;
362 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
365 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
366 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
368 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
372 std::move(localScvIndices));
386 LocalIndexType scvLocalIdx =
element.subEntities(dim);
387 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
390 const auto& isGeometry = intersection.geometry();
392 const auto idxInInside = intersection.indexInInside();
394 std::vector<GridIndexType> isVertexIndices(
numCorners);
395 for (
unsigned int vIdxLocal = 0; vIdxLocal <
numCorners; ++vIdxLocal)
396 isVertexIndices[vIdxLocal] = gridGeometry().vertexMapper().subIndex(element,
397 refElement.subEntity(idxInInside, 1, vIdxLocal, dim),
400 if (intersection.boundary())
402 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx <
numCorners; ++isScvfLocalIdx)
405 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, isScvfLocalIdx, dim));
406 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
408 scvfs_.emplace_back(geometryHelper,
413 std::move(localScvIndices));
421 if (this->gridGeometry().isOnFracture(element, intersection))
424 const auto curNumScvs = scvs_.size();
426 for (
unsigned int vIdxLocal = 0; vIdxLocal <
numCorners; ++vIdxLocal)
427 scvs_.emplace_back(geometryHelper,
431 static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, vIdxLocal, dim)),
435 isVertexIndices[vIdxLocal]);
440 const auto& faceRefElement = referenceElement(isGeometry);
441 for (
unsigned int edgeIdx = 0; edgeIdx < faceRefElement.size(1); ++edgeIdx)
444 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(faceRefElement.subEntity(edgeIdx, 1, 0, dim-1)),
445 static_cast<LocalIndexType
>(faceRefElement.subEntity(edgeIdx, 1, 1, dim-1))});
448 std::for_each( localScvIndices.begin(),
449 localScvIndices.end(),
450 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
453 scvfs_.emplace_back(geometryHelper,
458 std::move(localScvIndices),
459 intersection.boundary());
467 std::vector<LocalIndexType> localScvIndices({0, 1});
470 std::for_each( localScvIndices.begin(),
471 localScvIndices.end(),
472 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
475 scvfs_.emplace_back(geometryHelper,
480 std::move(localScvIndices),
481 intersection.boundary());
488 std::optional<Element> element_;
492 const GridGeometry* gridGeometryPtr_;
495 std::vector<SubControlVolume> scvs_;
496 std::vector<SubControlVolumeFace> scvfs_;
Class providing iterators over sub control volumes and sub control volume faces of an element.
std::size_t numCorners(Shape shape)
Returns the number of corners of a given geometry.
Definition: throatproperties.hh:215
Base class for the finite volume geometry vector for box discrete fracture model.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:54
typename GG::SubControlVolumeFace SubControlVolumeFace
Export type of subcontrol volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:72
void bindElement(const Element &element) &
Binding of an element, has to be called before using the fvgeometries.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:169
std::size_t numScv() const
The total number of sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:129
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:74
const Element & element() const
The bound element.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:184
void bind(const Element &element) &
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:149
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 GridView::template Codim< 0 >::Entity Element
export type of the element
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:68
typename GG::SubControlVolume SubControlVolume
Export type of subcontrol volume.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:70
const SubControlVolume & scv(std::size_t scvIdx) const
Get a sub control volume with a local scv index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:85
BoxDfmFVElementGeometry bind(const Element &element) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:141
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:176
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:180
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
BoxDfmFVElementGeometry bindElement(const Element &element) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:157
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:265
const SubControlVolumeFace & scvf(std::size_t scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:231
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:319
BoxDfmFVElementGeometry bindElement(const Element &element) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:301
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:211
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:273
void bind(const Element &element) &
Binding of an element, has to be called before using the fvgeometries Prepares all the volume variabl...
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:293
BoxDfmFVElementGeometry bind(const Element &element) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:281
const Element & element() const
The bound element.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:327
BoxDfmFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:223
std::size_t numScv() const
The total number of sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:269
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:323
const SubControlVolume & scv(std::size_t scvIdx) const
Get a sub control volume with a local scv index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:227
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:243
GG GridGeometry
Export type of finite volume grid geometry.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:217
typename GG::SubControlVolumeFace SubControlVolumeFace
Export type of subcontrol volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:215
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:258
typename GG::SubControlVolume SubControlVolume
Export type of subcontrol volume.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:213
void bindElement(const Element &element) &
Binding of an element, has to be called before using the fvgeometries Prepares all the volume variabl...
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:311
Create sub control volumes and sub control volume face geometries.
Definition: porousmediumflow/boxdfm/geometryhelper.hh:35
Helper class constructing the dual grid finite volume geometries for the box discrete fracture model.