24#ifndef DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
25#define DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
41template<
class ActualGr
idGeometry>
50 using GridView =
typename ActualGridGeometry::GridView;
52 using LocalView =
typename ActualGridGeometry::LocalView;
62 static constexpr bool isFace() {
return false; }
68 {
return typename ActualGridGeometry::DofTypeIndices::CellCenterIdx{}; }
74 {
return typename ActualGridGeometry::DofTypeIndices::FaceIdx{}; }
117template <
class ActualGr
idGeometry>
123 using ParentType::ParentType;
142template <
class ActualGr
idGeometry>
148 using ParentType::ParentType;
153 static constexpr bool isFace() {
return true; }
168template<
class GridView,
179template<
class GV,
class T>
187 using Element =
typename GV::template Codim<0>::Entity;
189 using IntersectionMapper =
typename T::IntersectionMapper;
190 using GeometryHelper =
typename T::GeometryHelper;
191 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
218 {
return typename DofTypeIndices::CellCenterIdx{}; }
222 {
return typename DofTypeIndices::FaceIdx{}; }
240 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
241 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
253 return scvfs_.size();
259 return numBoundaryScvf_;
266 return intersectionMapper_.numIntersections();
274 {
return this->
gridView().size(0); }
277 {
return this->
gridView().size(1); }
285 scvfIndicesOfScv_.clear();
286 if constexpr (Deprecated::hasUpdateGridView<IntersectionMapper, GridView>())
287 intersectionMapper_.update(this->gridView());
289 Deprecated::update(intersectionMapper_);
291 std::size_t numScvs = this->
gridView().size(0);
297 scvs_.resize(numScvs);
299 scvfIndicesOfScv_.resize(numScvs);
300 localToGlobalScvfIndices_.resize(numScvs);
301 hasBoundaryScvf_.resize(numScvs,
false);
304 GridIndexType scvfIdx = 0;
305 numBoundaryScvf_ = 0;
311 auto numLocalFaces = intersectionMapper_.numFaces(
element);
312 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
317 std::vector<GridIndexType> scvfsIndexSet;
318 scvfsIndexSet.reserve(numLocalFaces);
322 for (
const auto& intersection : intersections(this->
gridView(),
element))
324 geometryHelper.updateLocalFace(intersectionMapper_, intersection);
325 const int localFaceIndex = geometryHelper.localFaceIndex();
328 if (intersection.neighbor())
330 auto nIdx = this->
elementMapper().index(intersection.outside());
331 scvfs_.emplace_back(intersection,
332 intersection.geometry(),
334 std::vector<GridIndexType>({eIdx, nIdx}),
336 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
337 scvfsIndexSet.push_back(scvfIdx++);
340 else if (intersection.boundary())
342 scvfs_.emplace_back(intersection,
343 intersection.geometry(),
345 std::vector<GridIndexType>({eIdx, this->gridView().size(0) + numBoundaryScvf_++}),
347 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
348 scvfsIndexSet.push_back(scvfIdx++);
350 hasBoundaryScvf_[eIdx] =
true;
355 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
359 connectivityMap_.update(*
this);
365 return scvs_[scvIdx];
371 return scvfs_[scvfIdx];
377 return scvfIndicesOfScv_[scvIdx];
382 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
395 {
return connectivityMap_; }
400 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
406 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
423 {
return hasBoundaryScvf_[eIdx]; }
428 ConnectivityMap connectivityMap_;
431 std::vector<SubControlVolume> scvs_;
432 std::vector<SubControlVolumeFace> scvfs_;
433 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
434 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
435 GridIndexType numBoundaryScvf_;
436 std::vector<bool> hasBoundaryScvf_;
445template<
class GV,
class T>
453 using Element =
typename GV::template Codim<0>::Entity;
455 using IntersectionMapper =
typename T::IntersectionMapper;
456 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
485 {
return typename DofTypeIndices::CellCenterIdx{}; }
489 {
return typename DofTypeIndices::FaceIdx{}; }
507 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
508 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
515 scvfIndicesOfScv_.clear();
516 if constexpr (Deprecated::hasUpdateGridView<IntersectionMapper, GridView>())
517 intersectionMapper_.update(this->gridView());
519 Deprecated::update(intersectionMapper_);
520 neighborVolVarIndices_.clear();
524 numBoundaryScvf_ = 0;
525 scvfIndicesOfScv_.resize(numScvs_);
526 localToGlobalScvfIndices_.resize(numScvs_);
527 neighborVolVarIndices_.resize(numScvs_);
535 auto numLocalFaces = intersectionMapper_.numFaces(
element);
536 std::vector<GridIndexType> scvfsIndexSet;
537 scvfsIndexSet.reserve(numLocalFaces);
538 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
540 std::vector<GridIndexType> neighborVolVarIndexSet;
541 neighborVolVarIndexSet.reserve(numLocalFaces);
543 for (
const auto& intersection : intersections(this->
gridView(),
element))
545 const auto localFaceIndex = intersection.indexInInside();
546 localToGlobalScvfIndices_[eIdx][localFaceIndex] = numScvf_;
547 scvfsIndexSet.push_back(numScvf_++);
549 if (intersection.neighbor())
551 const auto nIdx = this->
elementMapper().index(intersection.outside());
552 neighborVolVarIndexSet.emplace_back(nIdx);
555 neighborVolVarIndexSet.emplace_back(numScvs_ + numBoundaryScvf_++);
559 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
560 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
564 connectivityMap_.update(*
this);
582 return numBoundaryScvf_;
588 return intersectionMapper_.numIntersections();
596 {
return this->
gridView().size(0); }
599 {
return this->
gridView().size(1); }
602 {
return scvfIndicesOfScv_[scvIdx]; }
606 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
614 {
return connectivityMap_; }
619 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
625 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
643 return intersectionMapper_;
648 {
return neighborVolVarIndices_[scvIdx]; }
653 std::size_t numScvs_;
654 std::size_t numScvf_;
655 std::size_t numBoundaryScvf_;
656 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
657 std::vector<std::vector<GridIndexType>> neighborVolVarIndices_;
660 ConnectivityMap connectivityMap_;
664 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.
Helper classes to compute the integration elements.
Base class for grid geometries.
BaseGridGeometry(const GridView &gridView)
Definition basegridgeometry.hh:78
DiscretizationMethod
The available discretization methods in Dumux.
Definition method.hh:37
@ staggered
Definition method.hh:38
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
defines an intersection mapper for mapping of global DOFs assigned to faces which also works for adap...
Definition intersectionmapper.hh:224
const ElementMapper & elementMapper() const
Definition basegridgeometry.hh:127
Element element(GridIndexType eIdx) const
Definition basegridgeometry.hh:171
const GridView & gridView() const
Definition basegridgeometry.hh:115
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:73
const auto & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition discretization/staggered/fvgridgeometry.hh:98
static constexpr bool isCellCenter()
Returns true if this view if related to cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:57
const ActualGridGeometry & actualGridGeometry() const
Returns the actual gridGeometry we are a restriction of.
Definition discretization/staggered/fvgridgeometry.hh:104
static constexpr DiscretizationMethod discMethod
Definition discretization/staggered/fvgridgeometry.hh:51
const ActualGridGeometry * gridGeometry_
Definition discretization/staggered/fvgridgeometry.hh:108
const auto & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:86
static constexpr auto cellCenterIdx()
Return an integral constant index for cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:67
const auto & gridView() const
Return the gridView this grid geometry object lives on.
Definition discretization/staggered/fvgridgeometry.hh:79
typename ActualGridGeometry::LocalView LocalView
Definition discretization/staggered/fvgridgeometry.hh:52
GridGeometryView(const ActualGridGeometry *actualGridGeometry)
Definition discretization/staggered/fvgridgeometry.hh:46
const auto & vertexMapper() const
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition discretization/staggered/fvgridgeometry.hh:92
typename ActualGridGeometry::GridView GridView
export the GridView type and the discretization method
Definition discretization/staggered/fvgridgeometry.hh:50
static constexpr bool isFace()
Returns true if this view if related to face dofs.
Definition discretization/staggered/fvgridgeometry.hh:62
Cell center specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition discretization/staggered/fvgridgeometry.hh:119
std::size_t numDofs() const
The total number of cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:133
static constexpr bool isCellCenter()
Returns true because this view is related to cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:128
Face specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition discretization/staggered/fvgridgeometry.hh:144
static constexpr bool isFace()
Returns true because this view is related to face dofs.
Definition discretization/staggered/fvgridgeometry.hh:153
std::size_t numDofs() const
The total number of cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:158
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition discretization/staggered/fvgridgeometry.hh:171
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:398
std::size_t numDofs() const
the total number of dofs
Definition discretization/staggered/fvgridgeometry.hh:270
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition discretization/staggered/fvgridgeometry.hh:369
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:410
static constexpr int upwindSchemeOrder
Definition discretization/staggered/fvgridgeometry.hh:199
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:375
typename T::PublicTraits Traits
export the traits
Definition discretization/staggered/fvgridgeometry.hh:195
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:257
static constexpr bool cachingEnabled
Definition discretization/staggered/fvgridgeometry.hh:201
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition discretization/staggered/fvgridgeometry.hh:214
std::size_t numFaceDofs() const
Definition discretization/staggered/fvgridgeometry.hh:276
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition discretization/staggered/fvgridgeometry.hh:225
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:206
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition discretization/staggered/fvgridgeometry.hh:231
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition discretization/staggered/fvgridgeometry.hh:234
static constexpr bool useHigherOrder
Definition discretization/staggered/fvgridgeometry.hh:200
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:251
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:208
std::size_t numIntersections() const
The total number of intersections.
Definition discretization/staggered/fvgridgeometry.hh:264
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:404
std::size_t numCellCenterDofs() const
Definition discretization/staggered/fvgridgeometry.hh:273
const SubControlVolumeFace & scvf(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:385
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:416
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition discretization/staggered/fvgridgeometry.hh:217
CellCenterFVGridGeometry< ThisType > CellCenterFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:228
static constexpr DiscretizationMethod discMethod
export discretization method
Definition discretization/staggered/fvgridgeometry.hh:198
FaceFVGridGeometry< ThisType > FaceFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:229
GV GridView
export the grid view type
Definition discretization/staggered/fvgridgeometry.hh:212
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:394
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition discretization/staggered/fvgridgeometry.hh:422
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition discretization/staggered/fvgridgeometry.hh:221
Extrusion_t< T > Extrusion
export the type of extrusion
Definition discretization/staggered/fvgridgeometry.hh:210
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/staggered/fvgridgeometry.hh:245
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:380
typename T::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/staggered/fvgridgeometry.hh:204
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition discretization/staggered/fvgridgeometry.hh:363
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:280
FaceFVGridGeometry< ThisType > FaceFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:496
typename T::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/staggered/fvgridgeometry.hh:471
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition discretization/staggered/fvgridgeometry.hh:488
typename T::DofTypeIndices DofTypeIndices
export the dof type indices
Definition discretization/staggered/fvgridgeometry.hh:481
typename T::PublicTraits Traits
export the traits
Definition discretization/staggered/fvgridgeometry.hh:460
CellCenterFVGridGeometry< ThisType > CellCenterFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:495
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:604
static constexpr int upwindSchemeOrder
Definition discretization/staggered/fvgridgeometry.hh:464
std::size_t numCellCenterDofs() const
Definition discretization/staggered/fvgridgeometry.hh:595
typename T::GeometryHelper GeometryHelper
Definition discretization/staggered/fvgridgeometry.hh:468
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:613
std::size_t numFaceDofs() const
Definition discretization/staggered/fvgridgeometry.hh:598
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:629
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition discretization/staggered/fvgridgeometry.hh:492
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition discretization/staggered/fvgridgeometry.hh:498
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition discretization/staggered/fvgridgeometry.hh:601
static constexpr DiscretizationMethod discMethod
export discretization method
Definition discretization/staggered/fvgridgeometry.hh:463
GV GridView
export the grid view type
Definition discretization/staggered/fvgridgeometry.hh:479
typename T::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:475
const IntersectionMapper & intersectionMapper() const
Return a reference to the intersection mapper.
Definition discretization/staggered/fvgridgeometry.hh:641
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition discretization/staggered/fvgridgeometry.hh:501
typename T::SubControlVolume SubControlVolume
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:473
std::size_t numIntersections() const
The total number of intersections.
Definition discretization/staggered/fvgridgeometry.hh:586
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:623
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:580
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:617
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:635
Extrusion_t< T > Extrusion
export the type of extrusion
Definition discretization/staggered/fvgridgeometry.hh:477
static constexpr bool useHigherOrder
Definition discretization/staggered/fvgridgeometry.hh:465
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition discretization/staggered/fvgridgeometry.hh:484
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:512
std::size_t numDofs() const
the total number of dofs
Definition discretization/staggered/fvgridgeometry.hh:592
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/staggered/fvgridgeometry.hh:568
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:647
static constexpr bool cachingEnabled
Definition discretization/staggered/fvgridgeometry.hh:466
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:574