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 Foam_waveMakerPointPatchVectorField_H
84 #define Foam_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  typedef waveMakerPointPatchVectorField this_bctype;
103  typedef fixedValuePointPatchField<vector> parent_bctype;
104 
105 public:
106 
107  // Public data types
108 
109  enum motionTypes
110  {
111  piston,
112  flap,
113  solitary
114  };
115 
116 private:
117 
118  // Private Data
119 
120  //- Names for motion types
121  static const Enum<motionTypes> motionTypeNames;
122 
123  //- Motion type
124  motionTypes motionType_;
125 
126  //- Patch normal direction
127  // Note: cannot use patch normal of the initial patch unless it is
128  // in its neutral position (flap mode)
129  vector n_;
130 
131  //- Vertical direction
132  vector gHat_;
133 
134  //- Initial water depth
135  scalar initialDepth_;
136 
137  //- Wave period
138  scalar wavePeriod_;
139 
140  //- Wave height
141  scalar waveHeight_;
142 
143  //- Wave phase
144  scalar wavePhase_;
145 
146  //- Wave angle
147  scalar waveAngle_;
148 
149  //- Start time
150  scalar startTime_;
151 
152  //- Ramp time
153  scalar rampTime_;
154 
155  //- On/off second order calculation switch
156  bool secondOrder_;
157 
158  //- Number of wave paddles
159  label nPaddle_;
160 
161  //- Paddle x co-ordinates / [m]
162  scalarField xPaddle_;
163 
164  //- Paddle y co-ordinates / [m]
165  scalarField yPaddle_;
167  //- Addressing from point patch index to paddle index
168  labelList pointToPaddle_;
169 
170  //- Addressing from patch face index to paddle index
171  labelList faceToPaddle_;
172 
173  //- Patch face centre x co-ordinates / [m]
174  scalarField x_;
175 
176  //- Patch face centre y co-ordinates / [m]
177  scalarField y_;
178 
179  //- Patch face centre z co-ordinates / [m]
180  scalarField z_;
181 
182  //- Overall (point) span in z-direction / [m]
183  scalar zSpan_;
184 
185  //- Minimum z (point) height per patch face / [m]
186  scalarField zMin_;
187 
188  //- Global Minimum z (point) / [m]
189  scalar zMinGb_;
190 
191  //- Maximum z (point) height per patch face / [m]
192  scalarField zMax_;
193 
194  //- Calculated water depth at the patch
195  scalarField waterDepthRef_;
196 
197  //
198  scalar firstTime = 0;
199 
200 
201  // Protected Member Functions
202 
203  //- Return the gravitational acceleration
204  const vector& g();
205 
206  //- Dispersion equation
207  virtual scalar waveLength(const scalar h, const scalar T);
208 
209  //- Return the time scaling coefficient
210  virtual scalar timeCoeff(const scalar t) const;
211 
212  //- Initialise
213  virtual void initialiseGeometry();
214 
215 
216 public:
217 
218  //- Runtime type information
219  TypeName("waveMaker");
220 
221 
222  // Constructors
223 
224  //- Construct from patch and internal field
226  (
227  const pointPatch&,
229  );
230 
231  //- Construct from patch, internal field and dictionary
233  (
234  const pointPatch&,
236  const dictionary&
237  );
238 
239  //- Construct by mapping onto a new patch
241  (
242  const this_bctype&,
243  const pointPatch&,
245  const pointPatchFieldMapper&
246  );
247 
248  //- Construct as copy setting internal field reference
250  (
251  const this_bctype&,
253  );
254 
255  //- No copy without an internal field
257 
258  //- Clone with an internal field reference
260  (
262  ) const
263  {
264  return pointPatchField<vector>::Clone(*this, iF);
265  }
266 
267 
268  // Member Functions
269 
270  //- Update the coefficients associated with the patch field
271  virtual void updateCoeffs();
272 
273  //- Write
274  virtual void write(Ostream&) const;
275 
276 
277  // Member Operators
278 
279  //- Inherit assignment
281 };
282 
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 } // End namespace Foam
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 #endif
291 
292 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
virtual void write(Ostream &) const
Write.
Foam::pointPatchFieldMapper.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual autoPtr< pointPatchField< vector > > clone() const
No clone without an internal field reference.
friend Ostream & operator(Ostream &, const pointPatchField< vector > &)
Point motion boundary condition to generate waves based on either piston or flap motions.
static autoPtr< pointPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
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...
waveMakerPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
const dimensionedScalar h
Planck constant.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
tmp< Field< vector > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: Field.C:745
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
TypeName("waveMaker")
Runtime type information.
Namespace for OpenFOAM.