waveMakerPointPatchVectorField.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2018-2019 IH-Cantabria
9  Copyright (C) 2018-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::waveMakerPointPatchVectorField
29 
30 Description
31  Point motion boundary condition to generate waves based on either piston
32  or flap motions.
33 
34  Based on the reference
35  \verbatim
36  Hughes, S.A. (1993).
37  Physical Models And Laboratory Techniques In Coastal Engineering.
38  Advanced Series On Ocean Engineering, volume 7
39  \endverbatim
40 
41 Usage
42  Example patch specification
43  \verbatim
44  leftwall
45  {
46  type waveMaker;
47  motionType flap;
48  n (1 0 0);
49  initialDepth 0.25;
50  wavePeriod 2.0;
51  waveHeight 0.06;
52  wavePhase 0;
53  rampTime 2.0;
54  }
55  \endverbatim
56 
57  where
58  \table
59  Property | Description | Required | Default value
60  motionType | See motion types below | yes |
61  n | Direction of motion | yes |
62  initialDepth | Initial depth | yes |
63  wavePeriod | wave period | yes |
64  waveHeight | Wave height | yes |
65  wavePhase | wave phase | yes |
66  waveAngle | wave angle | no | 0
67  startTime | Start time | no | case start time
68  rampTime | Time to reach maximum motion | yes |
69  secondOrder | Second order calculation | no | no
70  nPaddle | Number of paddles | no | 1
71  \endtable
72 
73  Available motion types include:
74  - piston
75  - flap
76  - solitary
77 
78 SourceFiles
79  waveMakerPointPatchVectorField.C
80 
81 \*---------------------------------------------------------------------------*/
82 
83 #ifndef waveMakerPointPatchVectorField_H
84 #define waveMakerPointPatchVectorField_H
85 
87 #include "Enum.H"
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 namespace Foam
92 {
93 
94 /*---------------------------------------------------------------------------*\
95  Class waveMakerPointPatchVectorField Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 class waveMakerPointPatchVectorField
99 :
100  public fixedValuePointPatchField<vector>
101 {
102  public:
103 
104  enum motionTypes
105  {
106  piston,
107  flap,
108  solitary
109  };
110 
111  //- Names for motion types
112  static const Enum<motionTypes> motionTypeNames;
113 
114 
115  // Private data
116 
117  //- Motion type
119 
120  //- Patch normal direction
121  // Note: cannot use patch normal of the initial patch unless it is
122  // in its neutral position (flap mode)
123  vector n_;
124 
125  //- Vertical direction
126  vector gHat_;
127 
128  //- Initial water depth
129  scalar initialDepth_;
130 
131  //- Wave period
132  scalar wavePeriod_;
133 
134  //- Wave height
135  scalar waveHeight_;
136 
137  //- Wave phase
138  scalar wavePhase_;
139 
140  //- Wave angle
141  scalar waveAngle_;
142 
143  //- Wave length
144  scalar waveLength_;
145 
146  //- Start time
147  scalar startTime_;
148 
149  //- Ramp time
150  scalar rampTime_;
151 
152  //- On/off second order calculation switch
153  scalar secondOrder_;
154 
155  //- Number of wave paddles
156  label nPaddle_;
157 
158  //- Rotation tensor from global to local system
160 
161  //- Rotation tensor from local to global system
164  //- Paddle x co-ordinates / [m]
166 
167  //- Paddle y co-ordinates / [m]
170  //- Addressing from point patch index to paddle index
172 
173  //- Addressing from patch face index to paddle index
175 
176  //- Patch face centre x co-ordinates / [m]
178 
179  //- Patch face centre y co-ordinates / [m]
180  scalarField y_;
181 
182  //- Patch face centre z co-ordinates / [m]
183  scalarField z_;
184 
185  //- Overall (point) span in z-direction / [m]
186  scalar zSpan_;
187 
188  //- Minimum z (point) height per patch face / [m]
191  //- Global Minimum z (point) / [m]
192  scalar zMinGb_;
193 
194  //- Maximum z (point) height per patch face / [m]
196 
197  //- Calculated water depth at the patch
199 
200  //
201  scalar firstTime = 0;
202 
203 
204  // Protected Member Functions
206  //- Return the gravitational acceleration
207  const vector& g();
208 
209  //- Dispersion equation
210  virtual scalar waveLength(const scalar h, const scalar T);
211 
212  //- Return the time scaling coefficient
213  virtual scalar timeCoeff(const scalar t) const;
214 
215  //- Initialise
216  virtual void initialiseGeometry();
217 
218 
219 public:
221  //- Runtime type information
222  TypeName("waveMaker");
223 
224 
225  // Constructors
226 
227  //- Construct from patch and internal field
229  (
230  const pointPatch&,
232  );
233 
234  //- Construct from patch, internal field and dictionary
236  (
237  const pointPatch&,
239  const dictionary&
240  );
241 
242  //- Construct by mapping given patch field onto a new patch
244  (
246  const pointPatch&,
248  const pointPatchFieldMapper&
249  );
251  //- Construct and return a clone
252  virtual autoPtr<pointPatchField<vector>> clone() const
253  {
255  (
257  (
258  *this
259  )
260  );
261  }
262 
263  //- Construct as copy setting internal field reference
265  (
268  );
269 
270  //- Construct and return a clone setting internal field reference
272  (
274  ) const
275  {
277  (
279  (
280  *this,
281  iF
282  )
283  );
284  }
286 
287  // Member functions
288 
289  // Evaluation functions
291  //- Update the coefficients associated with the patch field
292  virtual void updateCoeffs();
293 
294 
295  //- Write
296  virtual void write(Ostream&) const;
297 };
298 
299 
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 
302 } // End namespace Foam
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 #endif
307 
308 // ************************************************************************* //
scalarField x_
Patch face centre x co-ordinates / [m].
scalarField zMin_
Minimum z (point) height per patch face / [m].
scalarField zMax_
Maximum z (point) height per patch face / [m].
scalarField xPaddle_
Paddle x co-ordinates / [m].
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void write(Ostream &) const
Write.
scalarField z_
Patch face centre z co-ordinates / [m].
Foam::pointPatchFieldMapper.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
scalarField y_
Patch face centre y co-ordinates / [m].
scalar secondOrder_
On/off second order calculation switch.
virtual scalar timeCoeff(const scalar t) const
Return the time scaling coefficient.
const vector & g()
Return the gravitational acceleration.
virtual autoPtr< pointPatchField< vector > > clone() const
Construct and return a clone.
static const Enum< motionTypes > motionTypeNames
Names for motion types.
Point motion boundary condition to generate waves based on either piston or flap motions.
Vector< scalar > vector
Definition: vector.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
tensor Rgl_
Rotation tensor from global to local system.
waveMakerPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
scalar zMinGb_
Global Minimum z (point) / [m].
labelList pointToPaddle_
Addressing from point patch index to paddle index.
scalarField yPaddle_
Paddle y co-ordinates / [m].
const dimensionedScalar h
Planck constant.
scalar zSpan_
Overall (point) span in z-direction / [m].
scalarField waterDepthRef_
Calculated water depth at the patch.
virtual scalar waveLength(const scalar h, const scalar T)
Dispersion equation.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:61
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
labelList faceToPaddle_
Addressing from patch face index to paddle index.
tmp< Field< vector > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: Field.C:711
tensor Rlg_
Rotation tensor from local to global system.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Tensor of scalars, i.e. Tensor<scalar>.
TypeName("waveMaker")
Runtime type information.
Namespace for OpenFOAM.