GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/assembly/volvardeflectionhelper_.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 430 433 99.3%
Branches: 23 26 88.5%

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 Assembly
10 * \brief Volume variables deflection helper.
11 */
12
13 #ifndef DUMUX_ASSEMBLY_VOLVARS_DEFLECTION_HELPER_HH
14 #define DUMUX_ASSEMBLY_VOLVARS_DEFLECTION_HELPER_HH
15
16 #include <type_traits>
17 #include <dune/common/reservedvector.hh>
18
19 #ifndef DOXYGEN
20
21 namespace Dumux::Detail {
22
23 template<class VolVarAccessor, class FVElementGeometry>
24 class VolVarsDeflectionHelper
25 {
26 static constexpr int maxNumscvs = FVElementGeometry::maxNumElementScvs;
27
28 using SubControlVolume = typename FVElementGeometry::GridGeometry::SubControlVolume;
29 using VolumeVariablesRef = std::invoke_result_t<VolVarAccessor, const SubControlVolume&>;
30 using VolumeVariables = std::decay_t<VolumeVariablesRef>;
31 static_assert(std::is_lvalue_reference_v<VolumeVariablesRef>
32 && !std::is_const_v<std::remove_reference_t<VolumeVariablesRef>>);
33
34 public:
35 13952701 VolVarsDeflectionHelper(VolVarAccessor&& accessor,
36 const FVElementGeometry& fvGeometry,
37 bool deflectAllVolVars)
38 : deflectAll_(deflectAllVolVars)
39 13952701 , accessor_(std::move(accessor))
40
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150972 times.
13952701 , fvGeometry_(fvGeometry)
41 {
42
2/2
✓ Branch 0 taken 604200 times.
✓ Branch 1 taken 11392132 times.
13952701 if (deflectAll_)
43
4/4
✓ Branch 0 taken 1208400 times.
✓ Branch 1 taken 604200 times.
✓ Branch 2 taken 1208400 times.
✓ Branch 3 taken 604200 times.
3625200 for (const auto& curScv : scvs(fvGeometry))
44 3625200 origVolVars_.push_back(accessor_(curScv));
45 13952701 }
46
47 15256210 void setCurrent(const SubControlVolume& scv)
48 {
49
4/6
✓ Branch 0 taken 36977544 times.
✓ Branch 1 taken 1208400 times.
✓ Branch 2 taken 2886504 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30832 times.
✗ Branch 5 not taken.
41158192 if (!deflectAll_)
50 {
51 39535012 origVolVars_.clear();
52 80307152 origVolVars_.push_back(accessor_(scv));
53 }
54 15256210 }
55
56 template<class ElementSolution, class Problem>
57 100159458 void deflect(const ElementSolution& elemSol,
58 const SubControlVolume& scv,
59 const Problem& problem)
60 {
61
2/2
✓ Branch 0 taken 3625200 times.
✓ Branch 1 taken 88812798 times.
100159458 if (deflectAll_)
62
4/4
✓ Branch 0 taken 7250400 times.
✓ Branch 1 taken 3625200 times.
✓ Branch 2 taken 7250400 times.
✓ Branch 3 taken 3625200 times.
14500800 for (const auto& curScv : scvs(fvGeometry_))
63 21751200 accessor_(curScv).update(elemSol, problem, fvGeometry_.element(), curScv);
64 else
65 289602774 accessor_(scv).update(elemSol, problem, fvGeometry_.element(), scv);
66 100159458 }
67
68 98813538 void restore(const SubControlVolume& scv)
69 {
70
2/2
✓ Branch 0 taken 87466878 times.
✓ Branch 1 taken 3625200 times.
98813538 if (!deflectAll_)
71 285565014 accessor_(scv) = origVolVars_[0];
72 else
73
4/4
✓ Branch 0 taken 7250400 times.
✓ Branch 1 taken 3625200 times.
✓ Branch 2 taken 7250400 times.
✓ Branch 3 taken 3625200 times.
21751200 for (const auto& curScv : scvs(fvGeometry_))
74 21751200 accessor_(curScv) = origVolVars_[curScv.localDofIndex()];
75 98813538 }
76
77 private:
78 const bool deflectAll_;
79 VolVarAccessor accessor_;
80 const FVElementGeometry& fvGeometry_;
81 Dune::ReservedVector<VolumeVariables, maxNumscvs> origVolVars_;
82 };
83
84 template<class Accessor, class FVElementGeometry>
85 VolVarsDeflectionHelper(Accessor&&, FVElementGeometry&&) -> VolVarsDeflectionHelper<Accessor, std::decay_t<FVElementGeometry>>;
86
87 } // end namespace Dumux::Detail
88
89 #endif // DOXYGEN
90
91 #endif
92