GCC Code Coverage Report


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