GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/staggered/facesolution.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 8 9 88.9%
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 12502432 StaggeredFaceSolution(const SubControlVolumeFace& scvf, const FaceSolutionVector& sol,
35 const GridGeometry& gridGeometry)
36 25004864 {
37
38
1/2
✓ Branch 1 taken 12502432 times.
✗ Branch 2 not taken.
12502432 const auto& connectivityMap = gridGeometry.connectivityMap();
39
1/2
✓ Branch 1 taken 12502432 times.
✗ Branch 2 not taken.
12502432 const auto& stencil = connectivityMap(GridGeometry::faceIdx(), GridGeometry::faceIdx(), scvf.index());
40
41
2/4
✓ Branch 1 taken 12502432 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12502432 times.
✗ Branch 5 not taken.
25004864 facePriVars_.reserve(stencil.size()+1);
42
2/4
✓ Branch 1 taken 12502432 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12502432 times.
✗ Branch 5 not taken.
25004864 map_.reserve(stencil.size()+1);
43
44
2/6
✓ Branch 1 taken 12502432 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12502432 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25004864 map_.push_back(scvf.dofIndex());
45
3/6
✓ Branch 1 taken 12502432 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 12502432 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12502432 times.
✗ Branch 8 not taken.
37507296 facePriVars_.push_back(sol[scvf.dofIndex()]);
46
4/4
✓ Branch 0 taken 85929648 times.
✓ Branch 1 taken 12502432 times.
✓ Branch 2 taken 85929648 times.
✓ Branch 3 taken 12502432 times.
123436944 for(const auto dofJ : stencil)
47 {
48
1/2
✓ Branch 1 taken 85929648 times.
✗ Branch 2 not taken.
85929648 map_.push_back(dofJ);
49
2/4
✓ Branch 1 taken 85929648 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 85929648 times.
✗ Branch 5 not taken.
171859296 facePriVars_.push_back(sol[dofJ]);
50 }
51 12502432 }
52
53 //! bracket operator const access
54 template<typename IndexType>
55 1298800224 const FacePrimaryVariables& operator [](IndexType globalFaceDofIdx) const
56 {
57 3896400672 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
58
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 649400112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 649400112 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 649400112 times.
3896400672 assert (pos != map_.end());
59 5195200896 return facePriVars_[pos - map_.begin()];
60 }
61
62 //! bracket operator
63 template<typename IndexType>
64 225100496 FacePrimaryVariables& operator [](IndexType globalFaceDofIdx)
65 {
66 675301488 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
67
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 225100496 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 225100496 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 225100496 times.
675301488 assert (pos != map_.end());
68 900401984 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