GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/fluidmatrixinteractions/frictionlaws/nikuradse.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 11 11 100.0%
Functions: 1 1 100.0%
Branches: 3 6 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 Fluidmatrixinteractions
10 * \copydoc Dumux::FrictionLawNikuradse
11 */
12 #ifndef DUMUX_MATERIAL_FLUIDMATRIX_FRICTIONLAW_NIKURADSE_HH
13 #define DUMUX_MATERIAL_FLUIDMATRIX_FRICTIONLAW_NIKURADSE_HH
14
15 #include <algorithm>
16 #include <cmath>
17 #include <dune/common/math.hh>
18 #include "frictionlaw.hh"
19
20 namespace Dumux {
21 /*!
22 * \ingroup Fluidmatrixinteractions
23 * \brief Implementation of the friction law after Nikuradse.
24 *
25 * The LET mobility model is used to limit the friction for small water
26 * depths if a roughness height > 0.0 is provided (default roughnessHeight = 0.0).
27 */
28
29 template <typename VolumeVariables>
30 class FrictionLawNikuradse : public FrictionLaw<VolumeVariables>
31 {
32 using Scalar = typename VolumeVariables::PrimaryVariables::value_type;
33 public:
34 /*!
35 * \brief Constructor
36 *
37 * \param ks Equivalent sand roughness (in m)
38 * \param roughnessHeight roughness height (in m) default = 0.0
39 */
40 1 FrictionLawNikuradse(const Scalar ks, const Scalar roughnessHeight=0.0)
41
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 : ks_(ks), roughnessHeight_(roughnessHeight) {}
42
43 /*!
44 * \brief Compute the bottom shear stress.
45 *
46 * \param volVars Volume variables
47 *
48 * Compute the bottom shear stress due to bottom friction.
49 * The bottom shear stress is a projection of the shear stress tensor onto the river bed.
50 * It can therefore be represented by a (tangent) vector with two entries.
51 *
52 * \return shear stress in N/m^2. First entry is the x-component, the second the y-component.
53 */
54 1070877 Dune::FieldVector<Scalar, 2> bottomShearStress(const VolumeVariables& volVars) const final
55 {
56 using Dune::power;
57 using std::log;
58 using std::hypot;
59
60 1070877 Dune::FieldVector<Scalar, 2> shearStress(0.0);
61
62
2/4
✓ Branch 0 taken 1070877 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1070877 times.
✗ Branch 3 not taken.
2141754 const Scalar artificialWaterDepth = this->limitRoughH(roughnessHeight_, volVars.waterDepth());
63 1070877 const Scalar karmanConstant = 0.41; // Karman's constant is dimensionless
64 2141754 const Scalar dimensionlessFactor = power(karmanConstant, 2)/power(log((12*(volVars.waterDepth() + artificialWaterDepth))/ks_), 2);
65 3212631 const Scalar uv = hypot(volVars.velocity(0),volVars.velocity(1));
66
67 4283508 shearStress[0] = dimensionlessFactor * volVars.velocity(0) * uv * volVars.density();
68 4283508 shearStress[1] = dimensionlessFactor * volVars.velocity(1) * uv * volVars.density();
69
70 1070877 return shearStress;
71 }
72
73 private:
74 Scalar ks_;
75 Scalar roughnessHeight_;
76 };
77
78 } // end namespace Dumux
79
80 #endif
81