waveSuperposition.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-2022 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::waveSuperposition
26 
27 Description
28  A wrapper around a list of wave models. Superimposes the modelled values of
29  elevation and velocity. The New method looks up or or constructs an
30  instance of this class on demand and returns a reference. Properties are
31  read from a dictionary in constant.
32 
33 Usage
34  \table
35  Property | Description | Req'd? | Default
36  origin | origin of the wave coordinate system | yes |
37  direction | direction of the wave coordinate system | yes |
38  waves | list of wave models to superimpose | yes |
39  UMean | velocity of the mean flow | yes |
40  scale | scale factor in the direction | no | None
41  crossScale | scale factor perpendicular to the direction | no | None
42  heightAboveWave | use the height above the wave as the vertical \\
43  coordinate | no | false
44  \endtable
45 
46  Example specification:
47  \verbatim
48  origin (0 25 0);
49  direction (1 0 0);
50  waves
51  (
52  Airy
53  {
54  length 40;
55  amplitude 0.5;
56  phase 0;
57  angle 0;
58  }
59  Airy
60  {
61  length 20;
62  amplitude 0.25;
63  phase 1.5708;
64  angle 0;
65  }
66  );
67  UMean (2 0 0);
68  scale table ((100 1) (200 0));
69  crossScale constant 1;
70  heightAboveWave no;
71  \endverbatim
72 
73 SourceFiles
74  waveSuperposition.C
75  waveSuperpositionNew.C
76 
77 \*---------------------------------------------------------------------------*/
78 
79 #ifndef waveSuperposition_H
80 #define waveSuperposition_H
81 
82 #include "waveModel.H"
83 #include "IOdictionary.H"
84 #include "tensor.H"
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 namespace Foam
89 {
90 
91 /*---------------------------------------------------------------------------*\
92  Class waveSuperposition Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 class waveSuperposition
96 :
97  public IOdictionary
98 {
99 protected:
100 
101  // Protected Data
102 
103  //- The origin of the wave coordinate system
104  const vector origin_;
105 
106  //- The direction of the wave coordinate system
107  const vector direction_;
108 
109  //- Wave models to superimpose
110  PtrList<waveModel> waveModels_;
111 
112  //- The angle relative to the direction at which the waves propagate
114 
115  //- Mean velocity
116  const autoPtr<Function1<vector>> UMean_;
117 
118  //- Scaling in the local x-direction
119  const autoPtr<Function1<scalar>> scale_;
120 
121  //- Scaling perpendicular to the local x-direction
122  const autoPtr<Function1<scalar>> crossScale_;
123 
124  //- Calculate wave properties using the height above the wave (true) or
125  // the height above the origin (false)?
126  const Switch heightAboveWave_;
127 
128 
129  // Protected Member Functions
130 
131  //- Get the transformation to actual coordinates
132  void transformation
133  (
134  const scalar t,
135  const vectorField& p,
136  tensor& axes,
137  vector& drift,
138  vectorField& xyz
139  ) const;
140 
141  //- Get the wave elevation relative to the mean at a given time and
142  // local coordinates. Local x is aligned with the direction, and y is
143  // perpendicular to both x and gravity.
145  (
146  const scalar t,
147  const vector2D& drift,
148  const vector2DField& xy
149  ) const;
150 
151  //- Get the wave velocity at a given time and local coordinates. Local
152  // x is aligned with the direction, z with negative gravity, and y is
153  // perpendicular to both.
155  (
156  const scalar t,
157  const vector& drift,
158  const vectorField& xyz
159  ) const;
161  //- Get the scaling factor, calculated from the optional scaling
162  // functions. X and y are the same as for the elevation method.
163  tmp<scalarField> scale(const vector2DField& xy) const;
165 
166 public:
167 
168  //- Runtime type information
169  TypeName("wave");
170 
171 
172  // Declare runtime construction
174  (
175  autoPtr,
178  (const objectRegistry& db),
179  (db)
180  );
181 
182 
183  // Static Data
184 
185  //- The name of the dictionary
186  static const word dictName;
187 
188 
189  // Static Member Functions
190 
191  //- Return a reference to the wave model on the given database,
192  // constructing if it doesn't exist
193  static const waveSuperposition& New(const objectRegistry& db);
194 
195 
196  // Constructors
197 
198  //- Construct from a database
200 
201 
202  //- Destructor
204 
205 
206  // Member Functions
207 
208  //- Get the height above the waves at a given time and global positions
209  virtual tmp<scalarField> height
210  (
211  const scalar t,
212  const vectorField& p
213  ) const;
214 
215  //- Get the liquid velocity at a given time and global positions
216  virtual tmp<vectorField> ULiquid
217  (
218  const scalar t,
219  const vectorField& p
220  ) const;
221 
222  //- Get the gas velocity at a given time and global positions
223  virtual tmp<vectorField> UGas
224  (
225  const scalar t,
226  const vectorField& p
227  ) const;
228 
229  //- Inherit write from regIOobject
230  using regIOobject::write;
231 
232  //- Write
233  void write(Ostream&) const;
234 };
235 
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 } // End namespace Foam
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #endif
244 
245 // ************************************************************************* //
A wrapper around a list of wave models. Superimposes the modelled values of elevation and velocity...
virtual tmp< vectorField > UGas(const scalar t, const vectorField &p) const
Get the gas velocity at a given time and global positions.
const vector origin_
The origin of the wave coordinate system.
void write(Ostream &) const
Write.
tmp< vectorField > velocity(const scalar t, const vector &drift, const vectorField &xyz) const
Get the wave velocity at a given time and local coordinates. Local.
const vector direction_
The direction of the wave coordinate system.
const autoPtr< Function1< vector > > UMean_
Mean velocity.
scalarList waveAngles_
The angle relative to the direction at which the waves propagate.
~waveSuperposition()
Destructor.
virtual tmp< vectorField > ULiquid(const scalar t, const vectorField &p) const
Get the liquid velocity at a given time and global positions.
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
const Switch heightAboveWave_
Calculate wave properties using the height above the wave (true) or.
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:121
const autoPtr< Function1< scalar > > crossScale_
Scaling perpendicular to the local x-direction.
void transformation(const scalar t, const vectorField &p, tensor &axes, vector &drift, vectorField &xyz) const
Get the transformation to actual coordinates.
virtual tmp< scalarField > height(const scalar t, const vectorField &p) const
Get the height above the waves at a given time and global positions.
const autoPtr< Function1< scalar > > scale_
Scaling in the local x-direction.
A class for handling words, derived from string.
Definition: word.H:59
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:50
declareRunTimeSelectionTable(autoPtr, waveSuperposition, objectRegistry,(const objectRegistry &db),(db))
PtrList< waveModel > waveModels_
Wave models to superimpose.
static const waveSuperposition & New(const objectRegistry &db)
Return a reference to the wave model on the given database,.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
TypeName("wave")
Runtime type information.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
tmp< scalarField > scale(const vector2DField &xy) const
Get the scaling factor, calculated from the optional scaling.
virtual bool write(const bool write=true) const
Write using setting from DB.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:312
tmp< scalarField > elevation(const scalar t, const vector2D &drift, const vector2DField &xy) const
Get the wave elevation relative to the mean at a given time and.
Namespace for OpenFOAM.
waveSuperposition(const objectRegistry &db)
Construct from a database.