3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
box/elementfluxvariablescache.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_BOX_ELEMENT_FLUXVARSCACHE_HH
25#define DUMUX_DISCRETIZATION_BOX_ELEMENT_FLUXVARSCACHE_HH
26
27#include <cstddef>
28#include <vector>
29
30namespace Dumux {
31
40template<class GFVC, bool cachingEnabled>
42{};
43
48template<class GFVC>
50{
51public:
54
56 using FluxVariablesCache = typename GFVC::FluxVariablesCache;
57
59 : gridFluxVarsCachePtr_(&global) {}
60
61 // Function is called by the BoxLocalJacobian prior to flux calculations on the element.
62 // We assume the FVGeometries to be bound at this point
63 template<class FVElementGeometry, class ElementVolumeVariables>
64 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
65 const FVElementGeometry& fvGeometry,
66 const ElementVolumeVariables& elemVolVars)
67 {
68 bindElement(element, fvGeometry, elemVolVars);
69 }
70
71 template<class FVElementGeometry, class ElementVolumeVariables>
72 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
73 const FVElementGeometry& fvGeometry,
74 const ElementVolumeVariables& elemVolVars)
75 {
76 eIdx_ = fvGeometry.gridGeometry().elementMapper().index(element);
77 }
78
79 template<class FVElementGeometry, class ElementVolumeVariables>
80 void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
81 const FVElementGeometry& fvGeometry,
82 const ElementVolumeVariables& elemVolVars,
83 const typename FVElementGeometry::SubControlVolumeFace& scvf)
84 {
85 bindElement(element, fvGeometry, elemVolVars);
86 }
87
88 // access operator
89 template<class SubControlVolumeFace>
90 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
91 { return gridFluxVarsCache().cache(eIdx_, scvf.index()); }
92
95 { return *gridFluxVarsCachePtr_; }
96
97private:
98 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
99 std::size_t eIdx_;
100};
101
106template<class GFVC>
108{
109public:
112
114 using FluxVariablesCache = typename GFVC::FluxVariablesCache;
115
117 : gridFluxVarsCachePtr_(&global) {}
118
119 // Function is called by the BoxLocalJacobian prior to flux calculations on the element.
120 // We assume the FVGeometries to be bound at this point
121 template<class FVElementGeometry, class ElementVolumeVariables>
122 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
123 const FVElementGeometry& fvGeometry,
124 const ElementVolumeVariables& elemVolVars)
125 {
126 bindElement(element, fvGeometry, elemVolVars);
127 }
128
129 template<class FVElementGeometry, class ElementVolumeVariables>
130 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
131 const FVElementGeometry& fvGeometry,
132 const ElementVolumeVariables& elemVolVars)
133 {
134 // temporary resizing of the cache
135 fluxVarsCache_.resize(fvGeometry.numScvf());
136 for (auto&& scvf : scvfs(fvGeometry))
137 (*this)[scvf].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf);
138 }
139
140 template<class FVElementGeometry, class ElementVolumeVariables>
141 void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
142 const FVElementGeometry& fvGeometry,
143 const ElementVolumeVariables& elemVolVars,
144 const typename FVElementGeometry::SubControlVolumeFace& scvf)
145 {
146 fluxVarsCache_.resize(fvGeometry.numScvf());
147 (*this)[scvf].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf);
148 }
149
150 // access operator
151 template<class SubControlVolumeFace>
152 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
153 { return fluxVarsCache_[scvf.index()]; }
154
155 // access operator
156 template<class SubControlVolumeFace>
157 FluxVariablesCache& operator [](const SubControlVolumeFace& scvf)
158 { return fluxVarsCache_[scvf.index()]; }
159
162 { return *gridFluxVarsCachePtr_; }
163
164private:
165 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
166 std::vector<FluxVariablesCache> fluxVarsCache_;
167};
168
169} // end namespace Dumux
170
171#endif
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
The flux variables caches for an element.
Definition: box/elementfluxvariablescache.hh:42
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: box/elementfluxvariablescache.hh:72
typename GFVC::FluxVariablesCache FluxVariablesCache
export the type of the flux variables cache
Definition: box/elementfluxvariablescache.hh:56
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: box/elementfluxvariablescache.hh:64
BoxElementFluxVariablesCache(const GridFluxVariablesCache &global)
Definition: box/elementfluxvariablescache.hh:58
GFVC GridFluxVariablesCache
export the type of the grid flux variables cache
Definition: box/elementfluxvariablescache.hh:53
void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolumeFace &scvf)
Definition: box/elementfluxvariablescache.hh:80
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: box/elementfluxvariablescache.hh:94
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: box/elementfluxvariablescache.hh:161
void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolumeFace &scvf)
Definition: box/elementfluxvariablescache.hh:141
BoxElementFluxVariablesCache(const GridFluxVariablesCache &global)
Definition: box/elementfluxvariablescache.hh:116
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: box/elementfluxvariablescache.hh:130
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: box/elementfluxvariablescache.hh:122
GFVC GridFluxVariablesCache
export the type of the grid flux variables cache
Definition: box/elementfluxvariablescache.hh:111
typename GFVC::FluxVariablesCache FluxVariablesCache
export the type of the flux variables cache
Definition: box/elementfluxvariablescache.hh:114