irregular.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) 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::irregular
26 
27 Description
28  Irregular wave model. Phase fraction and velocity field are built up from
29  multiple first-order waves, sampled from a selectable wave spectrum.
30 
31 Usage
32  \table
33  Property | Description | Required? | Default
34  depth | The water depth [m] | no | great
35  spectrum | The wave spectrum | yes |
36  n | The number of times to sample \\
37  the spectrum | yes |
38  span | The fractional range across \\
39  which to sample the spectrum | no | (0.01 0.99)
40  setFormat | The format with which to plot \\
41  the spectrum | no | none
42  \endtable
43 
44  Example specification in constant/waveProperties:
45  \verbatim
46  waves
47  (
48  irregular
49  {
50  spectrum PiersonMoskowitz;
51 
52  PiersonMoskowitzCoeffs
53  {
54  U19_5 15;
55  }
56 
57  n 16;
58  span (0.01 0.99);
59  }
60  );
61  \endverbatim
62 
63 SourceFiles
64  irregular.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef irregular_H
69 #define irregular_H
70 
71 #include "waveModel.H"
72 #include "waveSpectrum.H"
73 #include "AiryCoeffs.H"
74 #include "setWriter.H"
75 
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77 
78 namespace Foam
79 {
80 namespace waveModels
81 {
82 
83 /*---------------------------------------------------------------------------*\
84  Class irregular Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 class irregular
88 :
89  public waveModel
90 {
91  // Private Data
92 
93  //- Depth [m]
94  const scalar depth_;
95 
96  //- Spectrum
97  autoPtr<waveSpectrum> spectrum_;
98 
99  //- The number of times to sample the spectrum
100  const label n_;
101 
102  //- The fractional range across which to sample the spectrum
103  const Pair<scalar> span_;
104 
105  //- Formatter with which to plot the spectrum
106  autoPtr<setWriter> formatter_;
107 
108  //- Amplitudes [m]
109  scalarList amplitudes_;
110 
111  //- Wavelengths [m]
112  scalarList lengths_;
113 
114  //- Phase offsets [rad]
115  scalarList phases_;
116 
117 
118  // Private Member Function
119 
120  //- Return the i-th wave coefficients
121  AiryCoeffs coeffs(const label i) const;
122 
123 
124 public:
125 
126  //- Runtime type information
127  TypeName("irregular");
128 
129 
130  // Constructors
131 
132  //- Construct a copy
133  irregular(const irregular& wave);
134 
135  //- Construct from a dictionary and gravity
136  irregular
137  (
138  const dictionary& dict,
139  const scalar g,
140  const word& modelName = irregular::typeName
141  );
142 
143  //- Construct a clone
144  virtual autoPtr<waveModel> clone() const
145  {
146  return autoPtr<waveModel>(new irregular(*this));
147  }
148 
149 
150  //- Destructor
151  virtual ~irregular();
152 
153 
154  // Member Functions
155 
156  // Access
157 
158  //- Get the depth
159  scalar depth() const
160  {
161  return depth_;
162  }
163 
164 
165  //- The wave celerity [m/s]
166  virtual scalar celerity() const;
167 
168  //- Get the wave elevation at a given time and local coordinates. Local
169  // x is aligned with the direction of propagation.
171  (
172  const scalar t,
173  const scalarField& x
174  ) const;
175 
176  //- Get the wave velocity at a given time and local coordinates. Local
177  // x is aligned with the direction of propagation, and z with negative
178  // gravity.
180  (
181  const scalar t,
182  const vector2DField& xz
183  ) const;
184 
185  //- Write
186  virtual void write(Ostream& os) const;
187 };
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace waveModels
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
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
Irregular wave model. Phase fraction and velocity field are built up from multiple first-order waves,...
Definition: irregular.H:116
virtual scalar celerity() const
The wave celerity [m/s].
Definition: irregular.C:237
virtual tmp< scalarField > elevation(const scalar t, const scalarField &x) const
Get the wave elevation at a given time and local coordinates. Local.
Definition: irregular.C:244
virtual autoPtr< waveModel > clone() const
Construct a clone.
Definition: irregular.H:170
virtual void write(Ostream &os) const
Write.
Definition: irregular.C:279
irregular(const irregular &wave)
Construct a copy.
Definition: irregular.C:57
virtual tmp< vector2DField > velocity(const scalar t, const vector2DField &xz) const
Get the wave velocity at a given time and local coordinates. Local.
Definition: irregular.C:262
TypeName("irregular")
Runtime type information.
scalar depth() const
Get the depth.
Definition: irregular.H:185
virtual ~irregular()
Destructor.
Definition: irregular.C:231
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
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:50
dictionary dict