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;
119 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
130 DUNE_THROW(Dune::InvalidStateException,
"The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
131 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
139 {
return this->elementMapper(); }
150 return scvfs_.size();
156 return numBoundaryScvf_;
161 {
return this->gridView().size(0); }
164 [[deprecated(
"Use update(gridView) instead! Will be removed after release 3.5.")]]
167 ParentType::update();
174 ParentType::update(gridView);
181 ParentType::update(std::move(gridView));
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> >;
426 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
437 DUNE_THROW(Dune::InvalidStateException,
"The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
438 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
446 {
return this->elementMapper(); }
463 return numBoundaryScvf_;
468 {
return this->gridView().size(0); }
471 [[deprecated(
"Use update(gridView) instead! Will be removed after release 3.5.")]]
474 ParentType::update();
481 ParentType::update(gridView);
488 ParentType::update(std::move(gridView));
493 {
return scvfIndicesOfScv_[scvIdx]; }
497 {
return neighborVolVarIndices_[scvIdx]; }
504 {
return connectivityMap_; }
511 scvfIndicesOfScv_.clear();
512 neighborVolVarIndices_.clear();
515 numScvs_ = numDofs();
517 numBoundaryScvf_ = 0;
518 scvfIndicesOfScv_.resize(numScvs_);
519 neighborVolVarIndices_.resize(numScvs_);
522 for (
const auto& element : elements(this->gridView()))
524 const auto eIdx = this->elementMapper().index(element);
527 auto numLocalFaces = element.subEntities(1);
528 std::vector<GridIndexType> scvfsIndexSet;
529 std::vector<NeighborVolVarIndices> neighborVolVarIndexSet;
530 scvfsIndexSet.reserve(numLocalFaces);
531 neighborVolVarIndexSet.reserve(numLocalFaces);
535 std::vector<NeighborVolVarIndices> outsideIndices;
538 outsideIndices.resize(numLocalFaces);
539 for (
const auto& intersection : intersections(this->gridView(), element))
541 if (intersection.neighbor())
543 const auto nIdx = this->elementMapper().index(intersection.outside());
544 outsideIndices[intersection.indexInInside()].push_back(nIdx);
549 for (
const auto& intersection : intersections(this->gridView(), element))
552 if (intersection.neighbor())
555 if (intersection.boundary())
560 scvfsIndexSet.push_back(numScvf_++);
561 const auto nIdx = this->elementMapper().index(intersection.outside());
562 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({nIdx}));
568 auto indexInInside = intersection.indexInInside();
570 if (outsideIndices[indexInInside].empty())
574 scvfsIndexSet.push_back(numScvf_++);
575 neighborVolVarIndexSet.emplace_back(std::move(outsideIndices[indexInInside]));
576 outsideIndices[indexInInside].clear();
581 else if (intersection.boundary())
583 scvfsIndexSet.push_back(numScvf_++);
584 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({
static_cast<GridIndexType
>(numScvs_ + numBoundaryScvf_++)}));
589 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
590 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
594 connectivityMap_.update(*
this);
598 std::size_t numScvs_;
599 std::size_t numScvf_;
600 std::size_t numBoundaryScvf_;
603 ConnectivityMap connectivityMap_;
606 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
607 std::vector<std::vector<NeighborVolVarIndices>> neighborVolVarIndices_;
Defines the default element and vertex mapper types.
Defines the index types used for grid and local indices.
Helper classes to compute the integration elements.
Base class for grid geometries.
Check the overlap size for different discretization methods.
The available discretization methods in Dumux.
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:177
Struture to define the index types used for grid and local indices.
Definition: indextraits.hh:38
Base class for all finite volume grid geometries.
Definition: basegridgeometry.hh:51
GV GridView
export the grid view type
Definition: basegridgeometry.hh:66
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
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
The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view This builds ...
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:92
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:104
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
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:165
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:142
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:110
CCTpfaFVGridGeometry(const GridView &gridView)
Constructor.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:125
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:106
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:108
std::size_t numDofs() const
The total number of degrees of freedom.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:160
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
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:148
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:154
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:112
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:186
const DofMapper & dofMapper() const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:138
The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view This builds ...
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:393
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:411
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:492
typename Traits::ElementMapper DofMapper
export dof mapper type
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:419
const DofMapper & dofMapper() const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:445
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:415
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:486
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:413
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:455
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:503
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:472
CCTpfaFVGridGeometry(const GridView &gridView)
Constructor.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:432
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:417
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:479
std::size_t numDofs() const
The total number of degrees of freedom.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:467
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:461
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:496
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:449
The sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:90
Check if the overlap size is valid for a given discretization method.
Definition: checkoverlapsize.hh:40
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...