12#ifndef DUMUX_DISCRETIZATION_CCMPFA_GRID_FLUXVARSCACHE_HH 
   13#define DUMUX_DISCRETIZATION_CCMPFA_GRID_FLUXVARSCACHE_HH 
   25template<
class ModelTraits>
 
   32    static constexpr int numPhases = ModelTraits::numFluidPhases();
 
 
   41         class FVC, 
class FVCF,
 
   55    template<
class Gr
idFluxVariablesCache, 
bool cachingEnabled>
 
 
   72template<
class Traits, 
bool cachingEnabled>
 
   80template<
class TheTraits>
 
   83    using Problem = 
typename TheTraits::Problem;
 
   87    using FluxVariablesCacheFiller = 
typename TheTraits::FluxVariablesCacheFiller;
 
   90    using Traits = TheTraits;
 
   93    using PrimaryInteractionVolume = 
typename Traits::PrimaryInteractionVolume;
 
   94    using SecondaryInteractionVolume = 
typename Traits::SecondaryInteractionVolume;
 
   97    using PrimaryIvDataHandle = 
typename Traits::PrimaryIvDataHandle;
 
   98    using SecondaryIvDataHandle = 
typename Traits::SecondaryIvDataHandle;
 
  101    using FluxVariablesCache = 
typename Traits::FluxVariablesCache;
 
  104    static constexpr bool cachingEnabled = 
true;
 
  107    using LocalView = 
typename Traits::template LocalView<ThisType, cachingEnabled>;
 
  111    : problemPtr_(&problem)
 
  115    template<
class Gr
idGeometry, 
class Gr
idVolumeVariables, 
class SolutionVector>
 
  116    void update(
const GridGeometry& gridGeometry,
 
  117                const GridVolumeVariables& gridVolVars,
 
  118                const SolutionVector& sol,
 
  119                bool forceUpdate = 
false)
 
  123        if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
 
  130                const auto& gridIvIndexSets = gridGeometry.gridInteractionVolumeIndexSets();
 
  131                const auto numPrimaryIvs = gridIvIndexSets.numPrimaryInteractionVolumes();
 
  132                const auto numSecondaryIVs = gridIvIndexSets.numSecondaryInteractionVolumes();
 
  133                ivDataStorage_.primaryInteractionVolumes.reserve(numPrimaryIvs);
 
  134                ivDataStorage_.secondaryInteractionVolumes.reserve(numSecondaryIVs);
 
  135                ivDataStorage_.primaryDataHandles.reserve(numPrimaryIvs);
 
  136                ivDataStorage_.secondaryDataHandles.reserve(numSecondaryIVs);
 
  139                fluxVarsCache_.resize(gridGeometry.numScvf());
 
  143            FluxVariablesCacheFiller filler(problem());
 
  146            for (
auto& cache : fluxVarsCache_)
 
  147                cache.setUpdateStatus(
false);
 
  149            auto fvGeometry = 
localView(gridGeometry);
 
  150            auto elemVolVars = 
localView(gridVolVars);
 
  151            for (
const auto& element : elements(gridGeometry.gridView()))
 
  153                fvGeometry.bind(element);
 
  154                elemVolVars.bind(element, fvGeometry, sol);
 
  158                for (
const auto& scvf : scvfs(fvGeometry))
 
  159                    if (!isEmbeddedInBoundaryIV_(scvf, gridGeometry) && !fluxVarsCache_[scvf.index()].isUpdated())
 
  160                        filler.fill(*
this, fluxVarsCache_[scvf.index()], ivDataStorage_, fvGeometry, elemVolVars, scvf, forceUpdate);
 
  165    template<
