version 3.8
discretization/facecentered/staggered/gridfluxvariablescache.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_GRID_FLUXVARSCACHE_HH
13#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_GRID_FLUXVARSCACHE_HH
14
16
17// make the local view function available whenever we use this class
20
21namespace Dumux {
22
27template<class P, class FVC, class FVCF>
29{
30 using Problem = P;
31 using FluxVariablesCache = FVC;
33
34 template<class GridFluxVariablesCache, bool cachingEnabled>
36};
37
43template<class Problem,
44 class FluxVariablesCache,
45 class FluxVariablesCacheFiller,
46 bool cachingEnabled = false,
49
55template<class P, class FVC, class FVCF, class Traits>
56class FaceCenteredStaggeredGridFluxVariablesCache<P, FVC, FVCF, true, Traits>
57{
58 using Problem = typename Traits::Problem;
60 using FluxVariablesCacheFiller = typename Traits::FluxVariablesCacheFiller;
61
62public:
64 using FluxVariablesCache = typename Traits::FluxVariablesCache;
65
67 static constexpr bool cachingEnabled = true;
68
70 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
71
72 FaceCenteredStaggeredGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
73
74 // When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
75 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
76 void update(const GridGeometry& gridGeometry,
77 const GridVolumeVariables& gridVolVars,
78 const SolutionVector& sol,
79 bool forceUpdate = false)
80 {
81 // only do the update if fluxes are solution dependent or if update is forced
82 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
83 {
84 // instantiate helper class to fill the caches
85 FluxVariablesCacheFiller filler(problem());
86
87 fluxVarsCache_.resize(gridGeometry.numScvf());
88
89 Dumux::parallelFor(gridGeometry.gridView().size(0), [&](const std::size_t eIdx)
90 {
91 // Prepare the geometries within the elements of the stencil
92 const auto element = gridGeometry.element(eIdx);
93 const auto fvGeometry = localView(gridGeometry).bind(element);
94 const auto elemVolVars = localView(gridVolVars).bind(element, fvGeometry, sol);
95
96 for (auto&& scvf : scvfs(fvGeometry))
97 {
98 filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate);
99 }
100 });
101 }
102 }
103
104 const Problem& problem() const
105 { return *problemPtr_; }
106
107 template<class SubControlVolumeFace>
108 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
109 { return fluxVarsCache_[scvf.index()]; }
110
111 template<class SubControlVolumeFace>
112 FluxVariablesCache& operator [](const SubControlVolumeFace& scvf)
113 { return fluxVarsCache_[scvf.index()]; }
114
115private:
116 // currently bound element
117 const Problem* problemPtr_;
118 std::vector<FluxVariablesCache> fluxVarsCache_;
119};
120
125template<class P, class FVC, class FVCF, class Traits>
126class FaceCenteredStaggeredGridFluxVariablesCache<P, FVC, FVCF, false, Traits>
127{
128 using Problem = typename Traits::Problem;
130
131public:
133 using FluxVariablesCache = typename Traits::FluxVariablesCache;
134
136 static constexpr bool cachingEnabled = false;
137
139 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
140
141 FaceCenteredStaggeredGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
142
143 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
144 void update(const GridGeometry& gridGeometry,
145 const GridVolumeVariables& gridVolVars,
146 const SolutionVector& sol,
147 bool forceUpdate = false) {}
148
149 const Problem& problem() const
150 { return *problemPtr_; }
151
152private:
153 const Problem* problemPtr_;
154};
155
156} // end namespace Dumux
157
158#endif
The flux variables caches for an element.
Definition: discretization/facecentered/staggered/elementfluxvariablescache.hh:30
Flux variable caches on a gridview with grid caching disabled.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:127
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:133
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:144
const Problem & problem() const
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:149
FaceCenteredStaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:141
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:139
Flux variable caches on a gridview with grid caching enabled.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:57
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:64
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:70
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:76
const Problem & problem() const
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:104
FaceCenteredStaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:72
Flux variable caches on a gridview.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:48
Global flux variable cache.
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: adapt.hh:17
Parallel for loop (multithreading)
Flux variable caches traits.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:29
FVCF FluxVariablesCacheFiller
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:32
P Problem
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:30
FVC FluxVariablesCache
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:31