12#ifndef DUMUX_DISCRETIZATION_FACECENTERED_ELEMENTVOLUMEVARIABLES_HH
13#define DUMUX_DISCRETIZATION_FACECENTERED_ELEMENTVOLUMEVARIABLES_HH
29template<
class Gr
idVolumeVariables,
bool cachingEnabled>
40 using Problem = std::decay_t<decltype(std::declval<GVV>().problem())>;
42 using FVElementGeometry =
typename GridGeometry::LocalView;
43 using SubControlVolume =
typename GridGeometry::SubControlVolume;
53 : gridVolumeVariablesPtr_(&gridVolumeVariables)
54 , numScv_(gridVolumeVariables.problem().gridGeometry().numScv())
60 if (scv.index() < numScv_)
63 return boundaryVolumeVariables_[getLocalIdx_(scv.index())];
73 return boundaryVolumeVariables_[getLocalIdx_(scvIdx)];
81 template<
class SolutionVector>
82 ThisType
bind(
const typename FVElementGeometry::Element& element,
83 const FVElementGeometry& fvGeometry,
84 const SolutionVector& sol) &&
86 this->
bind(element, fvGeometry, sol);
87 return std::move(*
this);
92 template<
class SolutionVector>
93 void bind(
const typename FVElementGeometry::Element& element,
94 const FVElementGeometry& fvGeometry,
95 const SolutionVector& sol) &
97 if (!fvGeometry.hasBoundaryScvf())
102 boundaryVolVarIndices_.reserve(fvGeometry.numScvf()-element.subEntities(1));
103 boundaryVolumeVariables_.reserve(fvGeometry.numScvf()-element.subEntities(1));
105 for (
const auto& scvf : scvfs(fvGeometry))
107 if (!scvf.boundary() || scvf.isFrontal() || scvf.processorBoundary())
112 const auto bcTypes = problem.boundaryTypes(element, scvf);
114 auto addBoundaryVolVars = [&](
const auto& scvFace)
116 const auto& scvI = fvGeometry.scv(scvFace.insideScvIdx());
117 typename VolumeVariables::PrimaryVariables pv(
118 problem.dirichlet(element, scvFace)[scvI.dofAxis()]
123 volVars.update(dirichletPriVars, problem, element, scvI);
125 boundaryVolumeVariables_.emplace_back(std::move(volVars));
126 boundaryVolVarIndices_.push_back(scvFace.outsideScvIdx());
129 if (bcTypes.hasDirichlet())
131 addBoundaryVolVars(scvf);
136 if (
const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf); orthogonalScvf.boundary())
137 if (problem.boundaryTypes(element, orthogonalScvf).hasDirichlet())
138 addBoundaryVolVars(scvf);
142 assert(boundaryVolumeVariables_.size() == boundaryVolVarIndices_.size());
150 template<
class SolutionVector>
151 ThisType
bindElement(
const typename FVElementGeometry::Element& element,
152 const FVElementGeometry& fvGeometry,
153 const SolutionVector& sol) &&
156 return std::move(*
this);
160 template<
class SolutionVector>
161 void bindElement(
const typename FVElementGeometry::Element& element,
162 const FVElementGeometry& fvGeometry,
163 const SolutionVector& sol) &
169 {
return *gridVolumeVariablesPtr_; }
174 if (scvIdx < numScv_)
178 const auto it = std::find(boundaryVolVarIndices_.begin(), boundaryVolVarIndices_.end(), scvIdx);
179 return it != boundaryVolVarIndices_.end();
187 boundaryVolVarIndices_.clear();
188 boundaryVolumeVariables_.clear();
192 int getLocalIdx_(
const std::size_t volVarIdx)
const
194 const auto it = std::find(boundaryVolVarIndices_.begin(), boundaryVolVarIndices_.end(), volVarIdx);
195 assert(it != boundaryVolVarIndices_.end() &&
"Could not find the current volume variables for volVarIdx!");
196 return std::distance(boundaryVolVarIndices_.begin(), it);
199 const GridVolumeVariables* gridVolumeVariablesPtr_;
200 const std::size_t numScv_;
201 std::vector<std::size_t> boundaryVolVarIndices_;
202 std::vector<VolumeVariables> boundaryVolumeVariables_;
213 using Problem = std::decay_t<decltype(std::declval<GVV>().problem())>;
215 using FVElementGeometry =
typename GridGeometry::LocalView;
216 using SubControlVolume =
typename GridGeometry::SubControlVolume;
218 static constexpr auto dim = GridGeometry::GridView::dimension;
219 static constexpr auto numInsideVolVars = dim * 2;
220 static constexpr auto numOutsideVolVars = numInsideVolVars * 2 * (dim - 1);
230 : gridVolumeVariablesPtr_(&globalFacesVars) {}
234 {
return volumeVariables_[getLocalIdx_(scv.index())]; }
238 {
return volumeVariables_[getLocalIdx_(scvIdx)]; }
242 {
return volumeVariables_[getLocalIdx_(scv.index())]; }
246 {
return volumeVariables_[getLocalIdx_(scvIdx)]; }
253 template<
class SolutionVector>
254 ThisType
bind(
const typename FVElementGeometry::Element& element,
255 const FVElementGeometry& fvGeometry,
256 const SolutionVector& sol) &&
258 this->bind_(element, fvGeometry, sol);
259 return std::move(*
this);
262 template<
class SolutionVector>
263 void bind(
const typename FVElementGeometry::Element& element,
264 const FVElementGeometry& fvGeometry,
265 const SolutionVector& sol) &
267 this->bind_(element, fvGeometry, sol);
275 template<
class SolutionVector>
276 ThisType
bindElement(
const typename FVElementGeometry::Element& element,
277 const FVElementGeometry& fvGeometry,
278 const SolutionVector& sol) &&
280 this->bindElement_(element, fvGeometry, sol);
281 return std::move(*
this);
284 template<
class SolutionVector>
285 void bindElement(
const typename FVElementGeometry::Element& element,
286 const FVElementGeometry& fvGeometry,
287 const SolutionVector& sol) &
288 { this->bindElement_(element, fvGeometry, sol); }
292 {
return *gridVolumeVariablesPtr_; }
296 {
return volVarsInserted_(scvIdx); }
301 template<
class SolutionVector>
302 void bind_(
const typename FVElementGeometry::Element& element,
303 const FVElementGeometry& fvGeometry,
304 const SolutionVector& sol)
308 const auto& problem = gridVolVars().problem();
309 const auto& gridGeometry = fvGeometry.gridGeometry();
311 volVarIndices_.reserve(numInsideVolVars + numInsideVolVars);
312 volumeVariables_.reserve(numInsideVolVars + numInsideVolVars);
314 for (
const auto& scv :
scvs(fvGeometry))
316 for (
const auto otherScvIdx : gridGeometry.connectivityMap()[scv.index()])
318 if (!volVarsInserted_(otherScvIdx))
320 const auto& otherScv = fvGeometry.scv(otherScvIdx);
321 volVarIndices_.push_back(otherScvIdx);
322 volumeVariables_.emplace_back();
323 const auto& otherElement = gridGeometry.element(otherScv.elementIndex());
324 volumeVariables_.back().update(
326 problem, otherElement, otherScv
332 if (fvGeometry.hasBoundaryScvf())
334 for (
const auto& scvf : scvfs(fvGeometry))
336 if (!scvf.boundary() || scvf.isFrontal())
340 const auto& problem = gridVolVars().problem();
341 const auto bcTypes = problem.boundaryTypes(element, scvf);
345 const auto& scvI = fvGeometry.scv(scvFace.insideScvIdx());
346 typename VolumeVariables::PrimaryVariables pv(
347 problem.dirichlet(element, scvFace)[scvI.dofAxis()]
351 VolumeVariables volVars;
352 volVars.update(dirichletPriVars,
357 volumeVariables_.emplace_back(std::move(volVars));
358 volVarIndices_.push_back(scvFace.outsideScvIdx());
361 if (bcTypes.hasDirichlet())
368 if (
const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf); orthogonalScvf.boundary())
369 if (problem.boundaryTypes(element, orthogonalScvf).hasDirichlet())
378 template<
class SolutionVector>
379 void bindElement_(
const typename FVElementGeometry::Element& element,
380 const FVElementGeometry& fvGeometry,
381 const SolutionVector& sol)
384 const auto& problem = gridVolVars().problem();
385 const auto& gridGeometry = fvGeometry.gridGeometry();
386 volVarIndices_.reserve(numInsideVolVars);
388 for (
const auto& scv :
scvs(fvGeometry))
390 volVarIndices_.push_back(scv.index());
391 volumeVariables_.emplace_back();
392 volumeVariables_.back().update(
394 problem, element, scv
402 volVarIndices_.clear();
403 volumeVariables_.clear();
406 bool volVarsInserted_(
const std::size_t scvIdx)
const
408 return std::find(volVarIndices_.begin(), volVarIndices_.end(), scvIdx) != volVarIndices_.end();
411 int getLocalIdx_(
const int scvfIdx)
const
413 const auto it = std::find(volVarIndices_.begin(), volVarIndices_.end(), scvfIdx);
414 assert(it != volVarIndices_.end() &&
"Could not find the current face variables for scvfIdx!");
415 return std::distance(volVarIndices_.begin(), it);
418 const GridVolumeVariables* gridVolumeVariablesPtr_;
419 std::vector<std::size_t> volVarIndices_;
420 std::vector<VolumeVariables> volumeVariables_;
GVV GridVolumeVariables
export type of the grid volume variables
Definition facecentered/staggered/elementvolumevariables.hh:224
ThisType bindElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition facecentered/staggered/elementvolumevariables.hh:276
void bind(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition facecentered/staggered/elementvolumevariables.hh:263
ThisType bind(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition facecentered/staggered/elementvolumevariables.hh:254
bool hasVolVars(const std::size_t scvIdx) const
Returns true if volVars exist for the given scv index.
Definition facecentered/staggered/elementvolumevariables.hh:295
void bindElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition facecentered/staggered/elementvolumevariables.hh:285
FaceCenteredStaggeredElementVolumeVariables(const GridVolumeVariables &globalFacesVars)
Definition facecentered/staggered/elementvolumevariables.hh:229
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition facecentered/staggered/elementvolumevariables.hh:227
const GridVolumeVariables & gridVolVars() const
The global volume variables object we are a restriction of.
Definition facecentered/staggered/elementvolumevariables.hh:291
void bindElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition facecentered/staggered/elementvolumevariables.hh:161
GVV GridVolumeVariables
export type of the grid volume variables
Definition facecentered/staggered/elementvolumevariables.hh:47
const GridVolumeVariables & gridVolVars() const
The global volume variables object we are a restriction of.
Definition facecentered/staggered/elementvolumevariables.hh:168
ThisType bindElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition facecentered/staggered/elementvolumevariables.hh:151
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition facecentered/staggered/elementvolumevariables.hh:50
bool hasVolVars(const std::size_t scvIdx) const
Returns true if volVars exist for the given scv index.
Definition facecentered/staggered/elementvolumevariables.hh:172
FaceCenteredStaggeredElementVolumeVariables(const GridVolumeVariables &gridVolumeVariables)
Definition facecentered/staggered/elementvolumevariables.hh:52
void bind(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition facecentered/staggered/elementvolumevariables.hh:93
ThisType bind(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition facecentered/staggered/elementvolumevariables.hh:82
Base class for the face variables vector.
Definition facecentered/staggered/elementvolumevariables.hh:30
Type traits for problem classes.
Element solution classes and factory functions.
void addBoundaryVolVars(std::vector< VolumeVariables > &volVars, std::vector< IndexType > &volVarIndices, const Problem &problem, const typename FVElemGeom::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElemGeom &fvGeometry)
Adds the boundary volume variables found within the stencil to the provided containers and stores the...
Definition cellcentered/mpfa/elementvolumevariables.hh:124
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethods::cctpfa||GridGeometry::discMethod==DiscretizationMethods::ccmpfa, CCElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for cell-centered schemes.
Definition cellcentered/elementsolution.hh:101
std::ranges::range auto scvs(const FVElementGeometry &fvGeometry, const LocalDof &localDof)
Definition localdof.hh:82
Detail::ProblemGridGeometry< Problem > GridGeometry
Definition common/typetraits/problem.hh:50