24#ifndef DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
25#define DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
43template<
class ActualGr
idGeometry>
52 using GridView =
typename ActualGridGeometry::GridView;
58 using LocalView =
typename ActualGridGeometry::LocalView;
68 static constexpr bool isFace() {
return false; }
74 {
return typename ActualGridGeometry::DofTypeIndices::CellCenterIdx{}; }
80 {
return typename ActualGridGeometry::DofTypeIndices::FaceIdx{}; }
123template <
class ActualGr
idGeometry>
129 using ParentType::ParentType;
148template <
class ActualGr
idGeometry>
154 using ParentType::ParentType;
159 static constexpr bool isFace() {
return true; }
174template<
class GridView,
185template<
class GV,
class T>
193 using Element =
typename GV::template Codim<0>::Entity;
195 using IntersectionMapper =
typename T::IntersectionMapper;
196 using GeometryHelper =
typename T::GeometryHelper;
197 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
226 {
return typename DofTypeIndices::CellCenterIdx{}; }
230 {
return typename DofTypeIndices::FaceIdx{}; }
248 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
249 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
263 return scvfs_.size();
269 return numBoundaryScvf_;
276 return intersectionMapper_.numIntersections();
284 {
return this->
gridView().size(0); }
287 {
return this->
gridView().size(1); }
290 [[deprecated(
"Use update(gridView) instead! Will be removed after release 3.5.")]]
294 updateIntersectionMapper_();
302 updateIntersectionMapper_();
310 updateIntersectionMapper_();
317 return scvs_[scvIdx];
323 return scvfs_[scvfIdx];
329 return scvfIndicesOfScv_[scvIdx];
334 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
347 {
return connectivityMap_; }
352 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
358 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
375 {
return hasBoundaryScvf_[eIdx]; }
379 void updateIntersectionMapper_()
381 if constexpr (Deprecated::hasUpdateGridView<IntersectionMapper, GridView>())
382 intersectionMapper_.update(this->gridView());
384 Deprecated::update(intersectionMapper_);
392 scvfIndicesOfScv_.clear();
393 localToGlobalScvfIndices_.clear();
396 std::size_t numScvs = this->gridView().size(0);
397 std::size_t numScvf = 0;
398 for (
const auto& element : elements(this->gridView()))
399 numScvf += element.subEntities(1);
402 scvs_.resize(numScvs);
403 scvfs_.reserve(numScvf);
404 scvfIndicesOfScv_.resize(numScvs);
405 localToGlobalScvfIndices_.resize(numScvs);
406 hasBoundaryScvf_.assign(numScvs,
false);
409 GridIndexType scvfIdx = 0;
410 numBoundaryScvf_ = 0;
411 for (
const auto& element : elements(this->gridView()))
413 auto eIdx = this->elementMapper().index(element);
416 auto numLocalFaces = intersectionMapper_.numFaces(element);
417 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
419 scvs_[eIdx] = SubControlVolume(element.geometry(), eIdx);
422 std::vector<GridIndexType> scvfsIndexSet;
423 scvfsIndexSet.reserve(numLocalFaces);
425 GeometryHelper geometryHelper(element, this->gridView());
427 for (
const auto& intersection : intersections(this->gridView(), element))
429 geometryHelper.updateLocalFace(intersectionMapper_, intersection);
430 const int localFaceIndex = geometryHelper.localFaceIndex();
433 if (intersection.neighbor())
435 auto nIdx = this->elementMapper().index(intersection.outside());
436 scvfs_.emplace_back(intersection,
437 intersection.geometry(),
439 std::vector<GridIndexType>({eIdx, nIdx}),
441 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
442 scvfsIndexSet.push_back(scvfIdx++);
445 else if (intersection.boundary())
447 scvfs_.emplace_back(intersection,
448 intersection.geometry(),
450 std::vector<GridIndexType>({eIdx, this->gridView().size(0) + numBoundaryScvf_++}),
452 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
453 scvfsIndexSet.push_back(scvfIdx++);
455 hasBoundaryScvf_[eIdx] =
true;
460 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
464 connectivityMap_.update(*
this);
468 ConnectivityMap connectivityMap_;
469 IntersectionMapper intersectionMapper_;
471 std::vector<SubControlVolume> scvs_;
472 std::vector<SubControlVolumeFace> scvfs_;
473 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
474 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
475 GridIndexType numBoundaryScvf_;
476 std::vector<bool> hasBoundaryScvf_;
485template<
class GV,
class T>
493 using Element =
typename GV::template Codim<0>::Entity;
495 using IntersectionMapper =
typename T::IntersectionMapper;
496 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
527 {
return typename DofTypeIndices::CellCenterIdx{}; }
531 {
return typename DofTypeIndices::FaceIdx{}; }
549 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
550 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
556 [[deprecated(
"Use update(gridView) instead! Will be removed after release 3.5.")]]
560 updateIntersectionMapper_();
568 updateIntersectionMapper_();
576 updateIntersectionMapper_();
595 return numBoundaryScvf_;
601 return intersectionMapper_.numIntersections();
609 {
return this->
gridView().size(0); }
612 {
return this->
gridView().size(1); }
615 {
return scvfIndicesOfScv_[scvIdx]; }
619 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
627 {
return connectivityMap_; }
632 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
638 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
656 return intersectionMapper_;
661 {
return neighborVolVarIndices_[scvIdx]; }
665 void updateIntersectionMapper_()
667 if constexpr (Deprecated::hasUpdateGridView<IntersectionMapper, GridView>())
668 intersectionMapper_.update(this->gridView());
670 Deprecated::update(intersectionMapper_);
676 scvfIndicesOfScv_.clear();
677 neighborVolVarIndices_.clear();
678 localToGlobalScvfIndices_.clear();
680 numScvs_ = numCellCenterDofs();
682 numBoundaryScvf_ = 0;
683 scvfIndicesOfScv_.resize(numScvs_);
684 localToGlobalScvfIndices_.resize(numScvs_);
685 neighborVolVarIndices_.resize(numScvs_);
688 for (
const auto& element : elements(this->gridView()))
690 auto eIdx = this->elementMapper().index(element);
693 auto numLocalFaces = intersectionMapper_.numFaces(element);
694 std::vector<GridIndexType> scvfsIndexSet;
695 scvfsIndexSet.reserve(numLocalFaces);
696 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
698 std::vector<GridIndexType> neighborVolVarIndexSet;
699 neighborVolVarIndexSet.reserve(numLocalFaces);
701 for (
const auto& intersection : intersections(this->gridView(), element))
703 const auto localFaceIndex = intersection.indexInInside();
704 localToGlobalScvfIndices_[eIdx][localFaceIndex] = numScvf_;
705 scvfsIndexSet.push_back(numScvf_++);
707 if (intersection.neighbor())
709 const auto nIdx = this->elementMapper().index(intersection.outside());
710 neighborVolVarIndexSet.emplace_back(nIdx);
713 neighborVolVarIndexSet.emplace_back(numScvs_ + numBoundaryScvf_++);
717 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
718 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
722 connectivityMap_.update(*
this);
726 std::size_t numScvs_;
727 std::size_t numScvf_;
728 std::size_t numBoundaryScvf_;
729 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
730 std::vector<std::vector<GridIndexType>> neighborVolVarIndices_;
733 ConnectivityMap connectivityMap_;
734 IntersectionMapper intersectionMapper_;
737 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
Defines the index types used for grid and local indices.
The available discretization methods in Dumux.
Helper classes to compute the integration elements.
Check the overlap size for different discretization methods.
Base class for grid geometries.
BaseGridGeometry(const GridView &gridView)
Definition basegridgeometry.hh:79
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition extrusion.hh:177
typename GridView::IndexSet::IndexType GridIndex
Definition indextraits.hh:39
unsigned int LocalIndex
Definition indextraits.hh:40
const GridView & gridView() const
Definition basegridgeometry.hh:120
void update()
Definition basegridgeometry.hh:94
static bool isValid(const GridView &gridView) noexcept
Definition checkoverlapsize.hh:42
static constexpr auto faceIdx()
Return an integral constant index for face dofs.
Definition discretization/staggered/fvgridgeometry.hh:79
DiscretizationMethods::Staggered DiscretizationMethod
export the discretization method this geometry belongs to
Definition discretization/staggered/fvgridgeometry.hh:55
const auto & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition discretization/staggered/fvgridgeometry.hh:104
static constexpr bool isCellCenter()
Returns true if this view if related to cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:63
const ActualGridGeometry & actualGridGeometry() const
Returns the actual gridGeometry we are a restriction of.
Definition discretization/staggered/fvgridgeometry.hh:110
static constexpr DiscretizationMethod discMethod
Definition discretization/staggered/fvgridgeometry.hh:56
const ActualGridGeometry * gridGeometry_
Definition discretization/staggered/fvgridgeometry.hh:114
const auto & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:92
static constexpr auto cellCenterIdx()
Return an integral constant index for cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:73
const auto & gridView() const
Return the gridView this grid geometry object lives on.
Definition discretization/staggered/fvgridgeometry.hh:85
typename ActualGridGeometry::LocalView LocalView
Definition discretization/staggered/fvgridgeometry.hh:58
GridGeometryView(const ActualGridGeometry *actualGridGeometry)
Definition discretization/staggered/fvgridgeometry.hh:48
const auto & vertexMapper() const
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition discretization/staggered/fvgridgeometry.hh:98
typename ActualGridGeometry::GridView GridView
export the GridView type and the discretization method
Definition discretization/staggered/fvgridgeometry.hh:52
static constexpr bool isFace()
Returns true if this view if related to face dofs.
Definition discretization/staggered/fvgridgeometry.hh:68
Cell center specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition discretization/staggered/fvgridgeometry.hh:125
std::size_t numDofs() const
The total number of cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:139
static constexpr bool isCellCenter()
Returns true because this view is related to cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:134
Face specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition discretization/staggered/fvgridgeometry.hh:150
static constexpr bool isFace()
Returns true because this view is related to face dofs.
Definition discretization/staggered/fvgridgeometry.hh:159
std::size_t numDofs() const
The total number of cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:164
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition discretization/staggered/fvgridgeometry.hh:177
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:350
std::size_t numDofs() const
the total number of dofs
Definition discretization/staggered/fvgridgeometry.hh:280
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition discretization/staggered/fvgridgeometry.hh:321
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:362
static constexpr int upwindSchemeOrder
Definition discretization/staggered/fvgridgeometry.hh:207
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:327
typename T::PublicTraits Traits
export the traits
Definition discretization/staggered/fvgridgeometry.hh:201
DiscretizationMethods::Staggered DiscretizationMethod
export the discretization method this geometry belongs to
Definition discretization/staggered/fvgridgeometry.hh:204
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:267
static constexpr bool cachingEnabled
Definition discretization/staggered/fvgridgeometry.hh:209
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition discretization/staggered/fvgridgeometry.hh:222
std::size_t numFaceDofs() const
Definition discretization/staggered/fvgridgeometry.hh:286
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition discretization/staggered/fvgridgeometry.hh:233
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:214
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition discretization/staggered/fvgridgeometry.hh:239
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:299
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition discretization/staggered/fvgridgeometry.hh:242
static constexpr bool useHigherOrder
Definition discretization/staggered/fvgridgeometry.hh:208
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:261
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:216
std::size_t numIntersections() const
The total number of intersections.
Definition discretization/staggered/fvgridgeometry.hh:274
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:356
std::size_t numCellCenterDofs() const
Definition discretization/staggered/fvgridgeometry.hh:283
const SubControlVolumeFace & scvf(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:337
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:368
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition discretization/staggered/fvgridgeometry.hh:225
CellCenterFVGridGeometry< ThisType > CellCenterFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:236
static constexpr DiscretizationMethod discMethod
Definition discretization/staggered/fvgridgeometry.hh:205
FaceFVGridGeometry< ThisType > FaceFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:237
GV GridView
export the grid view type
Definition discretization/staggered/fvgridgeometry.hh:220
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:346
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition discretization/staggered/fvgridgeometry.hh:374
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition discretization/staggered/fvgridgeometry.hh:229
Extrusion_t< T > Extrusion
export the type of extrusion
Definition discretization/staggered/fvgridgeometry.hh:218
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/staggered/fvgridgeometry.hh:255
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:332
typename T::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/staggered/fvgridgeometry.hh:212
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition discretization/staggered/fvgridgeometry.hh:315
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:307
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:291
FaceFVGridGeometry< ThisType > FaceFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:538
typename T::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/staggered/fvgridgeometry.hh:513
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition discretization/staggered/fvgridgeometry.hh:530
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition discretization/staggered/fvgridgeometry.hh:523
typename T::PublicTraits Traits
export the traits
Definition discretization/staggered/fvgridgeometry.hh:500
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:565
CellCenterFVGridGeometry< ThisType > CellCenterFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:537
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:617
static constexpr int upwindSchemeOrder
Definition discretization/staggered/fvgridgeometry.hh:506
std::size_t numCellCenterDofs() const
Definition discretization/staggered/fvgridgeometry.hh:608
typename T::GeometryHelper GeometryHelper
Definition discretization/staggered/fvgridgeometry.hh:510
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:626
std::size_t numFaceDofs() const
Definition discretization/staggered/fvgridgeometry.hh:611
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:642
DiscretizationMethods::Staggered DiscretizationMethod
export the discretization method this geometry belongs to
Definition discretization/staggered/fvgridgeometry.hh:503
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition discretization/staggered/fvgridgeometry.hh:534
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition discretization/staggered/fvgridgeometry.hh:540
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition discretization/staggered/fvgridgeometry.hh:614
static constexpr DiscretizationMethod discMethod
Definition discretization/staggered/fvgridgeometry.hh:504
GV GridView
export the grid view type
Definition discretization/staggered/fvgridgeometry.hh:521
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:517
const IntersectionMapper & intersectionMapper() const
Return a reference to the intersection mapper.
Definition discretization/staggered/fvgridgeometry.hh:654
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition discretization/staggered/fvgridgeometry.hh:543
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:515
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:573
std::size_t numIntersections() const
The total number of intersections.
Definition discretization/staggered/fvgridgeometry.hh:599
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:636
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:593
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:630
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:648
Extrusion_t< T > Extrusion
export the type of extrusion
Definition discretization/staggered/fvgridgeometry.hh:519
static constexpr bool useHigherOrder
Definition discretization/staggered/fvgridgeometry.hh:507
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition discretization/staggered/fvgridgeometry.hh:526
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:557
std::size_t numDofs() const
the total number of dofs
Definition discretization/staggered/fvgridgeometry.hh:605
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/staggered/fvgridgeometry.hh:581
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:660
static constexpr bool cachingEnabled
Definition discretization/staggered/fvgridgeometry.hh:508
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:587