Loading [MathJax]/extensions/tex2jax.js
3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test/freeflow/shallowwater/roughchannel/problem.hh
Go to the documentation of this file.
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_ROUGH_CHANNEL_TEST_PROBLEM_HH
25#define DUMUX_ROUGH_CHANNEL_TEST_PROBLEM_HH
26
27#include <dune/grid/yaspgrid.hh>
29#include "spatialparams.hh"
31
35
36namespace Dumux {
37
38template <class TypeTag>
39class RoughChannelProblem;
40
41// Specify the properties for the problem
42namespace Properties {
43
44// Create new type tags
45namespace TTag {
46struct RoughChannel { using InheritsFrom = std::tuple<ShallowWater, CCTpfaModel>; };
47} // end namespace TTag
48
49template<class TypeTag>
50struct Grid<TypeTag, TTag::RoughChannel>
51{ using type = Dune::YaspGrid<2, Dune::TensorProductCoordinates<GetPropType<TypeTag, Properties::Scalar>, 2> >; };
52
53// Set the problem property
54template<class TypeTag>
55struct Problem<TypeTag, TTag::RoughChannel>
57
58// Set the spatial parameters
59template<class TypeTag>
60struct SpatialParams<TypeTag, TTag::RoughChannel>
61{
62private:
65 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
66 using VolumeVariables = typename ElementVolumeVariables::VolumeVariables;
67public:
69};
70
71template<class TypeTag>
72struct EnableGridGeometryCache<TypeTag, TTag::RoughChannel>
73{ static constexpr bool value = true; };
74
75template<class TypeTag>
76struct EnableGridVolumeVariablesCache<TypeTag, TTag::RoughChannel>
77{ static constexpr bool value = false; };
78} // end namespace Properties
79
111template <class TypeTag>
113{
121 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
123 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
124 using VolumeVariables = typename ElementVolumeVariables::VolumeVariables;
125 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
126 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
128 using Element = typename GridView::template Codim<0>::Entity;
129 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
131 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
132
133public:
134 RoughChannelProblem(std::shared_ptr<const GridGeometry> gridGeometry)
136 {
137 name_ = getParam<std::string>("Problem.Name");
138 exactWaterDepth_.resize(gridGeometry->numDofs(), 0.0);
139 exactVelocityX_.resize(gridGeometry->numDofs(), 0.0);
140 constManningN_ = getParam<Scalar>("Problem.ManningN");
141 bedSlope_ = getParam<Scalar>("Problem.BedSlope");
142 discharge_ = getParam<Scalar>("Problem.Discharge");
143 hBoundary_ = this->gauklerManningStrickler(discharge_,constManningN_,bedSlope_);
144 }
145
147 const std::vector<Scalar>& getExactWaterDepth()
148 {
149 return exactWaterDepth_;
150 }
151
153 const std::vector<Scalar>& getExactVelocityX()
154 {
155 return exactVelocityX_;
156 }
157
159 Scalar gauklerManningStrickler(Scalar discharge, Scalar manningN, Scalar bedSlope)
160 {
161 using std::pow;
162 using std::abs;
163 using std::sqrt;
164
165 return pow(abs(discharge)*manningN/sqrt(bedSlope), 0.6);
166 }
167
170 {
171 using std::abs;
172
173 for (const auto& element : elements(this->gridGeometry().gridView()))
174 {
175 const Scalar h = this->gauklerManningStrickler(discharge_,constManningN_,bedSlope_);
176 const Scalar u = abs(discharge_)/h;
177
178 const auto eIdx = this->gridGeometry().elementMapper().index(element);
179 exactWaterDepth_[eIdx] = h;
180 exactVelocityX_[eIdx] = u;
181 }
182 }
183
187 // \{
188
194 const std::string& name() const
195 {
196 return name_;
197 }
198
217 NumEqVector source(const Element& element,
218 const FVElementGeometry& fvGeometry,
219 const ElementVolumeVariables& elemVolVars,
220 const SubControlVolume &scv) const
221 {
222
223 NumEqVector source (0.0);
224
225 source += bottomFrictionSource(element, fvGeometry, elemVolVars, scv);
226
227 return source;
228 }
229
240 NumEqVector bottomFrictionSource(const Element& element,
241 const FVElementGeometry& fvGeometry,
242 const ElementVolumeVariables& elemVolVars,
243 const SubControlVolume &scv) const
244 {
245 NumEqVector bottomFrictionSource(0.0);
246
247 const auto& volVars = elemVolVars[scv];
248 Dune::FieldVector<Scalar, 2> bottomShearStress = this->spatialParams().frictionLaw(element, scv).shearStress(volVars);
249
250 bottomFrictionSource[0] = 0.0;
251 bottomFrictionSource[1] =bottomShearStress[0];
252 bottomFrictionSource[2] =bottomShearStress[1];
253
255 }
256
257 // \}
258
262 // \{
263
270 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
271 {
272 BoundaryTypes bcTypes;
273 bcTypes.setAllNeumann();
274 return bcTypes;
275 }
276
289 NeumannFluxes neumann(const Element& element,
290 const FVElementGeometry& fvGeometry,
291 const ElementVolumeVariables& elemVolVars,
292 const ElementFluxVariablesCache& elemFluxVarsCache,
293 const SubControlVolumeFace& scvf) const
294 {
295 NeumannFluxes values(0.0);
296
297 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
298 const auto& insideVolVars = elemVolVars[insideScv];
299 const auto& nxy = scvf.unitOuterNormal();
300 const auto gravity = this->spatialParams().gravity(scvf.center());
301 std::array<Scalar, 3> boundaryStateVariables;
302
303 // impose discharge at the left side
304 if (scvf.center()[0] < 0.0 + eps_)
305 {
306 boundaryStateVariables = ShallowWater::fixedDischargeBoundary(discharge_,
307 insideVolVars.waterDepth(),
308 insideVolVars.velocity(0),
309 insideVolVars.velocity(1),
310 gravity,
311 nxy);
312 }
313 // impose water depth at the right side
314 else if (scvf.center()[0] > 100.0 - eps_)
315 {
316 boundaryStateVariables = ShallowWater::fixedWaterDepthBoundary(hBoundary_,
317 insideVolVars.waterDepth(),
318 insideVolVars.velocity(0),
319 insideVolVars.velocity(1),
320 gravity,
321 nxy);
322 }
323 // no flow boundary
324 else
325 {
326 boundaryStateVariables[0] = insideVolVars.waterDepth();
327 boundaryStateVariables[1] = -insideVolVars.velocity(0);
328 boundaryStateVariables[2] = -insideVolVars.velocity(1);
329 }
330
331 auto riemannFlux = ShallowWater::riemannProblem(insideVolVars.waterDepth(),
332 boundaryStateVariables[0],
333 insideVolVars.velocity(0),
334 boundaryStateVariables[1],
335 insideVolVars.velocity(1),
336 boundaryStateVariables[2],
337 insideVolVars.bedSurface(),
338 insideVolVars.bedSurface(),
339 gravity,
340 nxy);
341
342 values[Indices::massBalanceIdx] = riemannFlux[0];
343 values[Indices::velocityXIdx] = riemannFlux[1];
344 values[Indices::velocityYIdx] = riemannFlux[2];
345
346 return values;
347 }
348
349 // \}
350
354 // \{
355
364 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
365 {
366 PrimaryVariables values(0.0);
367
368 values[0] = hBoundary_;
369 values[1] = abs(discharge_)/hBoundary_;
370 values[2] = 0.0;
371
372 return values;
373 };
374
375 // \}
376
377private:
378 std::vector<Scalar> exactWaterDepth_;
379 std::vector<Scalar> exactVelocityX_;
380 Scalar hBoundary_;
381 Scalar constManningN_; // analytic solution is only available for const friction.
382 Scalar bedSlope_;
383 Scalar discharge_; // discharge at the inflow boundary
384 static constexpr Scalar eps_ = 1.0e-6;
385 std::string name_;
386};
387
388} //end namespace Dumux
389
390#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Properties for all models using cell-centered finite volume scheme with TPFA.
Compute boundary conditions for the Riemann Solver.
std::array< Scalar, 3 > riemannProblem(const Scalar waterDepthLeft, const Scalar waterDepthRight, Scalar velocityXLeft, Scalar velocityXRight, Scalar velocityYLeft, Scalar velocityYRight, const Scalar bedSurfaceLeft, const Scalar bedSurfaceRight, const Scalar gravity, const GlobalPosition &nxy)
Construct Riemann Problem and solve it.
Definition: riemannproblem.hh:66
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
std::array< Scalar, 3 > fixedDischargeBoundary(const Scalar dischargeBoundary, const Scalar waterDepthInside, const Scalar velocityXInside, const Scalar velocityYInside, const Scalar gravity, const GlobalPosition &nxy)
Compute the outer cell state for a fixed discharge boundary.
Definition: boundaryfluxes.hh:86
std::array< Scalar, 3 > fixedWaterDepthBoundary(const Scalar waterDepthBoundary, const Scalar waterDepthInside, const Scalar velocityXInside, const Scalar velocityYInside, const Scalar gravity, const GlobalPosition &nxy)
Compute the outer cell state for fixed water depth boundary.
Definition: boundaryfluxes.hh:52
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
The DUNE grid type.
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
Definition: common/properties.hh:169
If disabled, the volume variables are not stored (reduces memory, but is slower)
Definition: common/properties.hh:178
The type of the spatial parameters object.
Definition: common/properties.hh:221
Shallow water problem base class.
Definition: dumux/freeflow/shallowwater/problem.hh:39
const SpatialParams & spatialParams() const
Returns the spatial parameters object.
Definition: dumux/freeflow/shallowwater/problem.hh:78
A simple flow in a rough channel with friction law after Manning.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:113
NeumannFluxes neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Specifies the neumann boundary.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:289
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:270
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluate the source term for all balance equations within a given sub-control-volume.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:217
const std::vector< Scalar > & getExactWaterDepth()
Get the analytical water depth.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:147
const std::string & name() const
The problem name.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:194
const std::vector< Scalar > & getExactVelocityX()
Get the analytical velocity.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:153
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluate the initial values for a control volume.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:364
NumEqVector bottomFrictionSource(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Compute the source term due to bottom friction.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:240
void updateAnalyticalSolution()
Udpate the analytical solution.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:169
RoughChannelProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:134
Scalar gauklerManningStrickler(Scalar discharge, Scalar manningN, Scalar bedSlope)
Calculate the water depth with Gaukler-Manning-Strickler.
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:159
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:46
std::tuple< ShallowWater, CCTpfaModel > InheritsFrom
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:46
Dune::YaspGrid< 2, Dune::TensorProductCoordinates< GetPropType< TypeTag, Properties::Scalar >, 2 > > type
Definition: test/freeflow/shallowwater/roughchannel/problem.hh:51
The spatial parameters class for the rough channel test.
Definition: freeflow/shallowwater/roughchannel/spatialparams.hh:44
A two-dimensional shallow water equations model The two-dimensonal shallow water equations (SWEs) can...
Definition of the spatial parameters for the MaxwellStefan problem.