GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/material/fluidmatrixinteractions/frictionlaws/frictionlaw.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 8 8 100.0%
Functions: 0 0 -%
Branches: 4 14 28.6%

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 FrictionLaws
10 * \brief Implementation of the abstract base class for friction laws.
11 */
12
13 #ifndef DUMUX_MATERIAL_FLUIDMATRIX_FRICTIONLAW_HH
14 #define DUMUX_MATERIAL_FLUIDMATRIX_FRICTIONLAW_HH
15
16 #include <algorithm>
17 #include <cmath>
18
19 #include <dune/common/fvector.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup FrictionLaws
25 * \brief Implementation of the abstract base class for friction laws.
26 *
27 * A LET mobility model of Lomeland et al. 2005 \cite Lomeland2005 can be used to add an
28 * artificial water depth to limit the friction for small water depths.
29 *
30 * \note Instead of calculating the bed friction term \f$\mathbf{S_f}\f$
31 * of the shallow water equations, the implemented friction laws
32 * calculate the shear stress \f$\tau_{x}\f$ and \f$\tau_{y}\f$.
33 */
34
35 template <typename VolumeVariables >
36
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 class FrictionLaw
37 {
38 using Scalar = typename VolumeVariables::PrimaryVariables::value_type;
39 public:
40 /*!
41 * \brief Compute the bottom shear stress.
42 *
43 * \param volVars Volume variables
44 *
45 * Compute the bottom shear stress due to bottom friction.
46 * The bottom shear stress is a projection of the shear stress tensor onto the river bed.
47 * It can therefore be represented by a (tangent) vector with two entries.
48 *
49 * \return shear stress [N/m^2]. First entry is the x-component, the second the y-component.
50 */
51 virtual Dune::FieldVector<Scalar, 2> bottomShearStress(const VolumeVariables& volVars) const = 0;
52
53 /*!
54 * \brief Limit the friction for small water depth.
55 *
56 * Compute a small artificial water depth that is added to the
57 * actual water depth to avoid extreme friction values which can
58 * occur for small water depths.
59 *
60 * The function is called with a roughness height, which can be
61 * seen as roughness height of the surface (e.g. grain size). For a
62 * zero roughnessHeight the artificial water depth will be zero.
63 *
64 * A water depth minUpperH (minUpperH = 2 * roughnessHeight) is
65 * defined for the limiting. Limiting is applied between both
66 * depths.
67 *
68 * ------------------------- minUpperH -----------
69 *
70 *
71 *
72 * ------------------------roughnessHeight ---------------
73 * /\ /\ roughness /grain\
74 * -------------------------------bottom ------------------
75 * /////////////////////////////////////////////////
76 *
77 * For the limiting the LET model is used, which is usually applied in the
78 * porous media flow to limit the permeability due to the saturation. It employs
79 * the three empirical parameters L, E and T, which describe the limiting curve (mobility).
80 *
81 * auto mobility = (mobility_max * pow(sw,L))/(pow(sw,L) + E * pow(1.0-sw,T));
82 *
83 * For the limitation of the roughness height L = 0.0, T = 2.0 and E = 1.0 are chosen.
84 * Therefore the calculation of the mobility is simplified significantly.
85 *
86 * \param roughnessHeight roughness height of the representative structure (e.g. largest grain size).
87 * \param waterDepth water depth.
88 * \param eps If the roughness height falls below this threshold, this function returns zero.
89 */
90 2449747 Scalar limitRoughH(const Scalar roughnessHeight, const Scalar waterDepth, const Scalar eps=1.0e-12) const
91 {
92 using std::clamp;
93
94 // return zero if the roughness depth is near zero
95
2/4
✓ Branch 0 taken 1071465 times.
✓ Branch 1 taken 1378282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2449747 if (roughnessHeight < eps) return 0.0;
96
97 // calculate the artificial water depth
98 1071465 const Scalar mobilityMax = 1.0; //!< maximal mobility
99
100 1071465 const Scalar minUpperH = roughnessHeight * 2.0;
101
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1071465 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1071465 const Scalar sw = clamp(waterDepth * (1.0/minUpperH), 0.0, 1.0);
102 1071465 const Scalar mobility = mobilityMax /(1.0 + (1.0-sw)*(1.0-sw));
103 1071465 return roughnessHeight * (1.0 - mobility);
104 }
105
106 // virtual base class needs a virtual destructor
107 virtual ~FrictionLaw() = default;
108 };
109
110 } // end namespace Dumux
111
112 #endif
113