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 wrapper that can either contain a valid Scalar or NaN | ||
11 | */ | ||
12 | #ifndef DUMUX_COMMON_OPTIONAL_SCALAR_HH | ||
13 | #define DUMUX_COMMON_OPTIONAL_SCALAR_HH | ||
14 | |||
15 | #include <limits> | ||
16 | #include <cmath> | ||
17 | |||
18 | namespace Dumux { | ||
19 | |||
20 | /*! | ||
21 | * \ingroup Core | ||
22 | * \brief A type for an optional scalar (contains either a valid number or NaN) | ||
23 | * \tparam T Type of the underlying floating point number type | ||
24 | */ | ||
25 | template<class T> | ||
26 | struct OptionalScalar | ||
27 | { | ||
28 | static_assert(std::numeric_limits<T>::has_quiet_NaN, "T has to be able to represent a quiet NaN!"); | ||
29 | |||
30 |
21/66✓ Branch 1 taken 41563 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 41563 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 41563 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 3062797 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 3062797 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 3062797 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 1 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 1 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 1 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 3 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 3 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 3 times.
✗ Branch 113 not taken.
|
11577584 | OptionalScalar() = default; |
31 | |||
32 | OptionalScalar(T value) | ||
33 | : value_(value) | ||
34 | {} | ||
35 | |||
36 | ✗ | T value() const | |
37 | ✗ | { return value_; } | |
38 | |||
39 | ✗ | explicit operator bool() const | |
40 | { | ||
41 | using std::isnan; | ||
42 |
141/252✓ Branch 0 taken 4055467 times.
✓ Branch 1 taken 24370328 times.
✓ Branch 2 taken 23593339 times.
✓ Branch 3 taken 126836368 times.
✓ Branch 4 taken 16257055 times.
✓ Branch 5 taken 45969136 times.
✓ Branch 6 taken 882142936 times.
✓ Branch 7 taken 46347328 times.
✓ Branch 8 taken 33617298 times.
✓ Branch 9 taken 125815062 times.
✓ Branch 10 taken 23117576 times.
✓ Branch 11 taken 754505484 times.
✓ Branch 12 taken 35820493 times.
✓ Branch 13 taken 22782585 times.
✓ Branch 14 taken 29586981 times.
✓ Branch 15 taken 6802273 times.
✓ Branch 16 taken 8054833 times.
✓ Branch 17 taken 49251 times.
✓ Branch 18 taken 1371503 times.
✓ Branch 19 taken 301 times.
✓ Branch 20 taken 42 times.
✓ Branch 21 taken 1714 times.
✓ Branch 22 taken 1 times.
✓ Branch 23 taken 294563 times.
✓ Branch 24 taken 1174 times.
✓ Branch 25 taken 252659 times.
✓ Branch 26 taken 468 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4357186 times.
✓ Branch 29 taken 4886827 times.
✓ Branch 30 taken 4357186 times.
✓ Branch 31 taken 4886926 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 99 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 99 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 99 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 54 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 98 times.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 63 not taken.
✓ Branch 64 taken 99 times.
✗ Branch 66 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 72 not taken.
✓ Branch 73 taken 98 times.
✓ Branch 75 taken 16721 times.
✗ Branch 76 not taken.
✓ Branch 78 taken 16721 times.
✓ Branch 79 taken 99 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 1 times.
✓ Branch 84 taken 999 times.
✓ Branch 85 taken 1 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 1097 times.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✓ Branch 94 taken 99 times.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✓ Branch 97 taken 1 times.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✓ Branch 100 taken 1 times.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✓ Branch 103 taken 98 times.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✓ Branch 108 taken 1017359 times.
✓ Branch 109 taken 3 times.
✗ Branch 110 not taken.
✓ Branch 111 taken 88522 times.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✓ Branch 115 taken 3 times.
✓ Branch 116 taken 12867 times.
✓ Branch 117 taken 28793 times.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✓ Branch 121 taken 3 times.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 126 not taken.
✓ Branch 127 taken 3 times.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✓ Branch 132 taken 1 times.
✓ Branch 133 taken 5 times.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✓ Branch 138 taken 1 times.
✓ Branch 139 taken 5 times.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✓ Branch 144 taken 1 times.
✓ Branch 145 taken 5 times.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✓ Branch 150 taken 1 times.
✓ Branch 151 taken 5 times.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✓ Branch 156 taken 98 times.
✓ Branch 157 taken 2 times.
✓ Branch 159 taken 98 times.
✓ Branch 160 taken 2 times.
✓ Branch 162 taken 98 times.
✓ Branch 163 taken 2 times.
✓ Branch 165 taken 915 times.
✓ Branch 166 taken 2 times.
✓ Branch 168 taken 915 times.
✓ Branch 169 taken 2 times.
✓ Branch 171 taken 98 times.
✓ Branch 172 taken 2 times.
✓ Branch 174 taken 130538 times.
✓ Branch 175 taken 2 times.
✓ Branch 177 taken 98 times.
✓ Branch 178 taken 130442 times.
✓ Branch 180 taken 196 times.
✓ Branch 181 taken 4 times.
✗ Branch 182 not taken.
✓ Branch 183 taken 196 times.
✓ Branch 184 taken 4 times.
✗ Branch 185 not taken.
✓ Branch 186 taken 196 times.
✓ Branch 187 taken 4 times.
✗ Branch 188 not taken.
✓ Branch 189 taken 196 times.
✓ Branch 190 taken 4 times.
✗ Branch 191 not taken.
✓ Branch 192 taken 1 times.
✓ Branch 193 taken 8 times.
✗ Branch 194 not taken.
✓ Branch 195 taken 1 times.
✓ Branch 196 taken 8 times.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✓ Branch 206 taken 252600 times.
✓ Branch 207 taken 1237139 times.
✓ Branch 208 taken 8 times.
✗ Branch 209 not taken.
✓ Branch 210 taken 1 times.
✓ Branch 211 taken 8 times.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 219 not taken.
✗ Branch 220 not taken.
✓ Branch 222 taken 1 times.
✓ Branch 223 taken 8 times.
✓ Branch 225 taken 1 times.
✓ Branch 226 taken 8 times.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✓ Branch 237 taken 1 times.
✓ Branch 238 taken 8 times.
✓ Branch 240 taken 1 times.
✓ Branch 241 taken 8 times.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✗ Branch 246 not taken.
✗ Branch 247 not taken.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 252 not taken.
✓ Branch 253 taken 396 times.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 258 not taken.
✓ Branch 259 taken 396 times.
✗ Branch 261 not taken.
✓ Branch 262 taken 4 times.
✗ Branch 264 not taken.
✓ Branch 265 taken 396 times.
✗ Branch 267 not taken.
✓ Branch 268 taken 4 times.
✗ Branch 270 not taken.
✓ Branch 271 taken 4 times.
✗ Branch 273 not taken.
✓ Branch 274 taken 392 times.
✗ Branch 276 not taken.
✗ Branch 277 not taken.
✗ Branch 279 not taken.
✓ Branch 280 taken 12 times.
✗ Branch 282 not taken.
✗ Branch 283 not taken.
✓ Branch 285 taken 4 times.
✓ Branch 286 taken 20 times.
✗ Branch 288 not taken.
✗ Branch 289 not taken.
✓ Branch 291 taken 588 times.
✓ Branch 292 taken 12 times.
✓ Branch 294 taken 588 times.
✓ Branch 295 taken 12 times.
✓ Branch 297 taken 588 times.
✓ Branch 298 taken 12 times.
✓ Branch 300 taken 588 times.
✓ Branch 301 taken 12 times.
✓ Branch 303 taken 392 times.
✓ Branch 304 taken 8 times.
✓ Branch 306 taken 392 times.
✓ Branch 307 taken 8 times.
✓ Branch 309 taken 784 times.
✓ Branch 310 taken 16 times.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✓ Branch 314 taken 4 times.
✓ Branch 315 taken 32 times.
✓ Branch 317 taken 4 times.
✓ Branch 318 taken 32 times.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✗ Branch 323 not taken.
✗ Branch 324 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✓ Branch 329 taken 2652 times.
✓ Branch 330 taken 48 times.
|
2231745040 | return !isnan(value_); |
43 | } | ||
44 | private: | ||
45 | T value_ = std::numeric_limits<T>::quiet_NaN(); | ||
46 | }; | ||
47 | |||
48 | } // namespace Dumux | ||
49 | |||
50 | #endif | ||
51 |