GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/freeflow/shallowwater/roughchannel/spatialparams.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 13 22 59.1%
Functions: 2 5 40.0%
Branches: 11 34 32.4%

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 ShallowWaterTests
10 * \brief The spatial parameters for the rough channel problem.
11 */
12 #ifndef DUMUX_ROUGH_CHANNEL_SPATIAL_PARAMETERS_HH
13 #define DUMUX_ROUGH_CHANNEL_SPATIAL_PARAMETERS_HH
14
15 #include <dumux/common/parameters.hh>
16 #include <dumux/material/fluidmatrixinteractions/frictionlaws/frictionlaw.hh>
17 #include <dumux/material/fluidmatrixinteractions/frictionlaws/manning.hh>
18 #include <dumux/material/fluidmatrixinteractions/frictionlaws/nikuradse.hh>
19 #include <dumux/freeflow/spatialparams.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup ShallowWaterTests
25 * \brief The spatial parameters class for the rough channel test.
26 *
27 */
28 template<class GridGeometry, class Scalar, class VolumeVariables>
29 class RoughChannelSpatialParams
30 : public FreeFlowSpatialParams<GridGeometry, Scalar,
31 RoughChannelSpatialParams<GridGeometry, Scalar, VolumeVariables>>
32 {
33 using ThisType = RoughChannelSpatialParams<GridGeometry, Scalar, VolumeVariables>;
34 using ParentType = FreeFlowSpatialParams<GridGeometry, Scalar, ThisType>;
35 using GridView = typename GridGeometry::GridView;
36 using FVElementGeometry = typename GridGeometry::LocalView;
37 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
38 using Element = typename GridView::template Codim<0>::Entity;
39 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
40
41 public:
42 1 RoughChannelSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
43
4/16
✓ Branch 2 taken 1 times.
✗ Branch 3 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 12 not taken.
✗ Branch 13 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.
3 : ParentType(gridGeometry)
44 {
45
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 gravity_ = getParam<Scalar>("Problem.Gravity");
46
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 bedSlope_ = getParam<Scalar>("Problem.BedSlope");
47
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 frictionLawType_ = getParam<std::string>("Problem.FrictionLaw");
48
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 initFrictionLaw();
49 1 }
50
51 /*!
52 * \brief Initialize the FrictionLaw
53 */
54 1 void initFrictionLaw()
55 {
56
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 if (frictionLawType_ == "Manning")
57 {
58 1 Scalar manningN = getParam<Scalar>("Problem.ManningN");
59
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 frictionLaw_ = std::make_unique<FrictionLawManning<VolumeVariables>>(gravity_, manningN);
60 }
61 else if (frictionLawType_ == "Nikuradse")
62 {
63 Scalar ks = getParam<Scalar>("Problem.Ks"); // equivalent sand roughness
64 frictionLaw_ = std::make_unique<FrictionLawNikuradse<VolumeVariables>>(ks);
65 }
66 else
67 {
68 std::cout<<"The FrictionLaw in params.input is unknown. Valid entries are 'Manning' and 'Nikuradse'!"<<std::endl;
69 }
70 1 }
71
72 /*! \brief Define the gravitation.
73 *
74 * \return gravity constant
75 */
76 Scalar gravity(const GlobalPosition& globalPos) const
77 {
78 return gravity_;
79 }
80
81 /*! \brief Define the gravitation.
82 *
83 * \return gravity constant
84 */
85 Scalar gravity() const
86 {
87 return gravity_;
88 }
89
90 /*! \brief Get the frictionLaw.
91 *
92 * Get the frictionLaw, which already includes the friction value.
93 *
94 * \return frictionLaw
95 */
96
97 const FrictionLaw<VolumeVariables>& frictionLaw(const Element& element,
98 const SubControlVolume& scv) const
99 {
100 1047670 return *frictionLaw_;
101 }
102
103 /*! \brief Define the bed surface
104 *
105 * \param element The current element
106 * \param scv The sub-control volume inside the element.
107 *
108 * \return The bed surface
109 */
110 Scalar bedSurface(const Element& element,
111 const SubControlVolume& scv) const
112 {
113 // todo depends on index e.g. eIdx = scv.elementIndex();
114 return 10.0 - element.geometry().center()[0] * bedSlope_;
115 }
116
117 private:
118 Scalar gravity_;
119 Scalar bedSlope_;
120 std::string frictionLawType_;
121 std::unique_ptr<FrictionLaw<VolumeVariables>> frictionLaw_;
122 };
123
124 } // end namespace Dumux
125
126 #endif
127