3.6-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
31
32// make the local view function available whenever we use this class
35
36namespace Dumux {
37
45template<class Traits, bool cachingEnabled = false>
47
49template<class Traits>
50class CCGridVolumeVariables<Traits, /*cachingEnabled*/true>
51{
53
54public:
56 using Problem = typename Traits::Problem;
57
59 using VolumeVariables = typename Traits::VolumeVariables;
60
62 static constexpr bool cachingEnabled = true;
63
65 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
66
67 CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
68
69 template<class GridGeometry, class SolutionVector>
70 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
71 {
72 volumeVariables_.resize(gridGeometry.numScv());
73 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx)
74 {
75 const auto element = gridGeometry.element(eIdx);
76 const auto fvGeometry = localView(gridGeometry).bindElement(element);
77 for (const auto& scv : scvs(fvGeometry))
78 {
79 const auto elemSol = elementSolution(element, sol, gridGeometry);
80 volumeVariables_[scv.dofIndex()].update(elemSol, problem, element, scv);
81 }
82 });
83 }
84
85 const VolumeVariables& volVars(const std::size_t scvIdx) const
86 { return volumeVariables_[scvIdx]; }
87
88 VolumeVariables& volVars(const std::size_t scvIdx)
89 { return volumeVariables_[scvIdx]; }
90
91 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
92 const VolumeVariables& volVars(const SubControlVolume& scv) const
93 { return volumeVariables_[scv.dofIndex()]; }
94
95 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
96 VolumeVariables& volVars(const SubControlVolume& scv)
97 { return volumeVariables_[scv.dofIndex()]; }
98
99 // required for compatibility with the box method
100 const VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) const
101 { return volumeVariables_[scvIdx]; }
102
103 // required for compatibility with the box method
104 VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx)
105 { return volumeVariables_[scvIdx]; }
106
108 const Problem& problem() const
109 { return *problemPtr_; }
110
111private:
112 const Problem* problemPtr_;
113 std::vector<VolumeVariables> volumeVariables_;
114};
115
116
118template<class Traits>
119class CCGridVolumeVariables<Traits, /*cachingEnabled*/false>
120{
122
123public:
125 using Problem = typename Traits::Problem;
126
128 using VolumeVariables = typename Traits::VolumeVariables;
129
131 static constexpr bool cachingEnabled = false;
132
134 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
135
136 CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
137
138 template<class GridGeometry, class SolutionVector>
139 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
140
142 const Problem& problem() const
143 { return *problemPtr_;}
144
145private:
146 const Problem* problemPtr_;
147};
148
149} // end namespace Dumux
150
151#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
Base class for the grid volume variables.
Definition: cellcentered/gridvolumevariables.hh:46
specialization in case of storing the volume variables
Definition: cellcentered/gridvolumevariables.hh:51
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: cellcentered/gridvolumevariables.hh:70
VolumeVariables & volVars(const std::size_t scvIdx)
Definition: cellcentered/gridvolumevariables.hh:88
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cellcentered/gridvolumevariables.hh:65
VolumeVariables & volVars(const SubControlVolume &scv)
Definition: cellcentered/gridvolumevariables.hh:96
const Problem & problem() const
The problem we are solving.
Definition: cellcentered/gridvolumevariables.hh:108
const VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx) const
Definition: cellcentered/gridvolumevariables.hh:100
const VolumeVariables & volVars(const std::size_t scvIdx) const
Definition: cellcentered/gridvolumevariables.hh:85
typename Traits::Problem Problem
export the problem type
Definition: cellcentered/gridvolumevariables.hh:56
const VolumeVariables & volVars(const SubControlVolume &scv) const
Definition: cellcentered/gridvolumevariables.hh:92
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: cellcentered/gridvolumevariables.hh:59
CCGridVolumeVariables(const Problem &problem)
Definition: cellcentered/gridvolumevariables.hh:67
VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx)
Definition: cellcentered/gridvolumevariables.hh:104
Specialization when the current volume variables are not stored globally.
Definition: cellcentered/gridvolumevariables.hh:120
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: cellcentered/gridvolumevariables.hh:128
CCGridVolumeVariables(const Problem &problem)
Definition: cellcentered/gridvolumevariables.hh:136
typename Traits::Problem Problem
export the problem type
Definition: cellcentered/gridvolumevariables.hh:125
const Problem & problem() const
The problem we are solving.
Definition: cellcentered/gridvolumevariables.hh:142
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: cellcentered/gridvolumevariables.hh:139
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cellcentered/gridvolumevariables.hh:134
The local element solution class for cell-centered methods.