12#ifndef DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
13#define DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
18#include <dune/geometry/type.hh>
35template<
class GG,
bool enableGr
idGeometryCache>
42 using GridView =
typename GG::GridView;
43 static constexpr int dim = GridView::dimension;
44 static constexpr int dimWorld = GridView::dimensionworld;
47 using CoordScalar =
typename GridView::ctype;
48 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
51 using Element =
typename GridView::template Codim<0>::Entity;
59 static constexpr std::size_t maxNumElementScvs = (1<<dim);
63 : gridGeometryPtr_(&gridGeometry)
68 {
return gridGeometry().scvs(eIdx_)[scvIdx]; }
72 {
return gridGeometry().scvfs(eIdx_)[scvfIdx]; }
79 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
82 const auto& g = fvGeometry.gridGeometry();
83 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
84 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
92 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
95 const auto& g = fvGeometry.gridGeometry();
96 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
97 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
102 {
return gridGeometry().feCache().get(element_->type()).localBasis(); }
106 {
return gridGeometry().scvs(eIdx_).size(); }
110 {
return gridGeometry().scvfs(eIdx_).size(); }
119 this->bindElement(element);
120 return std::move(*
this);
127 { this->bindElement(element); }
136 this->bindElement(element);
137 return std::move(*
this);
146 eIdx_ = gridGeometry().elementMapper().index(element);
151 {
return *gridGeometryPtr_; }
155 {
return static_cast<bool>(element_); }
159 {
return *element_; }
163 #pragma GCC diagnostic push
164 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
168 {
return scv.geometry(); }
172 {
return scvf.geometry(); }
174 #pragma GCC diagnostic pop
177 const GridGeometry* gridGeometryPtr_;
180 std::optional<Element> element_;
187 using GridView =
typename GG::GridView;
188 static constexpr int dim = GridView::dimension;
189 static constexpr int dimWorld = GridView::dimensionworld;
194 using CoordScalar =
typename GridView::ctype;
195 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
197 using GeometryHelper =
typename GG::GeometryHelper;
200 using Element =
typename GridView::template Codim<0>::Entity;
208 static constexpr std::size_t maxNumElementScvs = (1<<dim);
212 : gridGeometryPtr_(&gridGeometry)
217 {
return scvs_[scvIdx]; }
221 {
return scvfs_[scvfIdx]; }
228 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
231 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
232 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
240 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
243 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
244 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
249 {
return gridGeometry().feCache().get(element_->type()).localBasis(); }
253 {
return scvs_.size(); }
257 {
return scvfs_.size(); }
266 this->bindElement(element);
267 return std::move(*
this);
274 { this->bindElement(element); }
283 this->bindElement(element);
284 return std::move(*
this);
293 eIdx_ = gridGeometry().elementMapper().index(element);
294 makeElementGeometries_();
299 {
return *gridGeometryPtr_; }
303 {
return static_cast<bool>(element_); }
307 {
return *element_; }
311 #pragma GCC diagnostic push
312 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
316 {
return scv.geometry(); }
320 {
return scvf.geometry(); }
322 #pragma GCC diagnostic pop
326 void makeElementGeometries_()
329 const auto& element = *element_;
330 const auto elementGeometry = element.geometry();
331 const auto refElement = referenceElement(elementGeometry);
334 GeometryHelper geometryHelper(elementGeometry);
338 scvs_.reserve(elementGeometry.corners());
339 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
340 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
341 scvs_.emplace_back(geometryHelper.getScvCorners(scvLocalIdx),
344 gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim));
347 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
349 scvfs_.reserve(numInnerScvf);
351 unsigned int scvfLocalIdx = 0;
352 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
355 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
356 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
359 scvfs_.emplace_back(geometryHelper,
363 std::move(localScvIndices));
368 std::vector<unsigned int> handledFacets;
369 for (
const auto& intersection : intersections(gridGeometry().gridView(),
element))
371 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
374 handledFacets.push_back(intersection.indexInInside());
377 const auto isGeometry = intersection.geometry();
378 const auto numFaceCorners = isGeometry.corners();
379 const auto idxInInside = intersection.indexInInside();
380 const auto boundary = intersection.boundary();
382 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
383 for (
int i = 0; i < numFaceCorners; ++i)
384 vIndicesLocal[i] =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, i, dim));
387 const bool isOnFacet = gridGeometry().isOnInteriorBoundary(element, intersection);
389 if (isOnFacet || boundary)
391 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
394 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
397 scvfs_.emplace_back(geometryHelper,
402 std::move(localScvIndices),
414 const GridGeometry* gridGeometryPtr_;
418 std::optional<Element> element_;
421 std::vector<SubControlVolume> scvs_;
422 std::vector<SubControlVolumeFace> scvfs_;
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
void bindElement(const Element &element) &
Definition: multidomain/facet/box/fvelementgeometry.hh:290
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:281
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: multidomain/facet/box/fvelementgeometry.hh:211
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: multidomain/facet/box/fvelementgeometry.hh:216
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: multidomain/facet/box/fvelementgeometry.hh:204
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: multidomain/facet/box/fvelementgeometry.hh:248
SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace &scvf) const
Create the geometry of a given sub control volume face.
Definition: multidomain/facet/box/fvelementgeometry.hh:319
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:241
void bind(const Element &element) &
Definition: multidomain/facet/box/fvelementgeometry.hh:273
std::size_t numScv() const
The total number of sub control volumes.
Definition: multidomain/facet/box/fvelementgeometry.hh:252
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: multidomain/facet/box/fvelementgeometry.hh:302
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: multidomain/facet/box/fvelementgeometry.hh:256
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:229
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: multidomain/facet/box/fvelementgeometry.hh:202
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition: multidomain/facet/box/fvelementgeometry.hh:200
GG GridGeometry
export type of finite volume grid geometry
Definition: multidomain/facet/box/fvelementgeometry.hh:206
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: multidomain/facet/box/fvelementgeometry.hh:298
SubControlVolume::Traits::Geometry geometry(const SubControlVolume &scv) const
Create the geometry of a given sub control volume.
Definition: multidomain/facet/box/fvelementgeometry.hh:315
const Element & element() const
The bound element.
Definition: multidomain/facet/box/fvelementgeometry.hh:306
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:264
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: multidomain/facet/box/fvelementgeometry.hh:220
void bindElement(const Element &element) &
Definition: multidomain/facet/box/fvelementgeometry.hh:143
GG GridGeometry
export type of finite volume grid geometry
Definition: multidomain/facet/box/fvelementgeometry.hh:57
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:117
SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace &scvf) const
Create the geometry of a given sub control volume face.
Definition: multidomain/facet/box/fvelementgeometry.hh:171
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: multidomain/facet/box/fvelementgeometry.hh:154
void bind(const Element &element) &
Definition: multidomain/facet/box/fvelementgeometry.hh:126
std::size_t numScv() const
The total number of sub control volumes.
Definition: multidomain/facet/box/fvelementgeometry.hh:105
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: multidomain/facet/box/fvelementgeometry.hh:67
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:93
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: multidomain/facet/box/fvelementgeometry.hh:71
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: multidomain/facet/box/fvelementgeometry.hh:53
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: multidomain/facet/box/fvelementgeometry.hh:62
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: multidomain/facet/box/fvelementgeometry.hh:150
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:80
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: multidomain/facet/box/fvelementgeometry.hh:55
SubControlVolume::Traits::Geometry geometry(const SubControlVolume &scv) const
Create the geometry of a given sub control volume.
Definition: multidomain/facet/box/fvelementgeometry.hh:167
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: multidomain/facet/box/fvelementgeometry.hh:109
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: multidomain/facet/box/fvelementgeometry.hh:101
const Element & element() const
The bound element.
Definition: multidomain/facet/box/fvelementgeometry.hh:158
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition: multidomain/facet/box/fvelementgeometry.hh:51
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:134
Base class for the element-local finite volume geometry for box models in the context of models consi...
Definition: multidomain/facet/box/fvelementgeometry.hh:36
Class providing iterators over sub control volumes and sub control volume faces of an element.
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28