12#ifndef DUMUX_DISCRETIZATION_CVFE_GRID_LOCAL_VARIABLES_HH
13#define DUMUX_DISCRETIZATION_CVFE_GRID_LOCAL_VARIABLES_HH
20#include <dumux/common/concepts/localdofs_.hh>
29template<
class P,
class V>
35 template<
class Gr
idVariablesCache,
bool cachingEnabled>
43template<
class Traits,
bool enableCaching>
64 static constexpr bool cachingEnabled =
true;
74 template<
class Gr
idGeometry,
class SolutionVector>
75 void update(
const GridGeometry& gridGeometry,
const SolutionVector& sol)
77 variables_.resize(gridGeometry.gridView().size(0));
78 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](
const std::size_t eIdx)
80 const auto element = gridGeometry.element(eIdx);
81 const auto fvGeometry =
localView(gridGeometry).bindElement(element);
86 variables_[eIdx].resize(Dumux::Detail::LocalDofs::numLocalDofs(fvGeometry));
87 for (
const auto& localDof :
localDofs(fvGeometry))
88 variables_[eIdx][localDof.index()].update(elemSol, problem, fvGeometry, ipData(fvGeometry, localDof));
94 template<class ScvOrLocalDof, typename std::enable_if_t<!std::is_integral<ScvOrLocalDof>::value,
int> = 0>
97 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
98 return variables_[scvOrLocalDof.elementIndex()][scvOrLocalDof.index()];
100 return variables_[scvOrLocalDof.elementIndex()][scvOrLocalDof.localDofIndex()];
103 template<class ScvOrLocalDof, typename std::enable_if_t<!std::is_integral<ScvOrLocalDof>::value,
int> = 0>
106 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
107 return variables_[scvOrLocalDof.elementIndex()][scvOrLocalDof.index()];
109 return variables_[scvOrLocalDof.elementIndex()][scvOrLocalDof.localDofIndex()];
113 {
return variables_[eIdx][localIdx]; }
116 {
return variables_[eIdx][localIdx]; }
119 {
return *problemPtr_; }
122 const Problem* problemPtr_;
123 std::vector<std::vector<Variables>> variables_;
127template<
class Traits>
144 static constexpr bool cachingEnabled =
false;
154 template<
class Gr
idGeometry,
class SolutionVector>
155 void update(
const GridGeometry& gridGeometry,
const SolutionVector& sol) {}
158 {
return *problemPtr_;}
161 const Problem* problemPtr_;
The (stencil) element variables class for control-volume finite element.
Definition: elementvariables.hh:34
Definition: gridvariablescache.hh:129
typename Traits::Problem Problem
export the problem type
Definition: gridvariablescache.hh:134
Variables VolumeVariables
Definition: gridvariablescache.hh:141
const Problem & problem() const
Definition: gridvariablescache.hh:157
typename Traits::Variables Variables
export the variables type
Definition: gridvariablescache.hh:137
CVFEGridVariablesCache(const Problem &problem)
Definition: gridvariablescache.hh:152
LocalView::MutableView MutableLocalView
export the type of the mutable local view
Definition: gridvariablescache.hh:150
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: gridvariablescache.hh:155
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: gridvariablescache.hh:147
Definition: gridvariablescache.hh:49
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: gridvariablescache.hh:67
Variables VolumeVariables
Definition: gridvariablescache.hh:61
CVFEGridVariablesCache(const Problem &problem)
Definition: gridvariablescache.hh:72
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: gridvariablescache.hh:75
Variables & volVars(const std::size_t eIdx, const std::size_t localIdx)
Definition: gridvariablescache.hh:115
LocalView::MutableView MutableLocalView
export the type of the mutable local view
Definition: gridvariablescache.hh:70
const Problem & problem() const
Definition: gridvariablescache.hh:118
Variables & volVars(const ScvOrLocalDof &scvOrLocalDof)
Definition: gridvariablescache.hh:104
typename Traits::Problem Problem
export the problem type
Definition: gridvariablescache.hh:54
const Variables & volVars(const std::size_t eIdx, const std::size_t localIdx) const
Definition: gridvariablescache.hh:112
typename Traits::Variables Variables
export the variables type
Definition: gridvariablescache.hh:57
const Variables & volVars(const ScvOrLocalDof &scvOrLocalDof) const
Definition: gridvariablescache.hh:95
Base class for the grid local variables.
Definition: gridvariablescache.hh:44
The local element solution class for control-volume finite element methods.
The element variables class.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
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
void parallelFor(const std::size_t count, const FunctorType &functor)
A parallel for loop (multithreading)
Definition: parallel_for.hh:160
Free function to get the local view of a grid cache object.
Definition: elementvariables.hh:24
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition: localdof.hh:50
Parallel for loop (multithreading)
Definition: gridvariablescache.hh:31
P Problem
Definition: gridvariablescache.hh:32
V Variables
Definition: gridvariablescache.hh:33