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 StaggeredDiscretization | ||
10 | * \copydoc Dumux::StaggeredGridFaceVariables | ||
11 | */ | ||
12 | #ifndef DUMUX_DISCRETIZATION_STAGGERED_GRID_FACEVARIABLES_HH | ||
13 | #define DUMUX_DISCRETIZATION_STAGGERED_GRID_FACEVARIABLES_HH | ||
14 | |||
15 | // make the local view function available whenever we use this class | ||
16 | #include <dumux/discretization/localview.hh> | ||
17 | #include <dumux/discretization/staggered/elementfacevariables.hh> | ||
18 | #include <dumux/discretization/staggered/facesolution.hh> | ||
19 | |||
20 | namespace Dumux { | ||
21 | |||
22 | /*! | ||
23 | * \ingroup StaggeredDiscretization | ||
24 | * \brief Traits class to be used for the StaggeredGridFaceVariables. | ||
25 | * | ||
26 | * \tparam P The problem type | ||
27 | * \tparam FV The face variables type | ||
28 | */ | ||
29 | template<class P, class FV> | ||
30 | struct StaggeredDefaultGridFaceVariablesTraits | ||
31 | { | ||
32 | template<class GridFaceVariables, bool enableCache> | ||
33 | using LocalView = StaggeredElementFaceVariables<GridFaceVariables, enableCache>; | ||
34 | |||
35 | using FaceVariables = FV; | ||
36 | using Problem = P; | ||
37 | }; | ||
38 | |||
39 | /*! | ||
40 | * \ingroup StaggeredDiscretization | ||
41 | * \brief Face variables cache class for staggered models | ||
42 | */ | ||
43 | template<class Problem, | ||
44 | class FaceVariables, | ||
45 | bool cachingEnabled = false, | ||
46 | class Traits = StaggeredDefaultGridFaceVariablesTraits<Problem, FaceVariables> > | ||
47 | class StaggeredGridFaceVariables; | ||
48 | |||
49 | /*! | ||
50 | * \ingroup StaggeredDiscretization | ||
51 | * \brief Face variables cache class for staggered models. | ||
52 | Specialization in case of storing the face variables. | ||
53 | */ | ||
54 | template<class P, class FV, class Traits> | ||
55 | 1283 | class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits> | |
56 | { | ||
57 | using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits>; | ||
58 | using Problem = typename Traits::Problem; | ||
59 | |||
60 | public: | ||
61 | //! make it possible to query if caching is enabled | ||
62 | static constexpr bool cachingEnabled = true; | ||
63 | |||
64 | //! export the type of the local view | ||
65 | using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>; | ||
66 | |||
67 | //! export the type of the face variables | ||
68 | using FaceVariables = typename Traits::FaceVariables; | ||
69 | |||
70 | 75 | StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {} | |
71 | |||
72 | //! Update all face variables | ||
73 | template<class GridGeometry, class SolutionVector> | ||
74 | 5751 | void update(const GridGeometry& gridGeometry, const SolutionVector& sol) | |
75 | { | ||
76 | 5751 | faceVariables_.resize(gridGeometry.numScvf()); | |
77 | 5751 | auto fvGeometry = localView(gridGeometry); | |
78 |
4/7✓ Branch 1 taken 48 times.
✓ Branch 2 taken 1782947 times.
✓ Branch 4 taken 1248 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1200 times.
✗ Branch 8 not taken.
✗ Branch 3 not taken.
|
5344827 | for (auto&& element : elements(gridGeometry.gridView())) |
79 | { | ||
80 | 1779692 | fvGeometry.bindElement(element); | |
81 | |||
82 |
2/2✓ Branch 1 taken 7113968 times.
✓ Branch 2 taken 1778492 times.
|
8898460 | for (auto&& scvf : scvfs(fvGeometry)) |
83 | { | ||
84 |
1/2✓ Branch 1 taken 4800 times.
✗ Branch 2 not taken.
|
7118768 | const auto faceSol = StaggeredFaceSolution(scvf, sol, gridGeometry); |
85 | 7118768 | faceVariables_[scvf.index()].update(faceSol, problem(), element, fvGeometry, scvf); | |
86 | } | ||
87 | } | ||
88 | 5751 | } | |
89 | |||
90 | 1658661491 | const FaceVariables& faceVars(const std::size_t facetIdx) const | |
91 |
16/16✓ Branch 1 taken 126520681 times.
✓ Branch 2 taken 76172172 times.
✓ Branch 3 taken 161011852 times.
✓ Branch 4 taken 88929596 times.
✓ Branch 5 taken 54363236 times.
✓ Branch 6 taken 94956384 times.
✓ Branch 11 taken 81901330 times.
✓ Branch 12 taken 51701442 times.
✓ Branch 13 taken 40846483 times.
✓ Branch 14 taken 11383988 times.
✓ Branch 7 taken 47750810 times.
✓ Branch 8 taken 114613624 times.
✓ Branch 9 taken 69501085 times.
✓ Branch 10 taken 80915779 times.
✓ Branch 0 taken 19 times.
✓ Branch 15 taken 3018495 times.
|
1521947115 | { return faceVariables_[facetIdx]; } |
92 | |||
93 | 48266280 | FaceVariables& faceVars(const std::size_t facetIdx) | |
94 | 48266280 | { return faceVariables_[facetIdx]; } | |
95 | |||
96 | 7113968 | const Problem& problem() const | |
97 | 7113968 | { return *problemPtr_; } | |
98 | |||
99 | private: | ||
100 | const Problem* problemPtr_; | ||
101 | std::vector<FaceVariables> faceVariables_; | ||
102 | }; | ||
103 | |||
104 | /*! | ||
105 | * \ingroup StaggeredDiscretization | ||
106 | * \brief Face variables cache class for staggered models. | ||
107 | Specialization in case of not storing the face variables. | ||
108 | */ | ||
109 | template<class P, class FV, class Traits> | ||
110 | class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits> | ||
111 | { | ||
112 | using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits>; | ||
113 | using Problem = typename Traits::Problem; | ||
114 | |||
115 | public: | ||
116 | //! make it possible to query if caching is enabled | ||
117 | static constexpr bool cachingEnabled = false; | ||
118 | |||
119 | //! export the type of the local view | ||
120 | using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>; | ||
121 | |||
122 | //! export the type of the face variables | ||
123 | using FaceVariables = typename Traits::FaceVariables; | ||
124 | |||
125 | StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {} | ||
126 | |||
127 | //! Do nothing here. | ||
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 |