24#ifndef DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
25#define DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
30#include <dune/geometry/type.hh>
47template<
class GG,
bool enableGr
idGeometryCache>
54 using GridView =
typename GG::GridView;
55 static constexpr int dim = GridView::dimension;
56 static constexpr int dimWorld = GridView::dimensionworld;
59 using CoordScalar =
typename GridView::ctype;
60 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
63 using Element =
typename GridView::template Codim<0>::Entity;
71 static constexpr std::size_t maxNumElementScvs = (1<<dim);
75 : gridGeometryPtr_(&gridGeometry)
80 {
return gridGeometry().scvs(eIdx_)[scvIdx]; }
84 {
return gridGeometry().scvfs(eIdx_)[scvfIdx]; }
91 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
94 const auto& g = fvGeometry.gridGeometry();
95 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
96 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
104 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
107 const auto& g = fvGeometry.gridGeometry();
108 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
109 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
114 {
return gridGeometry().feCache().get(element_->type()).localBasis(); }
118 {
return gridGeometry().scvs(eIdx_).size(); }
122 {
return gridGeometry().scvfs(eIdx_).size(); }
131 this->bindElement(element);
132 return std::move(*
this);
139 { this->bindElement(element); }
148 this->bindElement(element);
149 return std::move(*
this);
158 eIdx_ = gridGeometry().elementMapper().index(element);
163 {
return *gridGeometryPtr_; }
167 {
return static_cast<bool>(element_); }
171 {
return *element_; }
174 const GridGeometry* gridGeometryPtr_;
177 std::optional<Element> element_;
184 using GridView =
typename GG::GridView;
185 static constexpr int dim = GridView::dimension;
186 static constexpr int dimWorld = GridView::dimensionworld;
191 using CoordScalar =
typename GridView::ctype;
192 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
195 typename GG::SubControlVolume,
196 typename GG::SubControlVolumeFace>;
199 using Element =
typename GridView::template Codim<0>::Entity;
207 static constexpr std::size_t maxNumElementScvs = (1<<dim);
211 : gridGeometryPtr_(&gridGeometry)
216 {
return scvs_[scvIdx]; }
220 {
return scvfs_[scvfIdx]; }
227 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
230 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
231 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
239 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
242 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
243 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
248 {
return gridGeometry().feCache().get(element_->type()).localBasis(); }
252 {
return scvs_.size(); }
256 {
return scvfs_.size(); }
265 this->bindElement(element);
266 return std::move(*
this);
273 { this->bindElement(element); }
282 this->bindElement(element);
283 return std::move(*
this);
292 eIdx_ = gridGeometry().elementMapper().index(element);
293 makeElementGeometries_();
298 {
return *gridGeometryPtr_; }
302 {
return static_cast<bool>(element_); }
306 {
return *element_; }
310 void makeElementGeometries_()
313 const auto& element = *element_;
314 const auto elementGeometry = element.geometry();
315 const auto refElement = referenceElement(elementGeometry);
318 GeometryHelper geometryHelper(elementGeometry);
322 scvs_.reserve(elementGeometry.corners());
323 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
324 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
325 scvs_.emplace_back(geometryHelper,
328 gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim));
331 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
333 scvfs_.reserve(numInnerScvf);
335 unsigned int scvfLocalIdx = 0;
336 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
339 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
340 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
343 scvfs_.emplace_back(geometryHelper,
347 std::move(localScvIndices));
352 std::vector<unsigned int> handledFacets;
353 for (
const auto& intersection : intersections(gridGeometry().gridView(),
element))
355 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
358 handledFacets.push_back(intersection.indexInInside());
361 const auto isGeometry = intersection.geometry();
362 const auto numFaceCorners = isGeometry.corners();
363 const auto idxInInside = intersection.indexInInside();
364 const auto boundary = intersection.boundary();
366 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
367 for (
int i = 0; i < numFaceCorners; ++i)
368 vIndicesLocal[i] =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, i, dim));
371 const bool isOnFacet = gridGeometry().isOnInteriorBoundary(element, intersection);
373 if (isOnFacet || boundary)
375 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
378 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
381 scvfs_.emplace_back(geometryHelper,
386 std::move(localScvIndices),
398 const GridGeometry* gridGeometryPtr_;
402 std::optional<Element> element_;
405 std::vector<SubControlVolume> scvs_;
406 std::vector<SubControlVolumeFace> scvfs_;
Defines the index types used for grid and local indices.
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Class providing iterators over sub control volumes and sub control volume faces of an element.
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
unsigned int LocalIndex
Definition: indextraits.hh:40
Create sub control volumes and sub control volume face geometries.
Definition: boxgeometryhelper.hh:36
Base class for the element-local finite volume geometry for box models in the context of models consi...
Definition: multidomain/facet/box/fvelementgeometry.hh:48
void bindElement(const Element &element) &
Definition: multidomain/facet/box/fvelementgeometry.hh:155
GG GridGeometry
export type of finite volume grid geometry
Definition: multidomain/facet/box/fvelementgeometry.hh:69
BoxFacetCouplingFVElementGeometry 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: multidomain/facet/box/fvelementgeometry.hh:129
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: multidomain/facet/box/fvelementgeometry.hh:166
void bind(const Element &element) &
Definition: multidomain/facet/box/fvelementgeometry.hh:138
std::size_t numScv() const
The total number of sub control volumes.
Definition: multidomain/facet/box/fvelementgeometry.hh:117
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: multidomain/facet/box/fvelementgeometry.hh:79
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:105
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: multidomain/facet/box/fvelementgeometry.hh:83
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: multidomain/facet/box/fvelementgeometry.hh:65
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: multidomain/facet/box/fvelementgeometry.hh:74
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: multidomain/facet/box/fvelementgeometry.hh:162
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:92
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: multidomain/facet/box/fvelementgeometry.hh:67
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: multidomain/facet/box/fvelementgeometry.hh:121
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: multidomain/facet/box/fvelementgeometry.hh:113
const Element & element() const
The bound element.
Definition: multidomain/facet/box/fvelementgeometry.hh:170
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition: multidomain/facet/box/fvelementgeometry.hh:63
BoxFacetCouplingFVElementGeometry 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: multidomain/facet/box/fvelementgeometry.hh:146
void bindElement(const Element &element) &
Definition: multidomain/facet/box/fvelementgeometry.hh:289
BoxFacetCouplingFVElementGeometry 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: multidomain/facet/box/fvelementgeometry.hh:280
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: multidomain/facet/box/fvelementgeometry.hh:210
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: multidomain/facet/box/fvelementgeometry.hh:215
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: multidomain/facet/box/fvelementgeometry.hh:203
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: multidomain/facet/box/fvelementgeometry.hh:247
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:240
void bind(const Element &element) &
Definition: multidomain/facet/box/fvelementgeometry.hh:272
std::size_t numScv() const
The total number of sub control volumes.
Definition: multidomain/facet/box/fvelementgeometry.hh:251
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: multidomain/facet/box/fvelementgeometry.hh:301
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: multidomain/facet/box/fvelementgeometry.hh:255
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:228
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: multidomain/facet/box/fvelementgeometry.hh:201
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition: multidomain/facet/box/fvelementgeometry.hh:199
GG GridGeometry
export type of finite volume grid geometry
Definition: multidomain/facet/box/fvelementgeometry.hh:205
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: multidomain/facet/box/fvelementgeometry.hh:297
const Element & element() const
The bound element.
Definition: multidomain/facet/box/fvelementgeometry.hh:305
BoxFacetCouplingFVElementGeometry 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: multidomain/facet/box/fvelementgeometry.hh:263
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: multidomain/facet/box/fvelementgeometry.hh:219