class FVElementGeometry, 
class ElementVolumeVariables>
 
  166    void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
 
  167                       const FVElementGeometry& fvGeometry,
 
  168                       const ElementVolumeVariables& elemVolVars)
 
  172        if (FluxVariablesCacheFiller::isSolDependent)
 
  174            const auto& gridGeometry = fvGeometry.gridGeometry();
 
  175            const auto& assemblyMapI = gridGeometry.connectivityMap()[gridGeometry.elementMapper().index(element)];
 
  178            FluxVariablesCacheFiller filler(problem());
 
  181            for (
const auto& scvf : scvfs(fvGeometry))
 
  182                fluxVarsCache_[scvf.index()].setUpdateStatus(
false);
 
  183            for (
const auto& dataJ : assemblyMapI)
 
  184                for (
const auto scvfIdx : dataJ.scvfsJ)
 
  185                    fluxVarsCache_[scvfIdx].setUpdateStatus(
false);
 
  188            for (
const auto& scvf : scvfs(fvGeometry))
 
  190                auto& scvfCache = fluxVarsCache_[scvf.index()];
 
  191                if (!isEmbeddedInBoundaryIV_(scvf, gridGeometry) && !scvfCache.isUpdated())
 
  192                    filler.fill(*
this, scvfCache, ivDataStorage_, fvGeometry, elemVolVars, scvf);
 
  195            for (
const auto& dataJ : assemblyMapI)
 
  197                for (
const auto scvfIdx : dataJ.scvfsJ)
 
  199                    auto& scvfCache = fluxVarsCache_[scvfIdx];
 
  200                    const auto& scvf = fvGeometry.scvf(scvfIdx);
 
  201                    if (!isEmbeddedInBoundaryIV_(scvf, gridGeometry) && !scvfCache.isUpdated())
 
  202                        filler.fill(*
this, scvfCache, ivDataStorage_, fvGeometry, elemVolVars, scvf);
 
  209    template<
class SubControlVolumeFace>
 
  210    const FluxVariablesCache& operator [](
const SubControlVolumeFace& scvf)
 const 
  211    { 
return fluxVarsCache_[scvf.index()]; }
 
  214    template<
class SubControlVolumeFace>
 
  215    FluxVariablesCache& operator [](
const SubControlVolumeFace& scvf)
 
  216    { 
return fluxVarsCache_[scvf.index()]; }
 
  219    template<
class SubControlVolumeFace>
 
  220    const PrimaryInteractionVolume& primaryInteractionVolume(
const SubControlVolumeFace& scvf)
 const 
  221    { 
return ivDataStorage_.primaryInteractionVolumes[ (*this)[scvf].ivIndexInContainer() ]; }
 
  224    template<
class SubControlVolumeFace>
 
  225    const PrimaryIvDataHandle& primaryDataHandle(
const SubControlVolumeFace& scvf)
 const 
  226    { 
return ivDataStorage_.primaryDataHandles[ (*this)[scvf].ivIndexInContainer() ]; }
 
  229    template<
class SubControlVolumeFace>
 
  230    const SecondaryInteractionVolume& secondaryInteractionVolume(
const SubControlVolumeFace& scvf)
 const 
  231    { 
return ivDataStorage_.secondaryInteractionVolumes[ (*this)[scvf].ivIndexInContainer() ]; }
 
  234    template<
class SubControlVolumeFace>
 
  235    const SecondaryIvDataHandle& secondaryDataHandle(
const SubControlVolumeFace& scvf)
 const 
  236    { 
return ivDataStorage_.secondaryDataHandles[ (*this)[scvf].ivIndexInContainer() ]; }
 
  238    const Problem& problem()
 const 
  239    { 
return *problemPtr_; }
 
  243    template<
