Stokes2.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2017 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 kh = k()*depth();
69  const scalarField correction(k()*sqr(amplitude(t))*cos(2*angle(t, u, x))/2);
70 
71  if (shallow())
72  {
73  const scalar factor((3/sqr(tanh(kh)) - 1)/tanh(kh)/2);
74  return Airy::elevation(t, u, x) + factor*correction;
75  }
76  else
77  {
78  return Airy::elevation(t, u, x) + correction;
79  }
80 }
81 
82 
84 (
85  const scalar t,
86  const scalar u,
87  const vector2DField& xz
88 ) const
89 {
90  if (shallow())
91  {
92  const scalarField x(xz.component(0));
93  const scalarField z(xz.component(1));
94 
95  const scalarField phi(angle(t, u, x));
96  const scalarField kz(- k()*mag(z - elevation(t, u, x)));
97  const scalar kh = k()*depth();
98  const scalarField khz((kh + kz)*pos0(kh + kz));
99  const scalar kwaa = k()*omega(u)*sqr(amplitude(t));
100 
101  return
102  Airy::velocity(t, u, xz)
103  + 6*kwaa*zip
104  (
105  cosh(2*khz)*cos(2*phi),
106  sinh(2*khz)*sin(2*phi)
107  )/pow4(sinh(kh));
108  }
109  else
110  {
111  return Airy::velocity(t, u, xz);
112  }
113 }
114 
115 
116 // ************************************************************************* //
tmp< vector2DField > zip(const tmp< scalarField > &x, const tmp< scalarField > &y)
Definition: vector2DField.C:31
surfaceScalarField & phi
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
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
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:84
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)
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: Field.C:657
dimensionedScalar pos0(const dimensionedScalar &ds)
dimensionedScalar sin(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: Airy.C:73
dimensionedScalar sinh(const dimensionedScalar &ds)
dimensionedScalar pow4(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar cosh(const dimensionedScalar &ds)
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:62