29#ifndef DUMUX_POROUSMEDIUMFLOW_BOXDFM_FV_ELEMENT_GEOMETRY_HH
30#define DUMUX_POROUSMEDIUMFLOW_BOXDFM_FV_ELEMENT_GEOMETRY_HH
34#include <dune/common/version.hh>
35#include <dune/geometry/type.hh>
36#include <dune/localfunctions/lagrange/pqkfactory.hh>
52template<
class GG,
bool enableGr
idGeometryCache>
59 using GridView =
typename GG::GridView;
60 static constexpr int dim = GridView::dimension;
61 static constexpr int dimWorld = GridView::dimensionworld;
62 using GridIndexType =
typename GridView::IndexSet::IndexType;
63 using Element =
typename GridView::template Codim<0>::Entity;
64 using CoordScalar =
typename GridView::ctype;
65 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
76 static constexpr std::size_t maxNumElementScvs = (1<<dim)*3;
80 : gridGeometryPtr_(&gridGeometry) {}
84 {
return gridGeometry().scvs(eIdx_)[scvIdx]; }
88 {
return gridGeometry().scvfs(eIdx_)[scvfIdx]; }
98 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
101 const auto& g = fvGeometry.gridGeometry();
102 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
103 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
114 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
117 const auto& g = fvGeometry.gridGeometry();
118 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
119 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
124 {
return gridGeometry().feCache().get(element_->type()).localBasis(); }
128 {
return gridGeometry().scvs(eIdx_).size(); }
132 {
return gridGeometry().scvfs(eIdx_).size(); }
136 void bind(
const Element& element)
138 this->bindElement(element);
150 eIdx_ = gridGeometry().elementMapper().index(element);
155 {
return *gridGeometryPtr_; }
159 {
return static_cast<bool>(element_); }
163 {
return *element_; }
166 const GridGeometry* gridGeometryPtr_;
168 std::optional<Element> element_;
176 using GridView =
typename GG::GridView;
177 static constexpr int dim = GridView::dimension;
178 static constexpr int dimWorld = GridView::dimensionworld;
180 using GridIndexType =
typename GridView::IndexSet::IndexType;
181 using Element =
typename GridView::template Codim<0>::Entity;
183 using CoordScalar =
typename GridView::ctype;
184 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
186 typename GG::SubControlVolume,
187 typename GG::SubControlVolumeFace>;
197 static constexpr std::size_t maxNumElementScvs = (1<<dim)*3;
201 : gridGeometryPtr_(&gridGeometry) {}
205 {
return scvs_[scvIdx]; }
209 {
return scvfs_[scvfIdx]; }
219 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
222 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
223 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
234 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
237 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
238 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
243 {
return gridGeometry().feCache().get(element_->type()).localBasis(); }
247 {
return scvs_.size(); }
251 {
return scvfs_.size(); }
259 void bind(
const Element& element)
261 this->bindElement(element);
271 eIdx_ = gridGeometry().elementMapper().index(element);
272 makeElementGeometries_();
277 {
return *gridGeometryPtr_; }
281 {
return static_cast<bool>(element_); }
285 {
return *element_; }
289 void makeElementGeometries_()
292 const auto& element = *element_;
293 const auto elementGeometry = element.geometry();
294 const auto refElement = referenceElement(element);
297 GeometryHelper geometryHelper(elementGeometry);
300 scvs_.resize(elementGeometry.corners());
301 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
302 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
305 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
308 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
315 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
316 scvfs_.resize(numInnerScvf);
318 unsigned int scvfLocalIdx = 0;
319 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
322 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
323 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
325 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
329 std::move(localScvIndices));
343 LocalIndexType scvLocalIdx =
element.subEntities(dim);
344 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
347 const auto& isGeometry = intersection.geometry();
349 const auto idxInInside = intersection.indexInInside();
351 std::vector<GridIndexType> isVertexIndices(
numCorners);
352 for (
unsigned int vIdxLocal = 0; vIdxLocal <
numCorners; ++vIdxLocal)
353 isVertexIndices[vIdxLocal] = gridGeometry().vertexMapper().subIndex(element,
354 refElement.subEntity(idxInInside, 1, vIdxLocal, dim),
357 if (intersection.boundary())
359 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx <
numCorners; ++isScvfLocalIdx)
362 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, isScvfLocalIdx, dim));
363 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
365 scvfs_.emplace_back(geometryHelper,
370 std::move(localScvIndices));
378 if (this->gridGeometry().isOnFracture(element, intersection))
381 const auto curNumScvs = scvs_.size();
383 for (
unsigned int vIdxLocal = 0; vIdxLocal <
numCorners; ++vIdxLocal)
384 scvs_.emplace_back(geometryHelper,
388 static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, vIdxLocal, dim)),
392 isVertexIndices[vIdxLocal]);
397 const auto& faceRefElement = referenceElement(isGeometry);
398 for (
unsigned int edgeIdx = 0; edgeIdx < faceRefElement.size(1); ++edgeIdx)
401 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(faceRefElement.subEntity(edgeIdx, 1, 0, dim-1)),
402 static_cast<LocalIndexType
>(faceRefElement.subEntity(edgeIdx, 1, 1, dim-1))});
405 std::for_each( localScvIndices.begin(),
406 localScvIndices.end(),
407 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
410 scvfs_.emplace_back(geometryHelper,
415 std::move(localScvIndices),
416 intersection.boundary());
424 std::vector<LocalIndexType> localScvIndices({0, 1});
427 std::for_each( localScvIndices.begin(),
428 localScvIndices.end(),
429 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
432 scvfs_.emplace_back(geometryHelper,
437 std::move(localScvIndices),
438 intersection.boundary());
445 std::optional<Element> element_;
449 const GridGeometry* gridGeometryPtr_;
452 std::vector<SubControlVolume> scvs_;
453 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.
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:53
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:127
void bind(const Element &element)
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:136
void bindElement(const Element &element)
Binding of an element, has to be called before using the fvgeometries.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:147
const SubControlVolumeFace & scvf(std::size_t scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:87
GG GridGeometry
Export type of finite volume grid geometry.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:72
const Element & element() const
The bound element.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:162
BoxDfmFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:79
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:131
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:123
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:83
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:99
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:154
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:158
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:115
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:268
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:242
const SubControlVolumeFace & scvf(std::size_t scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:208
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:276
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:259
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:250
const Element & element() const
The bound element.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:284
BoxDfmFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:200
std::size_t numScv() const
The total number of sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:246
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:280
const SubControlVolume & scv(std::size_t scvIdx) const
Get a sub control volume with a local scv index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:204
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:220
GG GridGeometry
Export type of finite volume grid geometry.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:194
typename GG::SubControlVolumeFace SubControlVolumeFace
Export type of subcontrol volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:192
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:235
typename GG::SubControlVolume SubControlVolume
Export type of subcontrol volume.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:190
Create sub control volumes and sub control volume face geometries.
Definition: geometryhelper.hh:35