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/localfunctions/lagrange/pqkfactory.hh>
50template<
class GG,
bool enableGr
idGeometryCache>
57 using GridView =
typename GG::GridView;
58 static constexpr int dim = GridView::dimension;
59 static constexpr int dimWorld = GridView::dimensionworld;
60 using GridIndexType =
typename GridView::IndexSet::IndexType;
61 using Element =
typename GridView::template Codim<0>::Entity;
62 using CoordScalar =
typename GridView::ctype;
63 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
74 static constexpr std::size_t maxNumElementScvs = (1<<dim)*3;
78 : gridGeometryPtr_(&gridGeometry) {}
82 {
return gridGeometry().scvs(eIdx_)[scvIdx]; }
86 {
return gridGeometry().scvfs(eIdx_)[scvfIdx]; }
96 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
99 const auto& g = fvGeometry.gridGeometry();
100 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
101 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
112 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
115 const auto& g = fvGeometry.gridGeometry();
116 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
117 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
122 {
return gridGeometry().feCache().get(elemGeometryType_).localBasis(); }
126 {
return gridGeometry().scvs(eIdx_).size(); }
130 {
return gridGeometry().scvfs(eIdx_).size(); }
134 void bind(
const Element& element)
136 this->bindElement(element);
147 elemGeometryType_ = element.type();
148 eIdx_ = gridGeometry().elementMapper().index(element);
153 {
return *gridGeometryPtr_; }
156 Dune::GeometryType elemGeometryType_;
157 const GridGeometry* gridGeometryPtr_;
165 using GridView =
typename GG::GridView;
166 static constexpr int dim = GridView::dimension;
167 static constexpr int dimWorld = GridView::dimensionworld;
169 using GridIndexType =
typename GridView::IndexSet::IndexType;
170 using Element =
typename GridView::template Codim<0>::Entity;
172 using CoordScalar =
typename GridView::ctype;
173 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
175 typename GG::SubControlVolume,
176 typename GG::SubControlVolumeFace>;
186 static constexpr std::size_t maxNumElementScvs = (1<<dim)*3;
190 : gridGeometryPtr_(&gridGeometry) {}
194 {
return scvs_[scvIdx]; }
198 {
return scvfs_[scvfIdx]; }
208 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
211 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
212 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
223 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
226 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
227 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
232 {
return gridGeometry().feCache().get(elemGeometryType_).localBasis(); }
236 {
return scvs_.size(); }
240 {
return scvfs_.size(); }
244 void bind(
const Element& element)
246 this->bindElement(element);
257 eIdx_ = gridGeometry().elementMapper().index(element);
258 makeElementGeometries(element);
263 {
return *gridGeometryPtr_; }
267 void makeElementGeometries(
const Element& element)
269 auto eIdx = gridGeometry().elementMapper().index(element);
272 auto elementGeometry = element.geometry();
273 elemGeometryType_ = elementGeometry.type();
274 const auto refElement = referenceElement(element);
277 GeometryHelper geometryHelper(elementGeometry);
280 scvs_.resize(elementGeometry.corners());
281 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
282 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
285 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
288 scvs_[scvLocalIdx] = SubControlVolume(geometryHelper,
295 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
296 scvfs_.resize(numInnerScvf);
298 unsigned int scvfLocalIdx = 0;
299 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
302 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
303 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
305 scvfs_[scvfLocalIdx] = SubControlVolumeFace(geometryHelper,
309 std::move(localScvIndices));
323 LocalIndexType scvLocalIdx = element.subEntities(dim);
324 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
327 const auto& isGeometry = intersection.geometry();
328 const auto numCorners = isGeometry.corners();
329 const auto idxInInside = intersection.indexInInside();
331 std::vector<GridIndexType> isVertexIndices(numCorners);
332 for (
unsigned int vIdxLocal = 0; vIdxLocal < numCorners; ++vIdxLocal)
333 isVertexIndices[vIdxLocal] = gridGeometry().vertexMapper().subIndex(element,
334 refElement.subEntity(idxInInside, 1, vIdxLocal, dim),
337 if (intersection.boundary())
339 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < numCorners; ++isScvfLocalIdx)
342 const LocalIndexType insideScvIdx =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, isScvfLocalIdx, dim));
343 std::vector<LocalIndexType> localScvIndices = {insideScvIdx, insideScvIdx};
345 scvfs_.emplace_back(geometryHelper,
350 std::move(localScvIndices));
358 if (this->gridGeometry().isOnFracture(element, intersection))
361 const auto curNumScvs = scvs_.size();
362 scvs_.reserve(curNumScvs+numCorners);
363 for (
unsigned int vIdxLocal = 0; vIdxLocal < numCorners; ++vIdxLocal)
364 scvs_.emplace_back(geometryHelper,
368 static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, vIdxLocal, dim)),
372 isVertexIndices[vIdxLocal]);
377 const auto& faceRefElement = referenceElement(isGeometry);
378 for (
unsigned int edgeIdx = 0; edgeIdx < faceRefElement.size(1); ++edgeIdx)
381 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(faceRefElement.subEntity(edgeIdx, 1, 0, dim-1)),
382 static_cast<LocalIndexType
>(faceRefElement.subEntity(edgeIdx, 1, 1, dim-1))});
385 std::for_each( localScvIndices.begin(),
386 localScvIndices.end(),
387 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
390 scvfs_.emplace_back(geometryHelper,
395 std::move(localScvIndices),
396 intersection.boundary());
404 std::vector<LocalIndexType> localScvIndices({0, 1});
407 std::for_each( localScvIndices.begin(),
408 localScvIndices.end(),
409 [curNumScvs] (
auto& elemLocalIdx) { elemLocalIdx += curNumScvs; } );
412 scvfs_.emplace_back(geometryHelper,
417 std::move(localScvIndices),
418 intersection.boundary());
425 Dune::GeometryType elemGeometryType_;
429 const GridGeometry* gridGeometryPtr_;
438 std::vector<SubControlVolume> scvs_;
439 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.
Base class for the finite volume geometry vector for box discrete fracture model.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:51
typename GG::SubControlVolumeFace SubControlVolumeFace
Export type of subcontrol volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:68
std::size_t numScv() const
The total number of sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:125
void bind(const Element &element)
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:134
void bindElement(const Element &element)
Binding of an element, has to be called before using the fvgeometries.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:145
const SubControlVolumeFace & scvf(std::size_t scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:85
GG GridGeometry
Export type of finite volume grid geometry.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:70
BoxDfmFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:77
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:129
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:121
typename GG::SubControlVolume SubControlVolume
Export type of subcontrol volume.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:66
const SubControlVolume & scv(std::size_t scvIdx) const
Get a sub control volume with a local scv index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:81
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:97
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:152
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:113
void bindElement(const Element &element)
Binding of an element, has to be called before using the fvgeometries.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:255
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:231
const SubControlVolumeFace & scvf(std::size_t scvfIdx) const
Get a sub control volume face with a local scvf index.
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:262
void bind(const Element &element)
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:244
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:239
BoxDfmFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:189
std::size_t numScv() const
The total number of sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:235
const SubControlVolume & scv(std::size_t scvIdx) const
Get a sub control volume with a local scv index.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:193
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxDfmFVElementGeometry &fvGeometry)
Iterator range for sub control volumes.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:209
GG GridGeometry
Export type of finite volume grid geometry.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:183
typename GG::SubControlVolumeFace SubControlVolumeFace
Export type of subcontrol volume face.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:181
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:224
typename GG::SubControlVolume SubControlVolume
Export type of subcontrol volume.
Definition: porousmediumflow/boxdfm/fvelementgeometry.hh:179
Create sub control volumes and sub control volume face geometries.
Definition: geometryhelper.hh:35