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-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::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  vectorField& xyz
138  ) const;
139 
140  //- Get the wave elevation relative to the mean at a given time and
141  // local coordinates. Local x is aligned with the direction, and y is
142  // perpendicular to both x and gravity.
144  (
145  const scalar t,
146  const vector2DField& xy
147  ) const;
149  //- Get the wave velocity at a given time and local coordinates. Local
150  // x is aligned with the direction, z with negative gravity, and y is
151  // perpendicular to both.
152  tmp<vectorField> velocity(const scalar t, const vectorField& xyz) const;
153 
154  //- Get the wave pressure at a given time and local coordinates. Local
155  // x is aligned with the direction, z with negative gravity, and y is
156  // perpendicular to both.
157  tmp<scalarField> pressure(const scalar t, const vectorField& xyz) const;
158 
159  //- Get the scaling factor, calculated from the optional scaling
160  // functions. X and y are the same as for the elevation method.
161  tmp<scalarField> scale(const vector2DField& xy) const;
162 
163 
164 public:
165 
166  //- Runtime type information
167  TypeName("wave");
168 
169 
170  // Declare runtime construction
172  (
173  autoPtr,
176  (const objectRegistry& db),
177  (db)
178  );
179 
180 
181  // Static Data
182 
183  //- The name of the dictionary
184  static const word dictName;
185 
186 
187  // Static Member Functions
188 
189  //- Return a reference to the wave model on the given database,
190  // constructing if it doesn't exist
191  static const waveSuperposition& New(const objectRegistry& db);
192 
193 
194  // Constructors
195 
196  //- Construct from a database
198 
199 
200  //- Destructor
202 
203 
204  // Member Functions
205 
206  //- Get the height above the waves at a given time and global positions
207  virtual tmp<scalarField> height
208  (
209  const scalar t,
210  const vectorField& p
211  ) const;
212 
213  //- Get the liquid velocity at a given time and global positions
214  virtual tmp<vectorField> ULiquid
215  (
216  const scalar t,
217  const vectorField& p
218  ) const;
219 
220  //- Get the gas velocity at a given time and global positions
221  virtual tmp<vectorField> UGas
222  (
223  const scalar t,
224  const vectorField& p
225  ) const;
226 
227  //- Get the liquid pressure at a given time and global positions
228  virtual tmp<scalarField> pLiquid
229  (
230  const scalar t,
231  const vectorField& p
232  ) const;
233 
234  //- Get the gas pressure at a given time and global positions
235  virtual tmp<scalarField> pGas
236  (
237  const scalar t,
238  const vectorField& p
239  ) const;
240 
241  //- Inherit write from regIOobject
242  using regIOobject::write;
243 
244  //- Write
245  void write(Ostream&) const;
246 };
247 
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 } // End namespace Foam
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 #endif
256 
257 // ************************************************************************* //
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.
virtual tmp< scalarField > pLiquid(const scalar t, const vectorField &p) const
Get the liquid pressure at a given time and global positions.
tmp< scalarField > pressure(const scalar t, const vectorField &xyz) const
Get the wave pressure 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.
tmp< scalarField > elevation(const scalar t, const vector2DField &xy) const
Get the wave elevation relative to the mean at a given time and.
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.
virtual tmp< scalarField > height(const scalar t, const vectorField &p) const
Get the height above the waves at a given time and global positions.
virtual tmp< scalarField > pGas(const scalar t, const vectorField &p) const
Get the gas pressure 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.
tmp< vectorField > velocity(const scalar t, const vectorField &xyz) const
Get the wave velocity at a given time and local coordinates. Local.
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.
void transformation(const scalar t, const vectorField &p, tensor &axes, vectorField &xyz) const
Get the transformation to actual coordinates.
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
Namespace for OpenFOAM.
waveSuperposition(const objectRegistry &db)
Construct from a database.