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 | #ifndef DUMUX_ROUGH_CHANNEL_SPATIAL_PARAMETERS_HH | ||
9 | #define DUMUX_ROUGH_CHANNEL_SPATIAL_PARAMETERS_HH | ||
10 | |||
11 | // ## Parameter distributions (`spatialparams.hh`) | ||
12 | // | ||
13 | // This file contains the __spatial parameters class__ which defines the | ||
14 | // the friction law, including it's friction parameter, the acceleration | ||
15 | // due to gravity and the altitude of the channel bed surface. In this example only the bed | ||
16 | // surface has a non constant distribution. | ||
17 | // | ||
18 | // [[content]] | ||
19 | // | ||
20 | // ### Include files | ||
21 | // [[details]] includes | ||
22 | // We include the basic spatial parameters file for finite volumes, from which we will inherit. | ||
23 | #include <dumux/freeflow/spatialparams.hh> | ||
24 | // We include all friction laws. | ||
25 | #include <dumux/material/fluidmatrixinteractions/frictionlaws/frictionlaw.hh> | ||
26 | #include <dumux/material/fluidmatrixinteractions/frictionlaws/manning.hh> | ||
27 | #include <dumux/material/fluidmatrixinteractions/frictionlaws/nikuradse.hh> | ||
28 | #include <dumux/material/fluidmatrixinteractions/frictionlaws/nofriction.hh> | ||
29 | // [[/details]] | ||
30 | |||
31 | // | ||
32 | // ### The spatial parameters class | ||
33 | // | ||
34 | // In the `RoughChannelSpatialParams` class, we define all functions needed to describe | ||
35 | // the rough channel for the shallow water problem. | ||
36 | // We inherit from the `FVSpatialParams` class, which is the base class | ||
37 | // for spatial parameters in the context of | ||
38 | // applications using finite volume discretization schemes. | ||
39 | // [[codeblock]] | ||
40 | namespace Dumux { | ||
41 | |||
42 | template<class GridGeometry, class Scalar, class VolumeVariables> | ||
43 | class RoughChannelSpatialParams | ||
44 | : public FreeFlowSpatialParams<GridGeometry, Scalar, | ||
45 | RoughChannelSpatialParams<GridGeometry, Scalar, VolumeVariables>> | ||
46 | { | ||
47 | // [[/codeblock]] | ||
48 | // [[details]] convenience aliases | ||
49 | using ThisType = RoughChannelSpatialParams<GridGeometry, Scalar, VolumeVariables>; | ||
50 | using ParentType = FreeFlowSpatialParams<GridGeometry, Scalar, ThisType>; | ||
51 | using GridView = typename GridGeometry::GridView; | ||
52 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
53 | using SubControlVolume = typename FVElementGeometry::SubControlVolume; | ||
54 | using Element = typename GridView::template Codim<0>::Entity; | ||
55 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
56 | // [[/details]] | ||
57 | |||
58 | // In the constructor, the properties of the the rough channel are set. Namely, these are | ||
59 | // the friction law, including it's friction parameter, the acceleration | ||
60 | // due to gravity and the altitude of the channel bed surface. | ||
61 | // [[codeblock]] | ||
62 | public: | ||
63 | 1 | RoughChannelSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry) | |
64 |
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) |
65 | { | ||
66 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | gravity_ = getParam<Scalar>("Problem.Gravity"); |
67 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | bedSlope_ = getParam<Scalar>("Problem.BedSlope"); |
68 |
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"); |
69 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | initFrictionLaw(); |
70 | 1 | } | |
71 | |||
72 | // This function handles the initialization of the friction law based on the settings | ||
73 | // specified in `params.input`. | ||
74 | 1 | void initFrictionLaw() | |
75 | { | ||
76 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | if (frictionLawType_ == "Manning") |
77 | { | ||
78 | 1 | Scalar manningN = getParam<Scalar>("Problem.ManningN"); | |
79 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | frictionLaw_ = std::make_unique<FrictionLawManning<VolumeVariables>>(gravity_, manningN); |
80 | } | ||
81 | ✗ | else if (frictionLawType_ == "Nikuradse") | |
82 | { | ||
83 | ✗ | Scalar ks = getParam<Scalar>("Problem.Ks"); | |
84 | ✗ | frictionLaw_ = std::make_unique<FrictionLawNikuradse<VolumeVariables>>(ks); | |
85 | } | ||
86 | ✗ | else if (frictionLawType_ == "None") | |
87 | { | ||
88 | ✗ | frictionLaw_ = std::make_unique<FrictionLawNoFriction<VolumeVariables>>(); | |
89 | } | ||
90 | else | ||
91 | { | ||
92 | ✗ | std::cout<<"The FrictionLaw in params.input is unknown. Valid entries are `Manning`," | |
93 | ✗ | " `Nikuradse` and `None`!"<<std::endl; | |
94 | } | ||
95 | 1 | } | |
96 | // [[/codeblock]] | ||
97 | |||
98 | // The following functions expose the parameters required by the model. | ||
99 | |||
100 | // [[codeblock]] | ||
101 | // This function returns an object of the friction law class, already initialized with a friction value. | ||
102 | ✗ | const FrictionLaw<VolumeVariables>& frictionLaw(const Element& element, | |
103 | const SubControlVolume& scv) const | ||
104 | 1726122 | { return *frictionLaw_; } | |
105 | |||
106 | // This function returns the acceleration due to gravity. | ||
107 | ✗ | Scalar gravity(const GlobalPosition& globalPos) const | |
108 | ✗ | { return gravity_; } | |
109 | |||
110 | // Define the bed surface based on the bed slope and the bed level at the inflow (10 m). | ||
111 | ✗ | Scalar bedSurface(const Element& element, | |
112 | const SubControlVolume& scv) const | ||
113 | ✗ | { return 10.0 - element.geometry().center()[0] * bedSlope_; } | |
114 | // [[/codeblock]] | ||
115 | |||
116 | // [[details]] private variables | ||
117 | private: | ||
118 | Scalar gravity_; | ||
119 | Scalar bedSlope_; | ||
120 | std::string frictionLawType_; | ||
121 | std::unique_ptr<FrictionLaw<VolumeVariables>> frictionLaw_; | ||
122 | }; // end class definition of RoughChannelSpatialParams | ||
123 | } // end of namespace Dumux. | ||
124 | // [[/details]] | ||
125 | // [[/content]] | ||
126 | #endif | ||
127 |