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-2021 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 SourceFiles
40  Airy.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef Airy_H
45 #define Airy_H
46 
47 #include "waveModel.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 namespace waveModels
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class Airy Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class Airy
61 :
62  public waveModel
63 {
64  // Private Data
65 
66  //- Depth [m]
67  const scalar depth_;
68 
69  //- Peak-to-peak mean amplitude [m]
70  autoPtr<Function1<scalar>> amplitude_;
71 
72  //- Peak-to-peak length [m]
73  const scalar length_;
74 
75  //- Phase offset [rad]
76  const scalar phase_;
77 
78 
79 private:
80 
81  // Private Member Functions
82 
83  //- Read and return the wave length from the dictionary. Either reads
84  // the length directly, or reads the period and depth and calculates
85  // the length.
86  static scalar length
87  (
88  const dictionary& dict,
89  const scalar depth,
90  const scalar amplitude,
91  const scalar g,
92  scalar (*celerityPtr)(scalar, scalar, scalar, scalar)
93  );
94 
95 
96 protected:
97 
98  // Static Protected Member Functions
99 
100  //- The angular wavenumber [rad/m]
101  static scalar k(const scalar length);
102 
103  //- Return whether shallow and intermediate effects are to be omitted
104  static bool deep(const scalar length, const scalar depth);
105 
106  //- The wave celerity [m/s]
107  static scalar celerity
108  (
109  const scalar depth,
110  const scalar amplitude,
111  const scalar length,
112  const scalar g
113  );
114 
115 
116  // Protected Member Functions
117 
118  //- The angular wavenumber [rad/m]
119  scalar k() const
120  {
121  return k(length_);
122  }
123 
124  //- Return whether shallow and intermediate effects are to be omitted
125  bool deep() const
126  {
127  return deep(depth(), length());
128  }
129 
130  //- The wave celerity [m/s]
131  virtual scalar celerity() const
132  {
133  return celerity(depth(), amplitude(), length(), g());
134  }
135 
136  //- Angle of the oscillation [rad]
138  (
139  const scalar t,
140  const scalarField& x
141  ) const;
142 
143  //- Return the non-dimensionalised i-th harmonic of the velocity
145  (
146  const label i,
147  const scalar t,
148  const vector2DField& xz
149  ) const;
150 
151 
152 public:
153 
154  //- Runtime type information
155  TypeName("Airy");
156 
157 
158  // Constructors
159 
160  //- Construct a copy
161  Airy(const Airy& wave);
162 
163  //- Construct from a dictionary and gravity
164  Airy
165  (
166  const dictionary& dict,
167  const scalar g,
168  const word& modelName = Airy::typeName,
169  scalar (*modelCelerity)(scalar, scalar, scalar, scalar) =
171  );
172 
173  //- Construct a clone
174  virtual autoPtr<waveModel> clone() const
175  {
176  return autoPtr<waveModel>(new Airy(*this));
177  }
178 
179 
180  //- Destructor
181  virtual ~Airy();
182 
183 
184  // Member Functions
185 
186  // Access
187 
188  //- Get the depth
189  scalar depth() const
190  {
191  return depth_;
192  }
193 
194  //- Get the amplitude
195  scalar amplitude(const scalar t) const
196  {
197  return amplitude_->value(t);
198  }
199 
200  //- Get the amplitude at steady state
201  scalar amplitude() const
202  {
203  return amplitude_->value(great);
204  }
205 
206  //- Get the length
207  scalar length() const
208  {
209  return length_;
210  }
211 
212  //- Get the phase
213  scalar phase() const
214  {
215  return phase_;
216  }
217 
218  //- Get the wave elevation at a given time and local coordinates. Local
219  // x is aligned with the direction of propagation.
221  (
222  const scalar t,
223  const scalarField& x
224  ) const;
225 
226  //- Get the wave velocity at a given time and local coordinates. Local
227  // x is aligned with the direction of propagation, and z with negative
228  // gravity.
230  (
231  const scalar t,
232  const vector2DField& xz
233  ) const;
234 
235  //- Write
236  virtual void write(Ostream& os) const;
237 };
238 
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 } // End namespace waveModels
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
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:160
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
scalar g() const
Get the value of gravity.
Definition: waveModel.H:119
First-order wave model.
Definition: Airy.H:62
bool deep() const
Return whether shallow and intermediate effects are to be omitted.
Definition: Airy.H:124
virtual ~Airy()
Destructor.
Definition: Airy.C:192
scalar length() const
Get the length.
Definition: Airy.H:206
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:199
virtual autoPtr< waveModel > clone() const
Construct a clone.
Definition: Airy.H:173
TypeName("Airy")
Runtime type information.
scalar k() const
The angular wavenumber [rad/m].
Definition: Airy.H:118
virtual void write(Ostream &os) const
Write.
Definition: Airy.C:220
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:209
scalar amplitude() const
Get the amplitude at steady state.
Definition: Airy.H:200
virtual scalar celerity() const
The wave celerity [m/s].
Definition: Airy.H:130
scalar depth() const
Get the depth.
Definition: Airy.H:188
scalar phase() const
Get the phase.
Definition: Airy.H:212
tmp< scalarField > angle(const scalar t, const scalarField &x) const
Angle of the oscillation [rad].
Definition: Airy.C:118
tmp< vector2DField > vi(const label i, const scalar t, const vector2DField &xz) const
Return the non-dimensionalised i-th harmonic of the velocity.
Definition: Airy.C:128
Airy(const Airy &wave)
Construct a copy.
Definition: Airy.C:158
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dictionary dict