GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/discretization/facecentered/staggered/normalaxis.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 3 3 100.0%
Branches: 14 34 41.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-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 FaceCenteredStaggeredDiscretization
10 * \copydoc Dumux::FaceCenteredStaggeredFVGridGeometry
11 */
12 #ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_NORMAL_AXIS_HH
13 #define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_NORMAL_AXIS_HH
14
15 #include <cstddef>
16 #include <algorithm>
17 #include <numeric>
18
19 namespace Dumux {
20
21 /*!
22 * \ingroup FaceCenteredStaggeredDiscretization
23 * \brief Returns the normal axis index of a unit vector (0 = x, 1 = y, 2 = z)
24 */
25 template<class Vector>
26 41335702 inline static std::size_t normalAxis(const Vector& v)
27 {
28 using std::abs;
29
30 41335702 constexpr auto eps = 1e-8;
31
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 130 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 23674 times.
✓ Branch 9 taken 46480 times.
✓ Branch 10 taken 20622564 times.
✓ Branch 11 taken 20689464 times.
✓ Branch 12 taken 20689464 times.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 41335572 times.
103407348 assert(std::any_of(v.begin(), v.end(), [=](auto x){ return abs(x) > eps; }));
32
33
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 41335702 times.
41335702 const auto result = std::distance(
34
5/14
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 23674 times.
✓ Branch 9 taken 46480 times.
✓ Branch 10 taken 20622434 times.
✓ Branch 11 taken 20689464 times.
✓ Branch 12 taken 20689594 times.
✗ Branch 13 not taken.
62071646 std::begin(v), std::find_if(v.begin(), v.end(), [eps=eps](auto x){ return abs(x) > eps; })
35 );
36
37 // make sure there is only one non-zero entry
38
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41335702 times.
82671404 assert(v[result] == std::accumulate(v.begin(), v.end(), 0.0));
39
40 41335702 return result;
41 }
42
43 } // end namespace Dumux
44
45 #endif
46