24#ifndef DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
25#define DUMUX_FACETCOUPLING_BOX_FV_ELEMENT_GEOMETRY_HH
29#include <dune/geometry/type.hh>
46template<
class GG,
bool enableGr
idGeometryCache>
53 using GridView =
typename GG::GridView;
54 static constexpr int dim = GridView::dimension;
55 static constexpr int dimWorld = GridView::dimensionworld;
58 using CoordScalar =
typename GridView::ctype;
59 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
62 using Element =
typename GridView::template Codim<0>::Entity;
70 static constexpr std::size_t maxNumElementScvs = (1<<dim);
74 : gridGeometryPtr_(&gridGeometry)
79 {
return gridGeometry().scvs(eIdx_)[scvIdx]; }
83 {
return gridGeometry().scvfs(eIdx_)[scvfIdx]; }
90 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
93 const auto& g = fvGeometry.gridGeometry();
94 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
95 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
103 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
106 const auto& g = fvGeometry.gridGeometry();
107 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
108 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
113 {
return gridGeometry().feCache().get(elemGeometryType_).localBasis(); }
117 {
return gridGeometry().scvs(eIdx_).size(); }
121 {
return gridGeometry().scvfs(eIdx_).size(); }
128 this->bindElement(element);
136 elemGeometryType_ = element.type();
137 eIdx_ = gridGeometry().elementMapper().index(element);
142 {
return *gridGeometryPtr_; }
145 Dune::GeometryType elemGeometryType_;
146 const GridGeometry* gridGeometryPtr_;
155 using GridView =
typename GG::GridView;
156 static constexpr int dim = GridView::dimension;
157 static constexpr int dimWorld = GridView::dimensionworld;
162 using CoordScalar =
typename GridView::ctype;
163 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
166 typename GG::SubControlVolume,
167 typename GG::SubControlVolumeFace>;
170 using Element =
typename GridView::template Codim<0>::Entity;
178 static constexpr std::size_t maxNumElementScvs = (1<<dim);
182 : gridGeometryPtr_(&gridGeometry)
187 {
return scvs_[scvIdx]; }
191 {
return scvfs_[scvfIdx]; }
198 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
201 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
202 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
210 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
213 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
214 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
219 {
return gridGeometry().feCache().get(elemGeometryType_).localBasis(); }
223 {
return scvs_.size(); }
227 {
return scvfs_.size(); }
234 this->bindElement(element);
242 eIdx_ = gridGeometry().elementMapper().index(element);
243 makeElementGeometries(element);
248 {
return *gridGeometryPtr_; }
252 void makeElementGeometries(
const Element& element)
254 auto eIdx = gridGeometry().elementMapper().index(element);
257 auto elementGeometry = element.geometry();
258 elemGeometryType_ = elementGeometry.type();
259 const auto refElement = referenceElement(elementGeometry);
262 GeometryHelper geometryHelper(elementGeometry);
266 scvs_.reserve(elementGeometry.corners());
267 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
268 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
269 scvs_.emplace_back(geometryHelper,
272 gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim));
275 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
277 scvfs_.reserve(numInnerScvf);
279 unsigned int scvfLocalIdx = 0;
280 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
283 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
284 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
287 scvfs_.emplace_back(geometryHelper,
291 std::move(localScvIndices));
296 std::vector<unsigned int> handledFacets;
297 for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
299 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
302 handledFacets.push_back(intersection.indexInInside());
305 const auto isGeometry = intersection.geometry();
306 const auto numFaceCorners = isGeometry.corners();
307 const auto idxInInside = intersection.indexInInside();
308 const auto boundary = intersection.boundary();
310 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
311 for (
int i = 0; i < numFaceCorners; ++i)
312 vIndicesLocal[i] =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, i, dim));
315 const bool isOnFacet = gridGeometry().isOnInteriorBoundary(element, intersection);
317 if (isOnFacet || boundary)
319 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
322 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
325 scvfs_.emplace_back(geometryHelper,
330 std::move(localScvIndices),
342 Dune::GeometryType elemGeometryType_;
346 const GridGeometry* gridGeometryPtr_;
349 std::vector<SubControlVolume> scvs_;
350 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:47
GG GridGeometry
export type of finite volume grid geometry
Definition: multidomain/facet/box/fvelementgeometry.hh:68
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:116
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: multidomain/facet/box/fvelementgeometry.hh:78
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:104
void bindElement(const Element &element)
Definition: multidomain/facet/box/fvelementgeometry.hh:134
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: multidomain/facet/box/fvelementgeometry.hh:82
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: multidomain/facet/box/fvelementgeometry.hh:64
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: multidomain/facet/box/fvelementgeometry.hh:73
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: multidomain/facet/box/fvelementgeometry.hh:141
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:91
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: multidomain/facet/box/fvelementgeometry.hh:66
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: multidomain/facet/box/fvelementgeometry.hh:120
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: multidomain/facet/box/fvelementgeometry.hh:112
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition: multidomain/facet/box/fvelementgeometry.hh:62
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: multidomain/facet/box/fvelementgeometry.hh:181
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: multidomain/facet/box/fvelementgeometry.hh:186
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: multidomain/facet/box/fvelementgeometry.hh:174
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: multidomain/facet/box/fvelementgeometry.hh:218
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:211
std::size_t numScv() const
The total number of sub control volumes.
Definition: multidomain/facet/box/fvelementgeometry.hh:222
void bind(const Element &element)
Definition: multidomain/facet/box/fvelementgeometry.hh:232
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: multidomain/facet/box/fvelementgeometry.hh:226
void bindElement(const Element &element)
Definition: multidomain/facet/box/fvelementgeometry.hh:240
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition: multidomain/facet/box/fvelementgeometry.hh:199
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: multidomain/facet/box/fvelementgeometry.hh:172
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition: multidomain/facet/box/fvelementgeometry.hh:170
GG GridGeometry
export type of finite volume grid geometry
Definition: multidomain/facet/box/fvelementgeometry.hh:176
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: multidomain/facet/box/fvelementgeometry.hh:247
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: multidomain/facet/box/fvelementgeometry.hh:190