12#ifndef DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH 
   13#define DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH 
   27template<
class P, 
class FVC>
 
   33    template<
class Gr
idFluxVariablesCache, 
bool cachingEnabled>
 
 
   42template<
class Problem,
 
   43         class FluxVariablesCache,
 
   44         bool cachingEnabled = 
false,
 
   53template<
class P, 
class FVC, 
class Traits>
 
   56    using Problem = 
typename Traits::Problem;
 
   61    using FluxVariablesCache = 
typename Traits::FluxVariablesCache;
 
   64    static constexpr bool cachingEnabled = 
true;
 
   67    using LocalView = 
typename Traits::template LocalView<ThisType, cachingEnabled>;
 
   71    template<
class Gr
idGeometry, 
class Gr
idVolumeVariables, 
class SolutionVector>
 
   72    void update(
const GridGeometry& gridGeometry,
 
   73                const GridVolumeVariables& gridVolVars,
 
   74                const SolutionVector& sol,
 
   75                bool forceUpdate = 
false)
 
   80            fluxVarsCache_.resize(gridGeometry.gridView().size(0));
 
   81            Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](
const std::size_t eIdx)
 
   84                const auto element = gridGeometry.element(eIdx);
 
   85                const auto fvGeometry = 
localView(gridGeometry).bind(element);
 
   86                const auto elemVolVars = 
localView(gridVolVars).bind(element, fvGeometry, sol);
 
   89                fluxVarsCache_[eIdx].resize(fvGeometry.numScvf());
 
   90                for (
const auto& scvf : scvfs(fvGeometry))
 
   91                    cache(eIdx, scvf.index()).update(problem, element, fvGeometry, elemVolVars, scvf);
 
   96    template<
class FVElementGeometry, 
class ElementVolumeVariables>
 
   97    void updateElement(
const typename FVElementGeometry::Element& element,
 
   98                       const FVElementGeometry& fvGeometry,
 
   99                       const ElementVolumeVariables& elemVolVars)
 
  101        if constexpr (FluxVariablesCache::isSolDependent)
 
  103            const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
 
  104            fluxVarsCache_[eIdx].resize(fvGeometry.numScvf());
 
  105            for (
const auto& scvf : scvfs(fvGeometry))
 
  106                cache(eIdx, scvf.index()).update(problem(), element, fvGeometry, elemVolVars, scvf);
 
  110    const Problem& problem()
 const 
  111    { 
return *problemPtr_; }
 
  114    const FluxVariablesCache& cache(std::size_t eIdx, std::size_t scvfIdx)
 const 
  115    { 
return fluxVarsCache_[eIdx][scvfIdx]; }
 
  118    FluxVariablesCache& cache(std::size_t eIdx, std::size_t scvfIdx)
 
  119    { 
return fluxVarsCache_[eIdx][scvfIdx]; }
 
  123    const Problem* problemPtr_;
 
  124    std::vector<std::vector<FluxVariablesCache>> fluxVarsCache_;
 
  131template<
class P, 
class FVC, 
class Traits>
 
  134    using Problem = 
typename Traits::Problem;
 
  135    using ThisType = CVFEGridFluxVariablesCache<P, FVC, false, Traits>;
 
  139    using FluxVariablesCache = 
typename Traits::FluxVariablesCache;
 
  142    static constexpr bool cachingEnabled = 
false;
 
  145    using LocalView = 
typename Traits::template LocalView<ThisType, cachingEnabled>;
 
  147    CVFEGridFluxVariablesCache(
const Problem& problem) : problemPtr_(&problem) {}
 
  149    template<
class Gr
idGeometry, 
class Gr
idVolumeVariables, 
class SolutionVector>
 
  150    void update(
const GridGeometry& gridGeometry,
 
  151                const GridVolumeVariables& gridVolVars,
 
  152                const SolutionVector& sol,
 
  153                bool forceUpdate = 
false) {}
 
  155    const Problem& problem()
 const 
  156    { 
return *problemPtr_; }
 
  159    const Problem* problemPtr_;
 
The flux variables caches for an element.
Definition discretization/cvfe/elementfluxvariablescache.hh:31
Flux variable caches on a gridview.
Definition discretization/cvfe/gridfluxvariablescache.hh:46
Global flux variable cache.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition localview.hh:26
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.
Parallel for loop (multithreading)
Flux variable caches traits.
Definition discretization/cvfe/gridfluxvariablescache.hh:29
P Problem
Definition discretization/cvfe/gridfluxvariablescache.hh:30
FVC FluxVariablesCache
Definition discretization/cvfe/gridfluxvariablescache.hh:31
CVFEElementFluxVariablesCache< GridFluxVariablesCache, cachingEnabled > LocalView
Definition discretization/cvfe/gridfluxvariablescache.hh:34