3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
boundaryfluxes.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 *****************************************************************************/
30#ifndef DUMUX_SHALLOWWATER_BOUNDARYFLUXES_HH
31#define DUMUX_SHALLOWWATER_BOUNDARYFLUXES_HH
32
33#include <array>
34#include <cmath>
35
36namespace Dumux {
37namespace ShallowWater {
38
51template<class Scalar, class GlobalPosition>
52std::array<Scalar, 3> fixedWaterDepthBoundary(const Scalar waterDepthBoundary,
53 const Scalar waterDepthInside,
54 const Scalar velocityXInside,
55 const Scalar velocityYInside,
56 const Scalar gravity,
57 const GlobalPosition& nxy)
58
59{
60 std::array<Scalar, 3> cellStateOutside;
61 cellStateOutside[0] = waterDepthBoundary;
62
63 using std::sqrt;
64 const auto uboundIn = nxy[0] * velocityXInside + nxy[1] * velocityYInside;
65 const auto uboundQut = uboundIn + 2.0 * sqrt(gravity * waterDepthInside) - 2.0 * sqrt(gravity * cellStateOutside[0]);
66
67 cellStateOutside[1] = (nxy[0] * uboundQut); // we only use the normal part
68 cellStateOutside[2] = (nxy[1] * uboundQut); // we only use the normal part
69
70 return cellStateOutside;
71}
72
85template<class Scalar, class GlobalPosition>
86std::array<Scalar, 3> fixedDischargeBoundary(const Scalar dischargeBoundary,
87 const Scalar waterDepthInside,
88 const Scalar velocityXInside,
89 const Scalar velocityYInside,
90 const Scalar gravity,
91 const GlobalPosition& nxy)
92{
93 std::array<Scalar, 3> cellStateOutside;
94 using std::abs;
95 using std::sqrt;
96 using std::max;
97
98 // only impose if abs(q) > 0
99 if (abs(dischargeBoundary) > 1.0e-9)
100 {
101 const auto uboundIn = nxy[0]*velocityXInside + nxy[1]*velocityYInside;
102 const auto alphal = uboundIn + 2.0*sqrt(gravity * waterDepthInside);
103
104 //initial guess for hstar solved with newton
105 constexpr Scalar tol_hstar = 1.0E-12;
106 constexpr Scalar ink_hstar = 1.0E-9;
107 constexpr int maxstep_hstar = 30;
108
109 Scalar hstar = 0.1;
110 for (int i = 0; i < maxstep_hstar; ++i)
111 {
112 Scalar f_hstar = alphal - dischargeBoundary/hstar - 2 * sqrt(gravity * hstar);
113 Scalar df_hstar = (f_hstar -(alphal - dischargeBoundary/(hstar + ink_hstar) - 2 * sqrt(gravity * (hstar+ink_hstar))))/ink_hstar;
114 Scalar dx_hstar = -f_hstar/df_hstar;
115 hstar = max(hstar - dx_hstar,0.001);
116
117 if (dx_hstar*dx_hstar < tol_hstar)
118 break;
119 }
120
121 const auto qinner = (nxy[0] * waterDepthInside * velocityYInside) - (nxy[1] * waterDepthInside * velocityXInside);
122 cellStateOutside[0] = hstar;
123 cellStateOutside[1] = (nxy[0] * dischargeBoundary - nxy[1] * qinner)/hstar;
124 cellStateOutside[2] = (nxy[1] * dischargeBoundary + nxy[0] * qinner)/hstar;
125 }
126
127 return cellStateOutside;
128}
129
130} // end namespace ShallowWater
131} // end namespace Dumux
132
133#endif
Definition: adapt.hh:29
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