GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/common/reservedblockvector.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 10 12 83.3%
Functions: 0 43 0.0%
Branches: 92 110 83.6%

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 Core
10 * \brief A arithmetic block vector type based on DUNE's reserved vector
11 */
12 #ifndef DUMUX_RESERVED_BLOCK_VECTOR_HH
13 #define DUMUX_RESERVED_BLOCK_VECTOR_HH
14
15 #include <algorithm>
16 #include <dune/common/reservedvector.hh>
17
18 namespace Dumux {
19
20 /*!
21 * \ingroup Core
22 * \brief A arithmetic block vector type based on DUNE's reserved vector
23 */
24 template<class BlockType, int capacity>
25 class ReservedBlockVector : public Dune::ReservedVector<BlockType, capacity>
26 {
27 using Base = Dune::ReservedVector<BlockType, capacity>;
28 public:
29
30 using size_type = typename Base::size_type;
31 using value_type = BlockType;
32
33 10050676 using Base::Base;
34
35 18701568 explicit ReservedBlockVector() : Base() {}
36
31/33
✓ Branch 0 taken 10132137 times.
✓ Branch 1 taken 3304188 times.
✓ Branch 2 taken 10132137 times.
✓ Branch 3 taken 3496958 times.
✓ Branch 4 taken 10139093 times.
✓ Branch 5 taken 13434677 times.
✓ Branch 6 taken 20139085 times.
✓ Branch 7 taken 13076869 times.
✓ Branch 8 taken 20139051 times.
✓ Branch 9 taken 2907341 times.
✓ Branch 10 taken 20132115 times.
✓ Branch 11 taken 1793655 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 290974 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 371230 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 373847 times.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 373847 times.
✓ Branch 20 taken 2 times.
✓ Branch 21 taken 91542 times.
✓ Branch 22 taken 2 times.
✓ Branch 23 taken 91542 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 87680 times.
✓ Branch 26 taken 1 times.
✓ Branch 27 taken 374463 times.
✓ Branch 28 taken 1 times.
✓ Branch 29 taken 374463 times.
✓ Branch 30 taken 1 times.
✓ Branch 31 taken 374463 times.
✗ Branch 32 not taken.
2040725102 explicit ReservedBlockVector(size_type size) : Base() { this->resize(size); }
37
38 ReservedBlockVector(const ReservedBlockVector&) = default;
39 ReservedBlockVector(ReservedBlockVector&&) = default;
40
41 ReservedBlockVector& operator= (const ReservedBlockVector&) = default;
42 ReservedBlockVector& operator= (ReservedBlockVector&&) = default;
43
44 ~ReservedBlockVector() = default;
45
46 //! assignment from scalar
47 ReservedBlockVector& operator= (const typename BlockType::field_type& v)
48 {
49
15/15
✓ Branch 0 taken 31909 times.
✓ Branch 1 taken 92447938 times.
✓ Branch 2 taken 79756684 times.
✓ Branch 3 taken 16007654 times.
✓ Branch 4 taken 6365472 times.
✓ Branch 5 taken 2275653 times.
✓ Branch 6 taken 1692058 times.
✓ Branch 7 taken 406338 times.
✓ Branch 8 taken 3095856 times.
✓ Branch 9 taken 913285 times.
✓ Branch 10 taken 5651485 times.
✓ Branch 11 taken 424924 times.
✓ Branch 12 taken 217463 times.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 5780 times.
1332341906 std::fill(this->begin(), this->end(), v);
50 return *this;
51 }
52
53 //! vector space addition
54 ReservedBlockVector& operator+= (const ReservedBlockVector& other)
55 {
56
8/8
✓ Branch 0 taken 400697796 times.
✓ Branch 1 taken 165353811 times.
✓ Branch 2 taken 39532929 times.
✓ Branch 3 taken 21435513 times.
✓ Branch 4 taken 1367424 times.
✓ Branch 5 taken 1317424 times.
✓ Branch 6 taken 4820000 times.
✓ Branch 7 taken 2892000 times.
637416897 for (size_type i = 0; i < this->size(); ++i)
57 1785672596 (*this)[i] += other[i];
58 return *this;
59 }
60
61 //! vector space subtraction
62 ReservedBlockVector& operator-= (const ReservedBlockVector& other)
63 {
64
20/36
✓ Branch 0 taken 6097920 times.
✓ Branch 1 taken 1538880 times.
✓ Branch 2 taken 549201287 times.
✓ Branch 3 taken 130836182 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 219374547 times.
✓ Branch 7 taken 55311562 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 67619044 times.
✓ Branch 11 taken 16251316 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 62408640 times.
✓ Branch 15 taken 11066833 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 2279774 times.
✓ Branch 19 taken 544082 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 9276480 times.
✓ Branch 23 taken 2995984 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4548 times.
✓ Branch 27 taken 998 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 3168 times.
✓ Branch 31 taken 1056 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✓ Branch 34 taken 123328 times.
✓ Branch 35 taken 30832 times.
1134966461 for (size_type i = 0; i < this->size(); ++i)
65 3665554944 (*this)[i] -= other[i];
66 return *this;
67 }
68
69 //! division by scalar
70 ReservedBlockVector& operator/= (const typename BlockType::field_type& v)
71 {
72
18/18
✓ Branch 0 taken 555299207 times.
✓ Branch 1 taken 132375062 times.
✓ Branch 2 taken 219374547 times.
✓ Branch 3 taken 55311562 times.
✓ Branch 4 taken 67619044 times.
✓ Branch 5 taken 16251316 times.
✓ Branch 6 taken 62408640 times.
✓ Branch 7 taken 11066833 times.
✓ Branch 8 taken 2279774 times.
✓ Branch 9 taken 544082 times.
✓ Branch 10 taken 9276480 times.
✓ Branch 11 taken 2995984 times.
✓ Branch 12 taken 4548 times.
✓ Branch 13 taken 998 times.
✓ Branch 14 taken 3168 times.
✓ Branch 15 taken 1056 times.
✓ Branch 16 taken 123328 times.
✓ Branch 17 taken 30832 times.
1134966461 for (size_type i = 0; i < this->size(); ++i)
73 2749166208 (*this)[i] /= v;
74 return *this;
75 }
76
77 //! multiplication by scalar
78 ReservedBlockVector& operator*= (const typename BlockType::field_type& v)
79 {
80 for (size_type i = 0; i < this->size(); ++i)
81 (*this)[i] *= v;
82 return *this;
83 }
84 };
85
86 } // end namespace Dumux
87
88 #endif
89