3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * 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_FACECENTERED_STAGGERED_GRID_FLUXVARSCACHE_HH
25#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_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, class FVCF>
41{
42 using Problem = P;
43 using FluxVariablesCache = FVC;
45
46 template<class GridFluxVariablesCache, bool cachingEnabled>
48};
49
55template<class Problem,
56 class FluxVariablesCache,
57 class FluxVariablesCacheFiller,
58 bool cachingEnabled = false,
61
67template<class P, class FVC, class FVCF, class Traits>
68class FaceCenteredStaggeredGridFluxVariablesCache<P, FVC, FVCF, true, Traits>
69{
70 using Problem = typename Traits::Problem;
72 using FluxVariablesCacheFiller = typename Traits::FluxVariablesCacheFiller;
73
74public:
76 using FluxVariablesCache = typename Traits::FluxVariablesCache;
77
79 static constexpr bool cachingEnabled = true;
80
82 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
83
84 FaceCenteredStaggeredGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
85
86 // When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
87 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
88 void update(const GridGeometry& gridGeometry,
89 const GridVolumeVariables& gridVolVars,
90 const SolutionVector& sol,
91 bool forceUpdate = false)
92 {
93 // only do the update if fluxes are solution dependent or if update is forced
94 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
95 {
96 // instantiate helper class to fill the caches
97 FluxVariablesCacheFiller filler(problem());
98
99 fluxVarsCache_.resize(gridGeometry.numScvf());
100
101 Dumux::parallelFor(gridGeometry.gridView().size(0), [&](const std::size_t eIdx)
102 {
103 // Prepare the geometries within the elements of the stencil
104 const auto element = gridGeometry.element(eIdx);
105 const auto fvGeometry = localView(gridGeometry).bind(element);
106 const auto elemVolVars = localView(gridVolVars).bind(element, fvGeometry, sol);
107
108 for (auto&& scvf : scvfs(fvGeometry))
109 {
110 filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate);
111 }
112 });
113 }
114 }
115
116 const Problem& problem() const
117 { return *problemPtr_; }
118
119 template<class SubControlVolumeFace>
120 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
121 { return fluxVarsCache_[scvf.index()]; }
122
123 template<class SubControlVolumeFace>
124 FluxVariablesCache& operator [](const SubControlVolumeFace& scvf)
125 { return fluxVarsCache_[scvf.index()]; }
126
127private:
128 // currently bound element
129 const Problem* problemPtr_;
130 std::vector<FluxVariablesCache> fluxVarsCache_;
131};
132
137template<class P, class FVC, class FVCF, class Traits>
138class FaceCenteredStaggeredGridFluxVariablesCache<P, FVC, FVCF, false, Traits>
139{
140 using Problem = typename Traits::Problem;
142
143public:
145 using FluxVariablesCache = typename Traits::FluxVariablesCache;
146
148 static constexpr bool cachingEnabled = false;
149
151 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
152
153 FaceCenteredStaggeredGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
154
155 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
156 void update(const GridGeometry& gridGeometry,
157 const GridVolumeVariables& gridVolVars,
158 const SolutionVector& sol,
159 bool forceUpdate = false) {}
160
161 const Problem& problem() const
162 { return *problemPtr_; }
163
164private:
165 const Problem* problemPtr_;
166};
167
168} // end namespace Dumux
169
170#endif
Parallel for loop (multithreading)
Free function to get the local view of a grid cache object.
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/facecentered/staggered/elementfluxvariablescache.hh:42
Flux variable caches traits.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:41
FVCF FluxVariablesCacheFiller
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:44
P Problem
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:42
FVC FluxVariablesCache
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:43
Flux variable caches on a gridview.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:60
Flux variable caches on a gridview with grid caching enabled.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:69
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:76
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:82
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:88
const Problem & problem() const
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:116
FaceCenteredStaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:84
Flux variable caches on a gridview with grid caching disabled.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:139
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:145
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:156
const Problem & problem() const
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:161
FaceCenteredStaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:153
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:151
Global flux variable cache.