24#ifndef DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
25#define DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
42template<
class ActualGr
idGeometry>
51 using GridView =
typename ActualGridGeometry::GridView;
57 using LocalView =
typename ActualGridGeometry::LocalView;
67 static constexpr bool isFace() {
return false; }
73 {
return typename ActualGridGeometry::DofTypeIndices::CellCenterIdx{}; }
79 {
return typename ActualGridGeometry::DofTypeIndices::FaceIdx{}; }
122template <
class ActualGr
idGeometry>
128 using ParentType::ParentType;
147template <
class ActualGr
idGeometry>
153 using ParentType::ParentType;
158 static constexpr bool isFace() {
return true; }
173template<
class GridView,
184template<
class GV,
class T>
192 using Element =
typename GV::template Codim<0>::Entity;
194 using IntersectionMapper =
typename T::IntersectionMapper;
195 using GeometryHelper =
typename T::GeometryHelper;
196 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
206 static constexpr int upwindSchemeOrder = T::upwindSchemeOrder;
207 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
208 static constexpr bool cachingEnabled =
true;
225 {
return typename DofTypeIndices::CellCenterIdx{}; }
229 {
return typename DofTypeIndices::FaceIdx{}; }
233 {
return upwindSchemeOrder; }
243 , intersectionMapper_(gridView)
247 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
248 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
262 return scvfs_.size();
268 return numBoundaryScvf_;
275 return intersectionMapper_.numIntersections();
280 {
return numCellCenterDofs() + numFaceDofs(); }
283 {
return this->gridView().size(0); }
286 {
return this->gridView().size(1); }
291 ParentType::update(gridView);
292 updateIntersectionMapper_();
299 ParentType::update(std::move(gridView));
300 updateIntersectionMapper_();
307 return scvs_[scvIdx];
313 return scvfs_[scvfIdx];
319 return scvfIndicesOfScv_[scvIdx];
324 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
329 return scvf(localToGlobalScvfIndex(eIdx, localScvfIdx));
337 {
return connectivityMap_; }
342 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
348 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
365 {
return hasBoundaryScvf_[eIdx]; }
369 void updateIntersectionMapper_()
371 intersectionMapper_.update(this->gridView());
379 scvfIndicesOfScv_.clear();
380 localToGlobalScvfIndices_.clear();
383 std::size_t numScvs = this->gridView().size(0);
384 std::size_t numScvf = 0;
385 for (
const auto& element : elements(this->gridView()))
386 numScvf += element.subEntities(1);
389 scvs_.resize(numScvs);
390 scvfs_.reserve(numScvf);
391 scvfIndicesOfScv_.resize(numScvs);
392 localToGlobalScvfIndices_.resize(numScvs);
393 hasBoundaryScvf_.assign(numScvs,
false);
396 GridIndexType scvfIdx = 0;
397 numBoundaryScvf_ = 0;
398 for (
const auto& element : elements(this->gridView()))
400 auto eIdx = this->elementMapper().index(element);
403 auto numLocalFaces = intersectionMapper_.numFaces(element);
404 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
406 scvs_[eIdx] = SubControlVolume(element.geometry(), eIdx);
409 std::vector<GridIndexType> scvfsIndexSet;
410 scvfsIndexSet.reserve(numLocalFaces);
412 GeometryHelper geometryHelper(element, this->gridView());
414 for (
const auto& intersection : intersections(this->gridView(), element))
416 geometryHelper.updateLocalFace(intersectionMapper_, intersection);
417 const int localFaceIndex = geometryHelper.localFaceIndex();
420 if (intersection.neighbor())
422 auto nIdx = this->elementMapper().index(intersection.outside());
423 scvfs_.emplace_back(intersection,
424 intersection.geometry(),
426 std::vector<GridIndexType>({eIdx, nIdx}),
428 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
429 scvfsIndexSet.push_back(scvfIdx++);
432 else if (intersection.boundary())
434 scvfs_.emplace_back(intersection,
435 intersection.geometry(),
437 std::vector<GridIndexType>({eIdx, this->gridView().size(0) + numBoundaryScvf_++}),
439 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
440 scvfsIndexSet.push_back(scvfIdx++);
442 hasBoundaryScvf_[eIdx] =
true;
447 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
451 connectivityMap_.update(*
this);
455 ConnectivityMap connectivityMap_;
456 IntersectionMapper intersectionMapper_;
458 std::vector<SubControlVolume> scvs_;
459 std::vector<SubControlVolumeFace> scvfs_;
460 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
461 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
462 GridIndexType numBoundaryScvf_;
463 std::vector<bool> hasBoundaryScvf_;
472template<
class GV,
class T>
480 using Element =
typename GV::template Codim<0>::Entity;
482 using IntersectionMapper =
typename T::IntersectionMapper;
483 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
493 static constexpr int upwindSchemeOrder = T::upwindSchemeOrder;
494 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
495 static constexpr bool cachingEnabled =
false;
514 {
return typename DofTypeIndices::CellCenterIdx{}; }
518 {
return typename DofTypeIndices::FaceIdx{}; }
522 {
return upwindSchemeOrder; }
532 , intersectionMapper_(gridView)
536 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
537 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
546 ParentType::update(gridView);
547 updateIntersectionMapper_();
554 ParentType::update(std::move(gridView));
555 updateIntersectionMapper_();
574 return numBoundaryScvf_;
580 return intersectionMapper_.numIntersections();
585 {
return numCellCenterDofs() + numFaceDofs(); }
588 {
return this->gridView().size(0); }
591 {
return this->gridView().size(1); }
594 {
return scvfIndicesOfScv_[scvIdx]; }
598 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
606 {
return connectivityMap_; }
611 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
617 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
635 return intersectionMapper_;
640 {
return neighborVolVarIndices_[scvIdx]; }
644 void updateIntersectionMapper_()
646 intersectionMapper_.update(this->gridView());
652 scvfIndicesOfScv_.clear();
653 neighborVolVarIndices_.clear();
654 localToGlobalScvfIndices_.clear();
656 numScvs_ = numCellCenterDofs();
658 numBoundaryScvf_ = 0;
659 scvfIndicesOfScv_.resize(numScvs_);
660 localToGlobalScvfIndices_.resize(numScvs_);
661 neighborVolVarIndices_.resize(numScvs_);
664 for (
const auto& element : elements(this->gridView()))
666 auto eIdx = this->elementMapper().index(element);
669 auto numLocalFaces = intersectionMapper_.numFaces(element);
670 std::vector<GridIndexType> scvfsIndexSet;
671 scvfsIndexSet.reserve(numLocalFaces);
672 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
674 std::vector<GridIndexType> neighborVolVarIndexSet;
675 neighborVolVarIndexSet.reserve(numLocalFaces);
677 for (
const auto& intersection : intersections(this->gridView(), element))
679 const auto localFaceIndex = intersection.indexInInside();
680 localToGlobalScvfIndices_[eIdx][localFaceIndex] = numScvf_;
681 scvfsIndexSet.push_back(numScvf_++);
683 if (intersection.neighbor())
685 const auto nIdx = this->elementMapper().index(intersection.outside());
686 neighborVolVarIndexSet.emplace_back(nIdx);
689 neighborVolVarIndexSet.emplace_back(numScvs_ + numBoundaryScvf_++);
693 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
694 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
698 connectivityMap_.update(*
this);
702 std::size_t numScvs_;
703 std::size_t numScvf_;
704 std::size_t numBoundaryScvf_;
705 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
706 std::vector<std::vector<GridIndexType>> neighborVolVarIndices_;
709 ConnectivityMap connectivityMap_;
710 IntersectionMapper intersectionMapper_;
713 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
Defines the index types used for grid and local indices.
Check the overlap size for different discretization methods.
Base class for grid geometries.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:251
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:38
Base class for all grid geometries.
Definition: basegridgeometry.hh:61
Check if the overlap size is valid for a given discretization method.
Definition: checkoverlapsize.hh:40
Definition: method.hh:103
Base class for cell center of face specific auxiliary FvGridGeometry classes. Provides a common inter...
Definition: discretization/staggered/fvgridgeometry.hh:44
static constexpr auto faceIdx()
Return an integral constant index for face dofs.
Definition: discretization/staggered/fvgridgeometry.hh:78
const auto & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition: discretization/staggered/fvgridgeometry.hh:103
static constexpr bool isCellCenter()
Returns true if this view if related to cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:62
const ActualGridGeometry & actualGridGeometry() const
Returns the actual gridGeometry we are a restriction of.
Definition: discretization/staggered/fvgridgeometry.hh:109
static constexpr DiscretizationMethod discMethod
Definition: discretization/staggered/fvgridgeometry.hh:55
const ActualGridGeometry * gridGeometry_
Definition: discretization/staggered/fvgridgeometry.hh:113
const auto & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/staggered/fvgridgeometry.hh:91
static constexpr auto cellCenterIdx()
Return an integral constant index for cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:72
const auto & gridView() const
Return the gridView this grid geometry object lives on.
Definition: discretization/staggered/fvgridgeometry.hh:84
typename ActualGridGeometry::LocalView LocalView
Definition: discretization/staggered/fvgridgeometry.hh:57
GridGeometryView(const ActualGridGeometry *actualGridGeometry)
Definition: discretization/staggered/fvgridgeometry.hh:47
const auto & vertexMapper() const
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition: discretization/staggered/fvgridgeometry.hh:97
typename ActualGridGeometry::GridView GridView
export the GridView type and the discretization method
Definition: discretization/staggered/fvgridgeometry.hh:51
static constexpr bool isFace()
Returns true if this view if related to face dofs.
Definition: discretization/staggered/fvgridgeometry.hh:67
Cell center specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/fvgridgeometry.hh:124
std::size_t numDofs() const
The total number of cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:138
static constexpr bool isCellCenter()
Returns true because this view is related to cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:133
Face specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/fvgridgeometry.hh:149
static constexpr bool isFace()
Returns true because this view is related to face dofs.
Definition: discretization/staggered/fvgridgeometry.hh:158
std::size_t numDofs() const
The total number of cell centered dofs.
Definition: discretization/staggered/fvgridgeometry.hh:163
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/staggered/fvgridgeometry.hh:176
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/staggered/fvgridgeometry.hh:187
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:340
std::size_t numDofs() const
the total number of dofs
Definition: discretization/staggered/fvgridgeometry.hh:279
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition: discretization/staggered/fvgridgeometry.hh:311
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:352
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:317
typename T::PublicTraits Traits
export the traits
Definition: discretization/staggered/fvgridgeometry.hh:200
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:266
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition: discretization/staggered/fvgridgeometry.hh:221
std::size_t numFaceDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:285
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition: discretization/staggered/fvgridgeometry.hh:232
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:213
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition: discretization/staggered/fvgridgeometry.hh:238
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:289
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition: discretization/staggered/fvgridgeometry.hh:241
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:260
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:215
std::size_t numIntersections() const
The total number of intersections.
Definition: discretization/staggered/fvgridgeometry.hh:273
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:346
std::size_t numCellCenterDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:282
const SubControlVolumeFace & scvf(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:327
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:358
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition: discretization/staggered/fvgridgeometry.hh:224
GV GridView
export the grid view type
Definition: discretization/staggered/fvgridgeometry.hh:219
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/staggered/fvgridgeometry.hh:336
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/staggered/fvgridgeometry.hh:364
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition: discretization/staggered/fvgridgeometry.hh:228
Extrusion_t< T > Extrusion
export the type of extrusion
Definition: discretization/staggered/fvgridgeometry.hh:217
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/staggered/fvgridgeometry.hh:254
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:322
typename T::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition: discretization/staggered/fvgridgeometry.hh:211
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition: discretization/staggered/fvgridgeometry.hh:305
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:297
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition: discretization/staggered/fvgridgeometry.hh:475
typename T::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition: discretization/staggered/fvgridgeometry.hh:500
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition: discretization/staggered/fvgridgeometry.hh:517
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition: discretization/staggered/fvgridgeometry.hh:510
typename T::PublicTraits Traits
export the traits
Definition: discretization/staggered/fvgridgeometry.hh:487
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:544
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:596
std::size_t numCellCenterDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:587
typename T::GeometryHelper GeometryHelper
Definition: discretization/staggered/fvgridgeometry.hh:497
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition: discretization/staggered/fvgridgeometry.hh:605
std::size_t numFaceDofs() const
Definition: discretization/staggered/fvgridgeometry.hh:590
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:621
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition: discretization/staggered/fvgridgeometry.hh:521
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition: discretization/staggered/fvgridgeometry.hh:527
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition: discretization/staggered/fvgridgeometry.hh:593
GV GridView
export the grid view type
Definition: discretization/staggered/fvgridgeometry.hh:508
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:504
const IntersectionMapper & intersectionMapper() const
Return a reference to the intersection mapper.
Definition: discretization/staggered/fvgridgeometry.hh:633
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition: discretization/staggered/fvgridgeometry.hh:530
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/staggered/fvgridgeometry.hh:502
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/staggered/fvgridgeometry.hh:552
std::size_t numIntersections() const
The total number of intersections.
Definition: discretization/staggered/fvgridgeometry.hh:578
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:615
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:572
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:609
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition: discretization/staggered/fvgridgeometry.hh:627
Extrusion_t< T > Extrusion
export the type of extrusion
Definition: discretization/staggered/fvgridgeometry.hh:506
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition: discretization/staggered/fvgridgeometry.hh:513
std::size_t numDofs() const
the total number of dofs
Definition: discretization/staggered/fvgridgeometry.hh:584
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/staggered/fvgridgeometry.hh:560
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:639
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/staggered/fvgridgeometry.hh:566