Loading...
Searching...
No Matches
propellerInfo.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) 2021-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::functionObjects::propellerInfo
28
29Group
30 grpForcesFunctionObjects
31
32Description
33 Calculates propeller performance and wake field properties.
34
35 Controlled by \c executeControl:
36 - Propeller performance
37 - Thrust coefficient, Kt
38 - Torque coefficient, 10*Kq
39 - Advance coefficient, J
40 - Open water efficiency, etaO
41 - Written to postProcessing/<name>/<time>/propellerPerformance.dat
42
43 Controlled by writeControl:
44 - Wake field text file
45 - Wake: 1 - UzMean/URef
46 - Velocity in cylindrical coordinates at xyz locations
47 - Written to postProcessing/<name>/<time>/wake.dat
48 - Axial wake field text file
49 - 1 - Uz/URef at r/R and angle
50 - Written to postProcessing/<name>/<time>/axialWake.dat
51 - Velocity surface
52 - Written to postProcessing/<name>/surfaces/<time>/disk.<fileType>
53
54Usage
55 Example of function object specification:
56 \verbatim
57 propellerInfo1
58 {
59 type propellerInfo;
60 libs (forces);
61 writeControl writeTime;
62
63 patches ("propeller.*");
64
65 URef 5; // Function1 type; 'constant' form shown here
66 rho rhoInf; // incompressible
67 rhoInf 1.2;
68
69 // Optionally write propeller performance data
70 writePropellerPerformance yes;
71
72
73 // Propeller data:
74
75 // Radius
76 radius 0.1;
77
78 rotationMode specified; // specified | MRF
79
80 // rotationMode = specified:
81 origin (0 -0.1 0);
82 n 25.15;
83 axis (0 1 0);
84
85 // Optional reference direction for angle (alpha) = 0
86 alphaAxis (1 0 0);
87
88
92
93 // Optionally write wake text files
94 // Note: controlled by writeControl
95 writeWakeFields yes;
96
97 // Sample plane (disk) properties
98 // Note: controlled by writeControl
99 sampleDisk
100 {
101 surfaceWriter vtk;
102 r1 0.05;
103 r2 0.2;
104 nTheta 36;
105 nRadial 10;
106 interpolationScheme cellPoint;
107 errorOnPointNotFound false;
108 }
109 }
110 \endverbatim
111
112 Where the entries comprise:
113 \table
114 Property | Description | Reqd | Deflt
115 type | Type name: propellerInfo | yes |
116 log | Write to standard output | no | no
117 patches | Patches included in the forces calculation | yes |
118 p | Pressure field name | no | p
119 U | Velocity field name | no | U
120 rho | Density field name | no | rho
121 URef | Reference velocity | yes |
122 rotationMode | Rotation mode (see below) | yes |
123 origin | Sample disk centre | no* |
124 axis | Propeller axis | no* |
125 alphaAxis | Axis that defines alpha=0 dir | no |
126 n | Rotation speed [rev/sec] | no* |
127 rpm | Rotation speed [rev/min] | no* |
128 MRF | Name of MRF zone | no* |
129 originOffset | Origin offset for MRF mode | no | (0 0 0)
130 writePropellerPerformance| Write propeller performance text file | yes |
131 writeWakeFields | Write wake field text files | yes |
132 surfaceWriter | Sample disk surface writer | no* |
133 r1 | Sample disk inner radius | no | 0
134 r2 | Sample disk outer radius | no* |
135 nTheta | Divisions in theta direction | no* |
136 nRadial | Divisions in radial direction | no* |
137 interpolationScheme | Sampling interpolation scheme | no* | cell
138 \endtable
139
140
141Note
142- URef is a scalar Function1 type, i.e. supports constant, table, lookup values
143- rotationMode is used to set the origin, axis and revolutions per second
144 (alternatively rpm)
145 - if set to 'specified' all 3 entries are required
146 - note: origin is the sample disk origin
147 - if set to 'MRF' only the MRF entry is required
148 - to move the sample disk away from the MRF origin, use the originOffset
149- if writePropellerPerformance is set to on|true:
150 - propellerPerformance text file will be written
151- if writeWakeFields is set to on|true:
152 - wake and axialWake text files will be written
153- if the surfaceWriter entry is set, the sample disk surface will be written
154 - extents set according to the r1 and r2 entries
155 - discretised according to the nTheta and nRadial entries
156
157See also
158 Foam::functionObject::forces
159 Foam::Function1
160
161SourceFiles
162 propellerInfo.C
163
164\*---------------------------------------------------------------------------*/
165
166#ifndef Foam_functionObjects_propellerInfo_H
167#define Foam_functionObjects_propellerInfo_H
168
169#include "forces.H"
170#include "Enum.H"
171#include "faceList.H"
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175namespace Foam
176{
177
178// Forward Declarations
179template<class Type> class Function1;
180class surfaceWriter;
181
182namespace functionObjects
183{
184
185/*---------------------------------------------------------------------------*\
186 Class propellerInfo Declaration
187\*---------------------------------------------------------------------------*/
188
189class propellerInfo
190:
191 public forces
192{
193
194public:
195
196 enum class rotationMode
197 {
198 SPECIFIED,
199 MRF
200 };
201
202 static const Enum<rotationMode> rotationModeNames_;
203
204
205protected:
206
207 // Protected data
208
209 //- Copy of dictionary used during construction
211
212 //- Propeller radius
213 scalar radius_;
214
215 //- Reference velocity
216 autoPtr<Function1<scalar>> URefPtr_;
217
218 //- Rotation mode
220
221 //- Name of MRF zone (if applicable)
222 word MRFName_;
223
224 //- Propeller speed (revolutions per second)
225 scalar n_;
226
227 //- Flag to write performance data
229
230 //- Propeller performance file
231 autoPtr<OFstream> propellerPerformanceFilePtr_;
232
233 //- Flag to write wake fields
234 bool writeWakeFields_;
235
236
237 // Wake field output
238
239 //- Surface writer
240 autoPtr<surfaceWriter> surfaceWriterPtr_;
241
242 //- Number of surface divisions in theta direction
243 label nTheta_;
244
245 //- Number of surface divisions in radial direction
246 label nRadial_;
247
248 //- Surface points
250
251 //- Flag to raise an error if the sample point is not found in the
252 //- mesh. Default = false to enable. e.g. reduced geometry/symmetric
253 //- cases
255
256 //- Surface faces
258
259 //- Surface point sample cell IDs
261
262 //- List of participating points (parallel reduced)
264
265 //- Interpolation scheme
267
268 //- Wake field file
269 autoPtr<OFstream> wakeFilePtr_;
270
271 //- Axial wake field file
272 autoPtr<OFstream> axialWakeFilePtr_;
273
274 //- Default value when a sample point is not found; default =
275 //- scalar::min
276 scalar nanValue_;
277
278 //- Initialised flag
279 bool initialised_;
280
281
282 // Protected Member Functions
283
284 //- Set the coordinate system
286
287 //- Set the rotational speed
288 void setRotationalSpeed();
289
290 //- Create output files
291 void createFiles();
292
293 //- Return the velocity field
294 const volVectorField& U() const;
295
296
297 // Propeller performance text file
298
299 //- Write the wake fields
301
302
303 // Wake text files
305 //- Write the wake text file
306 void writeWake(const vectorField& U, const scalar URef);
307
308 //- Write the axial wake text file
309 void writeAxialWake(const vectorField& U, const scalar URef);
310
311 //- Write the wake fields
312 void writeWakeFields(const scalar URef);
315 // Sample surface functions
316
317 //- Set the faces and points for the sample surface
319 (
320 const coordinateSystem& coordSys,
321 const scalar r1,
322 const scalar r2,
323 const scalar nTheta,
324 const label nRadius,
325 faceList& faces,
327 ) const;
328
329 //- Set the sample surface based on dictionary settings
331
332 //- Set the sample cells corresponding to the sample points
334
335 //- Return the area average of a field
336 scalar meanSampleDiskField(const scalarField& field) const;
338 //- Write the sample surface
340 (
341 const vectorField& U,
342 const vectorField& Ur,
343 const scalar URef
344 );
345
346 //- Interpolate from the mesh onto the sample surface
347 template<class Type>
349 (
351 const Type& defaultValue
352 ) const;
353
354 //- No copy construct
355 propellerInfo(const propellerInfo&) = delete;
356
357 //- No copy assignment
358 void operator=(const propellerInfo&) = delete;
359
360
361public:
363 //- Runtime type information
364 TypeName("propellerInfo");
365
366
367 // Constructors
368
369 //- Construct from name, Time and dictionary
371 (
372 const word& name,
373 const Time& runTime,
374 const dictionary& dict,
375 const bool readFields = true
376 );
377
378 //- Construct from objectRegistry and dictionary
381 const word& name,
382 const objectRegistry& obr,
383 const dictionary& dict,
384 const bool readFields = true
385 );
386
387
388 //- Destructor
389 virtual ~propellerInfo() = default;
391
392 // Member Functions
393
394 //- Read the function-object dictionary
395 virtual bool read(const dictionary&);
396
397 //- Execute the function-object operations
398 virtual bool execute();
399
400 //- Write the function-object results
401 virtual bool write();
403 void UpdateMesh(const mapPolyMesh& mpm);
404
405 void movePoints(const polyMesh& mesh);
406};
408
409// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
410
411} // End namespace functionObjects
412} // End namespace Foam
413
414// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
415
416#endif
418// ************************************************************************* //
IOMRFZoneList & MRF
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition Function1.H:92
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Base class for coordinate system specification, the default coordinate system type is cartesian .
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Computes forces and moments over a given list of patches by integrating pressure and viscous forces a...
Definition forces.H:321
forces(const word &name, const Time &runTime, const dictionary &dict, const bool readFields=true)
Construct from name, Time and dictionary.
Definition forces.C:510
Calculates propeller performance and wake field properties.
word MRFName_
Name of MRF zone (if applicable).
label nTheta_
Number of surface divisions in theta direction.
boolList pointMask_
List of participating points (parallel reduced).
virtual ~propellerInfo()=default
Destructor.
autoPtr< OFstream > propellerPerformanceFilePtr_
Propeller performance file.
void UpdateMesh(const mapPolyMesh &mpm)
labelList cellIds_
Surface point sample cell IDs.
void writeWake(const vectorField &U, const scalar URef)
Write the wake text file.
void writeWakeFields(const scalar URef)
Write the wake fields.
void createFiles()
Create output files.
rotationMode rotationMode_
Rotation mode.
void setSampleDiskSurface(const dictionary &dict)
Set the sample surface based on dictionary settings.
void writeAxialWake(const vectorField &U, const scalar URef)
Write the axial wake text file.
autoPtr< OFstream > wakeFilePtr_
Wake field file.
void writeSampleDiskSurface(const vectorField &U, const vectorField &Ur, const scalar URef)
Write the sample surface.
const volVectorField & U() const
Return the velocity field.
dictionary dict_
Copy of dictionary used during construction.
propellerInfo(const propellerInfo &)=delete
No copy construct.
autoPtr< OFstream > axialWakeFilePtr_
Axial wake field file.
void writePropellerPerformance()
Write the wake fields.
void movePoints(const polyMesh &mesh)
Update for changes of mesh.
tmp< Field< Type > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &psi, const Type &defaultValue) const
Interpolate from the mesh onto the sample surface.
autoPtr< Function1< scalar > > URefPtr_
Reference velocity.
bool writePropellerPerformance_
Flag to write performance data.
bool errorOnPointNotFound_
Flag to raise an error if the sample point is not found in the mesh. Default = false to enable....
void setCoordinateSystem(const dictionary &dict)
Set the coordinate system.
scalar meanSampleDiskField(const scalarField &field) const
Return the area average of a field.
void setRotationalSpeed()
Set the rotational speed.
pointField points_
Surface points.
void setSampleDiskGeometry(const coordinateSystem &coordSys, const scalar r1, const scalar r2, const scalar nTheta, const label nRadius, faceList &faces, pointField &points) const
Set the faces and points for the sample surface.
scalar nanValue_
Default value when a sample point is not found; default = scalar::min.
word interpolationScheme_
Interpolation scheme.
label nRadial_
Number of surface divisions in radial direction.
autoPtr< surfaceWriter > surfaceWriterPtr_
Surface writer.
scalar n_
Propeller speed (revolutions per second).
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function-object results.
void updateSampleDiskCells()
Set the sample cells corresponding to the sample points.
void operator=(const propellerInfo &)=delete
No copy assignment.
TypeName("propellerInfo")
Runtime type information.
bool writeWakeFields_
Flag to write wake fields.
static const Enum< rotationMode > rotationModeNames_
virtual bool read(const dictionary &)
Read the function-object dictionary.
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition readFields.H:146
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
Base class for surface writers.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
const volScalarField & psi
rDeltaTY field()
dynamicFvMesh & mesh
engineTime & runTime
const pointField & points
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
List< label > labelList
A List of labels.
Definition List.H:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< bool > boolList
A List of bools.
Definition List.H:60
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
vectorField pointField
pointField is a vectorField.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68