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
29  of elevation and velocity.
30 
31 SourceFiles
32  waveSuperposition.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef waveSuperposition_H
37 #define waveSuperposition_H
38 
39 #include "waveModel.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class waveSuperposition Declaration
48 \*---------------------------------------------------------------------------*/
49 
51 {
52  // Private data
53 
54  //- Reference to the database
55  const objectRegistry& db_;
56 
57  //- The origin of the wave coordinate system
58  const vector origin_;
59 
60  //- The mean flow direction
61  const vector direction_;
62 
63  //- The mean flow speed
64  const scalar speed_;
65 
66  //- Wave models to superimpose
67  PtrList<waveModel> waveModels_;
68 
69  //- The angle relative to the mean velocity at which the waves propagate
70  scalarList waveAngles_;
71 
72  //- Ramp for the mean flow speed
73  const autoPtr<Function1<scalar>> ramp_;
74 
75  //- Scaling in the flow direction
76  const autoPtr<Function1<scalar>> scale_;
77 
78  //- Scaling perpendicular to the flow direction
79  const autoPtr<Function1<scalar>> crossScale_;
80 
81  //- Calculate wave properties using the height above the wave (true) or
82  // the height above the origin (false)?
83  const Switch heightAboveWave_;
84 
85 
86  // Private Member Functions
87 
88  //- Get the transformation to actual coordinates
89  void transformation
90  (
91  const vectorField& p,
92  tensor& axes,
93  scalar& u,
94  vectorField& xyz
95  ) const;
96 
97  //- Get the wave elevation relative to the mean at a given time, mean
98  // velocity and local coordinates. Local x is aligned with the mean
99  // velocity, and y is perpendicular to both x and gravity.
100  tmp<scalarField> elevation
101  (
102  const scalar t,
103  const vector2DField& xy
104  ) const;
105 
106  //- Get the wave velocity at a given time, mean velocity and local
107  // coordinates. Local x is aligned with the mean velocity, z with
108  // negative gravity, and y is perpendicular to both.
109  tmp<vectorField> velocity(const scalar t, const vectorField& xyz) const;
110 
111  //- Get the wave pressure at a given time, mean velocity and local
112  // coordinates. Local x is aligned with the mean velocity, z with
113  // negative gravity, and y is perpendicular to both.
114  tmp<scalarField> pressure(const scalar t, const vectorField& xyz) const;
115 
116  //- Get the scaling factor, calculated from the optional scaling
117  // functions. X and y are the same as for the elevation method.
118  tmp<scalarField> scale(const vector2DField& xy) const;
119 
120 
121 public:
122 
123  // Constructors
124 
125  //- Construct from a database
127 
128  //- Construct a copy
129  waveSuperposition(const waveSuperposition& waves);
130 
131  //- Construct from a database and gravity
132  waveSuperposition(const objectRegistry& db, const dictionary& dict);
133 
134 
135  //- Destructor
137 
138 
139  // Member Functions
140 
141  //- Get the height above the waves at a given time and global positions
142  tmp<scalarField> height(const scalar t, const vectorField& p) const;
143 
144  //- Get the liquid velocity at a given time and global positions
145  tmp<vectorField> ULiquid(const scalar t, const vectorField& p) const;
146 
147  //- Get the gas velocity at a given time and global positions
148  tmp<vectorField> UGas(const scalar t, const vectorField& p) const;
149 
150  //- Get the liquid pressure at a given time and global positions
151  tmp<scalarField> pLiquid(const scalar t, const vectorField& p) const;
152 
153  //- Get the gas pressure at a given time and global positions
154  tmp<scalarField> pGas(const scalar t, const vectorField& p) const;
155 
156  //- Get the mean flow velocity
157  inline vector UMean(const scalar t) const
158  {
159  return (ramp_.valid() ? ramp_->value(t) : 1)*direction_*speed_;
160  }
161 
162  //- Write
163  void write(Ostream&) const;
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace Foam
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
A wrapper around a list of wave models. Superimposes the modelled values of elevation and velocity...
dictionary dict
tmp< vectorField > UGas(const scalar t, const vectorField &p) const
Get the gas velocity at a given time and global positions.
void write(Ostream &) const
Write.
tmp< scalarField > pLiquid(const scalar t, const vectorField &p) const
Get the liquid pressure at a given time and global positions.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
~waveSuperposition()
Destructor.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
tmp< vectorField > ULiquid(const scalar t, const vectorField &p) const
Get the liquid velocity at a given time and global positions.
tmp< scalarField > height(const scalar t, const vectorField &p) const
Get the height above the waves at a given time and global positions.
tmp< scalarField > pGas(const scalar t, const vectorField &p) const
Get the gas pressure at a given time and global positions.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
vector UMean(const scalar t) const
Get the mean flow velocity.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:63
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
Namespace for OpenFOAM.
waveSuperposition(const objectRegistry &db)
Construct from a database.