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-2019 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 and local coordinates. Local
132  // x is aligned with the direction of propagation.
134  (
135  const scalar t,
136  const scalarField& x
137  ) const = 0;
138 
139  //- Get the wave velocity at a given time and local coordinates. Local
140  // x is aligned with the direction of propagation, and z with negative
141  // gravity.
143  (
144  const scalar t,
145  const vector2DField& xz
146  ) const = 0;
147 
148  //- Get the wave pressure at a given time and local coordinates. Local
149  // x is aligned with the direction of propagation, and z with negative
150  // gravity.
151  virtual tmp<scalarField> pressure
152  (
153  const scalar t,
154  const vector2DField& xz
155  ) const = 0;
156 
157  //- Write
158  virtual void write(Ostream& os) const;
159 };
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #endif
169 
170 // ************************************************************************* //
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: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
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.
virtual ~waveModel()
Destructor.
Definition: waveModel.C:61
static autoPtr< waveModel > New(const objectRegistry &db, const dictionary &dict)
Select.
Definition: newWaveModel.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: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.