GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/staggered/facesolution.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 9 9 100.0%
Branches: 14 26 53.8%

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::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 12556256 StaggeredFaceSolution(const SubControlVolumeFace& scvf, const FaceSolutionVector& sol,
35 const GridGeometry& gridGeometry)
36 12556256 {
37
38
1/2
✓ Branch 1 taken 12556256 times.
✗ Branch 2 not taken.
12556256 const auto& connectivityMap = gridGeometry.connectivityMap();
39
1/2
✓ Branch 1 taken 12556256 times.
✗ Branch 2 not taken.
12556256 const auto& stencil = connectivityMap(GridGeometry::faceIdx(), GridGeometry::faceIdx(), scvf.index());
40
41
1/2
✓ Branch 1 taken 12556256 times.
✗ Branch 2 not taken.
12556256 facePriVars_.reserve(stencil.size()+1);
42
1/2
✓ Branch 1 taken 12556256 times.
✗ Branch 2 not taken.
12556256 map_.reserve(stencil.size()+1);
43
44
1/2
✓ Branch 1 taken 12556256 times.
✗ Branch 2 not taken.
12556256 map_.push_back(scvf.dofIndex());
45
1/2
✓ Branch 1 taken 12556256 times.
✗ Branch 2 not taken.
12556256 facePriVars_.push_back(sol[scvf.dofIndex()]);
46
2/2
✓ Branch 0 taken 86287792 times.
✓ Branch 1 taken 12556256 times.
98844048 for(const auto dofJ : stencil)
47 {
48
1/2
✓ Branch 1 taken 86287792 times.
✗ Branch 2 not taken.
86287792 map_.push_back(dofJ);
49
1/2
✓ Branch 1 taken 86287792 times.
✗ Branch 2 not taken.
86287792 facePriVars_.push_back(sol[dofJ]);
50 }
51 12556256 }
52
53 //! bracket operator const access
54 template<typename IndexType>
55 1304424832 const FacePrimaryVariables& operator [](IndexType globalFaceDofIdx) const
56 {
57
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 652229696 times.
1304424832 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
58
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 652229696 times.
1304424832 assert (pos != map_.end());
59 1304424832 return facePriVars_[pos - map_.begin()];
60 }
61
62 //! bracket operator
63 template<typename IndexType>
64 183216120 FacePrimaryVariables& operator [](IndexType globalFaceDofIdx)
65 {
66
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183216120 times.
183216120 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183216120 times.
183216120 assert (pos != map_.end());
68 183216120 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