GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/freeflow/shallowwater/bowl/spatialparams.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 15 20 75.0%
Functions: 1 4 25.0%
Branches: 19 48 39.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-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 bowl problem.
11 */
12 #ifndef DUMUX_BOWL_SPATIAL_PARAMETERS_HH
13 #define DUMUX_BOWL_SPATIAL_PARAMETERS_HH
14
15 #include <dumux/common/parameters.hh>
16 #include <dumux/freeflow/spatialparams.hh>
17 #include <dumux/material/fluidmatrixinteractions/frictionlaws/frictionlaw.hh>
18 #include <dumux/material/fluidmatrixinteractions/frictionlaws/nofriction.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup ShallowWaterTests
24 * \brief The spatial parameters class for the bowl test.
25 * \note Analytical solution from Thacker (1981) section 4
26 * William Thacker, "Some exact solutions to the nonlinear shallow-water wave equations", Journal
27 * of Fluid Mechanics, 107:499–508, 1981
28 */
29 template<class GridGeometry, class Scalar, class VolumeVariables>
30 class BowlSpatialParams
31 : public FreeFlowSpatialParams<GridGeometry, Scalar, BowlSpatialParams<GridGeometry, Scalar, VolumeVariables>>
32 {
33 using ThisType = BowlSpatialParams<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 3 BowlSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
43
5/18
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 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.
12 : ParentType(gridGeometry)
44 {
45
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 gravity_ = getParam<Scalar>("Problem.Gravity");
46
3/6
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
3 frictionLaw_ = std::make_unique<FrictionLawNoFriction<VolumeVariables>>();
47
4/10
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
9 bedSurface_.assign(this->gridGeometry().gridView().size(0), 0.0);
48
49 // compute the bedSurface for all elements
50
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 const Scalar D0 = getParam<Scalar>("Problem.BowlDepthAtCenter");
51
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 const Scalar L = getParam<Scalar>("Problem.BowlParaboloidRadius");
52
4/8
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3283 times.
✗ Branch 10 not taken.
6569 for (const auto& element : elements(this->gridGeometry().gridView()))
53 {
54 9840 const auto eIdx = this->gridGeometry().elementMapper().index(element);
55 3280 const auto& globalPos = element.geometry().center();
56 // see Thacker (1981) Eq. (13) + shift bowl so that midpoint is a z=0
57 // the shift is arbitrary and doesn't affect the analytical solution
58 13120 const auto radiusSquared = globalPos[0]*globalPos[0] + globalPos[1]*globalPos[1];
59 3280 const auto D = D0*(1.0 - radiusSquared/(L*L));
60 6560 bedSurface_[eIdx] = D0 - D;
61 }
62 3 }
63
64 /*! \brief Define the gravitation.
65 *
66 * \return gravity constant
67 */
68 Scalar gravity(const GlobalPosition& globalPos) const
69 {
70 return gravity_;
71 }
72
73 /*! \brief Get the frictionLaw.
74 *
75 * Get the frictionLaw, which already includes the friction value.
76 *
77 * \return frictionLaw
78 */
79
80 const FrictionLaw<VolumeVariables>& frictionLaw(const Element& element,
81 const SubControlVolume& scv) const
82 { return *frictionLaw_; }
83
84 /*! \brief Define the bed surface
85 *
86 * \param element The current element
87 * \param scv The sub-control volume inside the element.
88 *
89 * \return The bed surface
90 */
91 Scalar bedSurface(const Element& element,
92 const SubControlVolume& scv) const
93 27696192 { return bedSurface_[scv.elementIndex()]; }
94
95 private:
96 std::vector<Scalar> bedSurface_;
97 Scalar gravity_;
98 std::string frictionLawType_;
99 std::unique_ptr<FrictionLaw<VolumeVariables>> frictionLaw_;
100 };
101
102 } // end namespace Dumux
103
104 #endif
105