3.6-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
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
56template<class Traits, bool cachingEnabled = false>
58
60template<class Traits>
61class FaceCenteredStaggeredGridVolumeVariables<Traits, /*cachingEnabled*/true>
62{
64
65public:
67 using Problem = typename Traits::Problem;
68
70 using VolumeVariables = typename Traits::VolumeVariables;
71
73 static constexpr bool cachingEnabled = true;
74
76 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
77
78 FaceCenteredStaggeredGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
79
80 template<class GridGeometry, class SolutionVector>
81 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
82 {
83 volumeVariables_.resize(gridGeometry.numScv());
84 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx)
85 {
86 const auto element = gridGeometry.element(eIdx);
87 const auto fvGeometry = localView(gridGeometry).bindElement(element);
88 const auto elemSol = elementSolution(element, sol, gridGeometry);
89
90 for (const auto& scv : scvs(fvGeometry))
91 volumeVariables_[scv.index()].update(elemSol, problem, element, scv);
92 });
93 }
94
95 const VolumeVariables& volVars(const std::size_t scvIdx) const
96 { return volumeVariables_[scvIdx]; }
97
98 VolumeVariables& volVars(const std::size_t scvIdx)
99 { return volumeVariables_[scvIdx]; }
100
101 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
102 const VolumeVariables& volVars(const SubControlVolume scv) const
103 { return volumeVariables_[scv.index()]; }
104
105 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
106 VolumeVariables& volVars(const SubControlVolume scv)
107 { return volumeVariables_[scv.index()]; }
108
109 // required for compatibility with the box method
110 const VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) const
111 { return volumeVariables_[scvIdx]; }
112
113 // required for compatibility with the box method
114 VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx)
115 { return volumeVariables_[scvIdx]; }
116
118 const Problem& problem() const
119 { return *problemPtr_; }
120
121private:
122 const Problem* problemPtr_;
123 std::vector<VolumeVariables> volumeVariables_;
124};
125
126
128template<class Traits>
129class FaceCenteredStaggeredGridVolumeVariables<Traits, /*cachingEnabled*/false>
130{
132
133public:
135 using Problem = typename Traits::Problem;
136
138 using VolumeVariables = typename Traits::VolumeVariables;
139
141 static constexpr bool cachingEnabled = false;
142
144 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
145
146 FaceCenteredStaggeredGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
147
148 template<class GridGeometry, class SolutionVector>
149 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
150
152 const Problem& problem() const
153 { return *problemPtr_;}
154
155private:
156 const Problem* problemPtr_;
157};
158
159} // end namespace Dumux
160
161#endif
Parallel for loop (multithreading)
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
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
Base class for the face variables vector.
Definition: facecentered/staggered/elementvolumevariables.hh:41
Definition: facecentered/staggered/gridvolumevariables.hh:41
P Problem
Definition: facecentered/staggered/gridvolumevariables.hh:42
VV VolumeVariables
Definition: facecentered/staggered/gridvolumevariables.hh:43
Base class for the grid volume variables.
Definition: facecentered/staggered/gridvolumevariables.hh:57
specialization in case of storing the volume variables
Definition: facecentered/staggered/gridvolumevariables.hh:62
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: facecentered/staggered/gridvolumevariables.hh:81
FaceCenteredStaggeredGridVolumeVariables(const Problem &problem)
Definition: facecentered/staggered/gridvolumevariables.hh:78
VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx)
Definition: facecentered/staggered/gridvolumevariables.hh:114
const VolumeVariables & volVars(const std::size_t scvIdx) const
Definition: facecentered/staggered/gridvolumevariables.hh:95
typename Traits::Problem Problem
export the problem type
Definition: facecentered/staggered/gridvolumevariables.hh:67
const VolumeVariables & volVars(const SubControlVolume scv) const
Definition: facecentered/staggered/gridvolumevariables.hh:102
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: facecentered/staggered/gridvolumevariables.hh:70
VolumeVariables & volVars(const SubControlVolume scv)
Definition: facecentered/staggered/gridvolumevariables.hh:106
VolumeVariables & volVars(const std::size_t scvIdx)
Definition: facecentered/staggered/gridvolumevariables.hh:98
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: facecentered/staggered/gridvolumevariables.hh:76
const Problem & problem() const
The problem we are solving.
Definition: facecentered/staggered/gridvolumevariables.hh:118
const VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx) const
Definition: facecentered/staggered/gridvolumevariables.hh:110
Specialization when the current volume variables are not stored globally.
Definition: facecentered/staggered/gridvolumevariables.hh:130
FaceCenteredStaggeredGridVolumeVariables(const Problem &problem)
Definition: facecentered/staggered/gridvolumevariables.hh:146
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: facecentered/staggered/gridvolumevariables.hh:138
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: facecentered/staggered/gridvolumevariables.hh:144
typename Traits::Problem Problem
export the problem type
Definition: facecentered/staggered/gridvolumevariables.hh:135
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: facecentered/staggered/gridvolumevariables.hh:149
const Problem & problem() const
The problem we are solving.
Definition: facecentered/staggered/gridvolumevariables.hh:152