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-2018 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 {
35  defineTypeNameAndDebug(Stokes2, 0);
36  addToRunTimeSelectionTable(waveModel, Stokes2, objectRegistry);
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const objectRegistry& db,
46  const dictionary& dict
47 )
48 :
49  Airy(db, dict)
50 {}
51 
52 
53 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
54 
56 {}
57 
58 
59 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
60 
62 (
63  const scalar t,
64  const scalar u,
65  const scalarField& x
66 ) const
67 {
68  const scalar kd = k()*depth(), ka = k()*amplitude(t);
69 
70  const scalar T = deep() ? 1 : tanh(kd);
71 
72  const scalar B22 = (3/sqr(T) - 1)/T/4;
73 
74  if (debug)
75  {
76  Info<< "B22 = " << B22 << endl;
77  }
78 
79  return
80  Airy::elevation(t, u, x)
81  + (1/k())*sqr(ka)*B22*cos(2*angle(t, u, x));
82 }
83 
84 
86 (
87  const scalar t,
88  const scalar u,
89  const vector2DField& xz
90 ) const
91 {
92  const scalar kd = k()*depth(), ka = k()*amplitude(t);
93 
94  const scalar A22ByA11 = deep() ? 0 : 0.375/pow3(sinh(kd));
95 
96  if (debug)
97  {
98  const scalar A11 = 1/sinh(kd);
99  Info<< "A22 = " << A22ByA11*A11 << endl;
100  }
101 
102  return
103  Airy::velocity(t, u, xz)
104  + celerity()*sqr(ka)*A22ByA11*vi(2, t, u, xz);
105 }
106 
107 
108 // ************************************************************************* //
dimensionedScalar tanh(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
defineTypeNameAndDebug(Airy, 0)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Stokes2(const objectRegistry &db, const dictionary &dict)
Construct from a database and a dictionary.
Definition: Stokes2.C:44
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
First-order wave model.
Definition: Airy.H:58
label k
Boltzmann constant.
Macros for easy insertion into run-time selection tables.
virtual ~Stokes2()
Destructor.
Definition: Stokes2.C:55
dimensionedScalar cos(const dimensionedScalar &ds)
virtual tmp< vector2DField > velocity(const scalar t, const scalar u, const vector2DField &xz) const
Get the wave velocity at a given time, mean velocity and local.
Definition: Stokes2.C:86
virtual tmp< scalarField > elevation(const scalar t, const scalar u, const scalarField &x) const
Get the wave elevation at a given time, mean velocity and local.
Definition: Stokes2.C:62
addToRunTimeSelectionTable(waveModel, Airy, objectRegistry)
virtual tmp< vector2DField > velocity(const scalar t, const scalar u, const vector2DField &xz) const
Get the wave velocity at a given time, mean velocity and local.
Definition: Airy.C:144
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensionedScalar pow3(const dimensionedScalar &ds)
dimensionedScalar sinh(const dimensionedScalar &ds)
messageStream Info
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
Namespace for OpenFOAM.
virtual tmp< scalarField > elevation(const scalar t, const scalar u, const scalarField &x) const
Get the wave elevation at a given time, mean velocity and local.
Definition: Airy.C:133