12#ifndef DUMUX_DISCRETIZATION_CVFE_ELEMENT_VOLUMEVARIABLES_HH
13#define DUMUX_DISCRETIZATION_CVFE_ELEMENT_VOLUMEVARIABLES_HH
19#include <dumux/common/concepts/localdofs_.hh>
32template<
class GVV,
bool cachingEnabled>
43 class MutableVariablesView
46 MutableVariablesView(GVV& gridCache)
47 : gridCache_(gridCache) {}
51 template<
class SubControlVolume>
53 {
return gridCache_.volVars(scv.elementIndex(), scv.indexInElement()); }
75 template<class ScvOrLocalDof, typename std::enable_if_t<!std::is_integral<ScvOrLocalDof>::value,
int> = 0>
78 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
79 return gridVolVars().volVars(eIdx_, scvOrLocalDof.index());
81 return gridVolVars().volVars(eIdx_, scvOrLocalDof.indexInElement());
89 template<
class FVElementGeometry,
class SolutionVector>
91 const FVElementGeometry& fvGeometry,
92 const SolutionVector& sol) &&
95 return std::move(*
this);
100 template<
class FVElementGeometry,
class SolutionVector>
101 void bind(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
102 const FVElementGeometry& fvGeometry,
103 const SolutionVector& sol) &
113 template<
class FVElementGeometry,
class SolutionVector>
115 const FVElementGeometry& fvGeometry,
116 const SolutionVector& sol) &&
119 return std::move(*
this);
123 template<
class FVElementGeometry,
class SolutionVector>
124 void bindElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
125 const FVElementGeometry& fvGeometry,
126 const SolutionVector& sol) &
128 const auto& gridDiscretization = Deprecated::gridGeometry(fvGeometry);
129 eIdx_ = gridDiscretization.elementMapper().index(element);
134 {
return *gridVolVarsPtr_; }
144 const GridVolumeVariables* gridVolVarsPtr_;
158 class MutableVariablesView
161 MutableVariablesView(ThisType& view)
166 template<
class SubControlVolume>
168 {
return view_[scv]; }
192 template<
class FVElementGeometry,
class SolutionVector>
194 const FVElementGeometry& fvGeometry,
195 const SolutionVector& sol) &&
198 return std::move(*
this);
202 template<
class FVElementGeometry,
class SolutionVector>
203 void bind(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
204 const FVElementGeometry& fvGeometry,
205 const SolutionVector& sol) &
215 template<
class FVElementGeometry,
class SolutionVector>
217 const FVElementGeometry& fvGeometry,
218 const SolutionVector& sol) &&
221 return std::move(*
this);
225 template<
class FVElementGeometry,
class SolutionVector>
226 void bindElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
227 const FVElementGeometry& fvGeometry,
228 const SolutionVector& sol) &
231 const auto& gridDiscretization = Deprecated::gridGeometry(fvGeometry);
235 volumeVariables_.resize(fvGeometry.numScv());
236 for (
auto&& scv :
scvs(fvGeometry))
237 volumeVariables_[scv.indexInElement()].update(elemSol,
gridVolVars().problem(), element, scv);
241 {
return volumeVariables_[scvIdx]; }
244 {
return volumeVariables_[scvIdx]; }
246 template<class ScvOrLocalDof, typename std::enable_if_t<!std::is_integral<ScvOrLocalDof>::value,
int> = 0>
249 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
250 return volumeVariables_[scvOrLocalDof.index()];
252 return volumeVariables_[scvOrLocalDof.indexInElement()];
255 template<class ScvOrLocalDof, typename std::enable_if_t<!std::is_integral<ScvOrLocalDof>::value,
int> = 0>
258 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
259 return volumeVariables_[scvOrLocalDof.index()];
261 return volumeVariables_[scvOrLocalDof.indexInElement()];
266 {
return *gridVolVarsPtr_; }
273 {
return { *
this }; }
276 const GridVolumeVariables* gridVolVarsPtr_;
277 std::vector<VolumeVariables> volumeVariables_;
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:193
MutableView asMutableView(GridVolumeVariables &)
return a local view on variables that is always mutable, regardless of the caching policy
Definition cvfe/elementvolumevariables.hh:272
GVV GridVolumeVariables
export type of the grid volume variables
Definition cvfe/elementvolumevariables.hh:175
const GridVolumeVariables & gridVolVars() const
The global volume variables object we are a restriction of.
Definition cvfe/elementvolumevariables.hh:265
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition cvfe/elementvolumevariables.hh:203
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition cvfe/elementvolumevariables.hh:181
CVFEElementVolumeVariables(const GridVolumeVariables &gridVolVars)
Constructor.
Definition cvfe/elementvolumevariables.hh:184
MutableVariablesView MutableView
export type of the mutable version of the view
Definition cvfe/elementvolumevariables.hh:178
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition cvfe/elementvolumevariables.hh:226
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:216
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition cvfe/elementvolumevariables.hh:101
MutableView asMutableView(GridVolumeVariables &gridVolVars)
return a local view on variables that is always mutable, regardless of the caching policy
Definition cvfe/elementvolumevariables.hh:140
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition cvfe/elementvolumevariables.hh:124
CVFEElementVolumeVariables(const GridVolumeVariables &gridVolVars)
Constructor.
Definition cvfe/elementvolumevariables.hh:69
const GridVolumeVariables & gridVolVars() const
The global volume variables object we are a restriction of.
Definition cvfe/elementvolumevariables.hh:133
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:90
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition cvfe/elementvolumevariables.hh:66
GVV GridVolumeVariables
export type of the grid volume variables
Definition cvfe/elementvolumevariables.hh:60
MutableVariablesView MutableView
export type of the mutable version of the view
Definition cvfe/elementvolumevariables.hh:63
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:114
The local (stencil) volume variables class for control-volume finite element.
Definition cvfe/elementvolumevariables.hh:33
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:82