waveModel.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::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-mean amplitude [m]
64  autoPtr<Function1<scalar>> amplitude_;
65 
66 
67 public:
68 
69  //- Runtime type information
70  TypeName("waveModel");
71 
72 
73  // Declare runtime construction
75  (
76  autoPtr,
77  waveModel,
79  (const objectRegistry& db, const dictionary& dict),
80  (db, dict)
81  );
82 
83 
84  // Constructors
85 
86  //- Construct a copy
87  waveModel(const waveModel& wave);
88 
89  //- Construct from a database and a dictionary
90  waveModel(const objectRegistry& db, const dictionary& dict);
91 
92  //- Construct a clone
93  virtual autoPtr<waveModel> clone() const = 0;
94 
95 
96  // Selectors
97 
98  //- Select
99  static autoPtr<waveModel> New
100  (
101  const objectRegistry& db,
102  const dictionary& dict
103  );
104 
105  //- Select
106  static autoPtr<waveModel> New
107  (
108  const word& type,
109  const objectRegistry& db,
110  const dictionary& dict
111  );
112 
113 
114  //- Destructor
115  virtual ~waveModel();
116 
117 
118  // Member Functions
119 
120  // Access
121 
122  //- Get the amplitude
123  scalar amplitude(const scalar t) const
124  {
125  return amplitude_->value(t);
126  }
127 
128  //- Get the (scalar) value of gravity.
129  scalar g() const;
130 
131  //- Get the wave elevation at a given time, mean velocity and local
132  // coordinates. Local x is aligned with the mean velocity.
134  (
135  const scalar t,
136  const scalar u,
137  const scalarField& x
138  ) const = 0;
139 
140  //- Get the wave velocity at a given time, mean velocity and local
141  // coordinates. Local x is aligned with the mean velocity, and z with
142  // negative gravity.
144  (
145  const scalar t,
146  const scalar u,
147  const vector2DField& xz
148  ) const = 0;
149 
150  //- Get the wave pressure at a given time, mean velocity and local
151  // coordinates. Local x is aligned with the mean velocity, and z with
152  // negative gravity.
153  virtual tmp<scalarField> pressure
154  (
155  const scalar t,
156  const scalar u,
157  const vector2DField& xz
158  ) const = 0;
159 
160  //- Write
161  virtual void write(Ostream& os) const;
162 };
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************************************************************* //
dictionary dict
declareRunTimeSelectionTable(autoPtr, waveModel, objectRegistry,(const objectRegistry &db, const dictionary &dict),(db, dict))
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.
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
scalar g() const
Get the (scalar) value of gravity.
Definition: waveModel.C:67
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:41
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:481
virtual ~waveModel()
Destructor.
Definition: waveModel.C:61
static autoPtr< waveModel > New(const objectRegistry &db, const dictionary &dict)
Select.
Definition: newWaveModel.C:31
scalar amplitude(const scalar t) const
Get the amplitude.
Definition: waveModel.H:122
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:73
virtual autoPtr< waveModel > clone() const =0
Construct a clone.
Namespace for OpenFOAM.
virtual tmp< scalarField > pressure(const scalar t, const scalar u, const vector2DField &xz) const =0
Get the wave pressure at a given time, mean velocity and local.