Airy.H
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 Class
25  Foam::waveModels::Airy
26 
27 Description
28  First-order wave model.
29 
30  Reference:
31  \verbatim
32  Stokes, G.G. (1847)
33  On the theory of oscillatory waves.
34  Transactions of the Cambridge Philosophical Society, 8, 441.
35  \endverbatim
36 
37  See the leading terms of equations 18 and 19.
38 
39 Usage
40  \table
41  Property | Description | Required? | Default
42  depth | The water depth [m] | no | great
43  amplitude | The amplitude [m] | yes |
44  length | The wave length [m] | if period not set |
45  period | The wave period [s] | if length not set |
46  phase | The phase offset [rad] | yes |
47  \endtable
48 
49  Example specification in constant/waveProperties:
50  \verbatim
51  waves
52  (
53  Airy
54  {
55  length 40;
56  amplitude 0.5;
57  phase 0;
58  }
59  );
60  \endverbatim
61 
62 SourceFiles
63  Airy.C
64 
65 \*---------------------------------------------------------------------------*/
66 
67 #ifndef Airy_H
68 #define Airy_H
69 
70 #include "waveModel.H"
71 #include "AiryCoeffs.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 namespace waveModels
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class Airy Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 class Airy
85 :
86  public waveModel
87 {
88  // Private Data
89 
90  //- Depth [m]
91  const scalar depth_;
92 
93  //- Amplitude [m]
94  autoPtr<Function1<scalar>> amplitude_;
95 
96  //- Wavelength [m]
97  const scalar length_;
98 
99  //- Phase offset [rad]
100  const scalar phase_;
101 
102 
103  // Private Member Functions
104 
105  //- Read and return the wave length from the dictionary. Either reads
106  // the length directly, or reads the period and depth and calculates
107  // the length.
108  static scalar readLength
109  (
110  const dictionary& dict,
111  const scalar depth,
112  const scalar amplitude,
113  const scalar g,
114  scalar (*celerityPtr)(const AiryCoeffs&)
115  );
116 
117 
118 protected:
119 
120  // Protected Member Functions
121 
122  //- Return the wave coefficients
123  AiryCoeffs coeffs(const scalar t) const;
124 
125  //- Return the wave coefficients at steady state
126  AiryCoeffs coeffs() const;
127 
128  //- The wave celerity [m/s]
129  static scalar celerity(const AiryCoeffs&);
130 
131 
132 public:
133 
134  //- Runtime type information
135  TypeName("Airy");
136 
137 
138  // Constructors
139 
140  //- Construct a copy
141  Airy(const Airy& wave);
142 
143  //- Construct from a dictionary and gravity
144  Airy
145  (
146  const dictionary& dict,
147  const scalar g,
148  const word& modelName = Airy::typeName,
149  scalar (*celerityPtr)(const AiryCoeffs&) = &AiryCoeffs::celerity
150  );
151 
152  //- Construct a clone
153  virtual autoPtr<waveModel> clone() const
154  {
155  return autoPtr<waveModel>(new Airy(*this));
156  }
157 
158 
159  //- Destructor
160  virtual ~Airy();
161 
162 
163  // Member Functions
164 
165  // Access
166 
167  //- Get the depth
168  scalar depth() const;
169 
170  //- Get the amplitude
171  scalar amplitude(const scalar t) const;
172 
173  //- Get the amplitude at steady state
174  scalar amplitude() const;
175 
176  //- Get the length
177  scalar length() const;
178 
179  //- Get the phase
180  scalar phase() const;
181 
182 
183  //- The wave celerity [m/s]
184  virtual scalar celerity() const;
185 
186  //- Get the wave elevation at a given time and local coordinates. Local
187  // x is aligned with the direction of propagation.
189  (
190  const scalar t,
191  const scalarField& x
192  ) const;
193 
194  //- Get the wave velocity at a given time and local coordinates. Local
195  // x is aligned with the direction of propagation, and z with negative
196  // gravity.
198  (
199  const scalar t,
200  const vector2DField& xz
201  ) const;
202 
203  //- Write
204  virtual void write(Ostream& os) const;
205 };
206 
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 } // End namespace waveModels
211 } // End namespace Foam
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #include "AiryI.H"
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
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
scalar g() const
Get the value of gravity.
Definition: waveModel.H:117
Calculation engine for the Airy wave model and other models that are a correction on top of the Airy ...
Definition: AiryCoeffs.H:52
scalar celerity() const
The wave celerity [m/s].
Definition: AiryCoeffs.C:111
First-order wave model.
Definition: Airy.H:116
scalar length() const
Get the length.
Definition: AiryI.H:65
scalar amplitude() const
Get the amplitude at steady state.
Definition: AiryI.H:59
virtual scalar celerity() const
The wave celerity [m/s].
Definition: Airy.C:131
virtual ~Airy()
Destructor.
Definition: Airy.C:125
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 autoPtr< waveModel > clone() const
Construct a clone.
Definition: Airy.H:182
TypeName("Airy")
Runtime type information.
virtual void write(Ostream &os) const
Write.
Definition: Airy.C:159
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
scalar depth() const
Get the depth.
Definition: AiryI.H:47
scalar phase() const
Get the phase.
Definition: AiryI.H:71
Airy(const Airy &wave)
Construct a copy.
Definition: Airy.C:91
A class for handling words, derived from string.
Definition: word.H:62
label wave(const fvMesh &mesh, const List< labelPair > &changedPatchAndFaces, const label nCorrections, GeometricField< scalar, PatchField, GeoMesh > &distance, TrackingData &td, GeometricField< DataType, PatchField, GeoMesh > &... data)
Wave distance (and maybe additional) data from faces. If nCorrections is.
Namespace for OpenFOAM.
dictionary dict