24#ifndef DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
25#define DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
29#include <dune/geometry/type.hh>
30#include <dune/geometry/referenceelements.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 Element =
typename GridView::template Codim<0>::Entity;
60 using CoordScalar =
typename GridView::ctype;
61 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
62 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
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(elemGeometryType_).localBasis(); }
118 {
return gridGeometry().scvs(eIdx_).size(); }
122 {
return gridGeometry().scvfs(eIdx_).size(); }
127 void bind(
const Element& element)
129 this->bindElement(element);
137 elemGeometryType_ = element.type();
138 eIdx_ = gridGeometry().elementMapper().index(element);
143 {
return *gridGeometryPtr_; }
146 Dune::GeometryType elemGeometryType_;
147 const GridGeometry* gridGeometryPtr_;
156 using GridView =
typename GG::GridView;
157 static constexpr int dim = GridView::dimension;
158 static constexpr int dimWorld = GridView::dimensionworld;
162 using Element =
typename GridView::template Codim<0>::Entity;
164 using CoordScalar =
typename GridView::ctype;
165 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
166 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
169 typename GG::SubControlVolume,
170 typename GG::SubControlVolumeFace>;
179 static constexpr std::size_t maxNumElementScvs = (1<<dim);
183 : gridGeometryPtr_(&gridGeometry)
188 {
return scvs_[scvIdx]; }
192 {
return scvfs_[scvfIdx]; }
199 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
202 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
203 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
211 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
214 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
215 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
220 {
return gridGeometry().feCache().get(elemGeometryType_).localBasis(); }
224 {
return scvs_.size(); }
228 {
return scvfs_.size(); }
233 void bind(
const Element& element)
235 this->bindElement(element);
243 eIdx_ = gridGeometry().elementMapper().index(element);
244 makeElementGeometries(element);
249 {
return *gridGeometryPtr_; }
253 void makeElementGeometries(
const Element& element)
255 auto eIdx = gridGeometry().elementMapper().index(element);
258 auto elementGeometry = element.geometry();
259 elemGeometryType_ = elementGeometry.type();
260 const auto referenceElement = ReferenceElements::general(elemGeometryType_);
263 GeometryHelper geometryHelper(elementGeometry);
267 scvs_.reserve(elementGeometry.corners());
268 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
269 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
270 scvs_.emplace_back(geometryHelper,
273 gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim));
276 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
278 scvfs_.reserve(numInnerScvf);
280 unsigned int scvfLocalIdx = 0;
281 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
284 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
285 static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
288 scvfs_.emplace_back(geometryHelper,
292 std::move(localScvIndices));
297 std::vector<unsigned int> handledFacets;
298 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
300 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
303 handledFacets.push_back(intersection.indexInInside());
306 const auto isGeometry = intersection.geometry();
307 const auto numFaceCorners = isGeometry.corners();
308 const auto idxInInside = intersection.indexInInside();
309 const auto boundary = intersection.boundary();
311 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
312 for (
int i = 0; i < numFaceCorners; ++i)
313 vIndicesLocal[i] =
static_cast<LocalIndexType
>(referenceElement.subEntity(idxInInside, 1, i, dim));
316 const bool isOnFacet = gridGeometry().isOnInteriorBoundary(element, intersection);
318 if (isOnFacet || boundary)
320 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
323 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
326 scvfs_.emplace_back(geometryHelper,
331 std::move(localScvIndices),
343 Dune::GeometryType elemGeometryType_;
347 const GridGeometry* gridGeometryPtr_;
350 std::vector<SubControlVolume> scvs_;
351 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:37
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
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
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
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: multidomain/facet/box/fvelementgeometry.hh:182
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: multidomain/facet/box/fvelementgeometry.hh:187
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: multidomain/facet/box/fvelementgeometry.hh:175
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: multidomain/facet/box/fvelementgeometry.hh:219
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:212
std::size_t numScv() const
The total number of sub control volumes.
Definition: multidomain/facet/box/fvelementgeometry.hh:223
void bind(const Element &element)
Definition: multidomain/facet/box/fvelementgeometry.hh:233
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: multidomain/facet/box/fvelementgeometry.hh:227
void bindElement(const Element &element)
Definition: multidomain/facet/box/fvelementgeometry.hh:241
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:200
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: multidomain/facet/box/fvelementgeometry.hh:173
GG GridGeometry
export type of finite volume grid geometry
Definition: multidomain/facet/box/fvelementgeometry.hh:177
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: multidomain/facet/box/fvelementgeometry.hh:248
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: multidomain/facet/box/fvelementgeometry.hh:191