Line | Branch | Exec | Source |
---|---|---|---|
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 | // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup CCDiscretization | ||
10 | * \brief The grid volume variables class for cell centered models | ||
11 | */ | ||
12 | #ifndef DUMUX_DISCRETIZATION_CC_GRID_VOLUMEVARIABLES_HH | ||
13 | #define DUMUX_DISCRETIZATION_CC_GRID_VOLUMEVARIABLES_HH | ||
14 | |||
15 | #include <vector> | ||
16 | #include <type_traits> | ||
17 | |||
18 | #include <dumux/parallel/parallel_for.hh> | ||
19 | |||
20 | // make the local view function available whenever we use this class | ||
21 | #include <dumux/discretization/localview.hh> | ||
22 | #include <dumux/discretization/cellcentered/elementsolution.hh> | ||
23 | |||
24 | namespace Dumux { | ||
25 | |||
26 | /*! | ||
27 | * \ingroup CCDiscretization | ||
28 | * \brief Base class for the grid volume variables | ||
29 | * \note This class has a cached version and a non-cached version | ||
30 | * \tparam Traits the traits class injecting the problem, volVar and elemVolVars type | ||
31 | * \tparam cachingEnabled if the cache is enabled | ||
32 | */ | ||
33 | template<class Traits, bool cachingEnabled = false> | ||
34 | class CCGridVolumeVariables {}; | ||
35 | |||
36 | //! specialization in case of storing the volume variables | ||
37 | template<class Traits> | ||
38 |
4/7✓ Branch 2 taken 2400 times.
✓ Branch 3 taken 1064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 483 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 346 times.
✗ Branch 9 not taken.
|
4097 | class CCGridVolumeVariables<Traits, /*cachingEnabled*/true> |
39 | { | ||
40 | using ThisType = CCGridVolumeVariables<Traits, true>; | ||
41 | |||
42 | public: | ||
43 | //! export the problem type | ||
44 | using Problem = typename Traits::Problem; | ||
45 | |||
46 | //! export the volume variables type | ||
47 | using VolumeVariables = typename Traits::VolumeVariables; | ||
48 | |||
49 | //! make it possible to query if caching is enabled | ||
50 | static constexpr bool cachingEnabled = true; | ||
51 | |||
52 | //! export the type of the local view | ||
53 | using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>; | ||
54 | |||
55 |
0/24✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
60 | CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {} |
56 | |||
57 | template<class GridGeometry, class SolutionVector> | ||
58 | 13515 | void update(const GridGeometry& gridGeometry, const SolutionVector& sol) | |
59 | { | ||
60 | 27030 | volumeVariables_.resize(gridGeometry.numScv()); | |
61 | 66529149 | Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx) | |
62 | { | ||
63 | 34092664 | const auto element = gridGeometry.element(eIdx); | |
64 |
4/10✓ Branch 1 taken 2384062 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2384062 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2384062 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2384062 times.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
70569390 | const auto fvGeometry = localView(gridGeometry).bindElement(element); |
65 |
12/12✓ Branch 0 taken 17948200 times.
✓ Branch 1 taken 17948200 times.
✓ Branch 2 taken 17948200 times.
✓ Branch 3 taken 17948200 times.
✓ Branch 5 taken 14544464 times.
✓ Branch 6 taken 12160402 times.
✓ Branch 7 taken 12160402 times.
✓ Branch 8 taken 12160402 times.
✓ Branch 10 taken 1600000 times.
✓ Branch 11 taken 1600000 times.
✓ Branch 12 taken 1600000 times.
✓ Branch 13 taken 1600000 times.
|
100442565 | for (const auto& scv : scvs(fvGeometry)) |
66 | { | ||
67 |
1/2✓ Branch 1 taken 2384062 times.
✗ Branch 2 not taken.
|
31708602 | const auto elemSol = elementSolution(element, sol, gridGeometry); |
68 |
3/6✓ Branch 1 taken 2384062 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2384062 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2384062 times.
✗ Branch 8 not taken.
|
95305806 | volumeVariables_[scv.dofIndex()].update(elemSol, problem, element, scv); |
69 | } | ||
70 | }); | ||
71 | 13515 | } | |
72 | |||
73 | const VolumeVariables& volVars(const std::size_t scvIdx) const | ||
74 | 14770018338 | { return volumeVariables_[scvIdx]; } | |
75 | |||
76 | VolumeVariables& volVars(const std::size_t scvIdx) | ||
77 | { return volumeVariables_[scvIdx]; } | ||
78 | |||
79 | template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0> | ||
80 | const VolumeVariables& volVars(const SubControlVolume& scv) const | ||
81 | { return volumeVariables_[scv.dofIndex()]; } | ||
82 | |||
83 | template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0> | ||
84 | VolumeVariables& volVars(const SubControlVolume& scv) | ||
85 |
20/29✓ Branch 1 taken 2392180 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2392180 times.
✓ Branch 5 taken 19968 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2392180 times.
✓ Branch 8 taken 19968 times.
✓ Branch 9 taken 294528 times.
✓ Branch 10 taken 2392180 times.
✓ Branch 11 taken 19968 times.
✓ Branch 12 taken 294528 times.
✓ Branch 13 taken 1392 times.
✓ Branch 14 taken 19968 times.
✓ Branch 15 taken 294528 times.
✓ Branch 16 taken 1392 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 294528 times.
✓ Branch 19 taken 1392 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1392 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 2363892 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 2363892 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 2363892 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 2363892 times.
✗ Branch 35 not taken.
|
194815848 | { return volumeVariables_[scv.dofIndex()]; } |
86 | |||
87 | // required for compatibility with the box method | ||
88 | const VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) const | ||
89 | { return volumeVariables_[scvIdx]; } | ||
90 | |||
91 | // required for compatibility with the box method | ||
92 | VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) | ||
93 | { return volumeVariables_[scvIdx]; } | ||
94 | |||
95 | //! The problem we are solving | ||
96 | ✗ | const Problem& problem() const | |
97 | ✗ | { return *problemPtr_; } | |
98 | |||
99 | private: | ||
100 | const Problem* problemPtr_; | ||
101 | std::vector<VolumeVariables> volumeVariables_; | ||
102 | }; | ||
103 | |||
104 | |||
105 | //! Specialization when the current volume variables are not stored globally | ||
106 | template<class Traits> | ||
107 | class CCGridVolumeVariables<Traits, /*cachingEnabled*/false> | ||
108 | { | ||
109 | using ThisType = CCGridVolumeVariables<Traits, false>; | ||
110 | |||
111 | public: | ||
112 | //! export the problem type | ||
113 | using Problem = typename Traits::Problem; | ||
114 | |||
115 | //! export the volume variables type | ||
116 | using VolumeVariables = typename Traits::VolumeVariables; | ||
117 | |||
118 | //! make it possible to query if caching is enabled | ||
119 | static constexpr bool cachingEnabled = false; | ||
120 | |||
121 | //! export the type of the local view | ||
122 | using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>; | ||
123 | |||
124 |
2/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
6 | CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {} |
125 | |||
126 | template<class GridGeometry, class SolutionVector> | ||
127 | ✗ | void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {} | |
128 | |||
129 | //! The problem we are solving | ||
130 | ✗ | const Problem& problem() const | |
131 | ✗ | { return *problemPtr_;} | |
132 | |||
133 | private: | ||
134 | const Problem* problemPtr_; | ||
135 | }; | ||
136 | |||
137 | } // end namespace Dumux | ||
138 | |||
139 | #endif | ||
140 |