3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
cvfe/elementvolumevariables.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_ELEMENT_VOLUMEVARIABLES_HH
25#define DUMUX_DISCRETIZATION_CVFE_ELEMENT_VOLUMEVARIABLES_HH
26
27#include <type_traits>
28#include <utility>
29#include <vector>
30
32
33namespace Dumux {
34
42template<class GVV, bool cachingEnabled>
44
50template<class GVV>
51class CVFEElementVolumeVariables<GVV, /*cachingEnabled*/true>
52{
53public:
56
58 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
59
62 : gridVolVarsPtr_(&gridVolVars) {}
63
64 const VolumeVariables& operator [](std::size_t scvIdx) const
65 { return gridVolVars().volVars(eIdx_, scvIdx); }
66
67 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
68 const VolumeVariables& operator [](const SubControlVolume& scv) const
69 { return gridVolVars().volVars(eIdx_, scv.indexInElement()); }
70
76 template<class FVElementGeometry, class SolutionVector>
77 CVFEElementVolumeVariables bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
78 const FVElementGeometry& fvGeometry,
79 const SolutionVector& sol) &&
80 {
81 this->bindElement(element, fvGeometry, sol);
82 return std::move(*this);
83 }
84
85 // For compatibility reasons with the case of not storing the vol vars.
86 // function to be called before assembling an element, preparing the vol vars within the stencil
87 template<class FVElementGeometry, class SolutionVector>
88 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
89 const FVElementGeometry& fvGeometry,
90 const SolutionVector& sol) &
91 {
92 bindElement(element, fvGeometry, sol);
93 }
94
100 template<class FVElementGeometry, class SolutionVector>
101 CVFEElementVolumeVariables bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
102 const FVElementGeometry& fvGeometry,
103 const SolutionVector& sol) &&
104 {
105 this->bindElement(element, fvGeometry, sol);
106 return std::move(*this);
107 }
108
109 // function to prepare the vol vars within the element
110 template<class FVElementGeometry, class SolutionVector>
111 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
112 const FVElementGeometry& fvGeometry,
113 const SolutionVector& sol) &
114 {
115 eIdx_ = fvGeometry.gridGeometry().elementMapper().index(element);
116 }
117
120 { return *gridVolVarsPtr_; }
121
122private:
123 const GridVolumeVariables* gridVolVarsPtr_;
124 std::size_t eIdx_;
125};
126
127
132template<class GVV>
133class CVFEElementVolumeVariables<GVV, /*cachingEnabled*/false>
134{
135public:
138
140 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
141
144 : gridVolVarsPtr_(&gridVolVars) {}
145
151 template<class FVElementGeometry, class SolutionVector>
152 CVFEElementVolumeVariables bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
153 const FVElementGeometry& fvGeometry,
154 const SolutionVector& sol) &&
155 {
156 this->bindElement(element, fvGeometry, sol);
157 return std::move(*this);
158 }
159
160 // specialization for control-volume finite element, simply forwards to the bindElement method
161 template<class FVElementGeometry, class SolutionVector>
162 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
163 const FVElementGeometry& fvGeometry,
164 const SolutionVector& sol) &
165 {
166 bindElement(element, fvGeometry, sol);
167 }
168
174 template<class FVElementGeometry, class SolutionVector>
175 CVFEElementVolumeVariables bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
176 const FVElementGeometry& fvGeometry,
177 const SolutionVector& sol) &&
178 {
179 this->bindElement(element, fvGeometry, sol);
180 return std::move(*this);
181 }
182
183 // specialization for control-volume finite element
184 template<class FVElementGeometry, class SolutionVector>
185 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
186 const FVElementGeometry& fvGeometry,
187 const SolutionVector& sol) &
188 {
189 // get the solution at the dofs of the element
190 auto elemSol = elementSolution(element, sol, fvGeometry.gridGeometry());
191
192 // resize volume variables to the required size
193 volumeVariables_.resize(fvGeometry.numScv());
194 for (auto&& scv : scvs(fvGeometry))
195 volumeVariables_[scv.indexInElement()].update(elemSol, gridVolVars().problem(), element, scv);
196 }
197
198 const VolumeVariables& operator [](std::size_t scvIdx) const
199 { return volumeVariables_[scvIdx]; }
200
201 VolumeVariables& operator [](std::size_t scvIdx)
202 { return volumeVariables_[scvIdx]; }
203
204 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
205 const VolumeVariables& operator [](const SubControlVolume& scv) const
206 { return volumeVariables_[scv.indexInElement()]; }
207
208 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
209 VolumeVariables& operator [](const SubControlVolume& scv)
210 { return volumeVariables_[scv.indexInElement()]; }
211
214 { return *gridVolVarsPtr_; }
215
216private:
217 const GridVolumeVariables* gridVolVarsPtr_;
218 std::vector<VolumeVariables> volumeVariables_;
219};
220
221} // end namespace Dumux
222
223#endif
Element solution classes and factory functions.
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethods::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition: box/elementsolution.hh:118
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
The local (stencil) volume variables class for control-volume finite element.
Definition: cvfe/elementvolumevariables.hh:43
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition: cvfe/elementvolumevariables.hh:88
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition: cvfe/elementvolumevariables.hh:111
CVFEElementVolumeVariables(const GridVolumeVariables &gridVolVars)
Constructor.
Definition: cvfe/elementvolumevariables.hh:61
const GridVolumeVariables & gridVolVars() const
The global volume variables object we are a restriction of.
Definition: cvfe/elementvolumevariables.hh:119
CVFEElementVolumeVariables bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: cvfe/elementvolumevariables.hh:77
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition: cvfe/elementvolumevariables.hh:58
GVV GridVolumeVariables
export type of the grid volume variables
Definition: cvfe/elementvolumevariables.hh:55
CVFEElementVolumeVariables bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: cvfe/elementvolumevariables.hh:101
CVFEElementVolumeVariables bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: cvfe/elementvolumevariables.hh:152
GVV GridVolumeVariables
export type of the grid volume variables
Definition: cvfe/elementvolumevariables.hh:137
const GridVolumeVariables & gridVolVars() const
The global volume variables object we are a restriction of.
Definition: cvfe/elementvolumevariables.hh:213
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition: cvfe/elementvolumevariables.hh:162
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition: cvfe/elementvolumevariables.hh:140
CVFEElementVolumeVariables(const GridVolumeVariables &gridVolVars)
Constructor.
Definition: cvfe/elementvolumevariables.hh:143
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &
Definition: cvfe/elementvolumevariables.hh:185
CVFEElementVolumeVariables bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const SolutionVector &sol) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: cvfe/elementvolumevariables.hh:175