12#ifndef DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
13#define DUMUX_DISCRETIZATION_STAGGERED_FV_GRID_GEOMETRY
30template<
class ActualGr
idGeometry>
39 using GridView =
typename ActualGridGeometry::GridView;
45 using LocalView =
typename ActualGridGeometry::LocalView;
55 static constexpr bool isFace() {
return false; }
61 {
return typename ActualGridGeometry::DofTypeIndices::CellCenterIdx{}; }
67 {
return typename ActualGridGeometry::DofTypeIndices::FaceIdx{}; }
110template <
class ActualGr
idGeometry>
116 using ParentType::ParentType;
135template <
class ActualGr
idGeometry>
141 using ParentType::ParentType;
146 static constexpr bool isFace() {
return true; }
161template<
class GridView,
172template<
class GV,
class T>
180 using Element =
typename GV::template Codim<0>::Entity;
183 using GeometryHelper =
typename T::GeometryHelper;
184 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
188 using Traits =
typename T::PublicTraits;
192 static constexpr DiscretizationMethod discMethod{};
194 static constexpr int upwindSchemeOrder = T::upwindSchemeOrder;
195 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
196 static constexpr bool cachingEnabled =
true;
199 using LocalView =
typename T::template LocalView<ThisType, true>;
201 using SubControlVolume =
typename T::SubControlVolume;
203 using SubControlVolumeFace =
typename T::SubControlVolumeFace;
209 using DofTypeIndices =
typename T::DofTypeIndices;
212 static constexpr auto cellCenterIdx()
213 {
return typename DofTypeIndices::CellCenterIdx{}; }
216 static constexpr auto faceIdx()
217 {
return typename DofTypeIndices::FaceIdx{}; }
220 static constexpr int upwindStencilOrder()
221 {
return upwindSchemeOrder; }
223 using CellCenterFVGridGeometryType = CellCenterFVGridGeometry<ThisType>;
224 using FaceFVGridGeometryType = FaceFVGridGeometry<ThisType>;
226 using FVGridGeometryTuple = std::tuple< CellCenterFVGridGeometry<ThisType>, FaceFVGridGeometry<ThisType> >;
229 StaggeredFVGridGeometry(
const GridView& gridView,
const std::string& paramGroup =
"")
230 : ParentType(gridView)
231 , intersectionMapper_(gridView)
235 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
236 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
242 std::size_t numScv()
const
248 std::size_t numScvf()
const
250 return scvfs_.size();
254 std::size_t numBoundaryScvf()
const
256 return numBoundaryScvf_;
261 std::size_t numIntersections()
const
263 return intersectionMapper_.numIntersections();
267 std::size_t numDofs()
const
268 {
return numCellCenterDofs() + numFaceDofs(); }
270 std::size_t numCellCenterDofs()
const
271 {
return this->gridView().size(0); }
273 std::size_t numFaceDofs()
const
274 {
return this->gridView().size(1); }
277 void update(
const GridView& gridView)
279 ParentType::update(gridView);
280 updateIntersectionMapper_();
285 void update(GridView&& gridView)
287 ParentType::update(std::move(gridView));
288 updateIntersectionMapper_();
293 const SubControlVolume& scv(GridIndexType scvIdx)
const
295 return scvs_[scvIdx];
299 const SubControlVolumeFace& scvf(GridIndexType scvfIdx)
const
301 return scvfs_[scvfIdx];
305 const std::vector<GridIndexType>& scvfIndicesOfScv(GridIndexType scvIdx)
const
307 return scvfIndicesOfScv_[scvIdx];
310 GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx)
const
312 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
315 const SubControlVolumeFace& scvf(GridIndexType eIdx, LocalIndexType localScvfIdx)
const
317 return scvf(localToGlobalScvfIndex(eIdx, localScvfIdx));
324 const ConnectivityMap &connectivityMap()
const
325 {
return connectivityMap_; }
328 std::unique_ptr<CellCenterFVGridGeometry<ThisType>> cellCenterFVGridGeometryPtr()
const
330 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
334 std::unique_ptr<FaceFVGridGeometry<ThisType>> faceFVGridGeometryPtr()
const
336 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
340 CellCenterFVGridGeometry<ThisType> cellCenterFVGridGeometry()
const
342 return CellCenterFVGridGeometry<ThisType>(
this);
346 FaceFVGridGeometry<ThisType> faceFVGridGeometry()
const
348 return FaceFVGridGeometry<ThisType>(
this);
352 bool hasBoundaryScvf(GridIndexType eIdx)
const
353 {
return hasBoundaryScvf_[eIdx]; }
357 void updateIntersectionMapper_()
359 intersectionMapper_.update(this->gridView());
367 scvfIndicesOfScv_.clear();
368 localToGlobalScvfIndices_.clear();
371 std::size_t numScvs = this->gridView().size(0);
372 std::size_t numScvf = 0;
373 for (
const auto& element : elements(this->gridView()))
374 numScvf +=
element.subEntities(1);
377 scvs_.resize(numScvs);
378 scvfs_.reserve(numScvf);
379 scvfIndicesOfScv_.resize(numScvs);
380 localToGlobalScvfIndices_.resize(numScvs);
381 hasBoundaryScvf_.assign(numScvs,
false);
384 GridIndexType scvfIdx = 0;
385 numBoundaryScvf_ = 0;
386 for (
const auto& element : elements(this->gridView()))
388 auto eIdx = this->elementMapper().index(element);
391 auto numLocalFaces = intersectionMapper_.numFaces(element);
392 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
394 scvs_[eIdx] = SubControlVolume(
element.geometry(), eIdx);
397 std::vector<GridIndexType> scvfsIndexSet;
398 scvfsIndexSet.reserve(numLocalFaces);
400 GeometryHelper geometryHelper(element, this->gridView());
402 for (
const auto& intersection : intersections(this->gridView(), element))
404 geometryHelper.updateLocalFace(intersectionMapper_, intersection);
405 const int localFaceIndex = geometryHelper.localFaceIndex();
408 if (intersection.neighbor())
410 auto nIdx = this->elementMapper().index(intersection.outside());
411 scvfs_.emplace_back(intersection,
412 intersection.geometry(),
414 std::vector<GridIndexType>({eIdx, nIdx}),
416 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
417 scvfsIndexSet.push_back(scvfIdx++);
420 else if (intersection.boundary())
422 scvfs_.emplace_back(intersection,
423 intersection.geometry(),
425 std::vector<GridIndexType>({eIdx, this->gridView().size(0) + numBoundaryScvf_++}),
427 localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx;
428 scvfsIndexSet.push_back(scvfIdx++);
430 hasBoundaryScvf_[eIdx] =
true;
435 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
439 connectivityMap_.update(*
this);
443 ConnectivityMap connectivityMap_;
444 IntersectionMapper intersectionMapper_;
446 std::vector<SubControlVolume> scvs_;
447 std::vector<SubControlVolumeFace> scvfs_;
448 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
449 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
450 GridIndexType numBoundaryScvf_;
451 std::vector<bool> hasBoundaryScvf_;
460template<
class GV,
class T>
464 using ThisType = StaggeredFVGridGeometry<GV, false, T>;
465 using ParentType = BaseGridGeometry<GV, T>;
468 using Element =
typename GV::template Codim<0>::Entity;
470 using IntersectionMapper =
typename T::IntersectionMapper;
471 using ConnectivityMap =
typename T::template ConnectivityMap<ThisType>;
475 using Traits =
typename T::PublicTraits;
478 using DiscretizationMethod = DiscretizationMethods::Staggered;
479 static constexpr DiscretizationMethod discMethod{};
481 static constexpr int upwindSchemeOrder = T::upwindSchemeOrder;
482 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
483 static constexpr bool cachingEnabled =
false;
485 using GeometryHelper =
typename T::GeometryHelper;
488 using LocalView =
typename T::template LocalView<ThisType, false>;
490 using SubControlVolume =
typename T::SubControlVolume;
492 using SubControlVolumeFace =
typename T::SubControlVolumeFace;
498 using DofTypeIndices =
typename T::DofTypeIndices;
501 static constexpr auto cellCenterIdx()
502 {
return typename DofTypeIndices::CellCenterIdx{}; }
505 static constexpr auto faceIdx()
506 {
return typename DofTypeIndices::FaceIdx{}; }
509 static constexpr int upwindStencilOrder()
510 {
return upwindSchemeOrder; }
512 using CellCenterFVGridGeometryType = CellCenterFVGridGeometry<ThisType>;
513 using FaceFVGridGeometryType = FaceFVGridGeometry<ThisType>;
515 using FVGridGeometryTuple = std::tuple< CellCenterFVGridGeometry<ThisType>, FaceFVGridGeometry<ThisType> >;
518 StaggeredFVGridGeometry(
const GridView& gridView,
const std::string& paramGroup =
"")
519 : ParentType(gridView)
520 , intersectionMapper_(gridView)
524 DUNE_THROW(Dune::InvalidStateException,
"The staggered discretization method needs at least an overlap of 1 for parallel computations. "
525 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
532 void update(
const GridView& gridView)
534 ParentType::update(gridView);
535 updateIntersectionMapper_();
540 void update(GridView&& gridView)
542 ParentType::update(std::move(gridView));
543 updateIntersectionMapper_();
548 std::size_t numScv()
const
554 std::size_t numScvf()
const
560 std::size_t numBoundaryScvf()
const
562 return numBoundaryScvf_;
566 std::size_t numIntersections()
const
568 return intersectionMapper_.numIntersections();
572 std::size_t numDofs()
const
573 {
return numCellCenterDofs() + numFaceDofs(); }
575 std::size_t numCellCenterDofs()
const
576 {
return this->gridView().size(0); }
578 std::size_t numFaceDofs()
const
579 {
return this->gridView().size(1); }
581 const std::vector<GridIndexType>& scvfIndicesOfScv(GridIndexType scvIdx)
const
582 {
return scvfIndicesOfScv_[scvIdx]; }
584 GridIndexType localToGlobalScvfIndex(GridIndexType eIdx, LocalIndexType localScvfIdx)
const
586 return localToGlobalScvfIndices_[eIdx][localScvfIdx];
593 const ConnectivityMap &connectivityMap()
const
594 {
return connectivityMap_; }
597 std::unique_ptr<CellCenterFVGridGeometry<ThisType>> cellCenterFVGridGeometryPtr()
const
599 return std::make_unique<CellCenterFVGridGeometry<ThisType>>(
this);
603 std::unique_ptr<FaceFVGridGeometry<ThisType>> faceFVGridGeometryPtr()
const
605 return std::make_unique<FaceFVGridGeometry<ThisType>>(
this);
609 CellCenterFVGridGeometry<ThisType> cellCenterFVGridGeometry()
const
611 return CellCenterFVGridGeometry<ThisType>(
this);
615 FaceFVGridGeometry<ThisType> faceFVGridGeometry()
const
617 return FaceFVGridGeometry<ThisType>(
this);
621 const IntersectionMapper& intersectionMapper()
const
623 return intersectionMapper_;
627 const std::vector<GridIndexType>& neighborVolVarIndices(GridIndexType scvIdx)
const
628 {
return neighborVolVarIndices_[scvIdx]; }
632 void updateIntersectionMapper_()
634 intersectionMapper_.update(this->gridView());
640 scvfIndicesOfScv_.clear();
641 neighborVolVarIndices_.clear();
642 localToGlobalScvfIndices_.clear();
644 numScvs_ = numCellCenterDofs();
646 numBoundaryScvf_ = 0;
647 scvfIndicesOfScv_.resize(numScvs_);
648 localToGlobalScvfIndices_.resize(numScvs_);
649 neighborVolVarIndices_.resize(numScvs_);
652 for (
const auto& element : elements(this->gridView()))
654 auto eIdx = this->elementMapper().index(element);
657 auto numLocalFaces = intersectionMapper_.numFaces(element);
658 std::vector<GridIndexType> scvfsIndexSet;
659 scvfsIndexSet.reserve(numLocalFaces);
660 localToGlobalScvfIndices_[eIdx].resize(numLocalFaces);
662 std::vector<GridIndexType> neighborVolVarIndexSet;
663 neighborVolVarIndexSet.reserve(numLocalFaces);
665 for (
const auto& intersection : intersections(this->gridView(), element))
667 const auto localFaceIndex = intersection.indexInInside();
668 localToGlobalScvfIndices_[eIdx][localFaceIndex] = numScvf_;
669 scvfsIndexSet.push_back(numScvf_++);
671 if (intersection.neighbor())
673 const auto nIdx = this->elementMapper().index(intersection.outside());
674 neighborVolVarIndexSet.emplace_back(nIdx);
677 neighborVolVarIndexSet.emplace_back(numScvs_ + numBoundaryScvf_++);
681 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
682 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
686 connectivityMap_.update(*
this);
690 std::size_t numScvs_;
691 std::size_t numScvf_;
692 std::size_t numBoundaryScvf_;
693 std::vector<std::vector<GridIndexType>> localToGlobalScvfIndices_;
694 std::vector<std::vector<GridIndexType>> neighborVolVarIndices_;
697 ConnectivityMap connectivityMap_;
698 IntersectionMapper intersectionMapper_;
701 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
Base class for grid geometries.
Check the overlap size for different discretization methods.
Base class for all grid geometries.
Definition basegridgeometry.hh:52
Cell center specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition discretization/staggered/fvgridgeometry.hh:112
std::size_t numDofs() const
The total number of cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:126
static constexpr bool isCellCenter()
Returns true because this view is related to cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:121
Traits extracting the public Extrusion type from T Defaults to NoExtrusion if no such type is found.
Definition extrusion.hh:155
Face specific auxiliary FvGridGeometry classes. Required for the Dumux multi-domain framework.
Definition discretization/staggered/fvgridgeometry.hh:137
static constexpr bool isFace()
Returns true because this view is related to face dofs.
Definition discretization/staggered/fvgridgeometry.hh:146
std::size_t numDofs() const
The total number of cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:151
static constexpr auto faceIdx()
Return an integral constant index for face dofs.
Definition discretization/staggered/fvgridgeometry.hh:66
DiscretizationMethods::Staggered DiscretizationMethod
export the discretization method this geometry belongs to
Definition discretization/staggered/fvgridgeometry.hh:42
const auto & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition discretization/staggered/fvgridgeometry.hh:91
static constexpr bool isCellCenter()
Returns true if this view if related to cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:50
const ActualGridGeometry & actualGridGeometry() const
Returns the actual gridGeometry we are a restriction of.
Definition discretization/staggered/fvgridgeometry.hh:97
static constexpr DiscretizationMethod discMethod
Definition discretization/staggered/fvgridgeometry.hh:43
const ActualGridGeometry * gridGeometry_
Definition discretization/staggered/fvgridgeometry.hh:101
const auto & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/staggered/fvgridgeometry.hh:79
static constexpr auto cellCenterIdx()
Return an integral constant index for cell centered dofs.
Definition discretization/staggered/fvgridgeometry.hh:60
const auto & gridView() const
Return the gridView this grid geometry object lives on.
Definition discretization/staggered/fvgridgeometry.hh:72
typename ActualGridGeometry::LocalView LocalView
Definition discretization/staggered/fvgridgeometry.hh:45
GridGeometryView(const ActualGridGeometry *actualGridGeometry)
Definition discretization/staggered/fvgridgeometry.hh:35
const auto & vertexMapper() const
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition discretization/staggered/fvgridgeometry.hh:85
typename ActualGridGeometry::GridView GridView
export the GridView type and the discretization method
Definition discretization/staggered/fvgridgeometry.hh:39
static constexpr bool isFace()
Returns true if this view if related to face dofs.
Definition discretization/staggered/fvgridgeometry.hh:55
defines an intersection mapper for mapping of global DOFs assigned to faces which also works for adap...
Definition intersectionmapper.hh:200
Base class for the finite volume geometry vector for staggered models This builds up the sub control ...
Definition discretization/staggered/fvgridgeometry.hh:164
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition extrusion.hh:166
static bool isValid(const GridView &gridView) noexcept
Definition checkoverlapsize.hh:30
typename GridView::IndexSet::IndexType GridIndex
Definition indextraits.hh:27
unsigned int LocalIndex
Definition indextraits.hh:28