12#ifndef DUMUX_DISCRETIZATION_PNM_FV_ELEMENT_GEOMETRY_HH
13#define DUMUX_DISCRETIZATION_PNM_FV_ELEMENT_GEOMETRY_HH
19#include <dune/geometry/type.hh>
32template<
class GG,
bool enableFVGr
idGeometryCache>
39 using GridView =
typename GG::GridView;
40 static constexpr int dim = GridView::dimension;
41 static constexpr int dimWorld = GridView::dimensionworld;
44 using CoordScalar =
typename GridView::ctype;
45 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
54 using Element =
typename GridView::template Codim<0>::Entity;
56 static constexpr std::size_t maxNumElementScvs = 2;
60 : gridGeometryPtr_(&gridGeometry) {}
65 return gridGeometry().scvs(eIdx_)[scvIdx];
71 return gridGeometry().scvfs(eIdx_)[scvfIdx];
81 const auto& g = fvGeometry.gridGeometry();
82 using Iter =
typename std::decay_t<
decltype(g.scvs(fvGeometry.eIdx_))>::const_iterator;
83 return Dune::IteratorRange<Iter>(g.scvs(fvGeometry.eIdx_).begin(), g.scvs(fvGeometry.eIdx_).end());
93 const auto& g = fvGeometry.gridGeometry();
94 using Iter =
typename std::decay_t<
decltype(g.scvfs(fvGeometry.eIdx_))>::const_iterator;
95 return Dune::IteratorRange<Iter>(g.scvfs(fvGeometry.eIdx_).begin(), g.scvfs(fvGeometry.eIdx_).end());
101 return gridGeometry().feCache().get(element_->type()).localBasis();
107 return gridGeometry().scvs(eIdx_).size();
113 return gridGeometry().scvfs(eIdx_).size();
123 this->bindElement(element);
124 return std::move(*
this);
131 { this->bindElement(element); }
140 this->bindElement(element);
141 return std::move(*
this);
150 eIdx_ = gridGeometry().elementMapper().index(element);
155 {
return static_cast<bool>(element_); }
159 {
return *element_; }
163 {
return *gridGeometryPtr_; }
167 {
return gridGeometry().hasBoundaryScvf(eIdx_); }
172 const auto geo = element().geometry();
174 Dune::GeometryTypes::simplex(dim),
175 std::array{{ geo.corner(scv.indexInElement()), geo.center() }}
181 {
return { scvf.center() }; }
184 std::optional<Element> element_;
194 using GridView =
typename GG::GridView;
195 static constexpr int dim = GridView::dimension;
196 static constexpr int dimWorld = GridView::dimensionworld;
199 using CoordScalar =
typename GridView::ctype;
200 using FeLocalBasis =
typename GG::FeCache::FiniteElementType::Traits::LocalBasisType;
210 using Element =
typename GridView::template Codim<0>::Entity;
212 static constexpr std::size_t maxNumElementScvs = 2;
216 : gridGeometryPtr_(&gridGeometry) {}
221 return scvs_[scvIdx];
237 using Iter =
typename std::decay_t<
decltype(fvGeometry.scvs_)>::const_iterator;
238 return Dune::IteratorRange<Iter>(fvGeometry.scvs_.begin(), fvGeometry.scvs_.end());
248 using Iter =
typename std::decay_t<
decltype(fvGeometry.scvfs_)>::const_iterator;
249 return Dune::IteratorRange<Iter>(fvGeometry.scvfs_.begin(), fvGeometry.scvfs_.end());
255 return gridGeometry().feCache().get(element_->type()).localBasis();
267 return scvfs_.size();
277 this->bindElement(element);
278 return std::move(*
this);
285 { this->bindElement(element); }
294 this->bindElement(element);
295 return std::move(*
this);
304 eIdx_ = gridGeometry().elementMapper().index(element);
305 makeElementGeometries(element);
310 {
return static_cast<bool>(element_); }
314 {
return *element_; }
318 {
return *gridGeometryPtr_; }
322 {
return hasBoundaryScvf_; }
327 const auto geo = element().geometry();
329 Dune::GeometryTypes::simplex(dim),
330 std::array{{ geo.corner(scv.indexInElement()), geo.center() }}
336 {
return { scvf.center() }; }
340 void makeElementGeometries(
const Element& element)
342 hasBoundaryScvf_ =
false;
345 auto elementGeometry = element.geometry();
348 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
351 const auto dofIdxGlobal = gridGeometry().vertexMapper().subIndex(element, scvLocalIdx, dim);
354 auto corners = std::array{elementGeometry.corner(scvLocalIdx), elementGeometry.center()};
357 const auto volume = gridGeometry().poreVolume(dofIdxGlobal) / gridGeometry().coordinationNumber(dofIdxGlobal);
360 scvs_[scvLocalIdx] = SubControlVolume(dofIdxGlobal,
366 if (gridGeometry().poreLabel(dofIdxGlobal) > 0)
367 hasBoundaryScvf_ =
true;
371 auto unitOuterNormal = elementGeometry.corner(1) - elementGeometry.corner(0);
372 unitOuterNormal /= unitOuterNormal.two_norm();
373 LocalIndexType scvfLocalIdx = 0;
374 scvfs_[0] = SubControlVolumeFace(elementGeometry.center(),
375 std::move(unitOuterNormal),
376 gridGeometry().throatCrossSectionalArea(gridGeometry().elementMapper().index(element)),
378 std::array<LocalIndexType, 2>({0, 1}));
382 std::optional<Element> element_;
386 const GridGeometry* gridGeometryPtr_;
389 std::array<SubControlVolume, 2> scvs_;
390 std::array<SubControlVolumeFace, 1> scvfs_;
392 bool hasBoundaryScvf_ =
false;
Base class for the finite volume geometry for porenetwork models.
Definition: discretization/porenetwork/gridgeometry.hh:477
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/porenetwork/fvelementgeometry.hh:219
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/porenetwork/fvelementgeometry.hh:206
void bind(const Element &element) &
Definition: discretization/porenetwork/fvelementgeometry.hh:284
const Element & element() const
The bound element.
Definition: discretization/porenetwork/fvelementgeometry.hh:313
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:275
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/porenetwork/fvelementgeometry.hh:259
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:292
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/porenetwork/fvelementgeometry.hh:208
SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace &scvf) const
Create the geometry of a given sub control volume face.
Definition: discretization/porenetwork/fvelementgeometry.hh:335
friend auto scvfs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:246
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: discretization/porenetwork/fvelementgeometry.hh:317
void bindElement(const Element &element) &
Definition: discretization/porenetwork/fvelementgeometry.hh:301
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/porenetwork/fvelementgeometry.hh:204
PNMFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/porenetwork/fvelementgeometry.hh:215
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/porenetwork/fvelementgeometry.hh:265
typename GridView::template Codim< 0 >::Entity Element
export element type
Definition: discretization/porenetwork/fvelementgeometry.hh:210
SubControlVolume::Traits::Geometry geometry(const SubControlVolume &scv) const
Create the geometry of a given sub control volume.
Definition: discretization/porenetwork/fvelementgeometry.hh:325
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/porenetwork/fvelementgeometry.hh:225
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/porenetwork/fvelementgeometry.hh:309
friend auto scvs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:235
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/porenetwork/fvelementgeometry.hh:321
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/porenetwork/fvelementgeometry.hh:253
const Element & element() const
The bound element.
Definition: discretization/porenetwork/fvelementgeometry.hh:158
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/porenetwork/fvelementgeometry.hh:48
const GridGeometry & gridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: discretization/porenetwork/fvelementgeometry.hh:162
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/porenetwork/fvelementgeometry.hh:50
SubControlVolume::Traits::Geometry geometry(const SubControlVolume &scv) const
Create the geometry of a given sub control volume.
Definition: discretization/porenetwork/fvelementgeometry.hh:170
SubControlVolumeFace::Traits::Geometry geometry(const SubControlVolumeFace &scvf) const
Create the geometry of a given sub control volume face.
Definition: discretization/porenetwork/fvelementgeometry.hh:180
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/porenetwork/fvelementgeometry.hh:166
const SubControlVolumeFace & scvf(LocalIndexType scvfIdx) const
Get a sub control volume face with a local scvf index.
Definition: discretization/porenetwork/fvelementgeometry.hh:69
bool isBound() const
Returns true if bind/bindElement has already been called.
Definition: discretization/porenetwork/fvelementgeometry.hh:154
friend auto scvfs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:91
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:121
void bind(const Element &element) &
Definition: discretization/porenetwork/fvelementgeometry.hh:130
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/porenetwork/fvelementgeometry.hh:111
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/porenetwork/fvelementgeometry.hh:52
void bindElement(const Element &element) &
Definition: discretization/porenetwork/fvelementgeometry.hh:147
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/porenetwork/fvelementgeometry.hh:105
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:138
typename GridView::template Codim< 0 >::Entity Element
export element type
Definition: discretization/porenetwork/fvelementgeometry.hh:54
PNMFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/porenetwork/fvelementgeometry.hh:59
friend auto scvs(const PNMFVElementGeometry &fvGeometry)
Definition: discretization/porenetwork/fvelementgeometry.hh:79
const FeLocalBasis & feLocalBasis() const
Get a local finite element basis.
Definition: discretization/porenetwork/fvelementgeometry.hh:99
const SubControlVolume & scv(LocalIndexType scvIdx) const
Get a sub control volume with a local scv index.
Definition: discretization/porenetwork/fvelementgeometry.hh:63
Base class for the local geometry for porenetworks.
Definition: discretization/porenetwork/fvelementgeometry.hh:33
auto volume(const Geometry &geo, unsigned int integrationOrder=4)
The volume of a given geometry.
Definition: volume.hh:159
Definition: discretization/porenetwork/fvelementgeometry.hh:24
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