12#ifndef DUMUX_DISCRETIZATION_FE_GRID_LOCAL_VARIABLES_HH
13#define DUMUX_DISCRETIZATION_FE_GRID_LOCAL_VARIABLES_HH
23#include <dumux/common/concepts/localdofs_.hh>
33template<
class P,
class V,
class IPD>
40 template<
class Gr
idVariablesCache,
bool cachingEnabled>
51template<
class Traits,
bool enableCaching,
bool enableIpDataCaching = enableCaching>
55template<
class Traits,
bool enableIpDataCaching>
75 static_assert(enableIpDataCaching || !InterpolationPointData::isSolDependent,
76 "Solution-dependent interpolation point data are stored together with the variables");
86 template<
class Gr
idDiscretization,
class SolutionVector>
90 if constexpr (enableIpDataCaching)
91 ipDataCache_ = std::make_shared<std::vector<ElementInterpolationPointDataCache>>(
gridDiscretization.gridView().size(0));
101 variables_[eIdx].resize(Dumux::Detail::LocalDofs::numLocalDofs(elemDisc));
102 for (
const auto& localDof :
localDofs(elemDisc))
103 variables_[eIdx][localDof.index()].update(elemSol,
problem, elemDisc, ipData(elemDisc, localDof));
105 if constexpr (enableIpDataCaching)
106 (*ipDataCache_)[eIdx].update(
problem, element, elemDisc, variables_[eIdx]);
110 template<
class Gr
idDiscretization,
class SolutionVector>
113 if constexpr (InterpolationPointData::isSolDependent)
115 auto newIpDataCache = std::make_shared<std::vector<ElementInterpolationPointDataCache>>(*ipDataCache_);
125 for (
const auto& localDof :
localDofs(elemDisc))
126 variables_[eIdx][localDof.index()].update(elemSol,
problem, elemDisc, ipData(elemDisc, localDof));
128 (*newIpDataCache)[eIdx].update(
problem, element, elemDisc, variables_[eIdx]);
131 ipDataCache_ = std::move(newIpDataCache);
143 for (
const auto& localDof :
localDofs(elemDisc))
144 variables_[eIdx][localDof.index()].update(elemSol,
problem, elemDisc, ipData(elemDisc, localDof));
149 template<
class LocalDof>
151 {
return variables_[localDof.elementIndex()][localDof.index()]; }
153 template<
class LocalDof>
155 {
return variables_[localDof.elementIndex()][localDof.index()]; }
158 {
return variables_[eIdx][localIdx]; }
161 {
return variables_[eIdx][localIdx]; }
165 {
return variables_[eIdx]; }
168 {
return (*ipDataCache_)[eIdx].elementCache(qpIdx); }
171 {
return (*ipDataCache_)[eIdx].elementCache(qpIdx); }
174 {
return (*ipDataCache_)[eIdx].boundaryFaceCache(bfIdx, qpIdx); }
177 {
return (*ipDataCache_)[eIdx].boundaryFaceCache(bfIdx, qpIdx); }
179 const auto&
cache(std::size_t eIdx)
const
180 {
return (*ipDataCache_)[eIdx]; }
183 {
return (*ipDataCache_)[eIdx]; }
186 {
return *problemPtr_; }
192 std::vector<std::vector<Variables>> variables_;
193 std::shared_ptr<std::vector<ElementInterpolationPointDataCache>> ipDataCache_;
197template<
class Traits,
bool enableIpDataCaching>
218 static_assert(!enableIpDataCaching || !InterpolationPointData::isSolDependent,
219 "Solution-dependent interpolation point data are stored together with the variables");
229 template<
class Gr
idDiscretization,
class SolutionVector>
232 if constexpr (enableIpDataCaching)
234 auto ipDataCache = std::make_shared<std::vector<ElementInterpolationPointDataCache>>(
gridDiscretization.gridView().size(0));
241 std::vector<Variables> variables(Dumux::Detail::LocalDofs::numLocalDofs(elemDisc));
242 for (
const auto& localDof :
localDofs(elemDisc))
243 variables[localDof.index()].update(elemSol,
problem, elemDisc, ipData(elemDisc, localDof));
245 (*ipDataCache)[eIdx].update(
problem, element, elemDisc, variables);
247 ipDataCache_ = std::move(ipDataCache);
251 template<
class Gr
idDiscretization,
class SolutionVector>
254 const auto&
cache(std::size_t eIdx)
const
255 {
return (*ipDataCache_)[eIdx]; }
258 {
return *problemPtr_;}
264 std::shared_ptr<const std::vector<ElementInterpolationPointDataCache>> ipDataCache_;
Interpolation point data at the quadrature points of an element and of its boundary faces.
Definition elementinterpolationpointdatacache.hh:80
The (stencil) element variables class for finite element schemes.
Definition fem/elementvariables.hh:40
typename Traits::Variables Variables
export the variables type
Definition fem/gridvariablescache.hh:207
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition fem/gridvariablescache.hh:222
typename Traits::InterpolationPointData InterpolationPointData
export interpolation point data type
Definition fem/gridvariablescache.hh:213
const Problem & problem() const
Definition fem/gridvariablescache.hh:257
void update(const GridDiscretization &gridDiscretization, const SolutionVector &sol)
Definition fem/gridvariablescache.hh:252
static constexpr bool interpolationPointDataCachingEnabled
make it possible to query if the interpolation point data are stored for the whole grid
Definition fem/gridvariablescache.hh:216
typename Traits::Problem Problem
export the problem type
Definition fem/gridvariablescache.hh:204
const auto & cache(std::size_t eIdx) const
Definition fem/gridvariablescache.hh:254
typename LocalView::MutableView MutableLocalView
export the type of the mutable local view
Definition fem/gridvariablescache.hh:225
void init(const GridDiscretization &gridDiscretization, const SolutionVector &sol)
Definition fem/gridvariablescache.hh:230
FEGridVariablesCache(const Problem &problem)
Definition fem/gridvariablescache.hh:227
static constexpr bool cachingEnabled
make it possible to query if caching is enabled
Definition fem/gridvariablescache.hh:210
const Variables & variables(const std::size_t eIdx, const std::size_t localIdx) const
Definition fem/gridvariablescache.hh:157
typename Traits::Variables Variables
export the variables type
Definition fem/gridvariablescache.hh:64
const InterpolationPointData & elementCache(std::size_t eIdx, std::size_t qpIdx) const
Definition fem/gridvariablescache.hh:167
auto & cache(std::size_t eIdx)
Definition fem/gridvariablescache.hh:182
InterpolationPointData & elementCache(std::size_t eIdx, std::size_t qpIdx)
Definition fem/gridvariablescache.hh:170
const Problem & problem() const
Definition fem/gridvariablescache.hh:185
const Variables & variables(const LocalDof &localDof) const
Definition fem/gridvariablescache.hh:150
const InterpolationPointData & boundaryFaceCache(std::size_t eIdx, int bfIdx, std::size_t qpIdx) const
Definition fem/gridvariablescache.hh:173
InterpolationPointData & boundaryFaceCache(std::size_t eIdx, int bfIdx, std::size_t qpIdx)
Definition fem/gridvariablescache.hh:176
const std::vector< Variables > & localDofVariables(const std::size_t eIdx) const
The variables of all local dofs of an element.
Definition fem/gridvariablescache.hh:164
Variables & variables(const LocalDof &localDof)
Definition fem/gridvariablescache.hh:154
typename Traits::InterpolationPointData InterpolationPointData
export interpolation point data type
Definition fem/gridvariablescache.hh:67
void update(const GridDiscretization &gridDiscretization, const SolutionVector &sol)
Definition fem/gridvariablescache.hh:111
typename LocalView::MutableView MutableLocalView
export the type of the mutable local view
Definition fem/gridvariablescache.hh:82
FEGridVariablesCache(const Problem &problem)
Definition fem/gridvariablescache.hh:84
typename Traits::Problem Problem
export the problem type
Definition fem/gridvariablescache.hh:61
static constexpr bool interpolationPointDataCachingEnabled
make it possible to query if the interpolation point data are stored for the whole grid
Definition fem/gridvariablescache.hh:73
const auto & cache(std::size_t eIdx) const
Definition fem/gridvariablescache.hh:179
void init(const GridDiscretization &gridDiscretization, const SolutionVector &sol)
Definition fem/gridvariablescache.hh:87
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition fem/gridvariablescache.hh:79
Variables & variables(const std::size_t eIdx, const std::size_t localIdx)
Definition fem/gridvariablescache.hh:160
static constexpr bool cachingEnabled
make it possible to query if caching is enabled
Definition fem/gridvariablescache.hh:70
Base class for the grid local variables.
Definition fem/gridvariablescache.hh:52
Base class for all standard finite volume or finite element problems.
Definition common/problem.hh:39
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
decltype(auto) gridDiscretization(const T &t, Args &&... args)
The grid discretization.
Definition griddiscretization.hh:65
Free function to get the local view of a grid cache object.
Definition assembly/assembler.hh:46
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition localdof.hh:50
Parallel for loop (multithreading).
Quadrature rules over sub-control volumes and sub-control volume faces.
Definition fem/gridvariablescache.hh:35
V Variables
Definition fem/gridvariablescache.hh:37
IPD InterpolationPointData
Definition fem/gridvariablescache.hh:38
FEElementVariables< GridVariablesCache, cachingEnabled > LocalView
Definition fem/gridvariablescache.hh:41
P Problem
Definition fem/gridvariablescache.hh:36