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-2018 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 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef waveSuperposition_H
79 #define waveSuperposition_H
80 
81 #include "waveModel.H"
82 #include "IOdictionary.H"
83 
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 
86 namespace Foam
87 {
88 
89 /*---------------------------------------------------------------------------*\
90  Class waveSuperposition Declaration
91 \*---------------------------------------------------------------------------*/
92 
93 class waveSuperposition
94 :
95  public IOdictionary
96 {
97 protected:
98 
99  // Protected Data
100 
101  //- The origin of the wave coordinate system
102  const vector origin_;
103 
104  //- The direction of the wave coordinate system
105  const vector direction_;
106 
107  //- Wave models to superimpose
108  PtrList<waveModel> waveModels_;
109 
110  //- The angle relative to the direction at which the waves propagate
112 
113  //- Mean velocity
114  const autoPtr<Function1<vector>> UMean_;
115 
116  //- Scaling in the local x-direction
117  const autoPtr<Function1<scalar>> scale_;
118 
119  //- Scaling perpendicular to the local x-direction
120  const autoPtr<Function1<scalar>> crossScale_;
121 
122  //- Calculate wave properties using the height above the wave (true) or
123  // the height above the origin (false)?
124  const Switch heightAboveWave_;
125 
126 
127  // Protected Member Functions
128 
129  //- Get the transformation to actual coordinates
130  void transformation
131  (
132  const scalar t,
133  const vectorField& p,
134  tensor& axes,
135  vectorField& xyz
136  ) const;
137 
138  //- Get the wave elevation relative to the mean at a given time and
139  // local coordinates. Local x is aligned with the direction, and y is
140  // perpendicular to both x and gravity.
142  (
143  const scalar t,
144  const vector2DField& xy
145  ) const;
147  //- Get the wave velocity at a given time and local coordinates. Local
148  // x is aligned with the direction, z with negative gravity, and y is
149  // perpendicular to both.
150  tmp<vectorField> velocity(const scalar t, const vectorField& xyz) const;
151 
152  //- Get the wave pressure at a given time and local coordinates. Local
153  // x is aligned with the direction, z with negative gravity, and y is
154  // perpendicular to both.
155  tmp<scalarField> pressure(const scalar t, const vectorField& xyz) const;
156 
157  //- Get the scaling factor, calculated from the optional scaling
158  // functions. X and y are the same as for the elevation method.
159  tmp<scalarField> scale(const vector2DField& xy) const;
160 
161 
162 public:
163 
164  //- Runtime type information
165  TypeName("wave");
166 
167 
168  // Declare runtime construction
170  (
171  autoPtr,
174  (const objectRegistry& db),
175  (db)
176  );
177 
178 
179  // Static Data
180 
181  //- The name of the dictionary
182  static const word dictName;
183 
184 
185  // Static Member Functions
186 
187  //- Return a reference to the wave model on the given database,
188  // constructing if it doesn't exist
189  static const waveSuperposition& New(const objectRegistry& db);
190 
191 
192  // Constructors
193 
194  //- Construct from a database
196 
197 
198  //- Destructor
200 
201 
202  // Member Functions
203 
204  //- Get the height above the waves at a given time and global positions
205  virtual tmp<scalarField> height
206  (
207  const scalar t,
208  const vectorField& p
209  ) const;
210 
211  //- Get the liquid velocity at a given time and global positions
212  virtual tmp<vectorField> ULiquid
213  (
214  const scalar t,
215  const vectorField& p
216  ) const;
217 
218  //- Get the gas velocity at a given time and global positions
219  virtual tmp<vectorField> UGas
220  (
221  const scalar t,
222  const vectorField& p
223  ) const;
224 
225  //- Get the liquid pressure at a given time and global positions
226  virtual tmp<scalarField> pLiquid
227  (
228  const scalar t,
229  const vectorField& p
230  ) const;
231 
232  //- Get the gas pressure at a given time and global positions
233  virtual tmp<scalarField> pGas
234  (
235  const scalar t,
236  const vectorField& p
237  ) const;
238 
239  //- Inherit write from regIOobject
240  using regIOobject::write;
241 
242  //- Write
243  void write(Ostream&) const;
244 };
245 
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 } // End namespace Foam
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #endif
254 
255 // ************************************************************************* //
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:123
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:53
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:354
Namespace for OpenFOAM.
waveSuperposition(const objectRegistry &db)
Construct from a database.