GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/common/partial.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 5 10 50.0%
Functions: 0 9 0.0%
Branches: 24 48 50.0%

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 Get only parts of a container or tuple
11 */
12 #ifndef DUMUX_COMMON_PARTIAL_HH
13 #define DUMUX_COMMON_PARTIAL_HH
14
15 #include <tuple>
16 #include <type_traits>
17
18 #include <dune/istl/multitypeblockvector.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \brief a function to get a MultiTypeBlockVector with references to some entries of another MultiTypeBlockVector
24 * \param v a MultiTypeBlockVector
25 * \param indices the indices of the entries that should be referenced
26 */
27 template<class ...Args, std::size_t ...i>
28 auto partial(Dune::MultiTypeBlockVector<Args...>& v, Dune::index_constant<i>... indices)
29 {
30
6/12
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
118 return Dune::MultiTypeBlockVector<std::add_lvalue_reference_t<std::decay_t<std::tuple_element_t<indices, std::tuple<Args...>>>>...>(v[indices]...);
31 }
32
33 /*!
34 * \brief a function to get a MultiTypeBlockVector with const references to some entries of another MultiTypeBlockVector
35 * \param v a MultiTypeBlockVector
36 * \param indices the indices of the entries that should be referenced
37 */
38 template<class ...Args, std::size_t ...i>
39 auto partial(const Dune::MultiTypeBlockVector<Args...>& v, Dune::index_constant<i>... indices)
40 {
41
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
4 return Dune::MultiTypeBlockVector<std::add_lvalue_reference_t<const std::decay_t<std::tuple_element_t<indices, std::tuple<Args...>>>>...>(v[indices]...);
42 }
43
44 /*!
45 * \brief a function to get a tuple with references to some entries of another tuple
46 * \param v a tuple
47 * \param indices a tuple of indices of the entries that should be referenced
48 */
49 template<class ...Args, std::size_t ...i>
50 auto partial(std::tuple<Args...>& v, Dune::index_constant<i>... indices)
51 {
52
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
6 return std::tuple<std::add_lvalue_reference_t<std::decay_t<std::tuple_element_t<indices, std::tuple<Args...>>>>...>(std::get<indices>(v)...);
53 }
54
55 /*!
56 * \brief a function to get a tuple with const references to some entries of another tuple
57 * \param v a tuple
58 * \param indices a tuple of indices of the entries that should be referenced
59 */
60 template<class ...Args, std::size_t ...i>
61 auto partial(const std::tuple<Args...>& v, Dune::index_constant<i>... indices)
62 {
63
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
4 return std::tuple<std::add_lvalue_reference_t<const std::decay_t<std::tuple_element_t<indices, std::tuple<Args...>>>>...>(std::get<indices>(v)...);
64 }
65
66 /*!
67 * \brief a function to get a MultiTypeBlockVector with references to some entries of another MultiTypeBlockVector
68 * \param t an std::tuple or Dune::MultiTypeBlockVector
69 * \param indices a tuple of indices of the entries that should be referenced
70 */
71 template<class T, std::size_t ...i>
72 auto partial(T& t, std::tuple<Dune::index_constant<i>...> indices)
73 {
74
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
4 return partial(t, Dune::index_constant<i>{}...);
75 }
76
77 } // end namespace Dumux
78
79 #endif
80