class SubControlVolumeFace, 
class Gr
idGeometry>
 
  244    bool isEmbeddedInBoundaryIV_(
const SubControlVolumeFace& scvf, 
const GridGeometry& gridGeometry)
 const 
  246        const auto& gridIvIndexSets = gridGeometry.gridInteractionVolumeIndexSets();
 
  247        if (gridGeometry.vertexUsesSecondaryInteractionVolume(scvf.vertexIndex()))
 
  248            return gridIvIndexSets.secondaryIndexSet(scvf).nodalIndexSet().numBoundaryScvfs() > 0;
 
  250            return gridIvIndexSets.primaryIndexSet(scvf).nodalIndexSet().numBoundaryScvfs() > 0;
 
  256        fluxVarsCache_.clear();
 
  257        ivDataStorage_.primaryInteractionVolumes.clear();
 
  258        ivDataStorage_.secondaryInteractionVolumes.clear();
 
  259        ivDataStorage_.primaryDataHandles.clear();
 
  260        ivDataStorage_.secondaryDataHandles.clear();
 
  263    const Problem* problemPtr_;
 
  264    std::vector<FluxVariablesCache> fluxVarsCache_;
 
  267    using IVDataStorage = InteractionVolumeDataStorage<PrimaryInteractionVolume,
 
  269                                                       SecondaryInteractionVolume,
 
  270                                                       SecondaryIvDataHandle>;
 
  271    IVDataStorage ivDataStorage_;
 
  278template<
class TheTraits>
 
  281    using Problem = 
typename TheTraits::Problem;
 
  282    using ThisType = CCMpfaGridFluxVariablesCache<TheTraits, false>;
 
  285    using FluxVariablesCacheFiller = 
typename TheTraits::FluxVariablesCacheFiller;
 
  288    using Traits = TheTraits;
 
  291    using PrimaryInteractionVolume = 
typename Traits::PrimaryInteractionVolume;
 
  292    using SecondaryInteractionVolume = 
typename Traits::SecondaryInteractionVolume;
 
  295    using PrimaryIvDataHandle = 
typename Traits::PrimaryIvDataHandle;
 
  296    using SecondaryIvDataHandle = 
typename Traits::SecondaryIvDataHandle;
 
  299    using FluxVariablesCache = 
typename Traits::FluxVariablesCache;
 
  302    static constexpr bool cachingEnabled = 
false;
 
  305    using LocalView = 
typename Traits::template LocalView<ThisType, cachingEnabled>;
 
  308    CCMpfaGridFluxVariablesCache(
const Problem& problem) : problemPtr_(&problem) {}
 
  311    template<
class Gr
idGeometry, 
class Gr
idVolumeVariables, 
class SolutionVector>
 
  312    void update(
const GridGeometry& gridGeometry,
 
  313                const GridVolumeVariables& gridVolVars,
 
  314                const SolutionVector& sol,
 
  315                bool forceUpdate = 
false) {}
 
  318    template<
class FVElementGeometry, 
class ElementVolumeVariables>
 
  319    void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
 
  320                       const FVElementGeometry& fvGeometry,
 
  321                       const ElementVolumeVariables& elemVolVars) {}
 
  323    const Problem& problem()
 const 
  324    { 
return *problemPtr_; }
 
  327    const Problem* problemPtr_;
 
The flux variables caches for an element.
Definition discretization/cellcentered/mpfa/elementfluxvariablescache.hh:50
Flux variable caches on a gridview.
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:73
The element-local object of flux variables caches.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition localview.hh:26
Free function to get the local view of a grid cache object.
Data handle physics traits.
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:45
FluxVariablesCacheFiller FluxVariablesCacheFiller
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:48
Problem Problem
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:46
FluxVariablesCache FluxVariablesCache
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:47
SecondaryIvDataHandle SecondaryIvDataHandle
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:53
static constexpr std::size_t maxLocalElementLevelDifference()
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:63
PrimaryInteractionVolume PrimaryInteractionVolume
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:50
PrimaryIvDataHandle PrimaryIvDataHandle
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:52
CCMpfaElementFluxVariablesCache< GridFluxVariablesCache, cachingEnabled > LocalView
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:56
SecondaryInteractionVolume SecondaryInteractionVolume
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:51
Data handle physics traits.
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:27
static constexpr bool enableHeatConduction
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:30
static constexpr bool enableMolecularDiffusion
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:29
static constexpr int numPhases
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:32
static constexpr bool enableAdvection
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:28
static constexpr int numComponents
Definition discretization/cellcentered/mpfa/gridfluxvariablescache.hh:33