26#ifndef DUMUX_DISCRETIZATION_CCTPFA_FV_GRID_GEOMETRY_HH
27#define DUMUX_DISCRETIZATION_CCTPFA_FV_GRID_GEOMETRY_HH
51template<
class Gr
idView,
class MapperTraits = DefaultMapperTraits<Gr
idView>>
58 template<
class Gr
idGeometry>
61 template<
class Gr
idGeometry,
bool enableCache>
68 static constexpr int maxNumScvfNeighbors = int(GridView::dimension)<int(GridView::dimensionworld) ? 8 : 1<<(GridView::dimension-1);
77template<
class GridView,
78 bool enableGridGeometryCache =
false,
88template<
class GV,
class Traits>
94 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
96 using Element =
typename GV::template Codim<0>::Entity;
98 static const int dim = GV::dimension;
99 static const int dimWorld = GV::dimensionworld;
117 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
128 DUNE_THROW(Dune::InvalidStateException,
"The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
129 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
135 {
return this->elementMapper(); }
146 return scvfs_.size();
152 return numBoundaryScvf_;
157 {
return this->gridView().size(0); }
162 ParentType::update();
167 scvfIndicesOfScv_.clear();
168 flipScvfIndices_.clear();
171 std::size_t numScvs = numDofs();
172 std::size_t numScvf = 0;
173 for (
const auto& element : elements(this->gridView()))
174 numScvf += element.subEntities(1);
177 scvs_.resize(numScvs);
178 scvfs_.reserve(numScvf);
179 scvfIndicesOfScv_.resize(numScvs);
180 hasBoundaryScvf_.resize(numScvs,
false);
183 GridIndexType scvfIdx = 0;
184 numBoundaryScvf_ = 0;
185 for (
const auto& element : elements(this->gridView()))
187 const auto eIdx = this->elementMapper().index(element);
191 std::vector<GridIndexType> scvfsIndexSet;
192 scvfsIndexSet.reserve(element.subEntities(1));
196 using ScvfGridIndexStorage =
typename SubControlVolumeFace::Traits::GridIndexStorage;
197 std::vector<ScvfGridIndexStorage> outsideIndices;
201 outsideIndices.resize(element.subEntities(1));
202 std::for_each(outsideIndices.begin(), outsideIndices.end(), [eIdx] (
auto& nIndices) { nIndices.push_back(eIdx); });
205 for (
const auto& intersection : intersections(this->gridView(), element))
207 if (intersection.neighbor())
209 const auto nIdx = this->elementMapper().index( intersection.outside() );
210 outsideIndices[intersection.indexInInside()].push_back(nIdx);
215 for (
const auto& intersection : intersections(this->gridView(), element))
218 if (intersection.neighbor())
221 if (intersection.boundary())
226 const auto nIdx = this->elementMapper().index(intersection.outside());
227 scvfs_.emplace_back(intersection,
228 intersection.geometry(),
230 ScvfGridIndexStorage({eIdx, nIdx}),
232 scvfsIndexSet.push_back(scvfIdx++);
238 auto indexInInside = intersection.indexInInside();
240 if (outsideIndices[indexInInside].empty())
244 scvfs_.emplace_back(intersection,
245 intersection.geometry(),
247 outsideIndices[indexInInside],
249 scvfsIndexSet.push_back(scvfIdx++);
250 outsideIndices[indexInInside].clear();
255 else if (intersection.boundary())
257 scvfs_.emplace_back(intersection,
258 intersection.geometry(),
260 ScvfGridIndexStorage({eIdx,
static_cast<GridIndexType
>(this->gridView().size(0) + numBoundaryScvf_++)}),
262 scvfsIndexSet.push_back(scvfIdx++);
264 hasBoundaryScvf_[eIdx] =
true;
269 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
273 if (dim < dimWorld || this->isPeriodic())
275 flipScvfIndices_.resize(scvfs_.size());
276 for (
auto&& scvf : scvfs_)
281 flipScvfIndices_[scvf.index()].resize(scvf.numOutsideScvs());
282 const auto insideScvIdx = scvf.insideScvIdx();
284 for (
unsigned int i = 0; i < scvf.numOutsideScvs(); ++i)
285 flipScvfIndices_[scvf.index()][i] = findFlippedScvfIndex_(insideScvIdx, scvf.outsideScvIdx(i));
290 connectivityMap_.update(*
this);
296 return scvs_[scvIdx];
302 return scvfs_[scvfIdx];
309 return scvfs_[flipScvfIndices_[scvfIdx][outsideScvfIdx]];
315 return scvfIndicesOfScv_[scvIdx];
323 {
return connectivityMap_; }
327 {
return hasBoundaryScvf_[eIdx]; }
331 GridIndexType findFlippedScvfIndex_(GridIndexType insideScvIdx, GridIndexType outsideScvIdx)
334 for (
auto outsideScvfIndex : scvfIndicesOfScv_[outsideScvIdx])
336 const auto& outsideScvf = this->scvf(outsideScvfIndex);
337 for (
unsigned int j = 0; j < outsideScvf.numOutsideScvs(); ++j)
338 if (outsideScvf.outsideScvIdx(j) == insideScvIdx)
339 return outsideScvf.index();
342 DUNE_THROW(Dune::InvalidStateException,
"No flipped version of this scvf found!");
346 ConnectivityMap connectivityMap_;
349 std::vector<SubControlVolume> scvs_;
350 std::vector<SubControlVolumeFace> scvfs_;
351 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
352 std::size_t numBoundaryScvf_;
353 std::vector<bool> hasBoundaryScvf_;
356 std::vector<std::vector<GridIndexType>> flipScvfIndices_;
366template<
class GV,
class Traits>
372 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
375 using Element =
typename GV::template Codim<0>::Entity;
377 static const int dim = GV::dimension;
378 static const int dimWorld = GV::dimensionworld;
380 using ScvfGridIndexStorage =
typename Traits::SubControlVolumeFace::Traits::GridIndexStorage;
381 using NeighborVolVarIndices =
typename std::conditional_t< (dim<dimWorld),
382 ScvfGridIndexStorage,
383 Dune::ReservedVector<GridIndexType, 1> >;
401 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
412 DUNE_THROW(Dune::InvalidStateException,
"The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
413 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
419 {
return this->elementMapper(); }
436 return numBoundaryScvf_;
441 {
return this->gridView().size(0); }
446 ParentType::update();
449 scvfIndicesOfScv_.clear();
450 neighborVolVarIndices_.clear();
453 numScvs_ = numDofs();
455 numBoundaryScvf_ = 0;
456 scvfIndicesOfScv_.resize(numScvs_);
457 neighborVolVarIndices_.resize(numScvs_);
460 for (
const auto& element : elements(this->gridView()))
462 const auto eIdx = this->elementMapper().index(element);
465 auto numLocalFaces = element.subEntities(1);
466 std::vector<GridIndexType> scvfsIndexSet;
467 std::vector<NeighborVolVarIndices> neighborVolVarIndexSet;
468 scvfsIndexSet.reserve(numLocalFaces);
469 neighborVolVarIndexSet.reserve(numLocalFaces);
473 std::vector<NeighborVolVarIndices> outsideIndices;
476 outsideIndices.resize(numLocalFaces);
477 for (
const auto& intersection : intersections(this->gridView(), element))
479 if (intersection.neighbor())
481 const auto nIdx = this->elementMapper().index(intersection.outside());
482 outsideIndices[intersection.indexInInside()].push_back(nIdx);
487 for (
const auto& intersection : intersections(this->gridView(), element))
490 if (intersection.neighbor())
493 if (intersection.boundary())
498 scvfsIndexSet.push_back(numScvf_++);
499 const auto nIdx = this->elementMapper().index(intersection.outside());
500 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({nIdx}));
506 auto indexInInside = intersection.indexInInside();
508 if (outsideIndices[indexInInside].empty())
512 scvfsIndexSet.push_back(numScvf_++);
513 neighborVolVarIndexSet.emplace_back(std::move(outsideIndices[indexInInside]));
514 outsideIndices[indexInInside].clear();
519 else if (intersection.boundary())
521 scvfsIndexSet.push_back(numScvf_++);
522 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({
static_cast<GridIndexType
>(numScvs_ + numBoundaryScvf_++)}));
527 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
528 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
532 connectivityMap_.update(*
this);
536 {
return scvfIndicesOfScv_[scvIdx]; }
540 {
return neighborVolVarIndices_[scvIdx]; }
547 {
return connectivityMap_; }
552 std::size_t numScvs_;
553 std::size_t numScvf_;
554 std::size_t numBoundaryScvf_;
557 ConnectivityMap connectivityMap_;
560 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
561 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.
The available discretization methods in Dumux.
Helper classes to compute the integration elements.
Base class for grid geometries.
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
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:50
GV GridView
export the grid view type
Definition: basegridgeometry.hh:65
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:51
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:54
static constexpr int maxNumScvfNeighbors
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:68
The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view This builds ...
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:80
The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view This builds ...
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:91
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:103
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:322
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:160
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:138
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:109
CCTpfaFVGridGeometry(const GridView &gridView)
Constructor.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:123
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:105
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:107
std::size_t numDofs() const
The total number of degrees of freedom.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:156
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:313
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:144
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:300
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:326
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:150
const SubControlVolumeFace & flipScvf(GridIndexType scvfIdx, unsigned int outsideScvfIdx=0) const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:307
typename Traits::ElementMapper DofMapper
export dof mapper type
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:111
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:294
const DofMapper & dofMapper() const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:134
The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view This builds ...
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:369
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:387
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:535
typename Traits::ElementMapper DofMapper
export dof mapper type
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:395
const DofMapper & dofMapper() const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:418
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:391
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:389
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:428
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:546
void update()
update all fvElementGeometries (do this again after grid adaption)
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:444
CCTpfaFVGridGeometry(const GridView &gridView)
Constructor.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:407
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:393
std::size_t numDofs() const
The total number of degrees of freedom.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:440
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:434
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:539
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:422
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...