24#ifndef DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
25#define DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
40template<
class ActualGr
idGeometry>
49 using GridView =
typename ActualGridGeometry::GridView;
51 using LocalView =
typename ActualGridGeometry::LocalView;
61 static constexpr bool isFace() {
return false; }
67 {
return typename ActualGridGeometry::DofTypeIndices::CellCenterIdx{}; }
73 {
return typename ActualGridGeometry::DofTypeIndices::FaceIdx{}; }
116template <
class ActualGr
idGeometry>
122 using ParentType::ParentType;
141template <
class ActualGr
idGeometry>
147 using ParentType::ParentType;
152 static constexpr bool isFace() {
return true; }
167template<
class GridView,
178template<
class GV,
class T>
186 using Element =
typename GV::template Codim<0>::Entity;
188 using IntersectionMapper =
typename T::IntersectionMapper;
189 using GeometryHelper =
typename T::GeometryHelper;
190 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
198 static constexpr int upwindSchemeOrder = T::upwindSchemeOrder;
199 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
200 static constexpr bool cachingEnabled =
true;
217 {
return typename DofTypeIndices::CellCenterIdx{}; }
221 {
return typename DofTypeIndices::FaceIdx{}; }
225 {
return upwindSchemeOrder; }
235 , intersectionMapper_(gridView)
239 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
240 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
252 return scvfs_.size();
258 return numBoundaryScvf_;
265 return intersectionMapper_.numIntersections();
270 {
return numCellCenterDofs() + numFaceDofs(); }
273 {
return this->gridView().size(0); }
276 {
return this->gridView().size(1); }
284 scvfIndicesOfScv_.clear();
285 intersectionMapper_.update();
288 std::size_t numScvs = this->gridView().size(0);
289 std::size_t numScvf = 0;
290 for (
const auto& element : elements(this->gridView()))
291 numScvf += element.subEntities(1);
294 scvs_.resize(numScvs);
295 scvfs_.reserve(numScvf);
296 scvfIndicesOfScv_.resize(numScvs);
297 localToGlobalScvfIndices_.resize(numScvs);
298 hasBoundaryScvf_.resize(numScvs,
false);
301 GridIndexType scvfIdx = 0;
302 numBoundaryScvf_ = 0;
303 for (
const auto& element : elements(this->gridView()))
305 auto eIdx = this->elementMapper().index(element);
308 auto numLocalFaces = intersectionMapper_.numFaces(element);
309 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
314 std::vector<GridIndexType> scvfsIndexSet;
315 scvfsIndexSet.reserve(numLocalFaces);
317 GeometryHelper geometryHelper(element, this->gridView());
319 for (
const auto& intersection : intersections(this->gridView(), element))
321 geometryHelper.updateLocalFace(intersectionMapper_, intersection);
322 const int localFaceIndex = geometryHelper.localFaceIndex();
325 if (intersection.neighbor())
327 auto nIdx = this->elementMapper().index(intersection.outside());
328 scvfs_.emplace_back(intersection,
329 intersection.geometry(),
331 std::vector<GridIndexType>({eIdx, nIdx}),
333 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
334 scvfsIndexSet.push_back(scvfIdx++);
337 else if (intersection.boundary())
339 scvfs_.emplace_back(intersection,
340 intersection.geometry(),
342 std::vector<GridIndexType>({eIdx, this->gridView().size(0) + numBoundaryScvf_++}),
344 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
345 scvfsIndexSet.push_back(scvfIdx++);
347 hasBoundaryScvf_[eIdx] =
true;
352 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
356 connectivityMap_.update(*
this);
362 return scvs_[scvIdx];
368 return scvfs_[scvfIdx];
374 return scvfIndicesOfScv_[scvIdx];
379 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
384 return scvf(localToGlobalScvfIndex(eIdx, localScvfIdx));
392 {
return connectivityMap_; }
397 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
403 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
420 {
return hasBoundaryScvf_[eIdx]; }
425 ConnectivityMap connectivityMap_;
428 std::vector<SubControlVolume> scvs_;
429 std::vector<SubControlVolumeFace> scvfs_;
430 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
431 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
432 GridIndexType numBoundaryScvf_;
433 std::vector<bool> hasBoundaryScvf_;
442template<
class GV,
class T>
450 using Element =
typename GV::template Codim<0>::Entity;
452 using IntersectionMapper =
typename T::IntersectionMapper;
453 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
461 static constexpr int upwindSchemeOrder = T::upwindSchemeOrder;
462 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
463 static constexpr bool cachingEnabled =
false;
482 {
return typename DofTypeIndices::CellCenterIdx{}; }
486 {
return typename DofTypeIndices::FaceIdx{}; }
490 {
return upwindSchemeOrder; }
500 , intersectionMapper_(gridView)
504 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
505 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
512 scvfIndicesOfScv_.clear();
513 intersectionMapper_.update();
514 neighborVolVarIndices_.clear();
516 numScvs_ = numCellCenterDofs();
518 numBoundaryScvf_ = 0;
519 scvfIndicesOfScv_.resize(numScvs_);
520 localToGlobalScvfIndices_.resize(numScvs_);
521 neighborVolVarIndices_.resize(numScvs_);
524 for (
const auto& element : elements(this->gridView()))
526 auto eIdx = this->elementMapper().index(element);
529 auto numLocalFaces = intersectionMapper_.numFaces(element);
530 std::vector<GridIndexType> scvfsIndexSet;
531 scvfsIndexSet.reserve(numLocalFaces);
532 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
534 std::vector<GridIndexType> neighborVolVarIndexSet;
535 neighborVolVarIndexSet.reserve(numLocalFaces);
537 for (
const auto& intersection : intersections(this->gridView(), element))
539 const auto localFaceIndex = intersection.indexInInside();
540 localToGlobalScvfIndices_[eIdx][localFaceIndex] = numScvf_;
541 scvfsIndexSet.push_back(numScvf_++);
543 if (intersection.neighbor())
545 const auto nIdx = this->elementMapper().index(intersection.outside());
546 neighborVolVarIndexSet.emplace_back(nIdx);
549 neighborVolVarIndexSet.emplace_back(numScvs_ + numBoundaryScvf_++);
553 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
554 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
558 connectivityMap_.update(*
this);
576 return numBoundaryScvf_;
582 return intersectionMapper_.numIntersections();
587 {
return numCellCenterDofs() + numFaceDofs(); }
590 {
return this->gridView().size(0); }
593 {
return this->gridView().size(1); }
596 {
return scvfIndicesOfScv_[scvIdx]; }
600 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
608 {
return connectivityMap_; }
613 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
619 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
637 return intersectionMapper_;
642 {
return neighborVolVarIndices_[scvIdx]; }
647 std::size_t numScvs_;
648 std::size_t numScvf_;
649 std::size_t numBoundaryScvf_;
650 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
651 std::vector<std::vector<GridIndexType>> neighborVolVarIndices_;
654 ConnectivityMap connectivityMap_;
658 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
Defines the index types used for grid and local indices.
Check the overlap size for different discretization methods.
The available discretization methods in Dumux.
Base class for grid geometries.
Helper classes to compute the integration elements.
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:177
Struture to define the index types used for grid and local indices.
Definition: indextraits.hh:38
defines an intersection mapper for mapping of global DOFs assigned to faces which also works for adap...
Definition: intersectionmapper.hh:185
Base class for all finite volume grid geometries.
Definition: basegridgeometry.hh:49
Check if the overlap size is valid for a given discretization method.
Definition: checkoverlapsize.hh:40
Base class for cell center of face specific auxiliary FvGridGeometry classes. Provides a common inter...
Definition: discretization/staggered/fvgridgeometry.hh:42
static constexpr auto faceIdx()
Return an integral constant index for face dofs.
Definition: discretization/staggered/fvgridgeometry.hh:72
const auto & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition: discretization/staggered/fvgridgeometry.hh:97
static constexpr bool isCellCenter()
Returns true if this view if related to cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:56
const ActualGridGeometry & actualGridGeometry() const
Returns the actual gridGeometry we are a restriction of.
Definition: discretization/staggered/fvgridgeometry.hh:103
static constexpr DiscretizationMethod discMethod
Definition: discretization/staggered/fvgridgeometry.hh:50
const ActualGridGeometry * gridGeometry_
Definition: discretization/staggered/fvgridgeometry.hh:107
const auto & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/staggered/fvgridgeometry.hh:85
static constexpr auto cellCenterIdx()
Return an integral constant index for cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:66
const auto & gridView() const
Return the gridView this grid geometry object lives on.
Definition: discretization/staggered/fvgridgeometry.hh:78
typename ActualGridGeometry::LocalView LocalView
Definition: discretization/staggered/fvgridgeometry.hh:51
GridGeometryView(const ActualGridGeometry *actualGridGeometry)
Definition: discretization/staggered/fvgridgeometry.hh:45
const auto & vertexMapper() const
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition: discretization/staggered/fvgridgeometry.hh:91
typename ActualGridGeometry::GridView GridView
export the GridView type and the discretization method
Definition: discretization/staggered/fvgridgeometry.hh:49
static constexpr bool isFace()
Returns true if this view if related to face dofs.
Definition: discretization/staggered/fvgridgeometry.hh:61
Cell center specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/fvgridgeometry.hh:118
std::size_t numDofs() const
The total number of cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:132
static constexpr bool isCellCenter()
Returns true because this view is related to cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:127
Face specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/fvgridgeometry.hh:143
static constexpr bool isFace()
Returns true because this view is related to face dofs.
Definition: discretization/staggered/fvgridgeometry.hh:152
std::size_t numDofs() const
The total number of cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:157
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/staggered/fvgridgeometry.hh:170
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/staggered/fvgridgeometry.hh:181
std::unique_ptr< CellCenterFVGridGeometry< ThisType > > cellCenterFVGridGeometryPtr() const
Returns a pointer the cell center specific auxiliary class. Required for the multi-domain FVAssembler...
Definition: discretization/staggered/fvgridgeometry.hh:395
std::size_t numDofs() const
the total number of dofs
Definition: discretization/staggered/fvgridgeometry.hh:269
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition: discretization/staggered/fvgridgeometry.hh:366
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:407
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Get the sub control volume face indices of an scv by global index.
Definition: discretization/staggered/fvgridgeometry.hh:372
typename T::PublicTraits Traits
export the traits
Definition: discretization/staggered/fvgridgeometry.hh:194
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:256
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition: discretization/staggered/fvgridgeometry.hh:213
std::size_t numFaceDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:275
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition: discretization/staggered/fvgridgeometry.hh:224
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:205
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition: discretization/staggered/fvgridgeometry.hh:230
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition: discretization/staggered/fvgridgeometry.hh:233
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:250
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:207
std::size_t numIntersections() const
The total number of intersections.
Definition: discretization/staggered/fvgridgeometry.hh:263
std::unique_ptr< FaceFVGridGeometry< ThisType > > faceFVGridGeometryPtr() const
Returns a pointer the face specific auxiliary class. Required for the multi-domain FVAssembler's ctor...
Definition: discretization/staggered/fvgridgeometry.hh:401
std::size_t numCellCenterDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:272
const SubControlVolumeFace & scvf(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:382
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:413
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition: discretization/staggered/fvgridgeometry.hh:216
GV GridView
export the grid view type
Definition: discretization/staggered/fvgridgeometry.hh:211
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/staggered/fvgridgeometry.hh:391
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/staggered/fvgridgeometry.hh:419
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition: discretization/staggered/fvgridgeometry.hh:220
Extrusion_t< T > Extrusion
export the type of extrusion
Definition: discretization/staggered/fvgridgeometry.hh:209
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/staggered/fvgridgeometry.hh:244
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:377
typename T::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition: discretization/staggered/fvgridgeometry.hh:203
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition: discretization/staggered/fvgridgeometry.hh:360
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:279
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/staggered/fvgridgeometry.hh:445
typename T::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition: discretization/staggered/fvgridgeometry.hh:468
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition: discretization/staggered/fvgridgeometry.hh:485
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition: discretization/staggered/fvgridgeometry.hh:478
typename T::PublicTraits Traits
export the traits
Definition: discretization/staggered/fvgridgeometry.hh:457
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:598
std::size_t numCellCenterDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:589
typename T::GeometryHelper GeometryHelper
Definition: discretization/staggered/fvgridgeometry.hh:465
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/staggered/fvgridgeometry.hh:607
std::size_t numFaceDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:592
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:623
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition: discretization/staggered/fvgridgeometry.hh:489
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition: discretization/staggered/fvgridgeometry.hh:495
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:595
GV GridView
export the grid view type
Definition: discretization/staggered/fvgridgeometry.hh:476
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:472
const IntersectionMapper & intersectionMapper() const
Return a reference to the intersection mapper.
Definition: discretization/staggered/fvgridgeometry.hh:635
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition: discretization/staggered/fvgridgeometry.hh:498
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:470
std::size_t numIntersections() const
The total number of intersections.
Definition: discretization/staggered/fvgridgeometry.hh:580
std::unique_ptr< FaceFVGridGeometry< ThisType > > faceFVGridGeometryPtr() const
Returns a pointer the face specific auxiliary class. Required for the multi-domain FVAssembler's ctor...
Definition: discretization/staggered/fvgridgeometry.hh:617
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:574
std::unique_ptr< CellCenterFVGridGeometry< ThisType > > cellCenterFVGridGeometryPtr() const
Returns a pointer the cell center specific auxiliary class. Required for the multi-domain FVAssembler...
Definition: discretization/staggered/fvgridgeometry.hh:611
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:629
Extrusion_t< T > Extrusion
export the type of extrusion
Definition: discretization/staggered/fvgridgeometry.hh:474
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition: discretization/staggered/fvgridgeometry.hh:481
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:509
std::size_t numDofs() const
the total number of dofs
Definition: discretization/staggered/fvgridgeometry.hh:586
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/staggered/fvgridgeometry.hh:562
const std::vector< GridIndexType > & neighborVolVarIndices(GridIndexType scvIdx) const
Return the neighbor volVar indices for all scvfs in the scv with index scvIdx.
Definition: discretization/staggered/fvgridgeometry.hh:641
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:568