26#ifndef DUMUX_DISCRETIZATION_CCTPFA_FV_GRID_GEOMETRY_HH
27#define DUMUX_DISCRETIZATION_CCTPFA_FV_GRID_GEOMETRY_HH
52template<
class Gr
idView,
class MapperTraits = DefaultMapperTraits<Gr
idView>>
59 template<
class Gr
idGeometry>
62 template<
class Gr
idGeometry,
bool enableCache>
69 static constexpr int maxNumScvfNeighbors = int(GridView::dimension)<int(GridView::dimensionworld) ? 8 : 1<<(GridView::dimension-1);
78template<
class GridView,
79 bool enableGridGeometryCache =
false,
89template<
class GV,
class Traits>
95 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
97 using Element =
typename GV::template Codim<0>::Entity;
99 static const int dim = GV::dimension;
100 static const int dimWorld = GV::dimensionworld;
128 : ParentType(std::move(gg))
132 DUNE_THROW(Dune::InvalidStateException,
"The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
133 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
157 return scvfs_.size();
163 return numBoundaryScvf_;
168 {
return this->
gridView().size(0); }
188 return scvs_[scvIdx];
194 return scvfs_[scvfIdx];
201 return scvfs_[flipScvfIndices_[scvfIdx][outsideScvfIdx]];
207 return scvfIndicesOfScv_[scvIdx];
215 {
return connectivityMap_; }
219 {
return hasBoundaryScvf_[eIdx]; }
228 scvfIndicesOfScv_.clear();
229 flipScvfIndices_.clear();
232 std::size_t numScvs = numDofs();
233 std::size_t numScvf = 0;
234 for (
const auto& element : elements(this->gridView()))
235 numScvf += element.subEntities(1);
238 scvs_.resize(numScvs);
239 scvfs_.reserve(numScvf);
240 scvfIndicesOfScv_.resize(numScvs);
241 hasBoundaryScvf_.assign(numScvs,
false);
244 GridIndexType scvfIdx = 0;
245 numBoundaryScvf_ = 0;
246 for (
const auto& element : elements(this->gridView()))
248 const auto eIdx = this->elementMapper().index(element);
249 scvs_[eIdx] = SubControlVolume(element.geometry(), eIdx);
252 std::vector<GridIndexType> scvfsIndexSet;
253 scvfsIndexSet.reserve(element.subEntities(1));
257 using ScvfGridIndexStorage =
typename SubControlVolumeFace::Traits::GridIndexStorage;
258 std::vector<ScvfGridIndexStorage> outsideIndices;
262 outsideIndices.resize(element.subEntities(1));
263 std::for_each(outsideIndices.begin(), outsideIndices.end(), [eIdx] (
auto& nIndices) { nIndices.push_back(eIdx); });
266 for (
const auto& intersection : intersections(this->gridView(), element))
268 if (intersection.neighbor())
270 const auto nIdx = this->elementMapper().index( intersection.outside() );
271 outsideIndices[intersection.indexInInside()].push_back(nIdx);
276 for (
const auto& intersection : intersections(this->gridView(), element))
279 if (intersection.neighbor())
282 if (intersection.boundary())
287 const auto nIdx = this->elementMapper().index(intersection.outside());
288 scvfs_.emplace_back(intersection,
289 intersection.geometry(),
291 ScvfGridIndexStorage({eIdx, nIdx}),
293 scvfsIndexSet.push_back(scvfIdx++);
299 auto indexInInside = intersection.indexInInside();
301 if (outsideIndices[indexInInside].empty())
305 scvfs_.emplace_back(intersection,
306 intersection.geometry(),
308 outsideIndices[indexInInside],
310 scvfsIndexSet.push_back(scvfIdx++);
311 outsideIndices[indexInInside].clear();
316 else if (intersection.boundary())
318 scvfs_.emplace_back(intersection,
319 intersection.geometry(),
321 ScvfGridIndexStorage({eIdx,
static_cast<GridIndexType
>(this->gridView().size(0) + numBoundaryScvf_++)}),
323 scvfsIndexSet.push_back(scvfIdx++);
325 hasBoundaryScvf_[eIdx] =
true;
330 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
334 if (dim < dimWorld || this->isPeriodic())
336 flipScvfIndices_.resize(scvfs_.size());
337 for (
auto&& scvf : scvfs_)
342 flipScvfIndices_[scvf.index()].resize(scvf.numOutsideScvs());
343 const auto insideScvIdx = scvf.insideScvIdx();
345 for (
unsigned int i = 0; i < scvf.numOutsideScvs(); ++i)
346 flipScvfIndices_[scvf.index()][i] = findFlippedScvfIndex_(insideScvIdx, scvf.outsideScvIdx(i));
351 connectivityMap_.update(*
this);
355 GridIndexType findFlippedScvfIndex_(GridIndexType insideScvIdx, GridIndexType outsideScvIdx)
358 for (
auto outsideScvfIndex : scvfIndicesOfScv_[outsideScvIdx])
360 const auto& outsideScvf = this->scvf(outsideScvfIndex);
361 for (
unsigned int j = 0; j < outsideScvf.numOutsideScvs(); ++j)
362 if (outsideScvf.outsideScvIdx(j) == insideScvIdx)
363 return outsideScvf.index();
366 DUNE_THROW(Dune::InvalidStateException,
"No flipped version of this scvf found!");
370 ConnectivityMap connectivityMap_;
373 std::vector<SubControlVolume> scvs_;
374 std::vector<SubControlVolumeFace> scvfs_;
375 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
376 std::size_t numBoundaryScvf_;
377 std::vector<bool> hasBoundaryScvf_;
380 std::vector<std::vector<GridIndexType>> flipScvfIndices_;
390template<
class GV,
class Traits>
396 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
399 using Element =
typename GV::template Codim<0>::Entity;
401 static const int dim = GV::dimension;
402 static const int dimWorld = GV::dimensionworld;
404 using ScvfGridIndexStorage =
typename Traits::SubControlVolumeFace::Traits::GridIndexStorage;
405 using NeighborVolVarIndices =
typename std::conditional_t< (dim<dimWorld),
406 ScvfGridIndexStorage,
407 Dune::ReservedVector<GridIndexType, 1> >;
435 : ParentType(std::move(gg))
439 DUNE_THROW(Dune::InvalidStateException,
"The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
440 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
470 return numBoundaryScvf_;
475 {
return this->
gridView().size(0); }
492 {
return scvfIndicesOfScv_[scvIdx]; }
496 {
return neighborVolVarIndices_[scvIdx]; }
503 {
return connectivityMap_; }
510 scvfIndicesOfScv_.clear();
511 neighborVolVarIndices_.clear();
514 numScvs_ = numDofs();
516 numBoundaryScvf_ = 0;
517 scvfIndicesOfScv_.resize(numScvs_);
518 neighborVolVarIndices_.resize(numScvs_);
521 for (
const auto& element : elements(this->gridView()))
523 const auto eIdx = this->elementMapper().index(element);
526 auto numLocalFaces = element.subEntities(1);
527 std::vector<GridIndexType> scvfsIndexSet;
528 std::vector<NeighborVolVarIndices> neighborVolVarIndexSet;
529 scvfsIndexSet.reserve(numLocalFaces);
530 neighborVolVarIndexSet.reserve(numLocalFaces);
534 std::vector<NeighborVolVarIndices> outsideIndices;
537 outsideIndices.resize(numLocalFaces);
538 for (
const auto& intersection : intersections(this->gridView(), element))
540 if (intersection.neighbor())
542 const auto nIdx = this->elementMapper().index(intersection.outside());
543 outsideIndices[intersection.indexInInside()].push_back(nIdx);
548 for (
const auto& intersection : intersections(this->gridView(), element))
551 if (intersection.neighbor())
554 if (intersection.boundary())
559 scvfsIndexSet.push_back(numScvf_++);
560 const auto nIdx = this->elementMapper().index(intersection.outside());
561 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({nIdx}));
567 auto indexInInside = intersection.indexInInside();
569 if (outsideIndices[indexInInside].empty())
573 scvfsIndexSet.push_back(numScvf_++);
574 neighborVolVarIndexSet.emplace_back(std::move(outsideIndices[indexInInside]));
575 outsideIndices[indexInInside].clear();
580 else if (intersection.boundary())
582 scvfsIndexSet.push_back(numScvf_++);
583 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({
static_cast<GridIndexType
>(numScvs_ + numBoundaryScvf_++)}));
588 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
589 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
593 connectivityMap_.update(*
this);
597 std::size_t numScvs_;
598 std::size_t numScvf_;
599 std::size_t numBoundaryScvf_;
602 ConnectivityMap connectivityMap_;
605 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
606 std::vector<std::vector<NeighborVolVarIndices>> neighborVolVarIndices_;
Defines the default element and vertex mapper types.
Defines the index types used for grid and local indices.
Check the overlap size for different discretization methods.
Base class for grid geometries.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
Dune::Std::detected_or_t< Dumux::BasicGridGeometry< GV, typename T::ElementMapper, typename T::VertexMapper >, Detail::SpecifiesBaseGridGeometry, T > BasicGridGeometry_t
Type of the basic grid geometry implementation used as backend.
Definition basegridgeometry.hh:47
BaseGridGeometry(std::shared_ptr< BaseImplementation > impl)
Constructor from a BaseImplementation.
Definition basegridgeometry.hh:81
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition extrusion.hh:251
typename GridView::IndexSet::IndexType GridIndex
Definition indextraits.hh:39
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition basegridgeometry.hh:121
const GridView & gridView() const
Return the gridView this grid geometry object lives on.
Definition basegridgeometry.hh:109
void update(const GridView &gridView)
Update all fvElementGeometries (call this after grid adaption).
Definition basegridgeometry.hh:97
A simple version of the connectivity map for cellcentered schemes. This implementation works for sche...
Definition cellcentered/connectivitymap.hh:53
Sub control volumes for cell-centered discretization schemes.
Definition discretization/cellcentered/subcontrolvolume.hh:63
Stencil-local finite volume geometry (scvs and scvfs) for cell-centered TPFA models This builds up th...
Definition discretization/cellcentered/tpfa/fvelementgeometry.hh:52
The default traits for the tpfa finite volume grid geometry Defines the scv and scvf types and the ma...
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:55
CCTpfaFVElementGeometry< GridGeometry, enableCache > LocalView
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:63
CCTpfaSubControlVolumeFace< GridView > SubControlVolumeFace
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:57
CCSimpleConnectivityMap< GridGeometry > ConnectivityMap
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:60
CCSubControlVolume< GridView > SubControlVolume
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:56
static constexpr int maxNumScvfNeighbors
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:69
The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view This builds ...
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:81
typename Traits::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:106
DiscretizationMethods::CCTpfa DiscretizationMethod
export the discretization method this geometry belongs to
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:117
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:214
GV GridView
export the grid view type
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:124
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:172
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:149
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:112
BasicGridGeometry_t< GV, Traits > BasicGridGeometry
export basic grid geometry type for the alternative constructor
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:104
CCTpfaFVGridGeometry(const GridView &gridView)
Constructor from gridView.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:139
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:108
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:110
std::size_t numDofs() const
The total number of degrees of freedom.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:167
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Get the sub control volume face indices of an scv by global index.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:205
static constexpr int maxElementStencilSize
The maximum admissible stencil size (used for static memory allocation during assembly).
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:121
static constexpr DiscretizationMethod discMethod
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:118
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:155
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:192
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:179
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:218
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:161
const SubControlVolumeFace & flipScvf(GridIndexType scvfIdx, unsigned int outsideScvfIdx=0) const
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:199
typename Traits::ElementMapper DofMapper
export dof mapper type
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:114
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:186
CCTpfaFVGridGeometry(std::shared_ptr< BasicGridGeometry > gg)
Constructor with basic grid geometry used to share state with another grid geometry on the same grid ...
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:127
const DofMapper & dofMapper() const
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:145
typename Traits::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:413
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:491
typename Traits::ElementMapper DofMapper
export dof mapper type
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:421
const DofMapper & dofMapper() const
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:452
CCTpfaFVGridGeometry(std::shared_ptr< BasicGridGeometry > gg)
Constructor with basic grid geometry used to share state with another grid geometry on the same grid ...
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:434
GV GridView
Export the type of the grid view.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:431
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:417
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:485
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:415
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:462
const ConnectivityMap & connectivityMap() const
Returns the connectivity map of which dofs have derivatives with respect to a given dof.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:502
BasicGridGeometry_t< GV, Traits > BasicGridGeometry
export basic grid geometry type for the alternative constructor
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:411
static constexpr DiscretizationMethod discMethod
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:425
CCTpfaFVGridGeometry(const GridView &gridView)
Constructor from gridView.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:446
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:419
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:478
static constexpr int maxElementStencilSize
The maximum admissible stencil size (used for static memory allocation during assembly).
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:428
DiscretizationMethods::CCTpfa DiscretizationMethod
Export the discretization method this geometry belongs to.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:424
std::size_t numDofs() const
The total number of degrees of freedom.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:474
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:468
const std::vector< NeighborVolVarIndices > & neighborVolVarIndices(GridIndexType scvIdx) const
Return the neighbor volVar indices for all scvfs in the scv with index scvIdx.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:495
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/cellcentered/tpfa/fvgridgeometry.hh:456
The sub control volume face.
Definition discretization/cellcentered/tpfa/subcontrolvolumeface.hh:90
static bool isValid(const GridView &gridView) noexcept
Definition checkoverlapsize.hh:42
Stencil-local finite volume geometry (scvs and scvfs) for cell-centered TPFA models This builds up th...
Sub control volumes for cell-centered discretization schemes.
The sub control volume face.
Stores the face indices corresponding to the neighbors of an element that contribute to the derivativ...