3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
facecentered/staggered/gridvolumevariables.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_GRID_VOLUMEVARIABLES_HH
25#define DUMUX_DISCRETIZATION_FACECENTERED_GRID_VOLUMEVARIABLES_HH
26
27#include <vector>
28#include <type_traits>
29
30// make the local view function available whenever we use this class
34
35namespace Dumux {
36
37template<class P, class VV>
39{
40 using Problem = P;
41 using VolumeVariables = VV;
42
43 template<class GridVolumeVariables, bool cachingEnabled>
45};
46
54template<class Traits, bool cachingEnabled = false>
56
58template<class Traits>
59class FaceCenteredStaggeredGridVolumeVariables<Traits, /*cachingEnabled*/true>
60{
62
63public:
65 using Problem = typename Traits::Problem;
66
68 using VolumeVariables = typename Traits::VolumeVariables;
69
71 static constexpr bool cachingEnabled = true;
72
74 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
75
76 FaceCenteredStaggeredGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
77
78 template<class GridGeometry, class SolutionVector>
79 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
80 {
81 const auto numScv = gridGeometry.numScv();
82 volumeVariables_.resize(numScv);
83
84 for (const auto& element : elements(gridGeometry.gridView()))
85 {
86 auto fvGeometry = localView(gridGeometry);
87 fvGeometry.bindElement(element);
88
89 for (auto&& scv : scvs(fvGeometry))
90 {
91 const auto elemSol = elementSolution(element, sol, gridGeometry);
92 volumeVariables_[scv.index()].update(elemSol, problem(), element, scv);
93 }
94 }
95 }
96
97 const VolumeVariables& volVars(const std::size_t scvIdx) const
98 { return volumeVariables_[scvIdx]; }
99
100 VolumeVariables& volVars(const std::size_t scvIdx)
101 { return volumeVariables_[scvIdx]; }
102
103 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
104 const VolumeVariables& volVars(const SubControlVolume scv) const
105 { return volumeVariables_[scv.index()]; }
106
107 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
108 VolumeVariables& volVars(const SubControlVolume scv)
109 { return volumeVariables_[scv.index()]; }
110
111 // required for compatibility with the box method
112 const VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) const
113 { return volumeVariables_[scvIdx]; }
114
115 // required for compatibility with the box method
116 VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx)
117 { return volumeVariables_[scvIdx]; }
118
120 const Problem& problem() const
121 { return *problemPtr_; }
122
123private:
124 const Problem* problemPtr_;
125 std::vector<VolumeVariables> volumeVariables_;
126};
127
128
130template<class Traits>
131class FaceCenteredStaggeredGridVolumeVariables<Traits, /*cachingEnabled*/false>
132{
134
135public:
137 using Problem = typename Traits::Problem;
138
140 using VolumeVariables = typename Traits::VolumeVariables;
141
143 static constexpr bool cachingEnabled = false;
144
146 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
147
148 FaceCenteredStaggeredGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
149
150 template<class GridGeometry, class SolutionVector>
151 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
152
154 const Problem& problem() const
155 { return *problemPtr_;}
156
157private:
158 const Problem* problemPtr_;
159};
160
161} // end namespace Dumux
162
163#endif
Free function to get the local view of a grid cache object.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
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
Definition: adapt.hh:29
Base class for the face variables vector.
Definition: facecentered/staggered/elementvolumevariables.hh:41
Definition: facecentered/staggered/gridvolumevariables.hh:39
P Problem
Definition: facecentered/staggered/gridvolumevariables.hh:40
VV VolumeVariables
Definition: facecentered/staggered/gridvolumevariables.hh:41
Base class for the grid volume variables.
Definition: facecentered/staggered/gridvolumevariables.hh:55
specialization in case of storing the volume variables
Definition: facecentered/staggered/gridvolumevariables.hh:60
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: facecentered/staggered/gridvolumevariables.hh:79
FaceCenteredStaggeredGridVolumeVariables(const Problem &problem)
Definition: facecentered/staggered/gridvolumevariables.hh:76
VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx)
Definition: facecentered/staggered/gridvolumevariables.hh:116
const VolumeVariables & volVars(const std::size_t scvIdx) const
Definition: facecentered/staggered/gridvolumevariables.hh:97
typename Traits::Problem Problem
export the problem type
Definition: facecentered/staggered/gridvolumevariables.hh:65
const VolumeVariables & volVars(const SubControlVolume scv) const
Definition: facecentered/staggered/gridvolumevariables.hh:104
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: facecentered/staggered/gridvolumevariables.hh:68
VolumeVariables & volVars(const SubControlVolume scv)
Definition: facecentered/staggered/gridvolumevariables.hh:108
VolumeVariables & volVars(const std::size_t scvIdx)
Definition: facecentered/staggered/gridvolumevariables.hh:100
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: facecentered/staggered/gridvolumevariables.hh:74
const Problem & problem() const
The problem we are solving.
Definition: facecentered/staggered/gridvolumevariables.hh:120
const VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx) const
Definition: facecentered/staggered/gridvolumevariables.hh:112
Specialization when the current volume variables are not stored globally.
Definition: facecentered/staggered/gridvolumevariables.hh:132
FaceCenteredStaggeredGridVolumeVariables(const Problem &problem)
Definition: facecentered/staggered/gridvolumevariables.hh:148
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: facecentered/staggered/gridvolumevariables.hh:140
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: facecentered/staggered/gridvolumevariables.hh:146
typename Traits::Problem Problem
export the problem type
Definition: facecentered/staggered/gridvolumevariables.hh:137
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: facecentered/staggered/gridvolumevariables.hh:151
const Problem & problem() const
The problem we are solving.
Definition: facecentered/staggered/gridvolumevariables.hh:154