12#ifndef DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
13#define DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
30template<
class ActualGr
idGeometry>
39 using GridView =
typename ActualGridGeometry::GridView;
45 using LocalView =
typename ActualGridGeometry::LocalView;
55 static constexpr bool isFace() {
return false; }
61 {
return typename ActualGridGeometry::DofTypeIndices::CellCenterIdx{}; }
67 {
return typename ActualGridGeometry::DofTypeIndices::FaceIdx{}; }
110template <
class ActualGr
idGeometry>
116 using ParentType::ParentType;
135template <
class ActualGr
idGeometry>
141 using ParentType::ParentType;
146 static constexpr bool isFace() {
return true; }
161template<
class GridView,
172template<
class GV,
class T>
180 using Element =
typename GV::template Codim<0>::Entity;
182 using IntersectionMapper =
typename T::IntersectionMapper;
183 using GeometryHelper =
typename T::GeometryHelper;
184 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
194 static constexpr int upwindSchemeOrder = T::upwindSchemeOrder;
195 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
196 static constexpr bool cachingEnabled =
true;
213 {
return typename DofTypeIndices::CellCenterIdx{}; }
217 {
return typename DofTypeIndices::FaceIdx{}; }
221 {
return upwindSchemeOrder; }
231 , intersectionMapper_(gridView)
235 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
236 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
250 return scvfs_.size();
256 return numBoundaryScvf_;
263 return intersectionMapper_.numIntersections();
268 {
return numCellCenterDofs() + numFaceDofs(); }
271 {
return this->gridView().size(0); }
274 {
return this->gridView().size(1); }
279 ParentType::update(gridView);
280 updateIntersectionMapper_();
287 ParentType::update(std::move(gridView));
288 updateIntersectionMapper_();
295 return scvs_[scvIdx];
301 return scvfs_[scvfIdx];
307 return scvfIndicesOfScv_[scvIdx];
312 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
317 return scvf(localToGlobalScvfIndex(eIdx, localScvfIdx));
325 {
return connectivityMap_; }
330 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
336 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
353 {
return hasBoundaryScvf_[eIdx]; }
357 void updateIntersectionMapper_()
359 intersectionMapper_.update(this->gridView());
367 scvfIndicesOfScv_.clear();
368 localToGlobalScvfIndices_.clear();
371 std::size_t numScvs = this->gridView().size(0);
372 std::size_t numScvf = 0;
373 for (
const auto& element : elements(this->gridView()))
374 numScvf += element.subEntities(1);
377 scvs_.resize(numScvs);
378 scvfs_.reserve(numScvf);
379 scvfIndicesOfScv_.resize(numScvs);
380 localToGlobalScvfIndices_.resize(numScvs);
381 hasBoundaryScvf_.assign(numScvs,
false);
384 GridIndexType scvfIdx = 0;
385 numBoundaryScvf_ = 0;
386 for (
const auto& element : elements(this->gridView()))
388 auto eIdx = this->elementMapper().index(element);
391 auto numLocalFaces = intersectionMapper_.numFaces(element);
392 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
394 scvs_[eIdx] = SubControlVolume(element.geometry(), eIdx);
397 std::vector<GridIndexType> scvfsIndexSet;
398 scvfsIndexSet.reserve(numLocalFaces);
400 GeometryHelper geometryHelper(element, this->gridView());
402 for (
const auto& intersection : intersections(this->gridView(), element))
404 geometryHelper.updateLocalFace(intersectionMapper_, intersection);
405 const int localFaceIndex = geometryHelper.localFaceIndex();
408 if (intersection.neighbor())
410 auto nIdx = this->elementMapper().index(intersection.outside());
411 scvfs_.emplace_back(intersection,
412 intersection.geometry(),
414 std::vector<GridIndexType>({eIdx, nIdx}),
416 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
417 scvfsIndexSet.push_back(scvfIdx++);
420 else if (intersection.boundary())
422 scvfs_.emplace_back(intersection,
423 intersection.geometry(),
425 std::vector<GridIndexType>({eIdx, this->gridView().size(0) + numBoundaryScvf_++}),
427 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
428 scvfsIndexSet.push_back(scvfIdx++);
430 hasBoundaryScvf_[eIdx] =
true;
435 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
439 connectivityMap_.update(*
this);
443 ConnectivityMap connectivityMap_;
444 IntersectionMapper intersectionMapper_;
446 std::vector<SubControlVolume> scvs_;
447 std::vector<SubControlVolumeFace> scvfs_;
448 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
449 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
450 GridIndexType numBoundaryScvf_;
451 std::vector<bool> hasBoundaryScvf_;
460template<
class GV,
class T>
468 using Element =
typename GV::template Codim<0>::Entity;
470 using IntersectionMapper =
typename T::IntersectionMapper;
471 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
481 static constexpr int upwindSchemeOrder = T::upwindSchemeOrder;
482 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
483 static constexpr bool cachingEnabled =
false;
502 {
return typename DofTypeIndices::CellCenterIdx{}; }
506 {
return typename DofTypeIndices::FaceIdx{}; }
510 {
return upwindSchemeOrder; }
520 , intersectionMapper_(gridView)
524 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
525 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
534 ParentType::update(gridView);
535 updateIntersectionMapper_();
542 ParentType::update(std::move(gridView));
543 updateIntersectionMapper_();
562 return numBoundaryScvf_;
568 return intersectionMapper_.numIntersections();
573 {
return numCellCenterDofs() + numFaceDofs(); }
576 {
return this->gridView().size(0); }
579 {
return this->gridView().size(1); }
582 {
return scvfIndicesOfScv_[scvIdx]; }
586 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
594 {
return connectivityMap_; }
599 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
605 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
623 return intersectionMapper_;
628 {
return neighborVolVarIndices_[scvIdx]; }
632 void updateIntersectionMapper_()
634 intersectionMapper_.update(this->gridView());
640 scvfIndicesOfScv_.clear();
641 neighborVolVarIndices_.clear();
642 localToGlobalScvfIndices_.clear();
644 numScvs_ = numCellCenterDofs();
646 numBoundaryScvf_ = 0;
647 scvfIndicesOfScv_.resize(numScvs_);
648 localToGlobalScvfIndices_.resize(numScvs_);
649 neighborVolVarIndices_.resize(numScvs_);
652 for (
const auto& element : elements(this->gridView()))
654 auto eIdx = this->elementMapper().index(element);
657 auto numLocalFaces = intersectionMapper_.numFaces(element);
658 std::vector<GridIndexType> scvfsIndexSet;
659 scvfsIndexSet.reserve(numLocalFaces);
660 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
662 std::vector<GridIndexType> neighborVolVarIndexSet;
663 neighborVolVarIndexSet.reserve(numLocalFaces);
665 for (
const auto& intersection : intersections(this->gridView(), element))
667 const auto localFaceIndex = intersection.indexInInside();
668 localToGlobalScvfIndices_[eIdx][localFaceIndex] = numScvf_;
669 scvfsIndexSet.push_back(numScvf_++);
671 if (intersection.neighbor())
673 const auto nIdx = this->elementMapper().index(intersection.outside());
674 neighborVolVarIndexSet.emplace_back(nIdx);
677 neighborVolVarIndexSet.emplace_back(numScvs_ + numBoundaryScvf_++);
681 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
682 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
686 connectivityMap_.update(*
this);
690 std::size_t numScvs_;
691 std::size_t numScvf_;
692 std::size_t numBoundaryScvf_;
693 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
694 std::vector<std::vector<GridIndexType>> neighborVolVarIndices_;
697 ConnectivityMap connectivityMap_;
698 IntersectionMapper intersectionMapper_;
701 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
Base class for grid geometries.
Check the overlap size for different discretization methods.
Base class for all grid geometries.
Definition: basegridgeometry.hh:52
Cell center specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/fvgridgeometry.hh:112
std::size_t numDofs() const
The total number of cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:126
static constexpr bool isCellCenter()
Returns true because this view is related to cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:121
Face specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/fvgridgeometry.hh:137
static constexpr bool isFace()
Returns true because this view is related to face dofs.
Definition: discretization/staggered/fvgridgeometry.hh:146
std::size_t numDofs() const
The total number of cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:151
Base class for cell center of face specific auxiliary FvGridGeometry classes. Provides a common inter...
Definition: discretization/staggered/fvgridgeometry.hh:32
static constexpr auto faceIdx()
Return an integral constant index for face dofs.
Definition: discretization/staggered/fvgridgeometry.hh:66
const auto & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition: discretization/staggered/fvgridgeometry.hh:91
static constexpr bool isCellCenter()
Returns true if this view if related to cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:50
const ActualGridGeometry & actualGridGeometry() const
Returns the actual gridGeometry we are a restriction of.
Definition: discretization/staggered/fvgridgeometry.hh:97
static constexpr DiscretizationMethod discMethod
Definition: discretization/staggered/fvgridgeometry.hh:43
const ActualGridGeometry * gridGeometry_
Definition: discretization/staggered/fvgridgeometry.hh:101
const auto & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/staggered/fvgridgeometry.hh:79
static constexpr auto cellCenterIdx()
Return an integral constant index for cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:60
const auto & gridView() const
Return the gridView this grid geometry object lives on.
Definition: discretization/staggered/fvgridgeometry.hh:72
typename ActualGridGeometry::LocalView LocalView
Definition: discretization/staggered/fvgridgeometry.hh:45
GridGeometryView(const ActualGridGeometry *actualGridGeometry)
Definition: discretization/staggered/fvgridgeometry.hh:35
const auto & vertexMapper() const
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition: discretization/staggered/fvgridgeometry.hh:85
typename ActualGridGeometry::GridView GridView
export the GridView type and the discretization method
Definition: discretization/staggered/fvgridgeometry.hh:39
static constexpr bool isFace()
Returns true if this view if related to face dofs.
Definition: discretization/staggered/fvgridgeometry.hh:55
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/staggered/fvgridgeometry.hh:463
typename T::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition: discretization/staggered/fvgridgeometry.hh:488
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition: discretization/staggered/fvgridgeometry.hh:505
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition: discretization/staggered/fvgridgeometry.hh:498
typename T::PublicTraits Traits
export the traits
Definition: discretization/staggered/fvgridgeometry.hh:475
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:532
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:584
std::size_t numCellCenterDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:575
typename T::GeometryHelper GeometryHelper
Definition: discretization/staggered/fvgridgeometry.hh:485
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/staggered/fvgridgeometry.hh:593
std::size_t numFaceDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:578
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:609
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition: discretization/staggered/fvgridgeometry.hh:509
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition: discretization/staggered/fvgridgeometry.hh:515
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:581
GV GridView
export the grid view type
Definition: discretization/staggered/fvgridgeometry.hh:496
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:492
const IntersectionMapper & intersectionMapper() const
Return a reference to the intersection mapper.
Definition: discretization/staggered/fvgridgeometry.hh:621
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition: discretization/staggered/fvgridgeometry.hh:518
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:490
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:540
std::size_t numIntersections() const
The total number of intersections.
Definition: discretization/staggered/fvgridgeometry.hh:566
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:603
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:560
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:597
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:615
Extrusion_t< T > Extrusion
export the type of extrusion
Definition: discretization/staggered/fvgridgeometry.hh:494
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition: discretization/staggered/fvgridgeometry.hh:501
std::size_t numDofs() const
the total number of dofs
Definition: discretization/staggered/fvgridgeometry.hh:572
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/staggered/fvgridgeometry.hh:548
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:627
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:554
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/staggered/fvgridgeometry.hh:175
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:328
std::size_t numDofs() const
the total number of dofs
Definition: discretization/staggered/fvgridgeometry.hh:267
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition: discretization/staggered/fvgridgeometry.hh:299
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:340
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:305
typename T::PublicTraits Traits
export the traits
Definition: discretization/staggered/fvgridgeometry.hh:188
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:254
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition: discretization/staggered/fvgridgeometry.hh:209
std::size_t numFaceDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:273
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition: discretization/staggered/fvgridgeometry.hh:220
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:201
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition: discretization/staggered/fvgridgeometry.hh:226
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:277
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition: discretization/staggered/fvgridgeometry.hh:229
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:248
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:203
std::size_t numIntersections() const
The total number of intersections.
Definition: discretization/staggered/fvgridgeometry.hh:261
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:334
std::size_t numCellCenterDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:270
const SubControlVolumeFace & scvf(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:315
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:346
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition: discretization/staggered/fvgridgeometry.hh:212
GV GridView
export the grid view type
Definition: discretization/staggered/fvgridgeometry.hh:207
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/staggered/fvgridgeometry.hh:324
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/staggered/fvgridgeometry.hh:352
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition: discretization/staggered/fvgridgeometry.hh:216
Extrusion_t< T > Extrusion
export the type of extrusion
Definition: discretization/staggered/fvgridgeometry.hh:205
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/staggered/fvgridgeometry.hh:242
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:310
typename T::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition: discretization/staggered/fvgridgeometry.hh:199
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition: discretization/staggered/fvgridgeometry.hh:293
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:285
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/staggered/fvgridgeometry.hh:164
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:166
Check if the overlap size is valid for a given discretization method.
Definition: checkoverlapsize.hh:28
Definition: method.hh:114
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:26