GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/discretization/staggered/elementsolution.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 14 19 73.7%
Branches: 19 96 19.8%

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 * \brief The local element solution class for staggered methods
11 */
12 #ifndef DUMUX_STAGGERED_ELEMENT_SOLUTION_HH
13 #define DUMUX_STAGGERED_ELEMENT_SOLUTION_HH
14
15 #include <type_traits>
16 #include <dune/istl/bvector.hh>
17 #include <dumux/discretization/method.hh>
18
19 namespace Dumux {
20
21 /*!
22 * \ingroup StaggeredDiscretization
23 * \brief Helper function to create a PrimaryVariables object from CellCenterPrimaryVariables
24 * \tparam PrimaryVariables The type of the desired primary variables object
25 * \tparam CellCenterPrimaryVariables The type of the cell center (input) primary variables object
26 * \param cellCenterPriVars The cell center (input) primary variables object
27 */
28 template<class PrimaryVariables, class CellCenterPrimaryVariables>
29 PrimaryVariables makePriVarsFromCellCenterPriVars(const CellCenterPrimaryVariables& cellCenterPriVars)
30 {
31 static_assert(int(PrimaryVariables::dimension) > int(CellCenterPrimaryVariables::dimension),
32 "PrimaryVariables' size must be greater than the one of CellCenterPrimaryVariables");
33
34 60707430 PrimaryVariables priVars(0.0);
35 constexpr auto offset = PrimaryVariables::dimension - CellCenterPrimaryVariables::dimension;
36
10/84
✓ Branch 0 taken 120444508 times.
✓ Branch 1 taken 33500244 times.
✓ Branch 2 taken 58602770 times.
✓ Branch 3 taken 17590790 times.
✓ Branch 4 taken 7427546 times.
✓ Branch 5 taken 2653704 times.
✓ Branch 6 taken 1138150 times.
✓ Branch 7 taken 381120 times.
✓ Branch 8 taken 756942 times.
✓ Branch 9 taken 214136 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
255558350 for (std::size_t i = 0; i < cellCenterPriVars.size(); ++i)
37
9/12
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1016716 times.
✓ Branch 2 taken 3191836 times.
✓ Branch 3 taken 1016716 times.
✓ Branch 4 taken 3191836 times.
✓ Branch 5 taken 421772 times.
✓ Branch 6 taken 1327516 times.
✓ Branch 7 taken 421772 times.
✓ Branch 8 taken 1327511 times.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
577945628 priVars[i + offset] = cellCenterPriVars[i];
38 return priVars;
39 }
40
41 template<class PrimaryVariables>
42 using StaggeredElementSolution = Dune::BlockVector<PrimaryVariables>;
43
44 /*!
45 * \ingroup Discretization
46 * \brief Make an element solution for staggered schemes
47 * \note This is e.g. used to construct an element solution at Dirichlet boundaries
48 */
49 template<class FVElementGeometry, class PrimaryVariables>
50 109074808 auto elementSolution(PrimaryVariables&& priVars)
51 -> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::staggered,
52 StaggeredElementSolution<PrimaryVariables>>
53 {
54 109074808 return StaggeredElementSolution<PrimaryVariables>({std::move(priVars)});
55 }
56
57 /*!
58 * \ingroup Discretization
59 * \brief Helper function to create an elementSolution from cell center primary variables
60 * \tparam PrimaryVariables The type of the desired primary variables object
61 * \tparam CellCenterPrimaryVariables The type of the cell center (input) primary variables object
62 * \param cellCenterPriVars The cell center (input) primary variables object
63 */
64 template<class PrimaryVariables, class CellCenterPrimaryVariables>
65 56784 StaggeredElementSolution<PrimaryVariables> makeElementSolutionFromCellCenterPrivars(const CellCenterPrimaryVariables& cellCenterPriVars)
66 {
67 113568 return StaggeredElementSolution<PrimaryVariables>({makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars)});
68 }
69
70 } // end namespace Dumux
71
72 #endif
73