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 using FVGridGeometry [[deprecated(
"Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]] =
GridGeometry;
93 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
96 const auto& g = fvGeometry.gridGeometry();
97 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
98 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
106 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
109 const auto& g = fvGeometry.gridGeometry();
110 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
111 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
116 {
return gridGeometry().feCache().get(elemGeometryType_).localBasis(); }
129 void bind(
const Element& element)
139 elemGeometryType_ = element.type();
144 [[deprecated(
"Use gridGeometry() instead. fvGridGeometry() will be removed after 3.1!")]]
146 {
return *gridGeometryPtr_; }
150 {
return *gridGeometryPtr_; }
153 Dune::GeometryType elemGeometryType_;
154 const GridGeometry* gridGeometryPtr_;
163 using GridView =
typename GG::GridView;
164 static constexpr int dim = GridView::dimension;
165 static constexpr int dimWorld = GridView::dimensionworld;
169 using Element =
typename GridView::template Codim<0>::Entity;
171 using CoordScalar =
typename GridView::ctype;
172 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
173 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
176 typename GG::SubControlVolume,
177 typename GG::SubControlVolumeFace>;
186 using FVGridGeometry [[deprecated(
"Use more general GridGeometry instead. FVGridGeometry will be removed after 3.1!")]] =
GridGeometry;
197 {
return scvs_[scvIdx]; }
201 {
return scvfs_[scvfIdx]; }
208 friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
211 using Iter =
typename std::vector<SubControlVolume>::const_iterator;
212 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
220 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
223 using Iter =
typename std::vector<SubControlVolumeFace>::const_iterator;
224 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
229 {
return gridGeometry().feCache().get(elemGeometryType_).localBasis(); }
233 {
return scvs_.size(); }
237 {
return scvfs_.size(); }
242 void bind(
const Element& element)
253 makeElementGeometries(element);
257 [[deprecated(
"Use gridGeometry() instead. fvGridGeometry() will be removed after 3.1!")]]
259 {
return *gridGeometryPtr_; }
263 {
return *gridGeometryPtr_; }
267 void makeElementGeometries(
const Element& element)
269 auto eIdx = gridGeometry().elementMapper().index(element);
272 auto elementGeometry = element.geometry();
273 elemGeometryType_ = elementGeometry.type();
274 const auto referenceElement = ReferenceElements::general(elemGeometryType_);
277 GeometryHelper geometryHelper(elementGeometry);
281 scvs_.reserve(elementGeometry.corners());
282 using LocalIndexType =
typename SubControlVolumeFace::Traits::LocalIndexType;
283 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
284 scvs_.emplace_back(geometryHelper,
287 gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim));
290 const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
292 scvfs_.reserve(numInnerScvf);
294 unsigned int scvfLocalIdx = 0;
295 for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
298 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
299 static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
302 scvfs_.emplace_back(geometryHelper,
306 std::move(localScvIndices));
311 std::vector<unsigned int> handledFacets;
312 for (
const auto& intersection :
intersections(gridGeometry().gridView(), element))
314 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
317 handledFacets.push_back(intersection.indexInInside());
320 const auto isGeometry = intersection.geometry();
321 const auto numFaceCorners = isGeometry.corners();
322 const auto idxInInside = intersection.indexInInside();
323 const auto boundary = intersection.boundary();
325 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
326 for (
int i = 0; i < numFaceCorners; ++i)
327 vIndicesLocal[i] =
static_cast<LocalIndexType
>(referenceElement.subEntity(idxInInside, 1, i, dim));
330 const bool isOnFacet = gridGeometry().isOnInteriorBoundary(element, intersection);
332 if (isOnFacet || boundary)
334 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
337 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
340 scvfs_.emplace_back(geometryHelper,
345 std::move(localScvIndices),
357 Dune::GeometryType elemGeometryType_;
361 const GridGeometry* gridGeometryPtr_;
364 std::vector<SubControlVolume> scvs_;
365 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.
Dune::IteratorRange< typename MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper >::Intersections::const_iterator > intersections(const MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper > &glue)
Range generator to iterate with range-based for loops over all intersections as follows: for (const a...
Definition glue.hh:62
make the local view function available whenever we use the grid geometry
Definition adapt.hh:29
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:129
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvelementgeometry.hh:119
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition multidomain/facet/box/fvelementgeometry.hh:81
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:107
void bindElement(const Element &element)
Definition multidomain/facet/box/fvelementgeometry.hh:137
const GridGeometry & fvGridGeometry() const
The global finite volume geometry we are a restriction of.
Definition multidomain/facet/box/fvelementgeometry.hh:145
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition multidomain/facet/box/fvelementgeometry.hh:85
static constexpr std::size_t maxNumElementScvs
the maximum number of scvs per element (2^dim for cubes)
Definition multidomain/facet/box/fvelementgeometry.hh:73
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:76
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition multidomain/facet/box/fvelementgeometry.hh:149
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:94
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:123
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition multidomain/facet/box/fvelementgeometry.hh:115
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition multidomain/facet/box/fvelementgeometry.hh:191
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition multidomain/facet/box/fvelementgeometry.hh:196
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition multidomain/facet/box/fvelementgeometry.hh:182
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition multidomain/facet/box/fvelementgeometry.hh:228
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:221
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvelementgeometry.hh:232
void bind(const Element &element)
Definition multidomain/facet/box/fvelementgeometry.hh:242
std::size_t numScvf() const
The total number of sub control volume faces.
Definition multidomain/facet/box/fvelementgeometry.hh:236
void bindElement(const Element &element)
Definition multidomain/facet/box/fvelementgeometry.hh:250
const GridGeometry & fvGridGeometry() const
The global finite volume geometry we are a restriction of.
Definition multidomain/facet/box/fvelementgeometry.hh:258
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:209
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition multidomain/facet/box/fvelementgeometry.hh:180
GG GridGeometry
export type of finite volume grid geometry
Definition multidomain/facet/box/fvelementgeometry.hh:184
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition multidomain/facet/box/fvelementgeometry.hh:262
static constexpr std::size_t maxNumElementScvs
the maximum number of scvs per element (2^dim for cubes)
Definition multidomain/facet/box/fvelementgeometry.hh:188
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition multidomain/facet/box/fvelementgeometry.hh:200