24#ifndef DUMUX_DISCRETIZATION_STAGGERED_FV_ELEMENT_GEOMETRY_HH
25#define DUMUX_DISCRETIZATION_STAGGERED_FV_ELEMENT_GEOMETRY_HH
41template<
class GG,
bool enableGr
idGeometryCache>
56 using GridView =
typename GG::GridView;
63 using ParentType::ParentType;
67 template<
class CellCenterOrFaceFVGr
idGeometry>
69 :
ParentType(gridGeometry.actualGridGeometry()) {}
72 using ParentType::scvf;
75 return this->gridGeometry().scvf(eIdx, localScvfIdx);
91 using GridView =
typename GG::GridView;
94 using Element =
typename GridView::template Codim<0>::Entity;
106 template<
class CellCenterOrFaceFVGr
idGeometry>
108 : gridGeometryPtr_(&gridGeometry.actualGridGeometry()) {}
112 : gridGeometryPtr_(&gridGeometry) {}
117 return scvf(this->gridGeometry().localToGlobalScvfIndex(eIdx, localScvfIdx));
124 if (scvIdx == scvIndices_[0])
127 return neighborScvs_[findLocalIndex_(scvIdx, neighborScvIndices_)];
134 auto it = std::find(scvfIndices_.begin(), scvfIndices_.end(), scvfIdx);
135 if (it != scvfIndices_.end())
136 return scvfs_[std::distance(scvfIndices_.begin(), it)];
138 return neighborScvfs_[findLocalIndex_(scvfIdx, neighborScvfIndices_)];
146 friend inline Dune::IteratorRange<typename std::array<SubControlVolume, 1>::const_iterator>
149 using IteratorType =
typename std::array<SubControlVolume, 1>::const_iterator;
150 return Dune::IteratorRange<IteratorType>(g.scvs_.begin(), g.scvs_.end());
158 friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator>
161 using IteratorType =
typename std::vector<SubControlVolumeFace>::const_iterator;
162 return Dune::IteratorRange<IteratorType>(g.scvfs_.begin(), g.scvfs_.end());
167 {
return scvs_.size(); }
171 {
return scvfs_.size(); }
175 void bind(
const Element& element)
177 bindElement(element);
179 neighborScvs_.reserve(element.subEntities(1));
180 neighborScvfIndices_.reserve(element.subEntities(1));
181 neighborScvfs_.reserve(element.subEntities(1));
183 std::vector<GridIndexType> handledNeighbors;
184 handledNeighbors.reserve(element.subEntities(1));
185 for (
const auto& intersection :
intersections(gridGeometry().gridView(), element))
187 if (intersection.neighbor())
189 const auto outside = intersection.outside();
190 const auto outsideIdx = gridGeometry().elementMapper().index(outside);
193 if ( std::find(handledNeighbors.begin(), handledNeighbors.end(), outsideIdx) == handledNeighbors.end() )
195 makeNeighborGeometries_(outside, outsideIdx);
196 handledNeighbors.push_back(outsideIdx);
206 elementPtr_ = &element;
207 scvfs_.reserve(element.subEntities(1));
208 scvfIndices_.reserve(element.subEntities(1));
209 makeElementGeometries_(element);
213 [[deprecated(
"Use gridGeometry() instead. fvGridGeometry() will be removed after 3.1!")]]
215 {
return gridGeometry(); }
217 {
return *gridGeometryPtr_; }
221 {
return hasBoundaryScvf_; }
226 void makeElementGeometries_(
const Element& element)
228 const auto eIdx = gridGeometry().elementMapper().index(element);
229 scvs_[0] = SubControlVolume(element.geometry(), eIdx);
230 scvIndices_[0] = eIdx;
232 const auto& scvFaceIndices = gridGeometry().scvfIndicesOfScv(eIdx);
233 const auto& neighborVolVarIndices = gridGeometry().neighborVolVarIndices(eIdx);
235 typename GridGeometry::GeometryHelper geometryHelper(element, gridGeometry().gridView());
238 for (
const auto& intersection :
intersections(gridGeometry().gridView(), element))
240 const auto& scvfNeighborVolVarIndex = neighborVolVarIndices[scvfCounter];
242 if (intersection.neighbor() || intersection.boundary())
244 geometryHelper.updateLocalFace(gridGeometry().intersectionMapper(), intersection);
245 std::vector<GridIndexType> scvIndices{eIdx, scvfNeighborVolVarIndex};
246 scvfs_.emplace_back(intersection,
247 intersection.geometry(),
248 scvFaceIndices[scvfCounter],
251 scvfIndices_.emplace_back(scvFaceIndices[scvfCounter]);
254 if (intersection.boundary())
255 hasBoundaryScvf_ =
true;
261 void makeNeighborGeometries_(
const Element& element,
const GridIndexType eIdx)
266 neighborScvs_.emplace_back(element.geometry(), eIdx);
267 neighborScvIndices_.push_back(eIdx);
269 const auto& scvFaceIndices = gridGeometry().scvfIndicesOfScv(eIdx);
270 const auto& neighborVolVarIndices = gridGeometry().neighborVolVarIndices(eIdx);
272 typename GridGeometry::GeometryHelper geometryHelper(element, gridGeometry().gridView());
275 for (
const auto& intersection :
intersections(gridGeometry().gridView(), element))
277 const auto& scvfNeighborVolVarIndex = neighborVolVarIndices[scvfCounter];
278 geometryHelper.updateLocalFace(gridGeometry().intersectionMapper(), intersection);
280 if (intersection.neighbor())
283 if (intersection.outside() == *elementPtr_)
285 std::vector<GridIndexType> scvIndices{eIdx, scvfNeighborVolVarIndex};
286 neighborScvfs_.emplace_back(intersection,
287 intersection.geometry(),
288 scvFaceIndices[scvfCounter],
292 neighborScvfIndices_.push_back(scvFaceIndices[scvfCounter]);
296 else if (intersection.boundary())
301 const LocalIndexType findLocalIndex_(
const GridIndexType idx,
302 const std::vector<GridIndexType>& indices)
const
304 auto it = std::find(indices.begin(), indices.end(), idx);
305 assert(it != indices.end() &&
"Could not find the scv/scvf! Make sure to properly bind this class!");
306 return std::distance(indices.begin(), it);
312 scvfIndices_.clear();
315 neighborScvIndices_.clear();
316 neighborScvfIndices_.clear();
317 neighborScvs_.clear();
318 neighborScvfs_.clear();
320 hasBoundaryScvf_ =
false;
323 const Element* elementPtr_;
324 const GridGeometry* gridGeometryPtr_;
327 std::array<GridIndexType, 1> scvIndices_;
328 std::array<SubControlVolume, 1> scvs_;
330 std::vector<GridIndexType> scvfIndices_;
331 std::vector<SubControlVolumeFace> scvfs_;
333 std::vector<GridIndexType> neighborScvIndices_;
334 std::vector<SubControlVolume> neighborScvs_;
336 std::vector<GridIndexType> neighborScvfIndices_;
337 std::vector<SubControlVolumeFace> neighborScvfs_;
339 bool hasBoundaryScvf_ =
false;
Defines the index types used for grid and local indices.
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
Stencil-local finite volume geometry (scvs and scvfs) for cell-centered TPFA models This builds up th...
Definition: discretization/cellcentered/tpfa/fvelementgeometry.hh:50
Stencil-local finite volume geometry (scvs and scvfs) for cell-centered TPFA models Specialization fo...
Definition: discretization/cellcentered/tpfa/fvelementgeometry.hh:60
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/cellcentered/tpfa/fvelementgeometry.hh:70
Stencil-local finite volume geometry (scvs and scvfs) for staggered models This builds up the sub con...
Definition: discretization/staggered/fvelementgeometry.hh:42
const SubControlVolumeFace & scvf(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvelementgeometry.hh:73
StaggeredFVElementGeometry(const CellCenterOrFaceFVGridGeometry &gridGeometry)
Definition: discretization/staggered/fvelementgeometry.hh:68
Base class for the finite volume geometry vector for staggered models This locally builds up the sub ...
Definition: discretization/staggered/fvelementgeometry.hh:89
bool hasBoundaryScvf() const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/staggered/fvelementgeometry.hh:220
friend Dune::IteratorRange< typename std::vector< SubControlVolumeFace >::const_iterator > scvfs(const ThisType &g)
Definition: discretization/staggered/fvelementgeometry.hh:159
typename GG::SubControlVolume SubControlVolume
export type of subcontrol volume
Definition: discretization/staggered/fvelementgeometry.hh:97
const SubControlVolume & scv(GridIndexType scvIdx) const
Definition: discretization/staggered/fvelementgeometry.hh:122
StaggeredFVElementGeometry(const CellCenterOrFaceFVGridGeometry &gridGeometry)
Definition: discretization/staggered/fvelementgeometry.hh:107
const GridGeometry & fvGridGeometry() const
The global finite volume geometry we are a restriction of.
Definition: discretization/staggered/fvelementgeometry.hh:214
std::size_t numScv() const
number of sub control volumes in this fv element geometry
Definition: discretization/staggered/fvelementgeometry.hh:166
const SubControlVolumeFace & scvf(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Get a sub control volume face with an element index and a local scvf index.
Definition: discretization/staggered/fvelementgeometry.hh:115
const GridGeometry & gridGeometry() const
Definition: discretization/staggered/fvelementgeometry.hh:216
GridGeometry FVGridGeometry
Definition: discretization/staggered/fvelementgeometry.hh:102
std::size_t numScvf() const
number of sub control volumes in this fv element geometry
Definition: discretization/staggered/fvelementgeometry.hh:170
StaggeredFVElementGeometry(const GridGeometry &gridGeometry)
Constructor.
Definition: discretization/staggered/fvelementgeometry.hh:111
typename GG::SubControlVolumeFace SubControlVolumeFace
export type of subcontrol volume face
Definition: discretization/staggered/fvelementgeometry.hh:99
friend Dune::IteratorRange< typename std::array< SubControlVolume, 1 >::const_iterator > scvs(const ThisType &g)
Definition: discretization/staggered/fvelementgeometry.hh:147
void bindElement(const Element &element)
Binding of an element preparing the geometries only inside the element.
Definition: discretization/staggered/fvelementgeometry.hh:203
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Definition: discretization/staggered/fvelementgeometry.hh:132
GG GridGeometry
export type of finite volume grid geometry
Definition: discretization/staggered/fvelementgeometry.hh:101
void bind(const Element &element)
Definition: discretization/staggered/fvelementgeometry.hh:175
Stencil-local finite volume geometry (scvs and scvfs) for cell-centered TPFA models This builds up th...