24#ifndef DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
25#define DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
39template<
class ActualGr
idGeometry>
48 using GridView =
typename ActualGridGeometry::GridView;
50 using LocalView =
typename ActualGridGeometry::LocalView;
60 static constexpr bool isFace() {
return false; }
66 {
return typename ActualGridGeometry::DofTypeIndices::CellCenterIdx{}; }
72 {
return typename ActualGridGeometry::DofTypeIndices::FaceIdx{}; }
102 [[deprecated(
"Use actualGridGeometry instead")]]
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 Traits>
192 using Element =
typename GV::template Codim<0>::Entity;
194 using IntersectionMapper =
typename Traits::IntersectionMapper;
195 using GeometryHelper =
typename Traits::GeometryHelper;
196 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
217 {
return typename DofTypeIndices::CellCenterIdx{}; }
221 {
return typename DofTypeIndices::FaceIdx{}; }
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();
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);
294 scvs_.resize(numScvs);
296 scvfIndicesOfScv_.resize(numScvs);
297 localToGlobalScvfIndices_.resize(numScvs);
298 hasBoundaryScvf_.resize(numScvs,
false);
301 GridIndexType scvfIdx = 0;
302 numBoundaryScvf_ = 0;
308 auto numLocalFaces = intersectionMapper_.numFaces(
element);
309 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
314 std::vector<GridIndexType> scvfsIndexSet;
315 scvfsIndexSet.reserve(numLocalFaces);
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];
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 Traits>
450 using Element =
typename GV::template Codim<0>::Entity;
452 using IntersectionMapper =
typename Traits::IntersectionMapper;
453 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
476 {
return typename DofTypeIndices::CellCenterIdx{}; }
480 {
return typename DofTypeIndices::FaceIdx{}; }
498 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
499 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
506 scvfIndicesOfScv_.clear();
507 intersectionMapper_.update();
508 neighborVolVarIndices_.clear();
512 numBoundaryScvf_ = 0;
513 scvfIndicesOfScv_.resize(numScvs_);
514 localToGlobalScvfIndices_.resize(numScvs_);
515 neighborVolVarIndices_.resize(numScvs_);
523 auto numLocalFaces = intersectionMapper_.numFaces(
element);
524 std::vector<GridIndexType> scvfsIndexSet;
525 scvfsIndexSet.reserve(numLocalFaces);
526 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
528 std::vector<GridIndexType> neighborVolVarIndexSet;
529 neighborVolVarIndexSet.reserve(numLocalFaces);
533 const auto localFaceIndex = intersection.indexInInside();
534 localToGlobalScvfIndices_[eIdx][localFaceIndex] = numScvf_;
535 scvfsIndexSet.push_back(numScvf_++);
537 if (intersection.neighbor())
539 const auto nIdx = this->
elementMapper().index(intersection.outside());
540 neighborVolVarIndexSet.emplace_back(nIdx);
543 neighborVolVarIndexSet.emplace_back(numScvs_ + numBoundaryScvf_++);
547 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
548 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
552 connectivityMap_.update(*
this);
570 return numBoundaryScvf_;
576 return intersectionMapper_.numIntersections();
584 {
return this->
gridView().size(0); }
587 {
return this->
gridView().size(1); }
590 {
return scvfIndicesOfScv_[scvIdx]; }
594 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
602 {
return connectivityMap_; }
607 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
613 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
631 return intersectionMapper_;
636 {
return neighborVolVarIndices_[scvIdx]; }
641 std::size_t numScvs_;
642 std::size_t numScvf_;
643 std::size_t numBoundaryScvf_;
644 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
645 std::vector<std::vector<GridIndexType>> neighborVolVarIndices_;
648 ConnectivityMap connectivityMap_;
652 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
Defines the index types used for grid and local indices.
Base class for grid geometries.
Check the overlap size for different discretization methods.
The available discretization methods in Dumux.
BaseGridGeometry(const GridView &gridView)
Constructor computes the bouding box of the entire domain, for e.g. setting boundary conditions.
Definition basegridgeometry.hh:77
DiscretizationMethod
The available discretization methods in Dumux.
Definition method.hh:37
@ staggered
Definition method.hh:38
Dune::IteratorRange< typename MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper >::Intersections::const_iterator > intersections(const MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper > &glue)
Range generator to iterate with range-based for loops over all intersections as follows: for (const a...
Definition glue.hh:62
make the local view function available whenever we use the grid geometry
Definition adapt.hh:29
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:185
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition basegridgeometry.hh:119
const GridView & gridView() const
Return the gridView this grid geometry object lives on.
Definition basegridgeometry.hh:107
Element element(const Scv &scv) const
Get an element from a sub-control volume.
Definition basegridgeometry.hh:166
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:71
const auto & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition discretization/staggered/fvgridgeometry.hh:96
static constexpr bool isCellCenter()
Returns true if this view if related to cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:55
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:49
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:84
static constexpr auto cellCenterIdx()
Return an integral constant index for cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:65
const auto & gridView() const
Return the gridView this grid geometry object lives on.
Definition discretization/staggered/fvgridgeometry.hh:77
typename ActualGridGeometry::LocalView LocalView
Definition discretization/staggered/fvgridgeometry.hh:50
GridGeometryView(const ActualGridGeometry *actualGridGeometry)
Definition discretization/staggered/fvgridgeometry.hh:44
const auto & vertexMapper() const
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition discretization/staggered/fvgridgeometry.hh:90
const ActualGridGeometry & actualfvGridGeometry() const
Returns the actual gridGeometry we are a restriction of.
Definition discretization/staggered/fvgridgeometry.hh:103
typename ActualGridGeometry::GridView GridView
export the GridView type and the discretization method
Definition discretization/staggered/fvgridgeometry.hh:48
static constexpr bool isFace()
Returns true if this view if related to face dofs.
Definition discretization/staggered/fvgridgeometry.hh:60
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
const SubControlVolumeFace & scvf(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:382
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:407
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
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:209
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition discretization/staggered/fvgridgeometry.hh:220
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:377
static constexpr int upwindSchemeOrder
Definition discretization/staggered/fvgridgeometry.hh:201
std::size_t numCellCenterDofs() const
Definition discretization/staggered/fvgridgeometry.hh:272
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:279
GV GridView
export the grid view type
Definition discretization/staggered/fvgridgeometry.hh:211
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition discretization/staggered/fvgridgeometry.hh:419
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
typename Traits::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/staggered/fvgridgeometry.hh:205
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 Traits::DofTypeIndices DofTypeIndices
export the dof type indices
Definition discretization/staggered/fvgridgeometry.hh:213
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
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
static constexpr bool useHigherOrder
Definition discretization/staggered/fvgridgeometry.hh:202
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition discretization/staggered/fvgridgeometry.hh:224
std::size_t numDofs() const
the total number of dofs
Definition discretization/staggered/fvgridgeometry.hh:269
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition discretization/staggered/fvgridgeometry.hh:230
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:256
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition discretization/staggered/fvgridgeometry.hh:360
FaceFVGridGeometry< ThisType > FaceFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:228
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/staggered/fvgridgeometry.hh:244
std::size_t numFaceDofs() const
Definition discretization/staggered/fvgridgeometry.hh:275
typename Traits::SubControlVolume SubControlVolume
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
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition discretization/staggered/fvgridgeometry.hh:366
static constexpr DiscretizationMethod discMethod
export discretization method
Definition discretization/staggered/fvgridgeometry.hh:200
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:413
CellCenterFVGridGeometry< ThisType > CellCenterFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:227
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition discretization/staggered/fvgridgeometry.hh:216
const IntersectionMapper & intersectionMapper() const
Return a reference to the intersection mapper.
Definition discretization/staggered/fvgridgeometry.hh:629
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/staggered/fvgridgeometry.hh:556
static constexpr DiscretizationMethod discMethod
export discretization method
Definition discretization/staggered/fvgridgeometry.hh:457
typename Traits::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/staggered/fvgridgeometry.hh:464
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition discretization/staggered/fvgridgeometry.hh:483
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:468
typename Traits::GeometryHelper GeometryHelper
Definition discretization/staggered/fvgridgeometry.hh:461
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:601
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:568
GV GridView
export the grid view type
Definition discretization/staggered/fvgridgeometry.hh:470
CellCenterFVGridGeometry< ThisType > CellCenterFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:486
static constexpr int upwindSchemeOrder
Definition discretization/staggered/fvgridgeometry.hh:458
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:562
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:503
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:611
FaceFVGridGeometry< ThisType > FaceFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:487
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:617
std::size_t numFaceDofs() const
Definition discretization/staggered/fvgridgeometry.hh:586
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition discretization/staggered/fvgridgeometry.hh:475
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:592
static constexpr bool useHigherOrder
Definition discretization/staggered/fvgridgeometry.hh:459
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition discretization/staggered/fvgridgeometry.hh:589
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:605
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:623
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition discretization/staggered/fvgridgeometry.hh:489
std::size_t numIntersections() const
The total number of intersections.
Definition discretization/staggered/fvgridgeometry.hh:574
std::size_t numDofs() const
the total number of dofs
Definition discretization/staggered/fvgridgeometry.hh:580
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition discretization/staggered/fvgridgeometry.hh:492
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:466
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:635
typename Traits::DofTypeIndices DofTypeIndices
export the dof type indices
Definition discretization/staggered/fvgridgeometry.hh:472
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition discretization/staggered/fvgridgeometry.hh:479
std::size_t numCellCenterDofs() const
Definition discretization/staggered/fvgridgeometry.hh:583