Airy.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 "Airy.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace waveModels
34 {
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const objectRegistry& db,
46  const dictionary& dict
47 )
48 :
49  waveModel(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  return amplitude(t)*cos(angle(t, u, x));
69 }
70 
71 
73 (
74  const scalar t,
75  const scalar u,
76  const vector2DField& xz
77 ) const
78 {
79  const scalarField x(xz.component(0));
80  const scalarField z(xz.component(1));
81 
82  const scalarField phi(angle(t, u, x));
83  const scalarField kz(- k()*mag(z - elevation(t, u, x)));
84  const scalar wa = omega(u)*amplitude(t);
85 
86  if (shallow())
87  {
88  const scalar kh = k()*depth();
89  const scalarField khz((kh + kz)*pos0(kh + kz));
90  return wa*zip(cosh(khz)*cos(phi), sinh(khz)*sin(phi))/sinh(kh);
91  }
92  else
93  {
94  return wa*exp(kz)*zip(cos(phi), sin(phi));
95  }
96 }
97 
98 
99 // ************************************************************************* //
tmp< vector2DField > zip(const tmp< scalarField > &x, const tmp< scalarField > &y)
Definition: vector2DField.C:31
surfaceScalarField & phi
Airy(const objectRegistry &db, const dictionary &dict)
Construct from a database and a dictionary.
Definition: Airy.C:44
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
defineTypeNameAndDebug(Airy, 0)
First-order wave model.
Definition: Airy.H:58
label k
Boltzmann constant.
Macros for easy insertion into run-time selection tables.
dimensionedScalar cos(const dimensionedScalar &ds)
dimensionedScalar exp(const dimensionedScalar &ds)
Generic base class for waves. Derived classes must implement field functions which return the elevati...
Definition: waveModel.H:55
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)
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar cosh(const dimensionedScalar &ds)
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
virtual ~Airy()
Destructor.
Definition: Airy.C:55
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