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;
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(); }
143 {
return *gridGeometryPtr_; }
147 {
return static_cast<bool>(element_); }
151 {
return *element_; }
154 const GridGeometry* gridGeometryPtr_;
157 std::optional<Element> element_;
164 using GridView =
typename GG::GridView;
165 static constexpr int dim = GridView::dimension;
166 static constexpr int dimWorld = GridView::dimensionworld;
171 using CoordScalar =
typename GridView::ctype;
172 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
175 typename GG::SubControlVolume,
176 typename GG::SubControlVolumeFace>;
179 using Element =
typename GridView::template Codim<0>::Entity;
196 {
return scvs_[scvIdx]; }
200 {
return scvfs_[scvfIdx]; }
207 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
210 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
211 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
219 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
222 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
223 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
228 {
return gridGeometry().feCache().get(element_->type()).localBasis(); }
232 {
return scvs_.size(); }
236 {
return scvfs_.size(); }
253 makeElementGeometries_();
258 {
return *gridGeometryPtr_; }
262 {
return static_cast<bool>(element_); }
266 {
return *element_; }
270 void makeElementGeometries_()
273 const auto& element = *element_;
274 const auto elementGeometry = element.geometry();
275 const auto refElement = referenceElement(elementGeometry);
278 GeometryHelper geometryHelper(elementGeometry);
282 scvs_.reserve(elementGeometry.corners());
283 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
284 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
285 scvs_.emplace_back(geometryHelper,
288 gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim));
291 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
293 scvfs_.reserve(numInnerScvf);
295 unsigned int scvfLocalIdx = 0;
296 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
299 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
300 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
303 scvfs_.emplace_back(geometryHelper,
307 std::move(localScvIndices));
312 std::vector<unsigned int> handledFacets;
313 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
315 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
318 handledFacets.push_back(intersection.indexInInside());
321 const auto isGeometry = intersection.geometry();
322 const auto numFaceCorners = isGeometry.corners();
323 const auto idxInInside = intersection.indexInInside();
324 const auto boundary = intersection.boundary();
326 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
327 for (
int i = 0; i < numFaceCorners; ++i)
328 vIndicesLocal[i] =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, i, dim));
331 const bool isOnFacet = gridGeometry().isOnInteriorBoundary(element, intersection);
333 if (isOnFacet || boundary)
335 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
338 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
341 scvfs_.emplace_back(geometryHelper,
346 std::move(localScvIndices),
358 const GridGeometry* gridGeometryPtr_;
362 std::optional<Element> element_;
365 std::vector<SubControlVolume> scvs_;
366 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
GG GridGeometry
export type of finite volume grid geometry
Definition multidomain/facet/box/fvelementgeometry.hh:69
void bind(const Element &element)
Definition multidomain/facet/box/fvelementgeometry.hh:127
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition multidomain/facet/box/fvelementgeometry.hh:146
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
void bindElement(const Element &element)
Definition multidomain/facet/box/fvelementgeometry.hh:135
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition multidomain/facet/box/fvelementgeometry.hh:83
static constexpr std::size_t maxNumElementScvs
the maximum number of scvs per element (2^dim for cubes)
Definition multidomain/facet/box/fvelementgeometry.hh:71
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:142
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:150
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition multidomain/facet/box/fvelementgeometry.hh:63
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition multidomain/facet/box/fvelementgeometry.hh:190
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition multidomain/facet/box/fvelementgeometry.hh:195
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition multidomain/facet/box/fvelementgeometry.hh:183
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition multidomain/facet/box/fvelementgeometry.hh:227
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:220
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvelementgeometry.hh:231
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition multidomain/facet/box/fvelementgeometry.hh:261
void bind(const Element &element)
Definition multidomain/facet/box/fvelementgeometry.hh:241
std::size_t numScvf() const
The total number of sub control volume faces.
Definition multidomain/facet/box/fvelementgeometry.hh:235
void bindElement(const Element &element)
Definition multidomain/facet/box/fvelementgeometry.hh:249
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:208
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition multidomain/facet/box/fvelementgeometry.hh:181
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition multidomain/facet/box/fvelementgeometry.hh:179
GG GridGeometry
export type of finite volume grid geometry
Definition multidomain/facet/box/fvelementgeometry.hh:185
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition multidomain/facet/box/fvelementgeometry.hh:257
const Element & element() const
The bound element.
Definition multidomain/facet/box/fvelementgeometry.hh:265
static constexpr std::size_t maxNumElementScvs
the maximum number of scvs per element (2^dim for cubes)
Definition multidomain/facet/box/fvelementgeometry.hh:187
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition multidomain/facet/box/fvelementgeometry.hh:199