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
159  tensor Rgl_;
160 
161  //- Rotation tensor from local to global system
162  tensor Rlg_;
163 
164  //- Paddle x co-ordinates / [m]
166 
167  //- Paddle y co-ordinates / [m]
169 
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]
190 
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
205 
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:
220 
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 patchField<vector> onto a new patch
244  (
246  const pointPatch&,
249  );
250 
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  }
285 
286 
287  // Member functions
288 
289  // Evaluation functions
290 
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 #endif
307 
308 // ************************************************************************* //
Foam::waveMakerPointPatchVectorField::waterDepthRef_
scalarField waterDepthRef_
Calculated water depth at the patch.
Definition: waveMakerPointPatchVectorField.H:257
Foam::Tensor< scalar >
Foam::Enum< motionTypes >
Foam::waveMakerPointPatchVectorField::xPaddle_
scalarField xPaddle_
Paddle x co-ordinates / [m].
Definition: waveMakerPointPatchVectorField.H:224
Foam::waveMakerPointPatchVectorField::waveAngle_
scalar waveAngle_
Wave angle.
Definition: waveMakerPointPatchVectorField.H:200
Foam::waveMakerPointPatchVectorField::zMin_
scalarField zMin_
Minimum z (point) height per patch face / [m].
Definition: waveMakerPointPatchVectorField.H:248
Foam::waveMakerPointPatchVectorField::nPaddle_
label nPaddle_
Number of wave paddles.
Definition: waveMakerPointPatchVectorField.H:215
Foam::waveMakerPointPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: waveMakerPointPatchVectorField.C:270
Foam::waveMakerPointPatchVectorField::gHat_
vector gHat_
Vertical direction.
Definition: waveMakerPointPatchVectorField.H:185
Foam::waveMakerPointPatchVectorField::startTime_
scalar startTime_
Start time.
Definition: waveMakerPointPatchVectorField.H:206
Foam::waveMakerPointPatchVectorField::waveHeight_
scalar waveHeight_
Wave height.
Definition: waveMakerPointPatchVectorField.H:194
Foam::waveMakerPointPatchVectorField::y_
scalarField y_
Patch face centre y co-ordinates / [m].
Definition: waveMakerPointPatchVectorField.H:239
Foam::waveMakerPointPatchVectorField::x_
scalarField x_
Patch face centre x co-ordinates / [m].
Definition: waveMakerPointPatchVectorField.H:236
Foam::waveMakerPointPatchVectorField::secondOrder_
scalar secondOrder_
On/off second order calculation switch.
Definition: waveMakerPointPatchVectorField.H:212
Foam::waveMakerPointPatchVectorField::firstTime
scalar firstTime
Definition: waveMakerPointPatchVectorField.H:260
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::waveMakerPointPatchVectorField::wavePhase_
scalar wavePhase_
Wave phase.
Definition: waveMakerPointPatchVectorField.H:197
Foam::waveMakerPointPatchVectorField::TypeName
TypeName("waveMaker")
Runtime type information.
Foam::waveMakerPointPatchVectorField::zSpan_
scalar zSpan_
Overall (point) span in z-direction / [m].
Definition: waveMakerPointPatchVectorField.H:245
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:48
Foam::waveMakerPointPatchVectorField::wavePeriod_
scalar wavePeriod_
Wave period.
Definition: waveMakerPointPatchVectorField.H:191
Foam::waveMakerPointPatchVectorField::waveLength_
scalar waveLength_
Wave length.
Definition: waveMakerPointPatchVectorField.H:203
Foam::waveMakerPointPatchVectorField::zMinGb_
scalar zMinGb_
Global Minimum z (point) / [m].
Definition: waveMakerPointPatchVectorField.H:251
Foam::fixedValuePointPatchField
A FixedValue boundary condition for pointField.
Definition: fixedValuePointPatchField.H:51
Foam::waveMakerPointPatchVectorField::yPaddle_
scalarField yPaddle_
Paddle y co-ordinates / [m].
Definition: waveMakerPointPatchVectorField.H:227
Foam::waveMakerPointPatchVectorField::clone
virtual autoPtr< pointPatchField< vector > > clone() const
Construct and return a clone.
Definition: waveMakerPointPatchVectorField.H:311
Foam::Field< scalar >
Foam::waveMakerPointPatchVectorField
Point motion boundary condition to generate waves based on either piston or flap motions.
Definition: waveMakerPointPatchVectorField.H:157
Foam::waveMakerPointPatchVectorField::z_
scalarField z_
Patch face centre z co-ordinates / [m].
Definition: waveMakerPointPatchVectorField.H:242
Foam::waveMakerPointPatchVectorField::motionTypeNames
static const Enum< motionTypes > motionTypeNames
Names for motion types.
Definition: waveMakerPointPatchVectorField.H:171
Foam::constant::universal::h
const dimensionedScalar h
Planck constant.
Definition: setRegionSolidFields.H:33
Foam::Field< vector >::T
tmp< Field< vector > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: Field.C:599
Foam::waveMakerPointPatchVectorField::waveMakerPointPatchVectorField
waveMakerPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
Definition: waveMakerPointPatchVectorField.C:141
fixedValuePointPatchField.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::waveMakerPointPatchVectorField::motionType_
motionTypes motionType_
Motion type.
Definition: waveMakerPointPatchVectorField.H:177
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::waveMakerPointPatchVectorField::waveLength
virtual scalar waveLength(const scalar h, const scalar T)
Dispersion equation.
Definition: waveMakerPointPatchVectorField.C:70
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::waveMakerPointPatchVectorField::Rlg_
tensor Rlg_
Rotation tensor from local to global system.
Definition: waveMakerPointPatchVectorField.H:221
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::waveMakerPointPatchVectorField::flap
Definition: waveMakerPointPatchVectorField.H:166
Foam::waveMakerPointPatchVectorField::rampTime_
scalar rampTime_
Ramp time.
Definition: waveMakerPointPatchVectorField.H:209
Foam::Vector< scalar >
Foam::List< label >
Foam::waveMakerPointPatchVectorField::pointToPaddle_
labelList pointToPaddle_
Addressing from point patch index to paddle index.
Definition: waveMakerPointPatchVectorField.H:230
Foam::waveMakerPointPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: waveMakerPointPatchVectorField.C:449
Foam::waveMakerPointPatchVectorField::solitary
Definition: waveMakerPointPatchVectorField.H:167
Foam::waveMakerPointPatchVectorField::piston
Definition: waveMakerPointPatchVectorField.H:165
Foam::waveMakerPointPatchVectorField::motionTypes
motionTypes
Definition: waveMakerPointPatchVectorField.H:163
Foam::waveMakerPointPatchVectorField::n_
vector n_
Patch normal direction.
Definition: waveMakerPointPatchVectorField.H:182
Foam::waveMakerPointPatchVectorField::initialiseGeometry
virtual void initialiseGeometry()
Initialise.
Definition: waveMakerPointPatchVectorField.C:96
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::waveMakerPointPatchVectorField::initialDepth_
scalar initialDepth_
Initial water depth.
Definition: waveMakerPointPatchVectorField.H:188
Foam::waveMakerPointPatchVectorField::timeCoeff
virtual scalar timeCoeff(const scalar t) const
Return the time scaling coefficient.
Definition: waveMakerPointPatchVectorField.C:88
Foam::waveMakerPointPatchVectorField::faceToPaddle_
labelList faceToPaddle_
Addressing from patch face index to paddle index.
Definition: waveMakerPointPatchVectorField.H:233
Foam::waveMakerPointPatchVectorField::g
const vector & g()
Return the gravitational acceleration.
Definition: waveMakerPointPatchVectorField.C:53
Foam::waveMakerPointPatchVectorField::Rgl_
tensor Rgl_
Rotation tensor from global to local system.
Definition: waveMakerPointPatchVectorField.H:218
Foam::waveMakerPointPatchVectorField::zMax_
scalarField zMax_
Maximum z (point) height per patch face / [m].
Definition: waveMakerPointPatchVectorField.H:254
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Enum.H