waveModel.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::waveModel
26 
27 Description
28  Generic base class for waves. Derived classes must implement field
29  functions which return the elevation above the wave surface and the
30  velocity field, both as a function of position.
31 
32 SourceFiles
33  waveModel.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef waveModel_H
38 #define waveModel_H
39 
40 #include "objectRegistry.H"
41 #include "dictionary.H"
42 #include "Function1.H"
43 #include "runTimeSelectionTables.H"
44 #include "vectorField.H"
45 #include "vector2DField.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class waveModel Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class waveModel
57 {
58  // Private data
59 
60  //- Reference to the database
61  const objectRegistry& db_;
62 
63  //- Peak-to-peak length [m]
64  const scalar length_;
65 
66  //- Peak-to-mean amplitude [m]
67  autoPtr<Function1<scalar>> amplitude_;
68 
69  //- Phase offset [rad]
70  const scalar phase_;
71 
72  //- Depth [m]
73  const scalar depth_;
74 
75 
76 protected:
77 
78  // Protected Member Functions
79 
80  //- The angular wavenumber [rad/m]
81  scalar k() const;
82 
83  //- The intrinsic angular frequency [rad/s]
84  scalar sigma() const;
85 
86  //- The observed angular frequency [rad/s]
87  scalar omega(const scalar u) const;
88 
89  //- Angle of the oscillation [rad]
91  (
92  const scalar t,
93  const scalar u,
94  const scalarField& x
95  ) const;
96 
97  //- Return whether shallow effects are to be included
98  bool shallow() const;
99 
100 
101 public:
102 
103  //- Runtime type information
104  TypeName("waveModel");
105 
106 
107  // Declare runtime construction
109  (
110  autoPtr,
111  waveModel,
113  (const objectRegistry& db, const dictionary& dict),
114  (db, dict)
115  );
116 
117 
118  // Constructors
119 
120  //- Construct a copy
121  waveModel(const waveModel& wave);
122 
123  //- Construct from a database and a dictionary
124  waveModel(const objectRegistry& db, const dictionary& dict);
125 
126  //- Construct a clone
127  virtual autoPtr<waveModel> clone() const = 0;
128 
129 
130  // Selectors
131 
132  //- Select
133  static autoPtr<waveModel> New
134  (
135  const objectRegistry& db,
136  const dictionary& dict
137  );
138 
139  //- Select
140  static autoPtr<waveModel> New
141  (
142  const word& type,
143  const objectRegistry& db,
144  const dictionary& dict
145  );
146 
147 
148  //- Destructor
149  virtual ~waveModel();
150 
151 
152  // Member Functions
153 
154  // Access
155 
156  //- Get the length
157  scalar length() const
158  {
159  return length_;
160  }
161 
162  //- Get the amplitude
163  scalar amplitude(const scalar t) const
164  {
165  return amplitude_->value(t);
166  }
167 
168  //- Get the phase
169  scalar phase() const
170  {
171  return phase_;
172  }
173 
174  //- Get the depth
175  scalar depth() const
176  {
177  return depth_;
178  }
179 
180  //- Get the wave elevation at a given time, mean velocity and local
181  // coordinates. Local x is aligned with the mean velocity.
183  (
184  const scalar t,
185  const scalar u,
186  const scalarField& x
187  ) const = 0;
188 
189  //- Get the wave velocity at a given time, mean velocity and local
190  // coordinates. Local x is aligned with the mean velocity, and z with
191  // negative gravity.
193  (
194  const scalar t,
195  const scalar u,
196  const vector2DField& xz
197  ) const = 0;
198 
199  //- Write
200  virtual void write(Ostream& os) const;
201 };
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace Foam
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
dictionary dict
declareRunTimeSelectionTable(autoPtr, waveModel, objectRegistry,(const objectRegistry &db, const dictionary &dict),(db, dict))
tmp< scalarField > angle(const scalar t, const scalar u, const scalarField &x) const
Angle of the oscillation [rad].
Definition: waveModel.C:64
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual tmp< vector2DField > velocity(const scalar t, const scalar u, const vector2DField &xz) const =0
Get the wave velocity at a given time, mean velocity and local.
bool shallow() const
Return whether shallow effects are to be included.
Definition: waveModel.C:74
scalar sigma() const
The intrinsic angular frequency [rad/s].
Definition: waveModel.C:48
scalar length() const
Get the length.
Definition: waveModel.H:156
Generic base class for waves. Derived classes must implement field functions which return the elevati...
Definition: waveModel.H:55
A class for handling words, derived from string.
Definition: word.H:59
virtual tmp< scalarField > elevation(const scalar t, const scalar u, const scalarField &x) const =0
Get the wave elevation at a given time, mean velocity and local.
waveModel(const waveModel &wave)
Construct a copy.
Definition: waveModel.C:82
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
TypeName("waveModel")
Runtime type information.
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:485
scalar phase() const
Get the phase.
Definition: waveModel.H:168
virtual ~waveModel()
Destructor.
Definition: waveModel.C:104
static autoPtr< waveModel > New(const objectRegistry &db, const dictionary &dict)
Select.
Definition: newWaveModel.C:31
scalar omega(const scalar u) const
The observed angular frequency [rad/s].
Definition: waveModel.C:57
scalar depth() const
Get the depth.
Definition: waveModel.H:174
scalar amplitude(const scalar t) const
Get the amplitude.
Definition: waveModel.H:162
scalar k() const
The angular wavenumber [rad/m].
Definition: waveModel.C:42
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Macros to ease declaration of run-time selection tables.
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
Foam::vector2DField.
virtual void write(Ostream &os) const
Write.
Definition: waveModel.C:110
virtual autoPtr< waveModel > clone() const =0
Construct a clone.
Namespace for OpenFOAM.