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-2020 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  waveModelNew.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef waveModel_H
39 #define waveModel_H
40 
41 #include "objectRegistry.H"
42 #include "dictionary.H"
43 #include "Function1.H"
44 #include "runTimeSelectionTables.H"
45 #include "vectorField.H"
46 #include "vector2DField.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class waveModel Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class waveModel
58 {
59  // Private Data
60 
61  //- Reference to the database
62  const objectRegistry& db_;
63 
64  //- Peak-to-mean amplitude [m]
65  autoPtr<Function1<scalar>> amplitude_;
66 
67 
68 public:
69 
70  //- Runtime type information
71  TypeName("waveModel");
72 
73 
74  // Declare runtime construction
76  (
77  autoPtr,
78  waveModel,
80  (const objectRegistry& db, const dictionary& dict),
81  (db, dict)
82  );
83 
84 
85  // Constructors
86 
87  //- Construct a copy
88  waveModel(const waveModel& wave);
89 
90  //- Construct from a database and a dictionary
91  waveModel(const objectRegistry& db, const dictionary& dict);
92 
93  //- Construct a clone
94  virtual autoPtr<waveModel> clone() const = 0;
95 
96 
97  // Selectors
98 
99  //- Select
100  static autoPtr<waveModel> New
101  (
102  const objectRegistry& db,
103  const dictionary& dict
104  );
105 
106  //- Select
107  static autoPtr<waveModel> New
108  (
109  const word& type,
110  const objectRegistry& db,
111  const dictionary& dict
112  );
113 
114 
115  //- Destructor
116  virtual ~waveModel();
117 
118 
119  // Member Functions
120 
121  // Access
122 
123  //- Get the amplitude
124  scalar amplitude(const scalar t) const
125  {
126  return amplitude_->value(t);
127  }
128 
129  //- Get the (scalar) value of gravity.
130  scalar g() const;
131 
132  //- Get the wave elevation at a given time and local coordinates. Local
133  // x is aligned with the direction of propagation.
135  (
136  const scalar t,
137  const scalarField& x
138  ) const = 0;
139 
140  //- Get the wave velocity at a given time and local coordinates. Local
141  // x is aligned with the direction of propagation, and z with negative
142  // gravity.
144  (
145  const scalar t,
146  const vector2DField& xz
147  ) const = 0;
148 
149  //- Get the wave pressure at a given time and local coordinates. Local
150  // x is aligned with the direction of propagation, and z with negative
151  // gravity.
152  virtual tmp<scalarField> pressure
153  (
154  const scalar t,
155  const vector2DField& xz
156  ) const = 0;
157 
158  //- Write
159  virtual void write(Ostream& os) const;
160 };
161 
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace Foam
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************************************************************* //
virtual tmp< scalarField > elevation(const scalar t, const scalarField &x) const =0
Get the wave elevation at a given time and local coordinates. Local.
dictionary dict
declareRunTimeSelectionTable(autoPtr, waveModel, objectRegistry,(const objectRegistry &db, const dictionary &dict),(db, dict))
virtual tmp< vector2DField > velocity(const scalar t, const vector2DField &xz) const =0
Get the wave velocity at a given time and local coordinates. Local.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual tmp< scalarField > pressure(const scalar t, const vector2DField &xz) const =0
Get the wave pressure at a given time and local coordinates. Local.
Generic base class for waves. Derived classes must implement field functions which return the elevati...
Definition: waveModel.H:56
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
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:54
TypeName("waveModel")
Runtime type information.
virtual ~waveModel()
Destructor.
Definition: waveModel.C:61
static autoPtr< waveModel > New(const objectRegistry &db, const dictionary &dict)
Select.
Definition: waveModelNew.C:31
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
scalar amplitude(const scalar t) const
Get the amplitude.
Definition: waveModel.H:123
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.