3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
cellcentered/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_CC_GRID_VOLUMEVARIABLES_HH
25#define DUMUX_DISCRETIZATION_CC_GRID_VOLUMEVARIABLES_HH
26
27#include <vector>
28#include <type_traits>
29
30// make the local view function available whenever we use this class
33
34namespace Dumux {
35
43template<class Traits, bool cachingEnabled = false>
45
47template<class Traits>
48class CCGridVolumeVariables<Traits, /*cachingEnabled*/true>
49{
51
52public:
54 using Problem = typename Traits::Problem;
55
57 using VolumeVariables = typename Traits::VolumeVariables;
58
60 static constexpr bool cachingEnabled = true;
61
63 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
64
65 CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
66
67 template<class GridGeometry, class SolutionVector>
68 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
69 {
70 const auto numScv = gridGeometry.numScv();
71 volumeVariables_.resize(numScv);
72
73 for (const auto& element : elements(gridGeometry.gridView()))
74 {
75 auto fvGeometry = localView(gridGeometry);
76 fvGeometry.bindElement(element);
77
78 for (auto&& scv : scvs(fvGeometry))
79 {
80 const auto elemSol = elementSolution(element, sol, gridGeometry);
81 volumeVariables_[scv.dofIndex()].update(elemSol, problem(), element, scv);
82 }
83 }
84 }
85
86 const VolumeVariables& volVars(const std::size_t scvIdx) const
87 { return volumeVariables_[scvIdx]; }
88
89 VolumeVariables& volVars(const std::size_t scvIdx)
90 { return volumeVariables_[scvIdx]; }
91
92 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
93 const VolumeVariables& volVars(const SubControlVolume& scv) const
94 { return volumeVariables_[scv.dofIndex()]; }
95
96 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
97 VolumeVariables& volVars(const SubControlVolume& scv)
98 { return volumeVariables_[scv.dofIndex()]; }
99
100 // required for compatibility with the box method
101 const VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) const
102 { return volumeVariables_[scvIdx]; }
103
104 // required for compatibility with the box method
105 VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx)
106 { return volumeVariables_[scvIdx]; }
107
109 const Problem& problem() const
110 { return *problemPtr_; }
111
112private:
113 const Problem* problemPtr_;
114 std::vector<VolumeVariables> volumeVariables_;
115};
116
117
119template<class Traits>
120class CCGridVolumeVariables<Traits, /*cachingEnabled*/false>
121{
123
124public:
126 using Problem = typename Traits::Problem;
127
129 using VolumeVariables = typename Traits::VolumeVariables;
130
132 static constexpr bool cachingEnabled = false;
133
135 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
136
137 CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
138
139 template<class GridGeometry, class SolutionVector>
140 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
141
143 const Problem& problem() const
144 { return *problemPtr_;}
145
146private:
147 const Problem* problemPtr_;
148};
149
150} // end namespace Dumux
151
152#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==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition: box/elementsolution.hh:115
Definition: adapt.hh:29
Base class for the grid volume variables.
Definition: cellcentered/gridvolumevariables.hh:44
specialization in case of storing the volume variables
Definition: cellcentered/gridvolumevariables.hh:49
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: cellcentered/gridvolumevariables.hh:68
VolumeVariables & volVars(const std::size_t scvIdx)
Definition: cellcentered/gridvolumevariables.hh:89
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cellcentered/gridvolumevariables.hh:63
VolumeVariables & volVars(const SubControlVolume &scv)
Definition: cellcentered/gridvolumevariables.hh:97
const Problem & problem() const
The problem we are solving.
Definition: cellcentered/gridvolumevariables.hh:109
const VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx) const
Definition: cellcentered/gridvolumevariables.hh:101
const VolumeVariables & volVars(const std::size_t scvIdx) const
Definition: cellcentered/gridvolumevariables.hh:86
typename Traits::Problem Problem
export the problem type
Definition: cellcentered/gridvolumevariables.hh:54
const VolumeVariables & volVars(const SubControlVolume &scv) const
Definition: cellcentered/gridvolumevariables.hh:93
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: cellcentered/gridvolumevariables.hh:57
CCGridVolumeVariables(const Problem &problem)
Definition: cellcentered/gridvolumevariables.hh:65
VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx)
Definition: cellcentered/gridvolumevariables.hh:105
Specialization when the current volume variables are not stored globally.
Definition: cellcentered/gridvolumevariables.hh:121
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: cellcentered/gridvolumevariables.hh:129
CCGridVolumeVariables(const Problem &problem)
Definition: cellcentered/gridvolumevariables.hh:137
typename Traits::Problem Problem
export the problem type
Definition: cellcentered/gridvolumevariables.hh:126
const Problem & problem() const
The problem we are solving.
Definition: cellcentered/gridvolumevariables.hh:143
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: cellcentered/gridvolumevariables.hh:140
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cellcentered/gridvolumevariables.hh:135
The local element solution class for cell-centered methods.