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;
121 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
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.");
146 {
return this->elementMapper(); }
157 return scvfs_.size();
163 return numBoundaryScvf_;
168 {
return this->gridView().size(0); }
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> >;
428 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
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.");
453 {
return this->elementMapper(); }
470 return numBoundaryScvf_;
475 {
return this->gridView().size(0); }
480 ParentType::update(gridView);
487 ParentType::update(std::move(gridView));
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:51
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
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:38
Base class for all grid geometries.
Definition: basegridgeometry.hh:61
typename BaseImplementation::GridView GridView
export the grid view type
Definition: basegridgeometry.hh:69
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:106
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(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
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
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: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
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
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
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
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...