waveSuperposition.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2017 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  //- Scaling in the flow direction
73  const autoPtr<Function1<scalar>> scale_;
74 
75  //- Scaling perpendicular to the flow direction
76  const autoPtr<Function1<scalar>> crossScale_;
77 
78 
79  // Private Member Functions
80 
81  //- Get the transformation to actual coordinates
82  void transformation
83  (
84  const vectorField& p,
85  tensor& axes,
86  scalar& u,
87  vectorField& xyz
88  ) const;
89 
90  //- Get the wave elevation relative to the mean at a given time, mean
91  // velocity and local coordinates. Local x is aligned with the mean
92  // velocity, and y is perpendicular to both x and gravity.
93  tmp<scalarField> elevation
94  (
95  const scalar t,
96  const vector2DField& xy
97  ) const;
98 
99  //- Get the wave velocity at a given time, mean velocity and local
100  // coordinates. Local x is aligned with the mean velocity, z with
101  // negative gravity, and y is perpendicular to both.
102  tmp<vectorField> velocity
103  (
104  const scalar t,
105  const vectorField& xyz
106  ) const;
107 
108  //- Get the scaling factor, calculated from the optional scaling
109  // functions. X and y are the same as for the elevation method.
110  tmp<scalarField> scale(const vector2DField& xy) const;
111 
112 
113 public:
114 
115  // Constructors
116 
117  //- Construct from a database
119 
120  //- Construct a copy
121  waveSuperposition(const waveSuperposition& waves);
122 
123  //- Construct from a database and gravity
124  waveSuperposition(const objectRegistry& db, const dictionary& dict);
125 
126 
127  //- Destructor
129 
130 
131  // Member Functions
132 
133  //- Get the height above the waves at a given time and global positions
134  tmp<scalarField> height(const scalar t, const vectorField& p) const;
135 
136  //- Get the liquid velocity at a given time and global positions
137  tmp<vectorField> ULiquid(const scalar t, const vectorField& p) const;
138 
139  //- Get the gas velocity at a given time and global positions
140  tmp<vectorField> UGas(const scalar t, const vectorField& p) const;
141 
142  //- Get the mean flow velocity
143  inline vector UMean() const
144  {
145  return direction_*speed_;
146  }
147 
148  //- Write
149  void write(Ostream&) const;
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace Foam
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
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.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
~waveSuperposition()
Destructor.
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.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
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
vector UMean() const
Get the mean flow velocity.
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.