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;
 
   50    using GeometryHelper = 
typename GG::GeometryHelper;
 
   53    using Element = 
typename GridView::template Codim<0>::Entity;
 
   81    friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
 
   84        const auto& g = fvGeometry.gridGeometry();
 
   85        using Iter = 
typename std::vector<SubControlVolume>::const_iterator;
 
   86        return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
 
 
   94    friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
 
   97        const auto& g = fvGeometry.gridGeometry();
 
   98        using Iter = 
typename std::vector<SubControlVolumeFace>::const_iterator;
 
   99        return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
 
 
  104    { 
return gridGeometry().feCache().get(element_->type()).localBasis(); }
 
 
  122        return std::move(*
this);
 
 
  139        return std::move(*
this);
 
 
  153    { 
return *gridGeometryPtr_; }
 
 
  157    { 
return static_cast<bool>(element_); }
 
 
  161    { 
return *element_; }
 
 
  167        const auto geo = 
element().geometry();
 
  168        return { Dune::GeometryTypes::cube(dim), GeometryHelper(geo).getScvCorners(
scv.indexInElement()) };
 
 
  175        using ScvfGeometry = 
typename SubControlVolumeFace::Traits::Geometry;
 
  177        if (
scvf.boundary() || 
scvf.interiorBoundary())
 
  179                Dune::GeometryTypes::cube(ScvfGeometry::mydimension),
 
  180                geometryHelper.getBoundaryScvfCorners(
 
  181                    scvf.facetIndexInElement(),
 
  182                    scvf.indexInElementFacet()
 
  187            Dune::GeometryTypes::cube(ScvfGeometry::mydimension), 
 
  188            geometryHelper.getScvfCorners(
scvf.index())
 
 
  193    const GridGeometry* gridGeometryPtr_;
 
  196    std::optional<Element> element_;
 
 
  203    using GridView = 
typename GG::GridView;
 
  204    static constexpr int dim = GridView::dimension;
 
  205    static constexpr int dimWorld = GridView::dimensionworld;
 
  210    using CoordScalar = 
typename GridView::ctype;
 
  211    using FeLocalBasis = 
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
 
  213    using GeometryHelper = 
typename GG::GeometryHelper;
 
  216    using Element = 
typename GridView::template Codim<0>::Entity;
 
  233    { 
return scvs_[scvIdx]; }
 
 
  237    { 
return scvfs_[scvfIdx]; }
 
 
  244    friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator>
 
  247        using Iter = 
typename std::vector<SubControlVolume>::const_iterator;
 
  248        return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
 
 
  256    friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
 
  259        using Iter = 
typename std::vector<SubControlVolumeFace>::const_iterator;
 
  260        return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
 
 
  265    { 
return gridGeometry().feCache().get(element_->type()).localBasis(); }
 
 
  269    { 
return scvs_.size(); }
 
 
  273    { 
return scvfs_.size(); }
 
 
  283        return std::move(*
this);
 
 
  300        return std::move(*
this);
 
 
  310        makeElementGeometries_();
 
 
  315    { 
return *gridGeometryPtr_; }
 
 
  319    { 
return static_cast<bool>(element_); }
 
 
  323    { 
return *element_; }
 
 
  329        const auto geo = 
element().geometry();
 
  330        return { Dune::GeometryTypes::cube(dim), GeometryHelper(geo).getScvCorners(
scv.indexInElement()) };
 
 
  337        using ScvfGeometry = 
typename SubControlVolumeFace::Traits::Geometry;
 
  340        if (
scvf.boundary() || 
scvf.interiorBoundary())
 
  342                Dune::GeometryTypes::cube(ScvfGeometry::mydimension),
 
  343                geometryHelper.getBoundaryScvfCorners(
 
  344                     scvf.facetIndexInElement(),
 
  345                     scvf.indexInElementFacet()
 
  350            Dune::GeometryTypes::cube(ScvfGeometry::mydimension),
 
  351            geometryHelper.getScvfCorners(
scvf.index())
 
 
  357    void makeElementGeometries_()
 
  360        const auto& element = *element_;
 
  361        const auto elementGeometry = element.geometry();
 
  362        const auto refElement = referenceElement(elementGeometry);
 
  365        GeometryHelper geometryHelper(elementGeometry);
 
  369        scvs_.reserve(elementGeometry.corners());
 
  370        using LocalIndexType = 
typename SubControlVolumeFace::Traits::LocalIndexType;
 
  371        for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
 
  372            scvs_.emplace_back(geometryHelper.getScvCorners(scvLocalIdx),
 
  375                               gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim));
 
  378        const auto numInnerScvf = (dim==1) ? 1 : element.subEntities(dim-1);
 
  380        scvfs_.reserve(numInnerScvf);
 
  382        unsigned int scvfLocalIdx = 0;
 
  383        for (; scvfLocalIdx < numInnerScvf; ++scvfLocalIdx)
 
  386            std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
 
  387                                                         static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
 
  390            scvfs_.emplace_back(geometryHelper,
 
  394                                std::move(localScvIndices));
 
  399        std::vector<unsigned int> handledFacets;
 
  400        for (
const auto& intersection : intersections(gridGeometry().gridView(), element))
 
  402            if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
 
  405            handledFacets.push_back(intersection.indexInInside());
 
  408            const auto isGeometry = intersection.geometry();
 
  409            const auto numFaceCorners = isGeometry.corners();
 
  410            const auto idxInInside = intersection.indexInInside();
 
  411            const auto boundary = intersection.boundary();
 
  413            std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
 
  414            for (
int i = 0; i < numFaceCorners; ++i)
 
  415                vIndicesLocal[i] = 
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, i, dim));
 
  418            const bool isOnFacet = gridGeometry().isOnInteriorBoundary(element, intersection);
 
  420            if (isOnFacet || boundary)
 
  422                for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx)
 
  425                    std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
 
  428                    scvfs_.emplace_back(geometryHelper,
 
  433                                        std::move(localScvIndices),
 
  445    const GridGeometry* gridGeometryPtr_;
 
  449    std::optional<Element> element_;
 
  452    std::vector<SubControlVolume> scvs_;
 
  453    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:306
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:297
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition multidomain/facet/box/fvelementgeometry.hh:227
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition multidomain/facet/box/fvelementgeometry.hh:232
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition multidomain/facet/box/fvelementgeometry.hh:220
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition multidomain/facet/box/fvelementgeometry.hh:264
SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace &scvf) const
Create the geometry of a given sub control volume face.
Definition multidomain/facet/box/fvelementgeometry.hh:334
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:257
void bind(const Element &element) &
Definition multidomain/facet/box/fvelementgeometry.hh:289
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvelementgeometry.hh:268
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition multidomain/facet/box/fvelementgeometry.hh:318
std::size_t numScvf() const
The total number of sub control volume faces.
Definition multidomain/facet/box/fvelementgeometry.hh:272
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:245
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition multidomain/facet/box/fvelementgeometry.hh:218
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition multidomain/facet/box/fvelementgeometry.hh:216
GG GridGeometry
export type of finite volume grid geometry
Definition multidomain/facet/box/fvelementgeometry.hh:222
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition multidomain/facet/box/fvelementgeometry.hh:314
SubControlVolume::Traits::Geometry geometry(const SubControlVolume &scv) const
Create the geometry of a given sub control volume.
Definition multidomain/facet/box/fvelementgeometry.hh:326
const Element & element() const
The bound element.
Definition multidomain/facet/box/fvelementgeometry.hh:322
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:280
static constexpr std::size_t maxNumElementScvs
the maximum number of scvs per element (2^dim for cubes)
Definition multidomain/facet/box/fvelementgeometry.hh:224
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition multidomain/facet/box/fvelementgeometry.hh:236
void bindElement(const Element &element) &
Definition multidomain/facet/box/fvelementgeometry.hh:145
GG GridGeometry
export type of finite volume grid geometry
Definition multidomain/facet/box/fvelementgeometry.hh:59
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:119
SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace &scvf) const
Create the geometry of a given sub control volume face.
Definition multidomain/facet/box/fvelementgeometry.hh:172
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition multidomain/facet/box/fvelementgeometry.hh:156
void bind(const Element &element) &
Definition multidomain/facet/box/fvelementgeometry.hh:128
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvelementgeometry.hh:107
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition multidomain/facet/box/fvelementgeometry.hh:69
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:95
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition multidomain/facet/box/fvelementgeometry.hh:73
static constexpr std::size_t maxNumElementScvs
the maximum number of scvs per element (2^dim for cubes)
Definition multidomain/facet/box/fvelementgeometry.hh:61
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition multidomain/facet/box/fvelementgeometry.hh:55
BoxFacetCouplingFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition multidomain/facet/box/fvelementgeometry.hh:64
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition multidomain/facet/box/fvelementgeometry.hh:152
friend Dune::IteratorRange< typename std::vector< SubControlVolume >::const_iterator > scvs(const BoxFacetCouplingFVElementGeometry &fvGeometry)
Definition multidomain/facet/box/fvelementgeometry.hh:82
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition multidomain/facet/box/fvelementgeometry.hh:57
SubControlVolume::Traits::Geometry geometry(const SubControlVolume &scv) const
Create the geometry of a given sub control volume.
Definition multidomain/facet/box/fvelementgeometry.hh:164
std::size_t numScvf() const
The total number of sub control volume faces.
Definition multidomain/facet/box/fvelementgeometry.hh:111
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition multidomain/facet/box/fvelementgeometry.hh:103
const Element & element() const
The bound element.
Definition multidomain/facet/box/fvelementgeometry.hh:160
typename GridView::template Codim< 0 >::Entity Element
export type of the element
Definition multidomain/facet/box/fvelementgeometry.hh:53
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:136
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