12#ifndef DUMUX_DISCRETIZATION_CVFE_ELEMENT_VOLUMEVARIABLES_HH
13#define DUMUX_DISCRETIZATION_CVFE_ELEMENT_VOLUMEVARIABLES_HH
19#include <dumux/common/concepts/localdofs_.hh>
31template<
class GVV,
bool cachingEnabled>
42 class MutableVariablesView
45 MutableVariablesView(GVV& gridCache)
46 : gridCache_(gridCache) {}
50 template<
class SubControlVolume>
52 {
return gridCache_.volVars(scv.elementIndex(), scv.indexInElement()); }
69 : gridVolVarsPtr_(&gridVolVars) {}
72 {
return gridVolVars().volVars(eIdx_, scvIdx); }
74 template<class ScvOrLocalDof, typename std::enable_if_t<!std::is_integral<ScvOrLocalDof>::value,
int> = 0>
77 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
78 return gridVolVars().volVars(eIdx_, scvOrLocalDof.index());
80 return gridVolVars().volVars(eIdx_, scvOrLocalDof.indexInElement());
88 template<
class FVElementGeometry,
class SolutionVector>
90 const FVElementGeometry& fvGeometry,
91 const SolutionVector& sol) &&
93 this->bindElement(element, fvGeometry, sol);
94 return std::move(*
this);
99 template<
class FVElementGeometry,
class SolutionVector>
100 void bind(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
101 const FVElementGeometry& fvGeometry,
102 const SolutionVector& sol) &
104 bindElement(element, fvGeometry, sol);
112 template<
class FVElementGeometry,
class SolutionVector>
114 const FVElementGeometry& fvGeometry,
115 const SolutionVector& sol) &&
117 this->bindElement(element, fvGeometry, sol);
118 return std::move(*
this);
122 template<
class FVElementGeometry,
class SolutionVector>
123 void bindElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
124 const FVElementGeometry& fvGeometry,
125 const SolutionVector& sol) &
127 eIdx_ = fvGeometry.gridGeometry().elementMapper().index(element);
132 {
return *gridVolVarsPtr_; }
139 {
return { gridVolVars }; }
142 const GridVolumeVariables* gridVolVarsPtr_;
156 class MutableVariablesView
159 MutableVariablesView(
ThisType& view)
164 template<
class SubControlVolume>
166 {
return view_[scv]; }
183 : gridVolVarsPtr_(&gridVolVars) {}
190 template<
class FVElementGeometry,
class SolutionVector>
192 const FVElementGeometry& fvGeometry,
193 const SolutionVector& sol) &&
195 this->bindElement(element, fvGeometry, sol);
196 return std::move(*
this);
200 template<
class FVElementGeometry,
class SolutionVector>
201 void bind(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
202 const FVElementGeometry& fvGeometry,
203 const SolutionVector& sol) &
205 bindElement(element, fvGeometry, sol);
213 template<
class FVElementGeometry,
class SolutionVector>
215 const FVElementGeometry& fvGeometry,
216 const SolutionVector& sol) &&
218 this->bindElement(element, fvGeometry, sol);
219 return std::move(*
this);
223 template<
class FVElementGeometry,
class SolutionVector>
224 void bindElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
225 const FVElementGeometry& fvGeometry,
226 const SolutionVector& sol) &
229 auto elemSol =
elementSolution(element, sol, fvGeometry.gridGeometry());
232 volumeVariables_.resize(fvGeometry.numScv());
233 for (
auto&& scv :
scvs(fvGeometry))
234 volumeVariables_[scv.indexInElement()].update(elemSol, gridVolVars().problem(), element, scv);
238 {
return volumeVariables_[scvIdx]; }
241 {
return volumeVariables_[scvIdx]; }
243 template<class ScvOrLocalDof, typename std::enable_if_t<!std::is_integral<ScvOrLocalDof>::value,
int> = 0>
246 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
247 return volumeVariables_[scvOrLocalDof.index()];
249 return volumeVariables_[scvOrLocalDof.indexInElement()];
252 template<class ScvOrLocalDof, typename std::enable_if_t<!std::is_integral<ScvOrLocalDof>::value,
int> = 0>
255 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
256 return volumeVariables_[scvOrLocalDof.index()];
258 return volumeVariables_[scvOrLocalDof.indexInElement()];
263 {
return *gridVolVarsPtr_; }
270 {
return { *
this }; }
273 const GridVolumeVariables* gridVolVarsPtr_;
274 std::vector<VolumeVariables> volumeVariables_;
The local (stencil) volume variables class for control-volume finite element without caching.
Definition: cvfe/elementvolumevariables.hh:153
CVFEElementVolumeVariables bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &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: cvfe/elementvolumevariables.hh:191
MutableView asMutableView(GridVolumeVariables &)
return a local view on variables that is always mutable, regardless of the caching policy
Definition: cvfe/elementvolumevariables.hh:269
GVV GridVolumeVariables
export type of the grid volume variables
Definition: cvfe/elementvolumevariables.hh:173
const GridVolumeVariables & gridVolVars() const
The global volume variables object we are a restriction of.
Definition: cvfe/elementvolumevariables.hh:262
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition: cvfe/elementvolumevariables.hh:201
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition: cvfe/elementvolumevariables.hh:179
CVFEElementVolumeVariables(const GridVolumeVariables &gridVolVars)
Constructor.
Definition: cvfe/elementvolumevariables.hh:182
MutableVariablesView MutableView
export type of the mutable version of the view
Definition: cvfe/elementvolumevariables.hh:176
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition: cvfe/elementvolumevariables.hh:224
CVFEElementVolumeVariables bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &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: cvfe/elementvolumevariables.hh:214
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition: cvfe/elementvolumevariables.hh:100
MutableView asMutableView(GridVolumeVariables &gridVolVars)
return a local view on variables that is always mutable, regardless of the caching policy
Definition: cvfe/elementvolumevariables.hh:138
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition: cvfe/elementvolumevariables.hh:123
CVFEElementVolumeVariables(const GridVolumeVariables &gridVolVars)
Constructor.
Definition: cvfe/elementvolumevariables.hh:68
const GridVolumeVariables & gridVolVars() const
The global volume variables object we are a restriction of.
Definition: cvfe/elementvolumevariables.hh:131
CVFEElementVolumeVariables bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &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: cvfe/elementvolumevariables.hh:89
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition: cvfe/elementvolumevariables.hh:65
GVV GridVolumeVariables
export type of the grid volume variables
Definition: cvfe/elementvolumevariables.hh:59
MutableVariablesView MutableView
export type of the mutable version of the view
Definition: cvfe/elementvolumevariables.hh:62
CVFEElementVolumeVariables bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &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: cvfe/elementvolumevariables.hh:113
The local (stencil) volume variables class for control-volume finite element.
Definition: cvfe/elementvolumevariables.hh:32
Element solution classes and factory functions.
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:79