17#ifndef DUMUX_POROUSMEDIUMFLOW_BOXDFM_FV_ELEMENT_GEOMETRY_HH
18#define DUMUX_POROUSMEDIUMFLOW_BOXDFM_FV_ELEMENT_GEOMETRY_HH
23#include <dune/geometry/type.hh>
24#include <dune/localfunctions/lagrange/pqkfactory.hh>
40template<
class GG,
bool enableGr
idGeometryCache>
47 using GridView =
typename GG::GridView;
48 static constexpr int dim = GridView::dimension;
49 static constexpr int dimWorld = GridView::dimensionworld;
50 using GridIndexType =
typename GridView::IndexSet::IndexType;
51 using CoordScalar =
typename GridView::ctype;
52 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
55 using Element =
typename GridView::template Codim<0>::Entity;
65 static constexpr std::size_t maxNumElementScvs = (1<<dim)*3;
69 : gridGeometryPtr_(&gridGeometry) {}
73 {
return gridGeometry().scvs(eIdx_)[scvIdx]; }
77 {
return gridGeometry().scvfs(eIdx_)[scvfIdx]; }
87 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
90 const auto& g = fvGeometry.gridGeometry();
91 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
92 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
103 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
106 const auto& g = fvGeometry.gridGeometry();
107 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
108 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
113 {
return gridGeometry().feCache().get(element_->type()).localBasis(); }
117 {
return gridGeometry().scvs(eIdx_).size(); }
121 {
return gridGeometry().scvfs(eIdx_).size(); }
130 this->bindElement(element);
131 return std::move(*
this);
137 { this->bindElement(element); }
146 this->bindElement(element);
147 return std::move(*
this);
159 eIdx_ = gridGeometry().elementMapper().index(element);
164 {
return *gridGeometryPtr_; }
168 {
return static_cast<bool>(element_); }
172 {
return *element_; }
176 #pragma GCC diagnostic push
177 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
181 {
return scv.geometry(); }
185 {
return scvf.geometry(); }
187 #pragma GCC diagnostic pop
190 const GridGeometry* gridGeometryPtr_;
192 std::optional<Element> element_;
200 using GridView =
typename GG::GridView;
201 static constexpr int dim = GridView::dimension;
202 static constexpr int dimWorld = GridView::dimensionworld;
204 using GridIndexType =
typename GridView::IndexSet::IndexType;
206 using CoordScalar =
typename GridView::ctype;
207 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
208 using GeometryHelper =
typename GG::GeometryHelper;
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 #pragma GCC diagnostic push
333 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
337 {
return scv.geometry(); }
341 {
return scvf.geometry(); }
343 #pragma GCC diagnostic pop
347 void makeElementGeometries_()
350 const auto& element = *element_;
351 const auto elementGeometry = element.geometry();
352 const auto refElement = referenceElement(element);
355 GeometryHelper geometryHelper(elementGeometry);
358 scvs_.resize(elementGeometry.corners());
359 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
360 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
363 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
366 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
373 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
374 scvfs_.resize(numInnerScvf);
376 unsigned int scvfLocalIdx = 0;
377 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
380 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
381 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
383 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
387 std::move(localScvIndices));
401 LocalIndexType scvLocalIdx =
element.subEntities(dim);
402 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
405 const auto& isGeometry = intersection.geometry();
407 const auto idxInInside = intersection.indexInInside();
409 std::vector<GridIndexType> isVertexIndices(
numCorners);
410 for (
unsigned int vIdxLocal = 0; vIdxLocal <
numCorners; ++vIdxLocal)
411 isVertexIndices[vIdxLocal] = gridGeometry().vertexMapper().subIndex(element,
412 refElement.subEntity(idxInInside, 1, vIdxLocal, dim),
415 if (intersection.boundary())
417 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx <
numCorners; ++isScvfLocalIdx)
420 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, isScvfLocalIdx, dim));
421 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
423 scvfs_.emplace_back(geometryHelper,
428 std::move(localScvIndices));
436 if (this->gridGeometry().isOnFracture(element, intersection))
439 const auto curNumScvs = scvs_.size();
441 for (
unsigned int vIdxLocal = 0; vIdxLocal <
numCorners; ++vIdxLocal)
442 scvs_.emplace_back(geometryHelper,
446 static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, vIdxLocal, dim)),
450 isVertexIndices[vIdxLocal]);
455 const auto& faceRefElement = referenceElement(isGeometry);
456 for (
unsigned int edgeIdx = 0; edgeIdx < faceRefElement.size(1); ++edgeIdx)
459 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(faceRefElement.subEntity(edgeIdx, 1, 0, dim-1)),
460 static_cast<LocalIndexType
>(faceRefElement.subEntity(edgeIdx, 1, 1, dim-1))});
463 std::for_each( localScvIndices.begin(),
464 localScvIndices.end(),
465 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
468 scvfs_.emplace_back(geometryHelper,
473 std::move(localScvIndices),
474 intersection.boundary());
482 std::vector<LocalIndexType> localScvIndices({0, 1});
485 std::for_each( localScvIndices.begin(),
486 localScvIndices.end(),
487 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
490 scvfs_.emplace_back(geometryHelper,
495 std::move(localScvIndices),
496 intersection.boundary());
503 std::optional<Element> element_;
507 const GridGeometry* gridGeometryPtr_;
510 std::vector<SubControlVolume> scvs_;
511 std::vector<SubControlVolumeFace> scvfs_;
SubControlVolume::Traits::Geometry geometry(const SubControlVolume &scv) const
Create the geometry of a given sub control volume.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:336
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
SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace &scvf) const
Create the geometry of a given sub control volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:340
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
typename GG::SubControlVolumeFace SubControlVolumeFace
Export type of subcontrol volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:59
void bindElement(const Element &element) &
Binding of an element, has to be called before using the fvgeometries.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:156
std::size_t numScv() const
The total number of sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:116
const SubControlVolumeFace & scvf(std::size_t scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:76
GG GridGeometry
Export type of finite volume grid geometry.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:61
const Element & element() const
The bound element.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:171
void bind(const Element &element) &
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:136
BoxDfmFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:68
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:120
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:112
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:55
typename GG::SubControlVolume SubControlVolume
Export type of subcontrol volume.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:57
SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace &scvf) const
Create the geometry of a given sub control volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:184
const SubControlVolume & scv(std::size_t scvIdx) const
Get a sub control volume with a local scv index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:72
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:128
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:88
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:163
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:167
SubControlVolume::Traits::Geometry geometry(const SubControlVolume &scv) const
Create the geometry of a given sub control volume.
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:104
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:144
Base class for the finite volume geometry vector for box discrete fracture model.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:41
std::size_t numCorners(Shape shape)
Returns the number of corners of a given geometry.
Definition: throatproperties.hh:220
Helper class constructing the dual grid finite volume geometries for the box discrete fracture model.
Class providing iterators over sub control volumes and sub control volume faces of an element.