Stokes2.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-2023 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 "Stokes2.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace waveModels
34 {
37 }
38 }
39 
40 
41 // * * * * * * * * * * Static Protected Member Functions * * * * * * ** * * //
42 
44 {
45  static const scalar kdGreat = log(great);
46  const scalar kd = min(max(coeffs.k()*coeffs.depth, - kdGreat), kdGreat);
47  const scalar ka = coeffs.k()*coeffs.amplitude;
48 
49  const scalar S = coeffs.deep() ? 0 : 1/cosh(2*kd);
50 
51  const scalar C0 = coeffs.celerity();
52  const scalar C2ByC0 = (2 + 7*sqr(S))/4/sqr(1 - S);
53 
54  if (debug)
55  {
56  Info<< "C2 = " << C2ByC0*C0 << endl;
57  }
58 
59  return Airy::celerity(coeffs) + sqr(ka)*C2ByC0*C0;
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64 
66 (
67  const dictionary& dict,
68  const scalar g,
69  const word& modelName,
70  scalar (*celerityPtr)(const AiryCoeffs&)
71 )
72 :
73  Airy(dict, g, modelName, celerityPtr)
74 {}
75 
76 
77 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
78 
80 {}
81 
82 
83 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
84 
86 {
87  return celerity(coeffs());
88 }
89 
90 
92 (
93  const scalar t,
94  const scalarField& x
95 ) const
96 {
97  const AiryCoeffs coeffs = this->coeffs();
98 
99  static const scalar kdGreat = log(great);
100  const scalar kd = min(max(coeffs.k()*depth(), - kdGreat), kdGreat);
101  const scalar ka = coeffs.k()*amplitude(t);
102 
103  const scalar T = coeffs.deep() ? 1 : tanh(kd);
104 
105  const scalar B22 = (3/sqr(T) - 1)/T/4;
106 
107  if (debug)
108  {
109  Info<< "B22 = " << B22 << endl;
110  }
111 
112  return
113  Airy::elevation(t, x)
114  + (1/coeffs.k())*sqr(ka)*B22*cos(2*coeffs.angle(phase(), t, x));
115 }
116 
117 
119 (
120  const scalar t,
121  const vector2DField& xz
122 ) const
123 {
124  const AiryCoeffs coeffs = this->coeffs();
125 
126  static const scalar kdGreat = log(great);
127  const scalar kd = min(max(coeffs.k()*depth(), - kdGreat), kdGreat);
128  const scalar ka = coeffs.k()*amplitude(t);
129 
130  const scalar A22ByA11 = coeffs.deep() ? 0 : 0.375/pow3(sinh(kd));
131 
132  if (debug)
133  {
134  const scalar A11 = 1/sinh(kd);
135  Info<< "A22 = " << A22ByA11*A11 << endl;
136  }
137 
138  return
139  Airy::velocity(t, xz)
140  + Airy::celerity()*sqr(ka)*A22ByA11*coeffs.vi(2, phase(), t, xz);
141 }
142 
143 
144 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for managing temporary objects.
Definition: tmp.H:55
Generic base class for waves. Derived classes must implement field functions which return the elevati...
Definition: waveModel.H:56
Calculation engine for the Airy wave model and other models that are a correction on top of the Airy ...
Definition: AiryCoeffs.H:52
const scalar depth
Depth [m].
Definition: AiryCoeffs.H:76
bool deep() const
Return whether shallow and intermediate effects are to be omitted.
Definition: AiryCoeffs.C:99
tmp< vector2DField > vi(const label i, const scalar phase, const scalar t, const vector2DField &xz) const
Return the non-dimensionalised i-th harmonic of the velocity.
Definition: AiryCoeffs.C:140
const scalar amplitude
Amplitude [m].
Definition: AiryCoeffs.H:79
tmp< scalarField > angle(const scalar phase, const scalar t, const scalarField &x) const
Angle of the oscillation [rad].
Definition: AiryCoeffs.C:118
static scalar celerity(const AiryCoeffs &coeffs)
The wave celerity [m/s].
Definition: AiryCoeffs.C:105
scalar k() const
The angular wavenumber [rad/m].
Definition: AiryCoeffs.C:93
First-order wave model.
Definition: Airy.H:116
virtual scalar celerity() const
The wave celerity [m/s].
Definition: Airy.C:131
AiryCoeffs coeffs() const
Return the wave coefficients at steady state.
Definition: AiryI.H:39
virtual tmp< scalarField > elevation(const scalar t, const scalarField &x) const
Get the wave elevation at a given time and local coordinates. Local.
Definition: Airy.C:138
virtual tmp< vector2DField > velocity(const scalar t, const vector2DField &xz) const
Get the wave velocity at a given time and local coordinates. Local.
Definition: Airy.C:148
Second-order wave model.
Definition: Stokes2.H:68
virtual scalar celerity() const
The wave celerity [m/s].
Definition: Stokes2.C:85
virtual ~Stokes2()
Destructor.
Definition: Stokes2.C:79
Stokes2(const dictionary &dict, const scalar g, const word &modelName=Stokes2::typeName, scalar(*celerityPtr)(const AiryCoeffs &)=&Stokes2::celerity)
Construct from a dictionary and gravity.
Definition: Stokes2.C:66
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:119
A class for handling words, derived from string.
Definition: word.H:62
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
defineTypeNameAndDebug(Airy, 0)
addToRunTimeSelectionTable(waveModel, Airy, dictionary)
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
dimensionedScalar pow3(const dimensionedScalar &ds)
dimensionedScalar cosh(const dimensionedScalar &ds)
dimensionedScalar tanh(const dimensionedScalar &ds)
messageStream Info
dimensionedScalar sinh(const dimensionedScalar &ds)
dimensionedScalar log(const dimensionedScalar &ds)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict