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 CVFEDiscretization | ||
10 | * \brief The grid volume variables class for control-volume finite element methods | ||
11 | */ | ||
12 | #ifndef DUMUX_DISCRETIZATION_CVFE_GRID_VOLUMEVARIABLES_HH | ||
13 | #define DUMUX_DISCRETIZATION_CVFE_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/cvfe/elementvolumevariables.hh> | ||
23 | #include <dumux/discretization/cvfe/elementsolution.hh> | ||
24 | |||
25 | namespace Dumux { | ||
26 | |||
27 | template<class P, class VV> | ||
28 | struct CVFEDefaultGridVolumeVariablesTraits | ||
29 | { | ||
30 | using Problem = P; | ||
31 | using VolumeVariables = VV; | ||
32 | |||
33 | template<class GridVolumeVariables, bool cachingEnabled> | ||
34 | using LocalView = CVFEElementVolumeVariables<GridVolumeVariables, cachingEnabled>; | ||
35 | }; | ||
36 | |||
37 | /*! | ||
38 | * \ingroup CVFEDiscretization | ||
39 | * \brief Base class for the grid volume variables | ||
40 | */ | ||
41 | template<class Traits, bool enableCaching> | ||
42 | class CVFEGridVolumeVariables; | ||
43 | |||
44 | // specialization in case of storing the volume variables | ||
45 | template<class Traits> | ||
46 |
3/5✓ Branch 2 taken 550 times.
✓ Branch 3 taken 621 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1524 times.
✗ Branch 6 not taken.
|
2761 | class CVFEGridVolumeVariables<Traits, /*cachingEnabled*/true> |
47 | { | ||
48 | using ThisType = CVFEGridVolumeVariables<Traits, true>; | ||
49 | |||
50 | public: | ||
51 | //! export the problem type | ||
52 | using Problem = typename Traits::Problem; | ||
53 | |||
54 | //! export the volume variables type | ||
55 | using VolumeVariables = typename Traits::VolumeVariables; | ||
56 | |||
57 | //! make it possible to query if caching is enabled | ||
58 | static constexpr bool cachingEnabled = true; | ||
59 | |||
60 | //! export the type of the local view | ||
61 | using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>; | ||
62 | |||
63 | ✗ | CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {} | |
64 | |||
65 | template<class GridGeometry, class SolutionVector> | ||
66 | 10160 | void update(const GridGeometry& gridGeometry, const SolutionVector& sol) | |
67 | { | ||
68 | 20320 | volumeVariables_.resize(gridGeometry.gridView().size(0)); | |
69 | 12822102 | Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx) | |
70 | { | ||
71 | 9596049 | const auto element = gridGeometry.element(eIdx); | |
72 |
8/20✓ Branch 1 taken 2926118 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2926118 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2321818 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2321818 times.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 15 taken 31200 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 31200 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 31200 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 31200 times.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
22753716 | const auto fvGeometry = localView(gridGeometry).bindElement(element); |
73 | |||
74 | // get the element solution | ||
75 |
1/2✓ Branch 1 taken 2926118 times.
✗ Branch 2 not taken.
|
7243031 | auto elemSol = elementSolution(element, sol, gridGeometry); |
76 | |||
77 | // update the volvars of the element | ||
78 |
6/12✓ Branch 1 taken 2926118 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2926118 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2926118 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 31200 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 31200 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 31200 times.
✗ Branch 17 not taken.
|
21729093 | volumeVariables_[eIdx].resize(fvGeometry.numScv()); |
79 |
8/8✓ Branch 0 taken 24514758 times.
✓ Branch 1 taken 6672885 times.
✓ Branch 2 taken 24514758 times.
✓ Branch 3 taken 6672885 times.
✓ Branch 4 taken 2007428 times.
✓ Branch 5 taken 570146 times.
✓ Branch 6 taken 2007428 times.
✓ Branch 7 taken 570146 times.
|
47725764 | for (const auto& scv : scvs(fvGeometry)) |
80 |
3/6✓ Branch 1 taken 9894354 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9894354 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9894354 times.
✗ Branch 8 not taken.
|
84144846 | volumeVariables_[eIdx][scv.indexInElement()].update(elemSol, problem, element, scv); |
81 | }); | ||
82 | 10160 | } | |
83 | |||
84 | template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0> | ||
85 | const VolumeVariables& volVars(const SubControlVolume& scv) const | ||
86 | { return volumeVariables_[scv.elementIndex()][scv.indexInElement()]; } | ||
87 | |||
88 | template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0> | ||
89 | VolumeVariables& volVars(const SubControlVolume& scv) | ||
90 |
8/22✓ Branch 1 taken 124800 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 124800 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 127605 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2805 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2839 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1868606 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1868606 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1868572 times.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
|
306530823 | { return volumeVariables_[scv.elementIndex()][scv.indexInElement()]; } |
91 | |||
92 | const VolumeVariables& volVars(const std::size_t eIdx, const std::size_t scvIdx) const | ||
93 |
78/88✓ Branch 0 taken 5019673 times.
✓ Branch 1 taken 49872607 times.
✓ Branch 2 taken 5019673 times.
✓ Branch 3 taken 49872607 times.
✓ Branch 4 taken 5019673 times.
✓ Branch 5 taken 49872607 times.
✓ Branch 6 taken 26136510 times.
✓ Branch 7 taken 28755770 times.
✓ Branch 8 taken 26136510 times.
✓ Branch 9 taken 28755770 times.
✓ Branch 10 taken 41115048 times.
✓ Branch 11 taken 289079032 times.
✓ Branch 12 taken 41115048 times.
✓ Branch 13 taken 289079032 times.
✓ Branch 14 taken 66491448 times.
✓ Branch 15 taken 289079032 times.
✓ Branch 16 taken 204574123 times.
✓ Branch 17 taken 150980517 times.
✓ Branch 18 taken 204574123 times.
✓ Branch 19 taken 150985305 times.
✓ Branch 20 taken 208007938 times.
✓ Branch 21 taken 245006978 times.
✓ Branch 22 taken 208007938 times.
✓ Branch 23 taken 245002190 times.
✓ Branch 24 taken 182636326 times.
✓ Branch 25 taken 245002190 times.
✓ Branch 26 taken 174716644 times.
✓ Branch 27 taken 103010904 times.
✓ Branch 28 taken 191634244 times.
✓ Branch 29 taken 103010904 times.
✓ Branch 30 taken 450573868 times.
✓ Branch 31 taken 50851724 times.
✓ Branch 32 taken 457937844 times.
✓ Branch 33 taken 49841724 times.
✓ Branch 34 taken 441020244 times.
✓ Branch 35 taken 58300524 times.
✓ Branch 36 taken 41201124 times.
✓ Branch 37 taken 92133408 times.
✓ Branch 38 taken 37283700 times.
✓ Branch 39 taken 92143408 times.
✓ Branch 40 taken 93952452 times.
✓ Branch 41 taken 92143408 times.
✓ Branch 42 taken 93952452 times.
✓ Branch 43 taken 23455324 times.
✓ Branch 44 taken 89974836 times.
✓ Branch 45 taken 23479882 times.
✓ Branch 46 taken 65447642 times.
✓ Branch 47 taken 20989552 times.
✓ Branch 48 taken 65447682 times.
✓ Branch 49 taken 6639508 times.
✓ Branch 50 taken 250369634 times.
✓ Branch 51 taken 13275990 times.
✓ Branch 52 taken 248779656 times.
✓ Branch 53 taken 6671000 times.
✓ Branch 54 taken 251330616 times.
✓ Branch 55 taken 6666000 times.
✓ Branch 56 taken 2560920 times.
✓ Branch 57 taken 63862664 times.
✓ Branch 58 taken 2575664 times.
✓ Branch 59 taken 63862664 times.
✓ Branch 60 taken 661224 times.
✓ Branch 61 taken 63857664 times.
✓ Branch 62 taken 661224 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 646480 times.
✓ Branch 65 taken 20800 times.
✓ Branch 66 taken 40560 times.
✓ Branch 67 taken 20800 times.
✓ Branch 68 taken 40560 times.
✓ Branch 69 taken 20800 times.
✓ Branch 70 taken 40680 times.
✗ Branch 71 not taken.
✓ Branch 72 taken 120 times.
✗ Branch 73 not taken.
✓ Branch 74 taken 120 times.
✗ Branch 75 not taken.
✓ Branch 82 taken 493848 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 493848 times.
✗ Branch 85 not taken.
✓ Branch 86 taken 493848 times.
✗ Branch 87 not taken.
✓ Branch 95 taken 40 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 40 times.
✗ Branch 99 not taken.
✓ Branch 101 taken 40 times.
✗ Branch 102 not taken.
|
12536383887 | { return volumeVariables_[eIdx][scvIdx]; } |
94 | |||
95 | VolumeVariables& volVars(const std::size_t eIdx, const std::size_t scvIdx) | ||
96 | { return volumeVariables_[eIdx][scvIdx]; } | ||
97 | |||
98 | ✗ | const Problem& problem() const | |
99 | ✗ | { return *problemPtr_; } | |
100 | |||
101 | private: | ||
102 | const Problem* problemPtr_; | ||
103 | std::vector<std::vector<VolumeVariables>> volumeVariables_; | ||
104 | }; | ||
105 | |||
106 | |||
107 | // Specialization when the current volume variables are not stored | ||
108 | template<class Traits> | ||
109 | class CVFEGridVolumeVariables<Traits, /*cachingEnabled*/false> | ||
110 | { | ||
111 | using ThisType = CVFEGridVolumeVariables<Traits, false>; | ||
112 | |||
113 | public: | ||
114 | //! export the problem type | ||
115 | using Problem = typename Traits::Problem; | ||
116 | |||
117 | //! export the volume variables type | ||
118 | using VolumeVariables = typename Traits::VolumeVariables; | ||
119 | |||
120 | //! make it possible to query if caching is enabled | ||
121 | static constexpr bool cachingEnabled = false; | ||
122 | |||
123 | //! export the type of the local view | ||
124 | using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>; | ||
125 | |||
126 |
4/16✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ 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.
|
16 | CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {} |
127 | |||
128 | template<class GridGeometry, class SolutionVector> | ||
129 | ✗ | void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {} | |
130 | |||
131 | ✗ | const Problem& problem() const | |
132 | ✗ | { return *problemPtr_;} | |
133 | |||
134 | private: | ||
135 | const Problem* problemPtr_; | ||
136 | }; | ||
137 | |||
138 | } // end namespace Dumux | ||
139 | |||
140 | #endif | ||
141 |