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-2021 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 "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  //- Gravitational acceleration [m/s^2]
61  const scalar g_;
62 
63 
64 public:
65 
66  //- Runtime type information
67  TypeName("waveModel");
68 
69 
70  // Declare runtime construction
72  (
73  autoPtr,
74  waveModel,
75  dictionary,
76  (const dictionary& dict, const scalar g),
77  (dict, g)
78  );
79 
80 
81  // Constructors
82 
83  //- Construct a copy
84  waveModel(const waveModel& wave);
85 
86  //- Construct from a dictionary and gravity
87  waveModel(const dictionary& dict, const scalar g);
88 
89  //- Construct a clone
90  virtual autoPtr<waveModel> clone() const = 0;
91 
92 
93  // Selectors
94 
95  //- Select
96  static autoPtr<waveModel> New
97  (
98  const dictionary& dict,
99  const scalar g
100  );
101 
102  //- Select
103  static autoPtr<waveModel> New
104  (
105  const word& type,
106  const dictionary& dict,
107  const scalar g
108  );
109 
110 
111  //- Destructor
112  virtual ~waveModel();
113 
114 
115  // Member Functions
116 
117  // Access
118 
119  //- Get the value of gravity
120  scalar g() const
121  {
122  return g_;
123  }
124 
125  //- Get the wave elevation at a given time and local coordinates. Local
126  // x is aligned with the direction of propagation.
128  (
129  const scalar t,
130  const scalarField& x
131  ) const = 0;
132 
133  //- Get the wave velocity at a given time and local coordinates. Local
134  // x is aligned with the direction of propagation, and z with negative
135  // gravity.
137  (
138  const scalar t,
139  const vector2DField& xz
140  ) const = 0;
141 
142  //- Write
143  virtual void write(Ostream& os) const;
144 };
145 
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace Foam
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 #endif
154 
155 // ************************************************************************* //
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
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:156
scalar g() const
Get the value of gravity.
Definition: waveModel.H:119
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
waveModel(const waveModel &wave)
Construct a copy.
Definition: waveModel.C:39
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:57
declareRunTimeSelectionTable(autoPtr, waveModel, dictionary,(const dictionary &dict, const scalar g),(dict, g))
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
static autoPtr< waveModel > New(const dictionary &dict, const scalar g)
Select.
Definition: waveModelNew.C:31
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
Foam::vector2DField.
label wave(const fvMesh &mesh, const List< labelPair > &changedPatchAndFaces, const label nCorrections, GeometricField< scalar, PatchField, GeoMesh > &distance, TrackingData &td, GeometricField< DataType, PatchField, GeoMesh > &... data)
Wave distance (and maybe additional) data from faces. If nCorrections is.
virtual void write(Ostream &os) const
Write.
Definition: waveModel.C:63
virtual autoPtr< waveModel > clone() const =0
Construct a clone.
Namespace for OpenFOAM.