12#ifndef DUMUX_DISCRETIZATION_HYBRID_CVFE_GRID_VARIABLES_CACHE_HH
13#define DUMUX_DISCRETIZATION_HYBRID_CVFE_GRID_VARIABLES_CACHE_HH
22#include <dumux/common/concepts/localdofs_.hh>
32template<
class P,
class V,
class IPD>
39 template<
class Gr
idVariablesCache,
bool cachingEnabled>
50template<
class Traits,
bool enableCaching,
bool enableIpDataCaching = enableCaching>
54template<
class Traits,
bool enableIpDataCaching>
74 static_assert(enableIpDataCaching || !InterpolationPointData::isSolDependent,
75 "Solution-dependent interpolation point data are stored together with the variables");
85 template<
class Gr
idDiscretization,
class SolutionVector>
89 if constexpr (enableIpDataCaching)
90 ipDataCache_ = std::make_shared<std::vector<ElementInterpolationPointDataCache>>(
gridDiscretization.gridView().size(0));
100 variables_[eIdx].resize(Dumux::Detail::LocalDofs::numLocalDofs(elemDisc));
101 for (
const auto& localDof :
localDofs(elemDisc))
102 variables_[eIdx][localDof.index()].update(elemSol,
problem, elemDisc, ipData(elemDisc, localDof));
104 if constexpr (enableIpDataCaching)
105 (*ipDataCache_)[eIdx].update(
problem, element, elemDisc, variables_[eIdx]);
109 template<
class Gr
idDiscretization,
class SolutionVector>
112 if constexpr (InterpolationPointData::isSolDependent)
114 auto newIpDataCache = std::make_shared<std::vector<ElementInterpolationPointDataCache>>(*ipDataCache_);
124 for (
const auto& localDof :
localDofs(elemDisc))
125 variables_[eIdx][localDof.index()].update(elemSol,
problem, elemDisc, ipData(elemDisc, localDof));
127 (*newIpDataCache)[eIdx].update(
problem, element, elemDisc, variables_[eIdx]);
130 ipDataCache_ = std::move(newIpDataCache);
142 for (
const auto& localDof :
localDofs(elemDisc))
143 variables_[eIdx][localDof.index()].update(elemSol,
problem, elemDisc, ipData(elemDisc, localDof));
148 template<
class ScvOrLocalDof>
151 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
152 return variables_[scvOrLocalDof.elementIndex()][scvOrLocalDof.index()];
154 return variables_[scvOrLocalDof.elementIndex()][scvOrLocalDof.localDofIndex()];
157 template<
class ScvOrLocalDof>
160 if constexpr (Concept::LocalDof<ScvOrLocalDof>)
161 return variables_[scvOrLocalDof.elementIndex()][scvOrLocalDof.index()];
163 return variables_[scvOrLocalDof.elementIndex()][scvOrLocalDof.localDofIndex()];
167 {
return variables_[eIdx][localIdx]; }
170 {
return variables_[eIdx][localIdx]; }
174 {
return variables_[eIdx]; }
177 {
return (*ipDataCache_)[eIdx].scvfCache(scvfIdx, qpIdx); }
180 {
return (*ipDataCache_)[eIdx].scvfCache(scvfIdx, qpIdx); }
183 {
return (*ipDataCache_)[eIdx].elementCache(qpIdx); }
186 {
return (*ipDataCache_)[eIdx].elementCache(qpIdx); }
189 {
return (*ipDataCache_)[eIdx].boundaryFaceCache(bfIdx, qpIdx); }
192 {
return (*ipDataCache_)[eIdx].boundaryFaceCache(bfIdx, qpIdx); }
194 const auto&
cache(std::size_t eIdx)
const
195 {
return (*ipDataCache_)[eIdx]; }
198 {
return (*ipDataCache_)[eIdx]; }
201 {
return *problemPtr_; }
207 std::vector<std::vector<Variables>> variables_;
208 std::shared_ptr<std::vector<ElementInterpolationPointDataCache>> ipDataCache_;
212template<
class Traits,
bool enableIpDataCaching>
233 static_assert(!enableIpDataCaching || !InterpolationPointData::isSolDependent,
234 "Solution-dependent interpolation point data are stored together with the variables");
244 template<
class Gr
idDiscretization,
class SolutionVector>
247 if constexpr (enableIpDataCaching)
249 auto ipDataCache = std::make_shared<std::vector<ElementInterpolationPointDataCache>>(
gridDiscretization.gridView().size(0));
256 std::vector<Variables> variables(Dumux::Detail::LocalDofs::numLocalDofs(elemDisc));
257 for (
const auto& localDof :
localDofs(elemDisc))
258 variables[localDof.index()].update(elemSol,
problem, elemDisc, ipData(elemDisc, localDof));
260 (*ipDataCache)[eIdx].update(
problem, element, elemDisc, variables);
262 ipDataCache_ = std::move(ipDataCache);
266 template<
class Gr
idDiscretization,
class SolutionVector>
269 const auto&
cache(std::size_t eIdx)
const
270 {
return (*ipDataCache_)[eIdx]; }
273 {
return *problemPtr_;}
279 std::shared_ptr<const std::vector<ElementInterpolationPointDataCache>> ipDataCache_;
Interpolation point data at the quadrature points of the sub-control volume faces,...
Definition elementinterpolationpointdatacache.hh:128
The (stencil) element variables class for hybrid control-volume finite element.
Definition cvfe/hybrid/elementvariables.hh:42
auto & cache(std::size_t eIdx)
Definition cvfe/hybrid/gridvariablescache.hh:197
InterpolationPointData & elementCache(std::size_t eIdx, std::size_t qpIdx)
Definition cvfe/hybrid/gridvariablescache.hh:185
const std::vector< Variables > & localDofVariables(const std::size_t eIdx) const
The variables of all local dofs of an element.
Definition cvfe/hybrid/gridvariablescache.hh:173
const InterpolationPointData & boundaryFaceCache(std::size_t eIdx, int bfIdx, std::size_t qpIdx) const
Definition cvfe/hybrid/gridvariablescache.hh:188
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition cvfe/hybrid/gridvariablescache.hh:78
typename LocalView::MutableView MutableLocalView
export the type of the mutable local view
Definition cvfe/hybrid/gridvariablescache.hh:81
void init(const GridDiscretization &gridDiscretization, const SolutionVector &sol)
Definition cvfe/hybrid/gridvariablescache.hh:86
const InterpolationPointData & scvfCache(std::size_t eIdx, std::size_t scvfIdx, std::size_t qpIdx) const
Definition cvfe/hybrid/gridvariablescache.hh:176
const Variables & variables(const std::size_t eIdx, const std::size_t localIdx) const
Definition cvfe/hybrid/gridvariablescache.hh:166
static constexpr bool interpolationPointDataCachingEnabled
make it possible to query if the interpolation point data are stored for the whole grid
Definition cvfe/hybrid/gridvariablescache.hh:72
const auto & cache(std::size_t eIdx) const
Definition cvfe/hybrid/gridvariablescache.hh:194
static constexpr bool cachingEnabled
make it possible to query if caching is enabled
Definition cvfe/hybrid/gridvariablescache.hh:69
void update(const GridDiscretization &gridDiscretization, const SolutionVector &sol)
Definition cvfe/hybrid/gridvariablescache.hh:110
HybridCVFEGridVariablesCache(const Problem &problem)
Definition cvfe/hybrid/gridvariablescache.hh:83
const Variables & variables(const ScvOrLocalDof &scvOrLocalDof) const
Definition cvfe/hybrid/gridvariablescache.hh:149
Variables & variables(const std::size_t eIdx, const std::size_t localIdx)
Definition cvfe/hybrid/gridvariablescache.hh:169
typename Traits::InterpolationPointData InterpolationPointData
export interpolation point data type
Definition cvfe/hybrid/gridvariablescache.hh:66
Variables & variables(const ScvOrLocalDof &scvOrLocalDof)
Definition cvfe/hybrid/gridvariablescache.hh:158
typename Traits::Problem Problem
export the problem type
Definition cvfe/hybrid/gridvariablescache.hh:60
InterpolationPointData & scvfCache(std::size_t eIdx, std::size_t scvfIdx, std::size_t qpIdx)
Definition cvfe/hybrid/gridvariablescache.hh:179
const InterpolationPointData & elementCache(std::size_t eIdx, std::size_t qpIdx) const
Definition cvfe/hybrid/gridvariablescache.hh:182
typename Traits::Variables Variables
export the variables type
Definition cvfe/hybrid/gridvariablescache.hh:63
InterpolationPointData & boundaryFaceCache(std::size_t eIdx, int bfIdx, std::size_t qpIdx)
Definition cvfe/hybrid/gridvariablescache.hh:191
const Problem & problem() const
Definition cvfe/hybrid/gridvariablescache.hh:200
typename Traits::InterpolationPointData InterpolationPointData
export interpolation point data type
Definition cvfe/hybrid/gridvariablescache.hh:228
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition cvfe/hybrid/gridvariablescache.hh:237
void init(const GridDiscretization &gridDiscretization, const SolutionVector &sol)
Definition cvfe/hybrid/gridvariablescache.hh:245
void update(const GridDiscretization &gridDiscretization, const SolutionVector &sol)
Definition cvfe/hybrid/gridvariablescache.hh:267
static constexpr bool interpolationPointDataCachingEnabled
make it possible to query if the interpolation point data are stored for the whole grid
Definition cvfe/hybrid/gridvariablescache.hh:231
static constexpr bool cachingEnabled
make it possible to query if caching is enabled
Definition cvfe/hybrid/gridvariablescache.hh:225
typename LocalView::MutableView MutableLocalView
export the type of the mutable local view
Definition cvfe/hybrid/gridvariablescache.hh:240
const auto & cache(std::size_t eIdx) const
Definition cvfe/hybrid/gridvariablescache.hh:269
typename Traits::Problem Problem
export the problem type
Definition cvfe/hybrid/gridvariablescache.hh:219
typename Traits::Variables Variables
export the variables type
Definition cvfe/hybrid/gridvariablescache.hh:222
const Problem & problem() const
Definition cvfe/hybrid/gridvariablescache.hh:272
HybridCVFEGridVariablesCache(const Problem &problem)
Definition cvfe/hybrid/gridvariablescache.hh:242
The grid variables cache class for hybrid control-volume finite element methods.
Definition cvfe/hybrid/gridvariablescache.hh:51
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 for hybrid control-volume finite element methods.
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 cvfe/hybrid/elementvariables.hh:32
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 cvfe/hybrid/gridvariablescache.hh:34
IPD InterpolationPointData
Definition cvfe/hybrid/gridvariablescache.hh:37
P Problem
Definition cvfe/hybrid/gridvariablescache.hh:35
V Variables
Definition cvfe/hybrid/gridvariablescache.hh:36
HybridCVFEElementVariables< GridVariablesCache, cachingEnabled > LocalView
Definition cvfe/hybrid/gridvariablescache.hh:40