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{}; }
115template <
class ActualGr
idGeometry>
121 using ParentType::ParentType;
140template <
class ActualGr
idGeometry>
146 using ParentType::ParentType;
151 static constexpr bool isFace() {
return true; }
166template<
class GridView,
177template<
class GV,
class Traits>
185 using Element =
typename GV::template Codim<0>::Entity;
187 using IntersectionMapper =
typename Traits::IntersectionMapper;
188 using GeometryHelper =
typename Traits::GeometryHelper;
189 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
210 {
return typename DofTypeIndices::CellCenterIdx{}; }
214 {
return typename DofTypeIndices::FaceIdx{}; }
232 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
233 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
245 return scvfs_.size();
251 return numBoundaryScvf_;
258 return intersectionMapper_.numIntersections();
266 {
return this->
gridView().size(0); }
269 {
return this->
gridView().size(1); }
277 scvfIndicesOfScv_.clear();
278 intersectionMapper_.update();
281 std::size_t numScvs = this->
gridView().size(0);
287 scvs_.resize(numScvs);
289 scvfIndicesOfScv_.resize(numScvs);
290 localToGlobalScvfIndices_.resize(numScvs);
291 hasBoundaryScvf_.resize(numScvs,
false);
294 GridIndexType scvfIdx = 0;
295 numBoundaryScvf_ = 0;
301 auto numLocalFaces = intersectionMapper_.numFaces(
element);
302 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
307 std::vector<GridIndexType> scvfsIndexSet;
308 scvfsIndexSet.reserve(numLocalFaces);
312 for (
const auto& intersection : intersections(this->
gridView(),
element))
314 geometryHelper.updateLocalFace(intersectionMapper_, intersection);
315 const int localFaceIndex = geometryHelper.localFaceIndex();
318 if (intersection.neighbor())
320 auto nIdx = this->
elementMapper().index(intersection.outside());
321 scvfs_.emplace_back(intersection,
322 intersection.geometry(),
324 std::vector<GridIndexType>({eIdx, nIdx}),
326 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
327 scvfsIndexSet.push_back(scvfIdx++);
330 else if (intersection.boundary())
332 scvfs_.emplace_back(intersection,
333 intersection.geometry(),
335 std::vector<GridIndexType>({eIdx, this->gridView().size(0) + numBoundaryScvf_++}),
337 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
338 scvfsIndexSet.push_back(scvfIdx++);
340 hasBoundaryScvf_[eIdx] =
true;
345 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
349 connectivityMap_.update(*
this);
355 return scvs_[scvIdx];
361 return scvfs_[scvfIdx];
367 return scvfIndicesOfScv_[scvIdx];
372 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
385 {
return connectivityMap_; }
390 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
396 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
413 {
return hasBoundaryScvf_[eIdx]; }
418 ConnectivityMap connectivityMap_;
421 std::vector<SubControlVolume> scvs_;
422 std::vector<SubControlVolumeFace> scvfs_;
423 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
424 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
425 GridIndexType numBoundaryScvf_;
426 std::vector<bool> hasBoundaryScvf_;
435template<
class GV,
class Traits>
443 using Element =
typename GV::template Codim<0>::Entity;
445 using IntersectionMapper =
typename Traits::IntersectionMapper;
446 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
469 {
return typename DofTypeIndices::CellCenterIdx{}; }
473 {
return typename DofTypeIndices::FaceIdx{}; }
491 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
492 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
499 scvfIndicesOfScv_.clear();
500 intersectionMapper_.update();
501 neighborVolVarIndices_.clear();
505 numBoundaryScvf_ = 0;
506 scvfIndicesOfScv_.resize(numScvs_);
507 localToGlobalScvfIndices_.resize(numScvs_);
508 neighborVolVarIndices_.resize(numScvs_);
516 auto numLocalFaces = intersectionMapper_.numFaces(
element);
517 std::vector<GridIndexType> scvfsIndexSet;
518 scvfsIndexSet.reserve(numLocalFaces);
519 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
521 std::vector<GridIndexType> neighborVolVarIndexSet;
522 neighborVolVarIndexSet.reserve(numLocalFaces);
524 for (
const auto& intersection : intersections(this->
gridView(),
element))
526 const auto localFaceIndex = intersection.indexInInside();
527 localToGlobalScvfIndices_[eIdx][localFaceIndex] = numScvf_;
528 scvfsIndexSet.push_back(numScvf_++);
530 if (intersection.neighbor())
532 const auto nIdx = this->
elementMapper().index(intersection.outside());
533 neighborVolVarIndexSet.emplace_back(nIdx);
536 neighborVolVarIndexSet.emplace_back(numScvs_ + numBoundaryScvf_++);
540 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
541 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
545 connectivityMap_.update(*
this);
563 return numBoundaryScvf_;
569 return intersectionMapper_.numIntersections();
577 {
return this->
gridView().size(0); }
580 {
return this->
gridView().size(1); }
583 {
return scvfIndicesOfScv_[scvIdx]; }
587 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
595 {
return connectivityMap_; }
600 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
606 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
624 return intersectionMapper_;
629 {
return neighborVolVarIndices_[scvIdx]; }
634 std::size_t numScvs_;
635 std::size_t numScvf_;
636 std::size_t numBoundaryScvf_;
637 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
638 std::vector<std::vector<GridIndexType>> neighborVolVarIndices_;
641 ConnectivityMap connectivityMap_;
645 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.
Base class for grid geometries.
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
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
Element element(GridIndexType eIdx) const
Get an element from a global element index.
Definition basegridgeometry.hh:163
const GridView & gridView() const
Return the gridView this grid geometry object lives on.
Definition basegridgeometry.hh:107
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:102
static constexpr DiscretizationMethod discMethod
Definition discretization/staggered/fvgridgeometry.hh:49
const ActualGridGeometry * gridGeometry_
Definition discretization/staggered/fvgridgeometry.hh:106
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
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:117
std::size_t numDofs() const
The total number of cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:131
static constexpr bool isCellCenter()
Returns true because this view is related to cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:126
Face specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition discretization/staggered/fvgridgeometry.hh:142
static constexpr bool isFace()
Returns true because this view is related to face dofs.
Definition discretization/staggered/fvgridgeometry.hh:151
std::size_t numDofs() const
The total number of cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:156
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition discretization/staggered/fvgridgeometry.hh:169
const SubControlVolumeFace & scvf(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:375
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:400
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:388
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:202
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition discretization/staggered/fvgridgeometry.hh:213
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:370
static constexpr int upwindSchemeOrder
Definition discretization/staggered/fvgridgeometry.hh:194
std::size_t numCellCenterDofs() const
Definition discretization/staggered/fvgridgeometry.hh:265
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:272
GV GridView
export the grid view type
Definition discretization/staggered/fvgridgeometry.hh:204
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition discretization/staggered/fvgridgeometry.hh:412
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:384
typename Traits::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/staggered/fvgridgeometry.hh:198
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:365
typename Traits::DofTypeIndices DofTypeIndices
export the dof type indices
Definition discretization/staggered/fvgridgeometry.hh:206
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:394
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition discretization/staggered/fvgridgeometry.hh:226
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:243
static constexpr bool useHigherOrder
Definition discretization/staggered/fvgridgeometry.hh:195
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition discretization/staggered/fvgridgeometry.hh:217
std::size_t numDofs() const
the total number of dofs
Definition discretization/staggered/fvgridgeometry.hh:262
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition discretization/staggered/fvgridgeometry.hh:223
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:249
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition discretization/staggered/fvgridgeometry.hh:353
FaceFVGridGeometry< ThisType > FaceFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:221
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/staggered/fvgridgeometry.hh:237
std::size_t numFaceDofs() const
Definition discretization/staggered/fvgridgeometry.hh:268
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:200
std::size_t numIntersections() const
The total number of intersections.
Definition discretization/staggered/fvgridgeometry.hh:256
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition discretization/staggered/fvgridgeometry.hh:359
static constexpr DiscretizationMethod discMethod
export discretization method
Definition discretization/staggered/fvgridgeometry.hh:193
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:406
CellCenterFVGridGeometry< ThisType > CellCenterFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:220
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition discretization/staggered/fvgridgeometry.hh:209
const IntersectionMapper & intersectionMapper() const
Return a reference to the intersection mapper.
Definition discretization/staggered/fvgridgeometry.hh:622
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/staggered/fvgridgeometry.hh:549
static constexpr DiscretizationMethod discMethod
export discretization method
Definition discretization/staggered/fvgridgeometry.hh:450
typename Traits::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/staggered/fvgridgeometry.hh:457
static constexpr int upwindStencilOrder()
The order of the stencil built.
Definition discretization/staggered/fvgridgeometry.hh:476
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:461
typename Traits::GeometryHelper GeometryHelper
Definition discretization/staggered/fvgridgeometry.hh:454
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:594
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:561
GV GridView
export the grid view type
Definition discretization/staggered/fvgridgeometry.hh:463
CellCenterFVGridGeometry< ThisType > CellCenterFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:479
static constexpr int upwindSchemeOrder
Definition discretization/staggered/fvgridgeometry.hh:451
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/staggered/fvgridgeometry.hh:555
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition discretization/staggered/fvgridgeometry.hh:496
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:604
FaceFVGridGeometry< ThisType > FaceFVGridGeometryType
Definition discretization/staggered/fvgridgeometry.hh:480
CellCenterFVGridGeometry< ThisType > cellCenterFVGridGeometry() const
Return a copy of the cell center specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:610
std::size_t numFaceDofs() const
Definition discretization/staggered/fvgridgeometry.hh:579
static constexpr auto cellCenterIdx()
return a integral constant for cell center dofs
Definition discretization/staggered/fvgridgeometry.hh:468
GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx) const
Definition discretization/staggered/fvgridgeometry.hh:585
static constexpr bool useHigherOrder
Definition discretization/staggered/fvgridgeometry.hh:452
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition discretization/staggered/fvgridgeometry.hh:582
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:598
FaceFVGridGeometry< ThisType > faceFVGridGeometry() const
Return a copy of the face specific auxiliary class.
Definition discretization/staggered/fvgridgeometry.hh:616
std::tuple< CellCenterFVGridGeometry< ThisType >, FaceFVGridGeometry< ThisType > > FVGridGeometryTuple
Definition discretization/staggered/fvgridgeometry.hh:482
std::size_t numIntersections() const
The total number of intersections.
Definition discretization/staggered/fvgridgeometry.hh:567
std::size_t numDofs() const
the total number of dofs
Definition discretization/staggered/fvgridgeometry.hh:573
StaggeredFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition discretization/staggered/fvgridgeometry.hh:485
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition discretization/staggered/fvgridgeometry.hh:459
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:628
typename Traits::DofTypeIndices DofTypeIndices
export the dof type indices
Definition discretization/staggered/fvgridgeometry.hh:465
static constexpr auto faceIdx()
return a integral constant for face dofs
Definition discretization/staggered/fvgridgeometry.hh:472
std::size_t numCellCenterDofs() const
Definition discretization/staggered/fvgridgeometry.hh:576