3.5-git
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 auto fvGeometry = localView(gridGeometry);
73 for (const auto& element : elements(gridGeometry.gridView()))
74 {
75 fvGeometry.bindElement(element);
76 for (auto&& scv : scvs(fvGeometry))
77 {
78 const auto elemSol = elementSolution(element, sol, gridGeometry);
79 volumeVariables_[scv.dofIndex()].update(elemSol, problem(), element, scv);
80 }
81 }
82 }
83
84 const VolumeVariables& volVars(const std::size_t scvIdx) const
85 { return volumeVariables_[scvIdx]; }
86
87 VolumeVariables& volVars(const std::size_t scvIdx)
88 { return volumeVariables_[scvIdx]; }
89
90 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
91 const VolumeVariables& volVars(const SubControlVolume& scv) const
92 { return volumeVariables_[scv.dofIndex()]; }
93
94 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
95 VolumeVariables& volVars(const SubControlVolume& scv)
96 { return volumeVariables_[scv.dofIndex()]; }
97
98 // required for compatibility with the box method
99 const VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) const
100 { return volumeVariables_[scvIdx]; }
101
102 // required for compatibility with the box method
103 VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx)
104 { return volumeVariables_[scvIdx]; }
105
107 const Problem& problem() const
108 { return *problemPtr_; }
109
110private:
111 const Problem* problemPtr_;
112 std::vector<VolumeVariables> volumeVariables_;
113};
114
115
117template<class Traits>
118class CCGridVolumeVariables<Traits, /*cachingEnabled*/false>
119{
121
122public:
124 using Problem = typename Traits::Problem;
125
127 using VolumeVariables = typename Traits::VolumeVariables;
128
130 static constexpr bool cachingEnabled = false;
131
133 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
134
135 CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
136
137 template<class GridGeometry, class SolutionVector>
138 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
139
141 const Problem& problem() const
142 { return *problemPtr_;}
143
144private:
145 const Problem* problemPtr_;
146};
147
148} // end namespace Dumux
149
150#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 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:87
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:95
const Problem & problem() const
The problem we are solving.
Definition: cellcentered/gridvolumevariables.hh:107
const VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx) const
Definition: cellcentered/gridvolumevariables.hh:99
const VolumeVariables & volVars(const std::size_t scvIdx) const
Definition: cellcentered/gridvolumevariables.hh:84
typename Traits::Problem Problem
export the problem type
Definition: cellcentered/gridvolumevariables.hh:54
const VolumeVariables & volVars(const SubControlVolume &scv) const
Definition: cellcentered/gridvolumevariables.hh:91
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:103
Specialization when the current volume variables are not stored globally.
Definition: cellcentered/gridvolumevariables.hh:119
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: cellcentered/gridvolumevariables.hh:127
CCGridVolumeVariables(const Problem &problem)
Definition: cellcentered/gridvolumevariables.hh:135
typename Traits::Problem Problem
export the problem type
Definition: cellcentered/gridvolumevariables.hh:124
const Problem & problem() const
The problem we are solving.
Definition: cellcentered/gridvolumevariables.hh:141
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: cellcentered/gridvolumevariables.hh:138
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cellcentered/gridvolumevariables.hh:133
The local element solution class for cell-centered methods.