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-FileCopyrightText: 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 |
2/3✓ Branch 3 taken 2245 times.
✗ Branch 4 not taken.
✓ Branch 2 taken 550 times.
|
2858 | 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 | //! export the type of the mutable local view | ||
64 | using MutableLocalView = LocalView::MutableView; | ||
65 | |||
66 |
2/4✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
63 | CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {} |
67 | |||
68 | template<class GridGeometry, class SolutionVector> | ||
69 | 10356 | void update(const GridGeometry& gridGeometry, const SolutionVector& sol) | |
70 | { | ||
71 | 10356 | volumeVariables_.resize(gridGeometry.gridView().size(0)); | |
72 | 680572 | Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx) | |
73 | { | ||
74 | 7407318 | const auto element = gridGeometry.element(eIdx); | |
75 |
4/8✓ Branch 1 taken 3459773 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2855473 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 9600 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 9600 times.
✗ Branch 10 not taken.
|
10876691 | const auto fvGeometry = localView(gridGeometry).bindElement(element); |
76 | |||
77 | // get the element solution | ||
78 |
1/2✓ Branch 1 taken 3438173 times.
✗ Branch 2 not taken.
|
7407318 | auto elemSol = elementSolution(element, sol, gridGeometry); |
79 | |||
80 | // update the volvars of the element | ||
81 |
2/4✓ Branch 1 taken 3459773 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9600 times.
✗ Branch 5 not taken.
|
7407318 | volumeVariables_[eIdx].resize(fvGeometry.numScv()); |
82 |
4/4✓ Branch 0 taken 26114991 times.
✓ Branch 1 taken 7384000 times.
✓ Branch 2 taken 138544 times.
✓ Branch 3 taken 23318 times.
|
33660853 | for (const auto& scv : scvs(fvGeometry)) |
83 |
1/2✓ Branch 1 taken 9894354 times.
✗ Branch 2 not taken.
|
26347135 | volumeVariables_[eIdx][scv.indexInElement()].update(elemSol, problem, element, scv); |
84 | 3469373 | }); | |
85 | 10356 | } | |
86 | |||
87 | template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0> | ||
88 | const VolumeVariables& volVars(const SubControlVolume& scv) const | ||
89 | { return volumeVariables_[scv.elementIndex()][scv.indexInElement()]; } | ||
90 | |||
91 | template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0> | ||
92 | 4362209 | VolumeVariables& volVars(const SubControlVolume& scv) | |
93 |
3/6✓ Branch 1 taken 128137 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2492966 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 34 times.
✗ Branch 8 not taken.
|
4362209 | { return volumeVariables_[scv.elementIndex()][scv.indexInElement()]; } |
94 | |||
95 | 4448514720 | const VolumeVariables& volVars(const std::size_t eIdx, const std::size_t scvIdx) const | |
96 |
24/26✓ Branch 0 taken 5019673 times.
✓ Branch 1 taken 51348955 times.
✓ Branch 2 taken 28473432 times.
✓ Branch 3 taken 23568836 times.
✓ Branch 4 taken 34130904 times.
✓ Branch 5 taken 290555380 times.
✓ Branch 6 taken 220885687 times.
✓ Branch 7 taken 246085617 times.
✓ Branch 8 taken 156040072 times.
✓ Branch 9 taken 136373892 times.
✓ Branch 10 taken 463060966 times.
✓ Branch 11 taken 156701086 times.
✓ Branch 12 taken 33306084 times.
✓ Branch 13 taken 83684608 times.
✓ Branch 14 taken 73083952 times.
✓ Branch 15 taken 14419534 times.
✓ Branch 16 taken 274422724 times.
✓ Branch 17 taken 9259214 times.
✓ Branch 18 taken 72038 times.
✓ Branch 19 taken 64499144 times.
✓ Branch 20 taken 10120 times.
✓ Branch 21 taken 20800 times.
✓ Branch 22 taken 534408 times.
✗ Branch 23 not taken.
✓ Branch 27 taken 40 times.
✗ Branch 28 not taken.
|
3819797220 | { return volumeVariables_[eIdx][scvIdx]; } |
97 | |||
98 | 101374850 | VolumeVariables& volVars(const std::size_t eIdx, const std::size_t scvIdx) | |
99 | 101374850 | { return volumeVariables_[eIdx][scvIdx]; } | |
100 | |||
101 | 212245 | const Problem& problem() const | |
102 |
7/12✓ Branch 1 taken 10 times.
✓ Branch 2 taken 7 times.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 3 times.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
✗ Branch 3 not taken.
✗ Branch 9 not taken.
✓ Branch 13 taken 5 times.
✗ Branch 14 not taken.
|
212245 | { return *problemPtr_; } |
103 | |||
104 | private: | ||
105 | const Problem* problemPtr_; | ||
106 | std::vector<std::vector<VolumeVariables>> volumeVariables_; | ||
107 | }; | ||
108 | |||
109 | |||
110 | // Specialization when the current volume variables are not stored | ||
111 | template<class Traits> | ||
112 | class CVFEGridVolumeVariables<Traits, /*cachingEnabled*/false> | ||
113 | { | ||
114 | using ThisType = CVFEGridVolumeVariables<Traits, false>; | ||
115 | |||
116 | public: | ||
117 | //! export the problem type | ||
118 | using Problem = typename Traits::Problem; | ||
119 | |||
120 | //! export the volume variables type | ||
121 | using VolumeVariables = typename Traits::VolumeVariables; | ||
122 | |||
123 | //! make it possible to query if caching is enabled | ||
124 | static constexpr bool cachingEnabled = false; | ||
125 | |||
126 | //! export the type of the local view | ||
127 | using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>; | ||
128 | |||
129 | //! export the type of the mutable local view | ||
130 | using MutableLocalView = LocalView::MutableView; | ||
131 | |||
132 |
5/8✓ Branch 0 taken 153 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
185 | CVFEGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {} |
133 | |||
134 | template<class GridGeometry, class SolutionVector> | ||
135 | 2 | void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {} | |
136 | |||
137 | 69894885 | const Problem& problem() const | |
138 |
38/46✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 528 times.
✓ Branch 5 taken 21 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 42340 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 46203 times.
✓ Branch 17 taken 10 times.
✓ Branch 18 taken 1 times.
✓ Branch 20 taken 8 times.
✓ Branch 21 taken 2 times.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 2 times.
✓ Branch 29 taken 4 times.
✓ Branch 30 taken 1 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✓ Branch 36 taken 1 times.
✓ Branch 37 taken 1 times.
✓ Branch 39 taken 1 times.
✓ Branch 40 taken 1 times.
✓ Branch 42 taken 1 times.
✓ Branch 43 taken 1 times.
✓ Branch 7 taken 5174 times.
✓ Branch 8 taken 14 times.
✓ Branch 6 taken 449 times.
✓ Branch 11 taken 40 times.
✓ Branch 14 taken 24 times.
✓ Branch 15 taken 1 times.
✓ Branch 19 taken 8 times.
✓ Branch 22 taken 6 times.
✓ Branch 23 taken 5 times.
✓ Branch 25 taken 6 times.
✓ Branch 28 taken 2 times.
✓ Branch 16 taken 7 times.
✗ Branch 38 not taken.
✗ Branch 41 not taken.
✗ Branch 44 not taken.
✓ Branch 47 taken 4368 times.
✗ Branch 48 not taken.
✓ Branch 51 taken 2014 times.
✗ Branch 52 not taken.
✓ Branch 24 taken 2 times.
✓ Branch 3 taken 6 times.
✗ Branch 31 not taken.
|
70230882 | { return *problemPtr_;} |
139 | |||
140 | private: | ||
141 | const Problem* problemPtr_; | ||
142 | }; | ||
143 | |||
144 | } // end namespace Dumux | ||
145 | |||
146 | #endif | ||
147 |