3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
cvfe/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_CVFE_GRID_VOLUMEVARIABLES_HH
25#define DUMUX_DISCRETIZATION_CVFE_GRID_VOLUMEVARIABLES_HH
26
27#include <vector>
28#include <type_traits>
29
31
32// make the local view function available whenever we use this class
36
37namespace Dumux {
38
39template<class P, class VV>
41{
42 using Problem = P;
43 using VolumeVariables = VV;
44
45 template<class GridVolumeVariables, bool cachingEnabled>
47};
48
53template<class Traits, bool enableCaching>
55
56// specialization in case of storing the volume variables
57template<class Traits>
58class CVFEGridVolumeVariables<Traits, /*cachingEnabled*/true>
59{
61
62public:
64 using Problem = typename Traits::Problem;
65
67 using VolumeVariables = typename Traits::VolumeVariables;
68
70 static constexpr bool cachingEnabled = true;
71
73 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
74
75 CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
76
77 template<class GridGeometry, class SolutionVector>
78 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
79 {
80 volumeVariables_.resize(gridGeometry.gridView().size(0));
81 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx)
82 {
83 const auto element = gridGeometry.element(eIdx);
84 const auto fvGeometry = localView(gridGeometry).bindElement(element);
85
86 // get the element solution
87 auto elemSol = elementSolution(element, sol, gridGeometry);
88
89 // update the volvars of the element
90 volumeVariables_[eIdx].resize(fvGeometry.numScv());
91 for (const auto& scv : scvs(fvGeometry))
92 volumeVariables_[eIdx][scv.indexInElement()].update(elemSol, problem, element, scv);
93 });
94 }
95
96 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
97 const VolumeVariables& volVars(const SubControlVolume& scv) const
98 { return volumeVariables_[scv.elementIndex()][scv.indexInElement()]; }
99
100 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
101 VolumeVariables& volVars(const SubControlVolume& scv)
102 { return volumeVariables_[scv.elementIndex()][scv.indexInElement()]; }
103
104 const VolumeVariables& volVars(const std::size_t eIdx, const std::size_t scvIdx) const
105 { return volumeVariables_[eIdx][scvIdx]; }
106
107 VolumeVariables& volVars(const std::size_t eIdx, const std::size_t scvIdx)
108 { return volumeVariables_[eIdx][scvIdx]; }
109
110 const Problem& problem() const
111 { return *problemPtr_; }
112
113private:
114 const Problem* problemPtr_;
115 std::vector<std::vector<VolumeVariables>> volumeVariables_;
116};
117
118
119// Specialization when the current volume variables are not stored
120template<class Traits>
121class CVFEGridVolumeVariables<Traits, /*cachingEnabled*/false>
122{
124
125public:
127 using Problem = typename Traits::Problem;
128
130 using VolumeVariables = typename Traits::VolumeVariables;
131
133 static constexpr bool cachingEnabled = false;
134
136 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
137
138 CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
139
140 template<class GridGeometry, class SolutionVector>
141 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
142
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.
Parallel for loop (multithreading)
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
void parallelFor(const std::size_t count, const FunctorType &functor)
A parallel for loop (multithreading)
Definition: parallel_for.hh:172
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
Definition: cvfe/gridvolumevariables.hh:41
VV VolumeVariables
Definition: cvfe/gridvolumevariables.hh:43
P Problem
Definition: cvfe/gridvolumevariables.hh:42
Base class for the grid volume variables.
Definition: cvfe/gridvolumevariables.hh:54
Definition: cvfe/gridvolumevariables.hh:59
CVFEGridVolumeVariables(const Problem &problem)
Definition: cvfe/gridvolumevariables.hh:75
const VolumeVariables & volVars(const std::size_t eIdx, const std::size_t scvIdx) const
Definition: cvfe/gridvolumevariables.hh:104
VolumeVariables & volVars(const std::size_t eIdx, const std::size_t scvIdx)
Definition: cvfe/gridvolumevariables.hh:107
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: cvfe/gridvolumevariables.hh:67
const Problem & problem() const
Definition: cvfe/gridvolumevariables.hh:110
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: cvfe/gridvolumevariables.hh:78
typename Traits::Problem Problem
export the problem type
Definition: cvfe/gridvolumevariables.hh:64
const VolumeVariables & volVars(const SubControlVolume &scv) const
Definition: cvfe/gridvolumevariables.hh:97
VolumeVariables & volVars(const SubControlVolume &scv)
Definition: cvfe/gridvolumevariables.hh:101
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cvfe/gridvolumevariables.hh:73
Definition: cvfe/gridvolumevariables.hh:122
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: cvfe/gridvolumevariables.hh:141
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: cvfe/gridvolumevariables.hh:130
typename Traits::Problem Problem
export the problem type
Definition: cvfe/gridvolumevariables.hh:127
CVFEGridVolumeVariables(const Problem &problem)
Definition: cvfe/gridvolumevariables.hh:138
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cvfe/gridvolumevariables.hh:136
const Problem & problem() const
Definition: cvfe/gridvolumevariables.hh:143
The local element solution class for the box method.
The local volume variables class.