Stokes5.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "Stokes5.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace waveModels
34 {
35  defineTypeNameAndDebug(Stokes5, 0);
36  addToRunTimeSelectionTable(waveModel, Stokes5, dictionary);
37 }
38 }
39 
40 
41 // * * * * * * * * * * Static Protected Member Functions * * * * * * ** * * //
42 
44 (
45  const scalar depth,
46  const scalar amplitude,
47  const scalar length,
48  const scalar g
49 )
50 {
51  static const scalar kdGreat = log(great);
52  const scalar kd = min(max(k(length)*depth, - kdGreat), kdGreat);
53  const scalar ka = k(length)*amplitude;
54 
55  const scalar S = deep(depth, length) ? 0 : 1/cosh(2*kd);
56 
57  const scalar C0 = Airy::celerity(depth, amplitude, length, g);
58  const scalar C4ByC0 =
59  1.0/32/pow5(1 - S)
60  *(4 + 32*S - 116*sqr(S) - 400*pow3(S) - 71*pow4(S) + 146*pow5(S));
61 
62  if (debug)
63  {
64  Info<< "C4 = " << C4ByC0*C0 << endl;
65  }
66 
67  return Stokes2::celerity(depth, amplitude, length, g) + pow4(ka)*C4ByC0*C0;
68 }
69 
70 
71 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
72 
74 (
75  const dictionary& dict,
76  const scalar g,
77  const word& modelName,
78  scalar (*modelCelerity)(scalar, scalar, scalar, scalar)
79 )
80 :
81  Stokes2(dict, g, modelName, modelCelerity)
82 {}
83 
84 
85 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
86 
88 {}
89 
90 
91 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
92 
94 (
95  const scalar t,
96  const scalarField& x
97 ) const
98 {
99  static const scalar kdGreat = log(great);
100  const scalar kd = min(max(k()*depth(), - kdGreat), kdGreat);
101  const scalar ka = k()*amplitude(t);
102 
103  const scalar S = deep() ? 0 : 1/cosh(2*kd), T = deep() ? 1 : tanh(kd);
104 
105  const scalar B31 =
106  - 3.0/8/pow3(1 - S)
107  *(
108  1 + 3*S + 3*sqr(S) + 2*pow3(S)
109  );
110 
111  const scalar B42 =
112  1.0/6/T/(3 + 2*S)/pow4(1 - S)
113  *(
114  6 - 26*S - 182*sqr(S) - 204*pow3(S) - 25*pow4(S) + 26*pow5(S)
115  );
116 
117  const scalar B44 =
118  1.0/24/T/(3 + 2*S)/pow4(1 - S)
119  *(
120  24 + 92*S + 122*sqr(S) + 66*pow3(S) + 67*pow4(S) + 34*pow5(S)
121  );
122 
123  const scalar B53 =
124  9.0/128/(3 + 2*S)/(4 + S)/pow6(1 - S)
125  *(
126  132 + 17*S - 2216*sqr(S) - 5897*pow3(S) - 6292*pow4(S)
127  - 2687*pow5(S) + 194*pow6(S) + 467*S*pow6(S) + 82*sqr(pow4(S))
128  );
129 
130  const scalar B55 =
131  5.0/384/(3 + 2*S)/(4 + S)/pow6(1 - S)
132  *(
133  300 + 1579*S + 3176*sqr(S) + 2949*pow3(S) + 1188*pow4(S)
134  + 675*pow5(S) + 1326*pow6(S) + 827*S*pow6(S) + 130*sqr(pow4(S))
135  );
136 
137  if (debug)
138  {
139  Info<< "B31 = " << B31 << endl
140  << "B42 = " << B42 << endl
141  << "B44 = " << B44 << endl
142  << "B53 = " << B53 << endl
143  << "B55 = " << B55 << endl;
144  }
145 
146  const scalarField phi(angle(t, x));
147 
148  return
149  Stokes2::elevation(t, x)
150  + (1/k())
151  *(
152  pow3(ka)*B31*(cos(phi) - cos(3*phi))
153  + pow4(ka)*(B42*cos(2*phi) + B44*cos(4*phi))
154  + pow5(ka)*(- (B53 + B55)*cos(phi) + B53*cos(3*phi) + B55*cos(5*phi))
155  );
156 }
157 
158 
160 (
161  const scalar t,
162  const vector2DField& xz
163 ) const
164 {
165  static const scalar kdGreat = log(great);
166  const scalar kd = min(max(k()*depth(), - kdGreat), kdGreat);
167  const scalar ka = k()*amplitude(t);
168 
169  const scalar S = deep() ? 0 : 1/cosh(2*kd);
170  const scalar SByA11 = deep() ? 0 : S*sinh(kd);
171 
172  const scalar A31ByA11 =
173  1.0/8/pow3(1 - S)
174  *(
175  - 4 - 20*S + 10*sqr(S) - 13*pow3(S)
176  );
177 
178  const scalar A33ByA11 =
179  1.0/8/pow3(1 - S)
180  *(
181  - 2*sqr(S) + 11*pow3(S)
182  );
183 
184  const scalar A42ByA11 =
185  SByA11/24/pow5(1 - S)
186  *(
187  12 - 14*S - 264*sqr(S) - 45*pow3(S) - 13*pow4(S)
188  );
189 
190  const scalar A44ByA11 =
191  SByA11/48/(3 + 2*S)/pow5(1 - S)
192  *(
193  10*sqr(S) - 174*pow3(S) + 291*pow4(S) + 278*pow5(S)
194  );
195 
196  const scalar A51ByA11 =
197  1.0/64/(3 + 2*S)/(4 + S)/pow6(1 - S)
198  *(
199  - 1184 + 32*S + 13232*sqr(S) + 21712*pow3(S) + 20940*pow4(S)
200  + 12554*pow5(S) - 500*pow6(S) - 3341*S*pow6(S) - 670*sqr(pow4(S))
201  );
202 
203  const scalar A53ByA11 =
204  1.0/32/(3 + 2*S)/pow6(1 - S)
205  *(
206  4*S + 105*sqr(S) + 198*pow3(S) - 1376*pow4(S) - 1302*pow5(S)
207  - 117*pow6(S) + 58*S*pow6(S)
208  );
209 
210  const scalar A55ByA11 =
211  1.0/64/(3 + 2*S)/(4 + S)/pow6(1 - S)
212  *(
213  - 6*pow3(S) + 272*pow4(S) - 1552*pow5(S) + 852*pow6(S)
214  + 2029*S*pow6(S) + 430*sqr(pow4(S))
215  );
216 
217  if (debug)
218  {
219  const scalar A11 = 1/sinh(kd);
220  Info<< "A31 = " << A31ByA11*A11 << endl
221  << "A33 = " << A33ByA11*A11 << endl
222  << "A42 = " << A42ByA11*A11 << endl
223  << "A44 = " << A44ByA11*A11 << endl
224  << "A51 = " << A51ByA11*A11 << endl
225  << "A53 = " << A53ByA11*A11 << endl
226  << "A55 = " << A55ByA11*A11 << endl;
227  }
228 
229  const vector2DField v1(vi(1, t, xz)), v3(vi(3, t, xz));
230 
231  return
232  Stokes2::velocity(t, xz)
233  + Airy::celerity()
234  *(
235  pow3(ka)*(A31ByA11*v1 + A33ByA11*v3)
236  + pow4(ka)*(A42ByA11*vi(2, t, xz) + A44ByA11*vi(4, t, xz))
237  + pow5(ka)*(A51ByA11*v1 + A53ByA11*v3 + A55ByA11*vi(5, t, xz))
238  );
239 }
240 
241 
242 // ************************************************************************* //
dimensionedScalar tanh(const dimensionedScalar &ds)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensionedScalar log(const dimensionedScalar &ds)
virtual scalar celerity() const
The wave celerity [m/s].
Definition: Stokes5.H:76
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
defineTypeNameAndDebug(Airy, 0)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
label k
Boltzmann constant.
virtual ~Stokes5()
Destructor.
Definition: Stokes5.C:87
dimensionedScalar pow5(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
virtual scalar celerity() const
The wave celerity [m/s].
Definition: Airy.H:130
virtual tmp< scalarField > elevation(const scalar t, const scalarField &x) const
Get the wave elevation at a given time and local coordinates. Local.
Definition: Stokes2.C:92
virtual tmp< vector2DField > velocity(const scalar t, const vector2DField &xz) const
Get the wave velocity at a given time and local coordinates. Local.
Definition: Stokes2.C:117
dimensionedScalar cos(const dimensionedScalar &ds)
virtual tmp< vector2DField > velocity(const scalar t, const vector2DField &xz) const
Get the wave velocity at a given time and local coordinates. Local.
Definition: Stokes5.C:160
A class for handling words, derived from string.
Definition: word.H:59
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const GeometricField< Type, fvPatchField, volMesh > &)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
phi
Definition: correctPhi.H:3
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
virtual tmp< scalarField > elevation(const scalar t, const scalarField &x) const
Get the wave elevation at a given time and local coordinates. Local.
Definition: Stokes5.C:94
dimensionedScalar pow3(const dimensionedScalar &ds)
Second-order wave model.
Definition: Stokes2.H:59
addToRunTimeSelectionTable(waveModel, Airy, dictionary)
dimensionedScalar sinh(const dimensionedScalar &ds)
dimensionedScalar pow4(const dimensionedScalar &ds)
virtual scalar celerity() const
The wave celerity [m/s].
Definition: Stokes2.H:77
dimensionedScalar pow6(const dimensionedScalar &ds)
messageStream Info
dimensionedScalar cosh(const dimensionedScalar &ds)
A class for managing temporary objects.
Definition: PtrList.H:53
Stokes5(const dictionary &dict, const scalar g, const word &modelName=Stokes5::typeName, scalar(*modelCelerity)(scalar, scalar, scalar, scalar)=&Stokes5::celerity)
Construct from a dictionary and gravity.
Definition: Stokes5.C:74
Namespace for OpenFOAM.