14#ifndef DUMUX_DISCRETIZATION_CCTPFA_FV_GRID_GEOMETRY_HH
15#define DUMUX_DISCRETIZATION_CCTPFA_FV_GRID_GEOMETRY_HH
40template<
class Gr
idView,
class MapperTraits = DefaultMapperTraits<Gr
idView>>
47 template<
class Gr
idGeometry>
50 template<
class Gr
idGeometry,
bool enableCache>
57 static constexpr int maxNumScvfNeighbors = int(GridView::dimension)<int(GridView::dimensionworld) ? 8 : 1<<(GridView::dimension-1);
66template<
class GridView,
67 bool enableGridGeometryCache =
false,
77template<
class GV,
class Traits>
83 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
85 using Element =
typename GV::template Codim<0>::Entity;
87 static const int dim = GV::dimension;
88 static const int dimWorld = GV::dimensionworld;
109 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
120 DUNE_THROW(Dune::InvalidStateException,
"The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
121 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
134 {
return this->elementMapper(); }
145 return scvfs_.size();
151 return numBoundaryScvf_;
156 {
return this->gridView().size(0); }
162 ParentType::update(gridView);
169 ParentType::update(std::move(gridView));
176 return scvs_[scvIdx];
182 return scvfs_[scvfIdx];
189 return scvfs_[flipScvfIndices_[scvfIdx][outsideScvfIdx]];
195 return scvfIndicesOfScv_[scvIdx];
203 {
return connectivityMap_; }
207 {
return hasBoundaryScvf_[eIdx]; }
216 scvfIndicesOfScv_.clear();
217 flipScvfIndices_.clear();
220 std::size_t numScvs = numDofs();
221 std::size_t numScvf = 0;
222 for (
const auto& element : elements(this->gridView()))
223 numScvf += element.subEntities(1);
226 scvs_.resize(numScvs);
227 scvfs_.reserve(numScvf);
228 scvfIndicesOfScv_.resize(numScvs);
229 hasBoundaryScvf_.assign(numScvs,
false);
232 GridIndexType scvfIdx = 0;
233 numBoundaryScvf_ = 0;
234 for (
const auto& element : elements(this->gridView()))
236 const auto eIdx = this->elementMapper().index(element);
237 scvs_[eIdx] = SubControlVolume(element.geometry(), eIdx);
240 std::vector<GridIndexType> scvfsIndexSet;
241 scvfsIndexSet.reserve(element.subEntities(1));
245 using ScvfGridIndexStorage =
typename SubControlVolumeFace::Traits::GridIndexStorage;
246 std::vector<ScvfGridIndexStorage> outsideIndices;
250 outsideIndices.resize(element.subEntities(1));
251 std::for_each(outsideIndices.begin(), outsideIndices.end(), [eIdx] (
auto& nIndices) { nIndices.push_back(eIdx); });
254 for (
const auto& intersection : intersections(this->gridView(), element))
256 if (intersection.neighbor())
258 const auto nIdx = this->elementMapper().index( intersection.outside() );
259 outsideIndices[intersection.indexInInside()].push_back(nIdx);
264 for (
const auto& intersection : intersections(this->gridView(), element))
267 if (intersection.neighbor())
270 if (intersection.boundary())
275 const auto nIdx = this->elementMapper().index(intersection.outside());
276 scvfs_.emplace_back(intersection,
277 intersection.geometry(),
279 ScvfGridIndexStorage({eIdx, nIdx}),
281 scvfsIndexSet.push_back(scvfIdx++);
287 auto indexInInside = intersection.indexInInside();
289 if (outsideIndices[indexInInside].empty())
293 scvfs_.emplace_back(intersection,
294 intersection.geometry(),
296 outsideIndices[indexInInside],
298 scvfsIndexSet.push_back(scvfIdx++);
299 outsideIndices[indexInInside].clear();
304 else if (intersection.boundary())
306 scvfs_.emplace_back(intersection,
307 intersection.geometry(),
309 ScvfGridIndexStorage({eIdx,
static_cast<GridIndexType
>(this->gridView().size(0) + numBoundaryScvf_++)}),
311 scvfsIndexSet.push_back(scvfIdx++);
313 hasBoundaryScvf_[eIdx] =
true;
318 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
322 if (dim < dimWorld || this->isPeriodic())
324 flipScvfIndices_.resize(scvfs_.size());
325 for (
auto&& scvf : scvfs_)
330 flipScvfIndices_[scvf.index()].resize(scvf.numOutsideScvs());
331 const auto insideScvIdx = scvf.insideScvIdx();
333 for (
unsigned int i = 0; i < scvf.numOutsideScvs(); ++i)
334 flipScvfIndices_[scvf.index()][i] = findFlippedScvfIndex_(insideScvIdx, scvf.outsideScvIdx(i));
339 connectivityMap_.update(*
this);
343 GridIndexType findFlippedScvfIndex_(GridIndexType insideScvIdx, GridIndexType outsideScvIdx)
346 for (
auto outsideScvfIndex : scvfIndicesOfScv_[outsideScvIdx])
348 const auto& outsideScvf = this->scvf(outsideScvfIndex);
349 for (
unsigned int j = 0; j < outsideScvf.numOutsideScvs(); ++j)
350 if (outsideScvf.outsideScvIdx(j) == insideScvIdx)
351 return outsideScvf.index();
354 DUNE_THROW(Dune::InvalidStateException,
"No flipped version of this scvf found!");
358 ConnectivityMap connectivityMap_;
361 std::vector<SubControlVolume> scvs_;
362 std::vector<SubControlVolumeFace> scvfs_;
363 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
364 std::size_t numBoundaryScvf_;
365 std::vector<bool> hasBoundaryScvf_;
368 std::vector<std::vector<GridIndexType>> flipScvfIndices_;
378template<
class GV,
class Traits>
384 using ConnectivityMap =
typename Traits::template ConnectivityMap<ThisType>;
387 using Element =
typename GV::template Codim<0>::Entity;
389 static const int dim = GV::dimension;
390 static const int dimWorld = GV::dimensionworld;
392 using ScvfGridIndexStorage =
typename Traits::SubControlVolumeFace::Traits::GridIndexStorage;
393 using NeighborVolVarIndices =
typename std::conditional_t< (dim<dimWorld),
394 ScvfGridIndexStorage,
395 Dune::ReservedVector<GridIndexType, 1> >;
416 static constexpr int maxElementStencilSize = LocalView::maxNumElementScvfs*Traits::maxNumScvfNeighbors + 1;
427 DUNE_THROW(Dune::InvalidStateException,
"The cctpfa discretization method needs at least an overlap of 1 for parallel computations. "
428 <<
" Set the parameter \"Grid.Overlap\" in the input file.");
441 {
return this->elementMapper(); }
458 return numBoundaryScvf_;
463 {
return this->gridView().size(0); }
468 ParentType::update(gridView);
475 ParentType::update(std::move(gridView));
480 {
return scvfIndicesOfScv_[scvIdx]; }
484 {
return neighborVolVarIndices_[scvIdx]; }
491 {
return connectivityMap_; }
498 scvfIndicesOfScv_.clear();
499 neighborVolVarIndices_.clear();
502 numScvs_ = numDofs();
504 numBoundaryScvf_ = 0;
505 scvfIndicesOfScv_.resize(numScvs_);
506 neighborVolVarIndices_.resize(numScvs_);
509 for (
const auto& element : elements(this->gridView()))
511 const auto eIdx = this->elementMapper().index(element);
514 auto numLocalFaces = element.subEntities(1);
515 std::vector<GridIndexType> scvfsIndexSet;
516 std::vector<NeighborVolVarIndices> neighborVolVarIndexSet;
517 scvfsIndexSet.reserve(numLocalFaces);
518 neighborVolVarIndexSet.reserve(numLocalFaces);
522 std::vector<NeighborVolVarIndices> outsideIndices;
525 outsideIndices.resize(numLocalFaces);
526 for (
const auto& intersection : intersections(this->gridView(), element))
528 if (intersection.neighbor())
530 const auto nIdx = this->elementMapper().index(intersection.outside());
531 outsideIndices[intersection.indexInInside()].push_back(nIdx);
536 for (
const auto& intersection : intersections(this->gridView(), element))
539 if (intersection.neighbor())
542 if (intersection.boundary())
547 scvfsIndexSet.push_back(numScvf_++);
548 const auto nIdx = this->elementMapper().index(intersection.outside());
549 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({nIdx}));
555 auto indexInInside = intersection.indexInInside();
557 if (outsideIndices[indexInInside].empty())
561 scvfsIndexSet.push_back(numScvf_++);
562 neighborVolVarIndexSet.emplace_back(std::move(outsideIndices[indexInInside]));
563 outsideIndices[indexInInside].clear();
568 else if (intersection.boundary())
570 scvfsIndexSet.push_back(numScvf_++);
571 neighborVolVarIndexSet.emplace_back(NeighborVolVarIndices({
static_cast<GridIndexType
>(numScvs_ + numBoundaryScvf_++)}));
576 scvfIndicesOfScv_[eIdx] = scvfsIndexSet;
577 neighborVolVarIndices_[eIdx] = neighborVolVarIndexSet;
581 connectivityMap_.update(*
this);
585 std::size_t numScvs_;
586 std::size_t numScvf_;
587 std::size_t numBoundaryScvf_;
590 ConnectivityMap connectivityMap_;
593 std::vector<std::vector<GridIndexType>> scvfIndicesOfScv_;
594 std::vector<std::vector<NeighborVolVarIndices>> neighborVolVarIndices_;
Base class for grid geometries.
Stores the face indices corresponding to the neighbors of an element that contribute to the derivativ...
Check the overlap size for different discretization methods.
Base class for all grid geometries.
Definition: basegridgeometry.hh:52
typename BaseImplementation::GridView GridView
export the grid view type
Definition: basegridgeometry.hh:60
A simple version of the connectivity map for cellcentered schemes. This implementation works for sche...
Definition: cellcentered/connectivitymap.hh:41
Sub control volumes for cell-centered discretization schemes.
Definition: discretization/cellcentered/subcontrolvolume.hh:47
Stencil-local finite volume geometry (scvs and scvfs) for cell-centered TPFA models This builds up th...
Definition: discretization/cellcentered/tpfa/fvelementgeometry.hh:53
The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view This builds ...
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:381
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:401
const std::vector< GridIndexType > & scvfIndicesOfScv(GridIndexType scvIdx) const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:479
typename Traits::ElementMapper DofMapper
export dof mapper type
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:409
const DofMapper & dofMapper() const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:440
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:422
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:405
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:473
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:403
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:450
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:490
BasicGridGeometry_t< GV, Traits > BasicGridGeometry
export basic grid geometry type for the alternative constructor
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:399
CCTpfaFVGridGeometry(const GridView &gridView)
Constructor from gridView.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:434
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:407
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:466
std::size_t numDofs() const
The total number of degrees of freedom.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:462
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:456
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:483
std::size_t numScv() const
The total number of sub control volumes.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:444
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
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:94
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:202
void update(const GridView &gridView)
update all fvElementGeometries (call this 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:137
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:100
BasicGridGeometry_t< GV, Traits > BasicGridGeometry
export basic grid geometry type for the alternative constructor
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:92
CCTpfaFVGridGeometry(const GridView &gridView)
Constructor from gridView.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:127
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:96
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:98
std::size_t numDofs() const
The total number of degrees of freedom.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:155
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:193
std::size_t numScvf() const
The total number of sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:143
const SubControlVolumeFace & scvf(GridIndexType scvfIdx) const
Get a sub control volume face with a global scvf index.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:180
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:167
bool hasBoundaryScvf(GridIndexType eIdx) const
Returns whether one of the geometry's scvfs lies on a boundary.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:206
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:149
const SubControlVolumeFace & flipScvf(GridIndexType scvfIdx, unsigned int outsideScvfIdx=0) const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:187
typename Traits::ElementMapper DofMapper
export dof mapper type
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:102
const SubControlVolume & scv(GridIndexType scvIdx) const
Get a sub control volume with a global scv index.
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:174
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:115
const DofMapper & dofMapper() const
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:133
The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view This builds ...
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:69
The sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:78
Defines the default element and vertex mapper types.
Sub control volumes for cell-centered discretization schemes.
Stencil-local finite volume geometry (scvs and scvfs) for cell-centered TPFA models This builds up th...
The sub control volume face.
Helper classes to compute the integration elements.
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:42
The available discretization methods in Dumux.
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:166
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:43
static constexpr int maxNumScvfNeighbors
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:57
Check if the overlap size is valid for a given discretization method.
Definition: checkoverlapsize.hh:28
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:26