24#ifndef DUMUX_DISCRETIZATION_PNM_FV_ELEMENT_GEOMETRY_HH
25#define DUMUX_DISCRETIZATION_PNM_FV_ELEMENT_GEOMETRY_HH
42template<
class GG,
bool enableFVGr
idGeometryCache>
49 using GridView =
typename GG::GridView;
50 static constexpr int dim = GridView::dimension;
51 static constexpr int dimWorld = GridView::dimensionworld;
54 using CoordScalar =
typename GridView::ctype;
55 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
64 using Element =
typename GridView::template Codim<0>::Entity;
66 static constexpr std::size_t maxNumElementScvs = 2;
70 : gridGeometryPtr_(&gridGeometry) {}
75 return gridGeometry().scvs(eIdx_)[scvIdx];
81 return gridGeometry().scvfs(eIdx_)[scvfIdx];
91 const auto& g = fvGeometry.gridGeometry();
92 using Iter =
typename std::decay_t<
decltype(g.scvs(fvGeometry.eIdx_))>::const_iterator;
93 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
103 const auto& g = fvGeometry.gridGeometry();
104 using Iter =
typename std::decay_t<
decltype(g.scvfs(fvGeometry.eIdx_))>::const_iterator;
105 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
111 return gridGeometry().feCache().get(element_->type()).localBasis();
117 return gridGeometry().scvs(eIdx_).size();
123 return gridGeometry().scvfs(eIdx_).size();
133 this->bindElement(element);
134 return std::move(*
this);
141 { this->bindElement(element); }
150 this->bindElement(element);
151 return std::move(*
this);
160 eIdx_ = gridGeometry().elementMapper().index(element);
165 {
return static_cast<bool>(element_); }
169 {
return *element_; }
173 {
return *gridGeometryPtr_; }
177 {
return gridGeometry().hasBoundaryScvf(eIdx_); }
180 std::optional<Element> element_;
190 using GridView =
typename GG::GridView;
191 static constexpr int dim = GridView::dimension;
192 static constexpr int dimWorld = GridView::dimensionworld;
195 using CoordScalar =
typename GridView::ctype;
196 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
206 using Element =
typename GridView::template Codim<0>::Entity;
208 static constexpr std::size_t maxNumElementScvs = 2;
212 : gridGeometryPtr_(&gridGeometry) {}
217 return scvs_[scvIdx];
233 using Iter =
typename std::decay_t<
decltype(fvGeometry.scvs_)>::const_iterator;
234 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
244 using Iter =
typename std::decay_t<
decltype(fvGeometry.scvfs_)>::const_iterator;
245 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
251 return gridGeometry().feCache().get(element_->type()).localBasis();
263 return scvfs_.size();
273 this->bindElement(element);
274 return std::move(*
this);
281 { this->bindElement(element); }
290 this->bindElement(element);
291 return std::move(*
this);
300 eIdx_ = gridGeometry().elementMapper().index(element);
301 makeElementGeometries(element);
306 {
return static_cast<bool>(element_); }
310 {
return *element_; }
314 {
return *gridGeometryPtr_; }
318 {
return hasBoundaryScvf_; }
322 void makeElementGeometries(
const Element& element)
324 hasBoundaryScvf_ =
false;
327 auto elementGeometry = element.geometry();
330 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
333 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
336 auto corners = std::array{elementGeometry.corner(scvLocalIdx), elementGeometry.center()};
339 const auto volume = gridGeometry().poreVolume(dofIdxGlobal) / gridGeometry().coordinationNumber(dofIdxGlobal);
342 scvs_[scvLocalIdx] = SubControlVolume(dofIdxGlobal,
348 if (gridGeometry().poreLabel(dofIdxGlobal) > 0)
349 hasBoundaryScvf_ =
true;
353 auto unitOuterNormal = elementGeometry.corner(1) - elementGeometry.corner(0);
354 unitOuterNormal /= unitOuterNormal.two_norm();
355 LocalIndexType scvfLocalIdx = 0;
356 scvfs_[0] = SubControlVolumeFace(elementGeometry.center(),
357 std::move(unitOuterNormal),
358 gridGeometry().throatCrossSectionalArea(gridGeometry().elementMapper().index(element)),
360 std::array<LocalIndexType, 2>({0, 1}));
364 std::optional<Element> element_;
368 const GridGeometry* gridGeometryPtr_;
371 std::array<SubControlVolume, 2> scvs_;
372 std::array<SubControlVolumeFace, 1> scvfs_;
374 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:34
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:43
const Element & element() const
The bound element.
Definition: discretization/porenetwork/fvelementgeometry.hh:168
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/porenetwork/fvelementgeometry.hh:58
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: discretization/porenetwork/fvelementgeometry.hh:172
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/porenetwork/fvelementgeometry.hh:60
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/porenetwork/fvelementgeometry.hh:176
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/porenetwork/fvelementgeometry.hh:79
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/porenetwork/fvelementgeometry.hh:164
friend auto scvfs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:101
PNMFVElementGeometry 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: discretization/porenetwork/fvelementgeometry.hh:131
void bind(const Element &element) &
Definition: discretization/porenetwork/fvelementgeometry.hh:140
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/porenetwork/fvelementgeometry.hh:121
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/porenetwork/fvelementgeometry.hh:62
void bindElement(const Element &element) &
Definition: discretization/porenetwork/fvelementgeometry.hh:157
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/porenetwork/fvelementgeometry.hh:115
PNMFVElementGeometry 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: discretization/porenetwork/fvelementgeometry.hh:148
typename GridView::template Codim< 0 >::Entity Element
export element type
Definition: discretization/porenetwork/fvelementgeometry.hh:64
PNMFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/porenetwork/fvelementgeometry.hh:69
friend auto scvs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:89
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/porenetwork/fvelementgeometry.hh:109
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/porenetwork/fvelementgeometry.hh:73
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/porenetwork/fvelementgeometry.hh:215
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/porenetwork/fvelementgeometry.hh:202
void bind(const Element &element) &
Definition: discretization/porenetwork/fvelementgeometry.hh:280
const Element & element() const
The bound element.
Definition: discretization/porenetwork/fvelementgeometry.hh:309
PNMFVElementGeometry 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: discretization/porenetwork/fvelementgeometry.hh:271
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/porenetwork/fvelementgeometry.hh:255
PNMFVElementGeometry 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: discretization/porenetwork/fvelementgeometry.hh:288
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/porenetwork/fvelementgeometry.hh:204
friend auto scvfs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:242
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: discretization/porenetwork/fvelementgeometry.hh:313
void bindElement(const Element &element) &
Definition: discretization/porenetwork/fvelementgeometry.hh:297
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/porenetwork/fvelementgeometry.hh:200
PNMFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/porenetwork/fvelementgeometry.hh:211
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/porenetwork/fvelementgeometry.hh:261
typename GridView::template Codim< 0 >::Entity Element
export element type
Definition: discretization/porenetwork/fvelementgeometry.hh:206
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/porenetwork/fvelementgeometry.hh:221
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/porenetwork/fvelementgeometry.hh:305
friend auto scvs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:231
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/porenetwork/fvelementgeometry.hh:317
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/porenetwork/fvelementgeometry.hh:249
Base class for the finite volume geometry for porenetwork models.
Definition: discretization/porenetwork/gridgeometry.hh:489