GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/staggered/facesolution.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 9 9 100.0%
Branches: 24 46 52.2%

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 StaggeredDiscretization
10 * \copydoc Dumux::StaggeredFaceSolution
11 */
12 #ifndef DUMUX_DISCRETIZATION_STAGGERED_FACE_SOLUTION_HH
13 #define DUMUX_DISCRETIZATION_STAGGERED_FACE_SOLUTION_HH
14
15 #include <algorithm>
16 #include <cassert>
17 #include <type_traits>
18 #include <vector>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup StaggeredDiscretization
24 * \brief The global face variables class for staggered models
25 */
26 template<class FaceSolutionVector>
27 class StaggeredFaceSolution
28 {
29 using FacePrimaryVariables = std::decay_t<decltype(std::declval<FaceSolutionVector>()[0])>;
30
31 public:
32
33 template<class SubControlVolumeFace, class GridGeometry>
34 12555232 StaggeredFaceSolution(const SubControlVolumeFace& scvf, const FaceSolutionVector& sol,
35 const GridGeometry& gridGeometry)
36 25110464 {
37
38
1/2
✓ Branch 1 taken 12555232 times.
✗ Branch 2 not taken.
12555232 const auto& connectivityMap = gridGeometry.connectivityMap();
39
1/2
✓ Branch 1 taken 12555232 times.
✗ Branch 2 not taken.
12555232 const auto& stencil = connectivityMap(GridGeometry::faceIdx(), GridGeometry::faceIdx(), scvf.index());
40
41
2/4
✓ Branch 1 taken 12555232 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12555232 times.
✗ Branch 5 not taken.
25110464 facePriVars_.reserve(stencil.size()+1);
42
2/4
✓ Branch 1 taken 12555232 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12555232 times.
✗ Branch 5 not taken.
25110464 map_.reserve(stencil.size()+1);
43
44
2/6
✓ Branch 1 taken 12555232 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12555232 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25110464 map_.push_back(scvf.dofIndex());
45
3/6
✓ Branch 1 taken 12555232 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12555232 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12555232 times.
✗ Branch 8 not taken.
37665696 facePriVars_.push_back(sol[scvf.dofIndex()]);
46
4/4
✓ Branch 0 taken 86281008 times.
✓ Branch 1 taken 12555232 times.
✓ Branch 2 taken 86281008 times.
✓ Branch 3 taken 12555232 times.
123946704 for(const auto dofJ : stencil)
47 {
48
1/2
✓ Branch 1 taken 86281008 times.
✗ Branch 2 not taken.
86281008 map_.push_back(dofJ);
49
2/4
✓ Branch 1 taken 86281008 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 86281008 times.
✗ Branch 5 not taken.
172562016 facePriVars_.push_back(sol[dofJ]);
50 }
51 12555232 }
52
53 //! bracket operator const access
54 template<typename IndexType>
55 1304349184 const FacePrimaryVariables& operator [](IndexType globalFaceDofIdx) const
56 {
57 3913047552 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
58
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 652191872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652191872 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 652191872 times.
3913047552 assert (pos != map_.end());
59 5217396736 return facePriVars_[pos - map_.begin()];
60 }
61
62 //! bracket operator
63 template<typename IndexType>
64 226024496 FacePrimaryVariables& operator [](IndexType globalFaceDofIdx)
65 {
66 678073488 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
67
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226024496 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 226024496 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226024496 times.
678073488 assert (pos != map_.end());
68 904097984 return facePriVars_[pos - map_.begin()];
69 }
70
71 private:
72
73 std::vector<FacePrimaryVariables> facePriVars_;
74 std::vector<unsigned int> map_;
75 };
76
77 } // end namespace Dumux
78
79 #endif
80