24#ifndef DUMUX_DISCRETIZATION_PNM_FV_ELEMENT_GEOMETRY_HH
25#define DUMUX_DISCRETIZATION_PNM_FV_ELEMENT_GEOMETRY_HH
41template<
class GG,
bool enableFVGr
idGeometryCache>
48 using GridView =
typename GG::GridView;
49 static constexpr int dim = GridView::dimension;
50 static constexpr int dimWorld = GridView::dimensionworld;
53 using CoordScalar =
typename GridView::ctype;
54 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
63 using Element =
typename GridView::template Codim<0>::Entity;
65 static constexpr std::size_t maxNumElementScvs = 2;
69 : gridGeometryPtr_(&gridGeometry) {}
74 return gridGeometry().scvs(eIdx_)[scvIdx];
80 return gridGeometry().scvfs(eIdx_)[scvfIdx];
90 const auto& g = fvGeometry.gridGeometry();
91 using Iter =
typename std::decay_t<
decltype(g.scvs(fvGeometry.eIdx_))>::const_iterator;
92 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
102 const auto& g = fvGeometry.gridGeometry();
103 using Iter =
typename std::decay_t<
decltype(g.scvfs(fvGeometry.eIdx_))>::const_iterator;
104 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
110 return gridGeometry().feCache().get(element_->type()).localBasis();
116 return gridGeometry().scvs(eIdx_).size();
122 return gridGeometry().scvfs(eIdx_).size();
130 this->bindElement(element);
139 eIdx_ = gridGeometry().elementMapper().index(element);
144 {
return static_cast<bool>(element_); }
148 {
return *element_; }
152 {
return *gridGeometryPtr_; }
156 {
return gridGeometry().hasBoundaryScvf(eIdx_); }
159 std::optional<Element> element_;
169 using GridView =
typename GG::GridView;
170 static constexpr int dim = GridView::dimension;
171 static constexpr int dimWorld = GridView::dimensionworld;
174 using CoordScalar =
typename GridView::ctype;
175 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
185 using Element =
typename GridView::template Codim<0>::Entity;
187 static constexpr std::size_t maxNumElementScvs = 2;
191 : gridGeometryPtr_(&gridGeometry) {}
196 return scvs_[scvIdx];
212 using Iter =
typename std::decay_t<
decltype(fvGeometry.scvs_)>::const_iterator;
213 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
223 using Iter =
typename std::decay_t<
decltype(fvGeometry.scvfs_)>::const_iterator;
224 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
230 return gridGeometry().feCache().get(element_->type()).localBasis();
242 return scvfs_.size();
250 this->bindElement(element);
259 eIdx_ = gridGeometry().elementMapper().index(element);
260 makeElementGeometries(element);
265 {
return static_cast<bool>(element_); }
269 {
return *element_; }
273 {
return *gridGeometryPtr_; }
277 {
return hasBoundaryScvf_; }
281 void makeElementGeometries(
const Element& element)
283 hasBoundaryScvf_ =
false;
286 auto elementGeometry = element.geometry();
289 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
292 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
295 auto corners = std::array{elementGeometry.corner(scvLocalIdx), elementGeometry.center()};
298 const auto volume = gridGeometry().poreVolume(dofIdxGlobal) / gridGeometry().coordinationNumber(dofIdxGlobal);
301 scvs_[scvLocalIdx] = SubControlVolume(dofIdxGlobal,
307 if (gridGeometry().poreLabel(dofIdxGlobal) > 0)
308 hasBoundaryScvf_ =
true;
312 auto unitOuterNormal = elementGeometry.corner(1) - elementGeometry.corner(0);
313 unitOuterNormal /= unitOuterNormal.two_norm();
314 LocalIndexType scvfLocalIdx = 0;
315 scvfs_[0] = SubControlVolumeFace(elementGeometry.center(),
316 std::move(unitOuterNormal),
317 gridGeometry().throatCrossSectionalArea(gridGeometry().elementMapper().index(element)),
319 std::array<LocalIndexType, 2>({0, 1}));
323 std::optional<Element> element_;
327 const GridGeometry* gridGeometryPtr_;
330 std::array<SubControlVolume, 2> scvs_;
331 std::array<SubControlVolumeFace, 1> scvfs_;
333 bool hasBoundaryScvf_ =
false;
Defines the index types used for grid and local indices.
Class providing iterators over sub control volumes and sub control volume faces of an element.
Definition: discretization/porenetwork/fvelementgeometry.hh:33
Scalar volume(Shape shape, Scalar inscribedRadius)
Returns the volume of a given geometry based on the inscribed radius.
Definition: poreproperties.hh:73
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
unsigned int LocalIndex
Definition: indextraits.hh:40
Base class for the local geometry for porenetworks.
Definition: discretization/porenetwork/fvelementgeometry.hh:42
const Element & element() const
The bound element.
Definition: discretization/porenetwork/fvelementgeometry.hh:147
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/porenetwork/fvelementgeometry.hh:57
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: discretization/porenetwork/fvelementgeometry.hh:151
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/porenetwork/fvelementgeometry.hh:59
void bindElement(const Element &element)
Definition: discretization/porenetwork/fvelementgeometry.hh:136
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/porenetwork/fvelementgeometry.hh:155
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/porenetwork/fvelementgeometry.hh:78
void bind(const Element &element)
Definition: discretization/porenetwork/fvelementgeometry.hh:128
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/porenetwork/fvelementgeometry.hh:143
friend auto scvfs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:100
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/porenetwork/fvelementgeometry.hh:120
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/porenetwork/fvelementgeometry.hh:61
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/porenetwork/fvelementgeometry.hh:114
typename GridView::template Codim< 0 >::Entity Element
export element type
Definition: discretization/porenetwork/fvelementgeometry.hh:63
PNMFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/porenetwork/fvelementgeometry.hh:68
friend auto scvs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:88
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/porenetwork/fvelementgeometry.hh:108
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/porenetwork/fvelementgeometry.hh:72
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/porenetwork/fvelementgeometry.hh:194
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/porenetwork/fvelementgeometry.hh:181
const Element & element() const
The bound element.
Definition: discretization/porenetwork/fvelementgeometry.hh:268
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/porenetwork/fvelementgeometry.hh:234
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/porenetwork/fvelementgeometry.hh:183
void bindElement(const Element &element)
Definition: discretization/porenetwork/fvelementgeometry.hh:256
friend auto scvfs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:221
void bind(const Element &element)
Definition: discretization/porenetwork/fvelementgeometry.hh:248
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: discretization/porenetwork/fvelementgeometry.hh:272
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/porenetwork/fvelementgeometry.hh:179
PNMFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/porenetwork/fvelementgeometry.hh:190
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/porenetwork/fvelementgeometry.hh:240
typename GridView::template Codim< 0 >::Entity Element
export element type
Definition: discretization/porenetwork/fvelementgeometry.hh:185
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/porenetwork/fvelementgeometry.hh:200
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/porenetwork/fvelementgeometry.hh:264
friend auto scvs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:210
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/porenetwork/fvelementgeometry.hh:276
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/porenetwork/fvelementgeometry.hh:228
Base class for the finite volume geometry for porenetwork models.
Definition: discretization/porenetwork/gridgeometry.hh:488