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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::functionObjects::propellerInfo
28 
29 Group
30  grpForcesFunctionObjects
31 
32 Description
33  Calculates propeller performance and wake field properties.
34 
35  Controlled by 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 
54 Usage
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 | Required | Deflt value
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 
141 Note
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 
157 See also
158  Foam::functionObject::forces
159  Foam::Function1
160 
161 SourceFiles
162  propellerInfo.C
163 
164 \*---------------------------------------------------------------------------*/
165 
166 #ifndef functionObjects_propellerInfo_H
167 #define functionObjects_propellerInfo_H
168 
169 #include "forces.H"
170 #include "Enum.H"
171 #include "faceList.H"
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 namespace Foam
176 {
177 
178 // Forward Declarations
179 template<class Type> class Function1;
180 class surfaceWriter;
181 
182 namespace functionObjects
183 {
184 
185 /*---------------------------------------------------------------------------*\
186  Class propellerInfo Declaration
187 \*---------------------------------------------------------------------------*/
188 
189 class propellerInfo
190 :
191  public forces
192 {
193 
194 public:
195 
196  enum class rotationMode
197  {
198  SPECIFIED,
199  MRF
200  };
201 
202  static const Enum<rotationMode> rotationModeNames_;
203 
204 
205 protected:
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
285  void setCoordinateSystem(const dictionary& dict);
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);
313 
314 
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
330  void setSampleDiskSurface(const dictionary& dict);
331 
332  //- Set the sample cells corresponding to the sample points
333  void updateSampleDiskCells();
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 
361 public:
363  //- Runtime type information
364  TypeName("propellerInfo");
365 
366 
367  // Constructors
368 
369  //- Construct from 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
380  (
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 forces data
395  virtual bool read(const dictionary&);
396 
397  //- Execute, currently does nothing
398  virtual bool execute();
399 
400  //- Write the forces
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 // ************************************************************************* //
autoPtr< OFstream > propellerPerformanceFilePtr_
Propeller performance file.
Base class for coordinate system specification, the default coordinate system type is cartesian ...
virtual bool execute()
Execute, currently does nothing.
autoPtr< OFstream > axialWakeFilePtr_
Axial wake field file.
void createFiles()
Create output files.
tmp< Field< Type > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &psi, const Type &defaultValue) const
Interpolate from the mesh onto the sample surface.
dictionary dict
void writePropellerPerformance()
Write the wake fields.
rDeltaTY field()
TypeName("propellerInfo")
Runtime type information.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void setRotationalSpeed()
Set the rotational speed.
propellerInfo(const propellerInfo &)=delete
No copy construct.
void movePoints(const polyMesh &mesh)
Update for changes of mesh.
engineTime & runTime
virtual bool write()
Write the forces.
word MRFName_
Name of MRF zone (if applicable)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
label nRadial_
Number of surface divisions in radial direction.
autoPtr< OFstream > wakeFilePtr_
Wake field file.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
const word & name() const noexcept
Return the name of this functionObject.
static const Enum< rotationMode > rotationModeNames_
List< face > faceList
List of faces.
Definition: faceListFwd.H:39
labelList cellIds_
Surface point sample cell IDs.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
word interpolationScheme_
Interpolation scheme.
dynamicFvMesh & mesh
virtual ~propellerInfo()=default
Destructor.
const pointField & points
void writeWakeFields(const scalar URef)
Write the wake fields.
void writeAxialWake(const vectorField &U, const scalar URef)
Write the axial wake text file.
void operator=(const propellerInfo &)=delete
No copy assignment.
bool initialised_
Initialised flag.
bool writeWakeFields_
Flag to write wake fields.
A class for handling words, derived from Foam::string.
Definition: word.H:63
void setCoordinateSystem(const dictionary &dict)
Set the coordinate system.
Definition: propellerInfo.C:54
dictionary dict_
Copy of dictionary used during construction.
scalar meanSampleDiskField(const scalarField &field) const
Return the area average of a field.
rotationMode rotationMode_
Rotation mode.
void updateSampleDiskCells()
Set the sample cells corresponding to the sample points.
scalar n_
Propeller speed (revolutions per second)
const volVectorField & U() const
Return the velocity field.
autoPtr< surfaceWriter > surfaceWriterPtr_
Surface writer.
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.
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition: readFields.H:151
pointField points_
Surface points.
scalar nanValue_
Default value when a sample point is not found; default = scalar::min.
void writeWake(const vectorField &U, const scalar URef)
Write the wake text file.
void writeSampleDiskSurface(const vectorField &U, const vectorField &Ur, const scalar URef)
Write the sample surface.
boolList pointMask_
List of participating points (parallel reduced)
void setSampleDiskSurface(const dictionary &dict)
Set the sample surface based on dictionary settings.
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...
Calculates propeller performance and wake field properties.
label nTheta_
Number of surface divisions in theta direction.
virtual bool read(const dictionary &)
Read the forces data.
faceList faces_
Surface faces.
const volScalarField & psi
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
List< label > labelList
A List of labels.
Definition: List.H:61
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Registry of regIOobjects.
List< bool > boolList
A List of bools.
Definition: List.H:59
scalar radius_
Propeller radius.
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
autoPtr< Function1< scalar > > URefPtr_
Reference velocity.
Namespace for OpenFOAM.
void UpdateMesh(const mapPolyMesh &mpm)