3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/cvfe/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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH
25#define DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH
26
28
29// make the local view function available whenever we use this class
32
33namespace Dumux {
34
39template<class P, class FVC>
41{
42 using Problem = P;
43 using FluxVariablesCache = FVC;
44
45 template<class GridFluxVariablesCache, bool cachingEnabled>
47};
48
54template<class Problem,
55 class FluxVariablesCache,
56 bool cachingEnabled = false,
59
65template<class P, class FVC, class Traits>
66class CVFEGridFluxVariablesCache<P, FVC, true, Traits>
67{
68 using Problem = typename Traits::Problem;
70
71public:
73 using FluxVariablesCache = typename Traits::FluxVariablesCache;
74
76 static constexpr bool cachingEnabled = true;
77
79 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
80
81 CVFEGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
82
83 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
84 void update(const GridGeometry& gridGeometry,
85 const GridVolumeVariables& gridVolVars,
86 const SolutionVector& sol,
87 bool forceUpdate = false)
88 {
89 // Here, we do not do anything unless it is a forced update
90 if (forceUpdate)
91 {
92 fluxVarsCache_.resize(gridGeometry.gridView().size(0));
93 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx)
94 {
95 // Prepare the geometries within the elements of the stencil
96 const auto element = gridGeometry.element(eIdx);
97 const auto fvGeometry = localView(gridGeometry).bind(element);
98 const auto elemVolVars = localView(gridVolVars).bind(element, fvGeometry, sol);
99
100 // only update shape functions for fluxes if update is forced
101 fluxVarsCache_[eIdx].resize(fvGeometry.numScvf());
102 for (const auto& scvf : scvfs(fvGeometry))
103 cache(eIdx, scvf.index()).update(problem, element, fvGeometry, elemVolVars, scvf);
104 });
105 }
106 }
107
108 const Problem& problem() const
109 { return *problemPtr_; }
110
111 // access operator
112 const FluxVariablesCache& cache(std::size_t eIdx, std::size_t scvfIdx) const
113 { return fluxVarsCache_[eIdx][scvfIdx]; }
114
115 // access operator
116 FluxVariablesCache& cache(std::size_t eIdx, std::size_t scvfIdx)
117 { return fluxVarsCache_[eIdx][scvfIdx]; }
118
119private:
120 // currently bound element
121 const Problem* problemPtr_;
122 std::vector<std::vector<FluxVariablesCache>> fluxVarsCache_;
123};
124
129template<class P, class FVC, class Traits>
130class CVFEGridFluxVariablesCache<P, FVC, false, Traits>
131{
132 using Problem = typename Traits::Problem;
134
135public:
137 using FluxVariablesCache = typename Traits::FluxVariablesCache;
138
140 static constexpr bool cachingEnabled = false;
141
143 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
144
145 CVFEGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
146
147 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
148 void update(const GridGeometry& gridGeometry,
149 const GridVolumeVariables& gridVolVars,
150 const SolutionVector& sol,
151 bool forceUpdate = false) {}
152
153 const Problem& problem() const
154 { return *problemPtr_; }
155
156private:
157 const Problem* problemPtr_;
158};
159
160} // end namespace Dumux
161
162#endif
Free function to get the local view of a grid cache object.
Parallel for loop (multithreading)
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
void parallelFor(const std::size_t count, const FunctorType &functor)
A parallel for loop (multithreading)
Definition: parallel_for.hh:172
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
The flux variables caches for an element.
Definition: discretization/cvfe/elementfluxvariablescache.hh:43
Flux variable caches traits.
Definition: discretization/cvfe/gridfluxvariablescache.hh:41
P Problem
Definition: discretization/cvfe/gridfluxvariablescache.hh:42
FVC FluxVariablesCache
Definition: discretization/cvfe/gridfluxvariablescache.hh:43
Flux variable caches on a gridview.
Definition: discretization/cvfe/gridfluxvariablescache.hh:58
Flux variable caches on a gridview with grid caching enabled.
Definition: discretization/cvfe/gridfluxvariablescache.hh:67
FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx)
Definition: discretization/cvfe/gridfluxvariablescache.hh:116
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cvfe/gridfluxvariablescache.hh:73
const Problem & problem() const
Definition: discretization/cvfe/gridfluxvariablescache.hh:108
const FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx) const
Definition: discretization/cvfe/gridfluxvariablescache.hh:112
CVFEGridFluxVariablesCache(const Problem &problem)
Definition: discretization/cvfe/gridfluxvariablescache.hh:81
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cvfe/gridfluxvariablescache.hh:79
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/cvfe/gridfluxvariablescache.hh:84
Flux variable caches on a gridview with grid caching disabled.
Definition: discretization/cvfe/gridfluxvariablescache.hh:131
CVFEGridFluxVariablesCache(const Problem &problem)
Definition: discretization/cvfe/gridfluxvariablescache.hh:145
const Problem & problem() const
Definition: discretization/cvfe/gridfluxvariablescache.hh:153
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cvfe/gridfluxvariablescache.hh:143
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cvfe/gridfluxvariablescache.hh:137
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/cvfe/gridfluxvariablescache.hh:148
Global flux variable cache.