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 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  n | Revolutions per second | no* |
125  axis | Propeller axis | no* |
126  alphaAxis | Axis that defines alpha=0 dir | no |
127  MRF | Name of MRF zone | no* |
128  originOffset | Origin offset for MRF mode | no | (0 0 0)
129  writePropellerPerformance| Write propeller performance text file | yes |
130  writeWakeFields | Write wake field text files | yes |
131  surfaceWriter | Sample disk surface writer | no* |
132  r1 | Sample disk inner radius | no | 0
133  r2 | Sample disk outer radius | no* |
134  nTheta | Divisions in theta direction | no* |
135  nRadial | Divisions in radial direction | no* |
136  interpolationScheme | Sampling interpolation scheme | no* | cell
137  \endtable
138 
139 
140 Note
141 - URef is a scalar Function1 type, i.e. supports constant, table, lookup values
142 - rotationMode is used to set the origin, axis and revolutions per second
143  - if set to 'specified' all 3 entries are required
144  - note: origin is the sample disk origin
145  - if set to 'MRF' only the MRF entry is required
146  - to move the sample disk away from the MRF origin, use the originOffset
147 - if writePropellerPerformance is set to on|true:
148  - propellerPerformance text file will be written
149 - if writeWakeFields is set to on|true:
150  - wake and axialWake text files will be written
151 - if the surfaceWriter entry is set, the sample disk surface will be written
152  - extents set according to the r1 and r2 entries
153  - discretised according to the nTheta and nRadial entries
154 
155 See also
156  Foam::functionObject::forces
157  Foam::Function1
158 
159 SourceFiles
160  propellerInfo.C
161 
162 \*---------------------------------------------------------------------------*/
163 
164 #ifndef functionObjects_propellerInfo_H
165 #define functionObjects_propellerInfo_H
166 
167 #include "forces.H"
168 #include "Enum.H"
169 #include "faceList.H"
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 namespace Foam
174 {
175 
176 template<class Type>
177 class Function1;
178 
179 class surfaceWriter;
180 
181 namespace functionObjects
182 {
183 
184 /*---------------------------------------------------------------------------*\
185  Class propellerInfo Declaration
186 \*---------------------------------------------------------------------------*/
187 
188 class propellerInfo
189 :
190  public forces
191 {
192 
193 public:
194 
195  enum class rotationMode
196  {
197  SPECIFIED,
198  MRF
199  };
200 
201  static const Enum<rotationMode> rotationModeNames_;
202 
203 
204 protected:
205 
206  // Protected data
207 
208  //- Propeller radius
209  scalar radius_;
210 
211  //- Reference velocity
212  autoPtr<Function1<scalar>> URefPtr_;
213 
214  //- Rotation mode
216 
217  //- Name of MRF zone (if applicable)
218  word MRFName_;
219 
220  //- Propeller speed (revolutions per second)
221  scalar n_;
222 
223  //- Flag to write performance data
225 
226  //- Propeller performance file
227  autoPtr<OFstream> propellerPerformanceFilePtr_;
228 
229  //- Flag to write wake fields
230  bool writeWakeFields_;
231 
232 
233  // Wake field output
234 
235  //- Surface writer
236  autoPtr<surfaceWriter> surfaceWriterPtr_;
237 
238  //- Number of surface divisions in theta direction
239  label nTheta_;
240 
241  //- Number of surface divisions in radial direction
242  label nRadial_;
243 
244  //- Surface points
246 
247  //- Flag to raise an error if the sample point is not found in the
248  //- mesh. Default = false to enable. e.g. reduced geometry/symmetric
249  //- cases
251 
252  //- Surface faces
254 
255  //- Surface point sample cell IDs
257 
258  //- List of participating points (parallel reduced)
260 
261  //- Interpolation scheme
263 
264  //- Wake field file
265  autoPtr<OFstream> wakeFilePtr_;
266 
267  //- Axial wake field file
268  autoPtr<OFstream> axialWakeFilePtr_;
269 
270  //- Default value when a sample point is not found; default =
271  //- scalar::min
272  scalar nanValue_;
273 
274 
275  // Protected Member Functions
276 
277  //- Set the coordinate system
278  void setCoordinateSystem(const dictionary& dict);
279 
280  //- Set the rotational speed
281  void setRotationalSpeed();
282 
283  //- Create output files
284  void createFiles();
285 
286  //- Return the velocity field
287  const volVectorField& U() const;
288 
289 
290  // Propeller performance text file
291 
292  //- Write the wake fields
294 
295 
296  // Wake text files
297 
298  //- Write the wake text file
299  void writeWake(const vectorField& U, const scalar URef);
300 
301  //- Write the axial wake text file
302  void writeAxialWake(const vectorField& U, const scalar URef);
303 
304  //- Write the wake fields
305  void writeWakeFields(const scalar URef);
306 
307 
308  // Sample surface functions
309 
310  //- Set the faces and points for the sample surface
312  (
313  const coordinateSystem& coordSys,
314  const scalar r1,
315  const scalar r2,
316  const scalar nTheta,
317  const label nRadius,
318  faceList& faces,
320  ) const;
321 
322  //- Set the sample surface based on dictionary settings
324 
325  //- Set the sample cells corresponding to the sample points
327 
328  //- Return the area average of a field
329  scalar meanSampleDiskField(const scalarField& field) const;
330 
331  //- Write the sample surface
333  (
334  const vectorField& U,
335  const vectorField& Ur,
336  const scalar URef
337  );
338 
339  //- Interpolate from the mesh onto the sample surface
340  template<class Type>
342  (
344  const Type& defaultValue
345  ) const;
346 
347  //- No copy construct
348  propellerInfo(const propellerInfo&) = delete;
349 
350  //- No copy assignment
351  void operator=(const propellerInfo&) = delete;
352 
353 
354 public:
355 
356  //- Runtime type information
357  TypeName("propellerInfo");
358 
359 
360  // Constructors
361 
362  //- Construct from Time and dictionary
364  (
365  const word& name,
366  const Time& runTime,
367  const dictionary& dict,
368  const bool readFields = true
369  );
370 
371  //- Construct from objectRegistry and dictionary
373  (
374  const word& name,
375  const objectRegistry& obr,
376  const dictionary& dict,
377  const bool readFields = true
378  );
379 
380 
381  //- Destructor
382  virtual ~propellerInfo() = default;
383 
384 
385  // Member Functions
386 
387  //- Read the forces data
388  virtual bool read(const dictionary&);
389 
390  //- Execute, currently does nothing
391  virtual bool execute();
392 
393  //- Write the forces
394  virtual bool write();
395 
396  void UpdateMesh(const mapPolyMesh& mpm);
397 
398  void movePoints(const polyMesh& mesh);
399 };
400 
401 
402 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
403 
404 } // End namespace functionObjects
405 } // End namespace Foam
406 
407 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
408 
409 #endif
410 
411 // ************************************************************************* //
Foam::functionObjects::propellerInfo::radius_
scalar radius_
Propeller radius.
Definition: propellerInfo.H:323
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::functionObjects::propellerInfo::movePoints
void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition: propellerInfo.C:918
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Enum< rotationMode >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::propellerInfo::propellerPerformanceFilePtr_
autoPtr< OFstream > propellerPerformanceFilePtr_
Propeller performance file.
Definition: propellerInfo.H:341
Foam::surfaceWriter
Base class for surface writers.
Definition: surfaceWriter.H:114
Foam::functionObjects::propellerInfo::axialWakeFilePtr_
autoPtr< OFstream > axialWakeFilePtr_
Axial wake field file.
Definition: propellerInfo.H:382
Foam::functionObjects::forces
Calculates the forces and moments by integrating the pressure and skin-friction forces over a given l...
Definition: forces.H:236
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::functionObjects::propellerInfo::wakeFilePtr_
autoPtr< OFstream > wakeFilePtr_
Wake field file.
Definition: propellerInfo.H:379
Foam::functionObjects::propellerInfo::createFiles
void createFiles()
Create output files.
Definition: propellerInfo.C:175
Foam::functionObjects::propellerInfo::writePropellerPerformance
void writePropellerPerformance()
Write the wake fields.
Definition: propellerInfo.C:554
Foam::functionObjects::propellerInfo::execute
virtual bool execute()
Execute, currently does nothing.
Definition: propellerInfo.C:869
Foam::functionObjects::propellerInfo::MRFName_
word MRFName_
Name of MRF zone (if applicable)
Definition: propellerInfo.H:332
Foam::functionObjects::propellerInfo::rotationMode::MRF
Foam::boolList
List< bool > boolList
A List of bools.
Definition: List.H:65
Foam::functionObjects::propellerInfo::TypeName
TypeName("propellerInfo")
Runtime type information.
Foam::functionObjects::propellerInfo::~propellerInfo
virtual ~propellerInfo()=default
Destructor.
Foam::functionObjects::propellerInfo::nRadial_
label nRadial_
Number of surface divisions in radial direction.
Definition: propellerInfo.H:356
Foam::functionObjects::propellerInfo::cellIds_
labelList cellIds_
Surface point sample cell IDs.
Definition: propellerInfo.H:370
Foam::functionObjects::propellerInfo::rotationMode::SPECIFIED
faceList.H
Foam::functionObjects::propellerInfo::writeAxialWake
void writeAxialWake(const vectorField &U, const scalar URef)
Write the axial wake text file.
Definition: propellerInfo.C:672
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:291
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::functionObjects::propellerInfo::propellerInfo
propellerInfo(const propellerInfo &)=delete
No copy construct.
Foam::functionObjects::propellerInfo::meanSampleDiskField
scalar meanSampleDiskField(const scalarField &field) const
Return the area average of a field.
Definition: propellerInfo.C:477
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::functionObjects::propellerInfo::writeWakeFields
void writeWakeFields(const scalar URef)
Write the wake fields.
Definition: propellerInfo.C:731
Foam::functionObjects::propellerInfo::writeWakeFields_
bool writeWakeFields_
Flag to write wake fields.
Definition: propellerInfo.H:344
Foam::functionObjects::propellerInfo::write
virtual bool write()
Write the forces.
Definition: propellerInfo.C:903
Foam::Field< vector >
Foam::functionObjects::propellerInfo::U
const volVectorField & U() const
Return the velocity field.
Definition: propellerInfo.C:212
Foam::functionObjects::propellerInfo::updateSampleDiskCells
void updateSampleDiskCells()
Set the sample cells corresponding to the sample points.
Definition: propellerInfo.C:379
Foam::functionObjects::propellerInfo
Calculates propeller performance and wake field properties.
Definition: propellerInfo.H:302
field
rDeltaTY field()
Foam::functionObjects::propellerInfo::operator=
void operator=(const propellerInfo &)=delete
No copy assignment.
Foam::functionObjects::propellerInfo::rotationModeNames_
static const Enum< rotationMode > rotationModeNames_
Definition: propellerInfo.H:315
Foam::functionObjects::propellerInfo::surfaceWriterPtr_
autoPtr< surfaceWriter > surfaceWriterPtr_
Surface writer.
Definition: propellerInfo.H:350
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::propellerInfo::interpolationScheme_
word interpolationScheme_
Interpolation scheme.
Definition: propellerInfo.H:376
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::propellerInfo::nanValue_
scalar nanValue_
Definition: propellerInfo.H:386
Foam::functionObjects::propellerInfo::n_
scalar n_
Propeller speed (revolutions per second)
Definition: propellerInfo.H:335
Foam::functionObjects::propellerInfo::writeSampleDiskSurface
void writeSampleDiskSurface(const vectorField &U, const vectorField &Ur, const scalar URef)
Write the sample surface.
Definition: propellerInfo.C:521
Foam::functionObjects::propellerInfo::setCoordinateSystem
void setCoordinateSystem(const dictionary &dict)
Set the coordinate system.
Definition: propellerInfo.C:61
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:62
Foam::functionObjects::propellerInfo::writePropellerPerformance_
bool writePropellerPerformance_
Flag to write performance data.
Definition: propellerInfo.H:338
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
forces.H
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::propellerInfo::rotationMode_
rotationMode rotationMode_
Rotation mode.
Definition: propellerInfo.H:329
Foam::faceList
List< face > faceList
A List of faces.
Definition: faceListFwd.H:47
Foam::functionObjects::propellerInfo::points_
pointField points_
Surface points.
Definition: propellerInfo.H:359
Foam::List< face >
Foam::functionObjects::propellerInfo::writeWake
void writeWake(const vectorField &U, const scalar URef)
Write the wake text file.
Definition: propellerInfo.C:613
Foam::functionObjects::regionFunctionObject::obr
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Definition: regionFunctionObject.C:47
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::functionObjects::propellerInfo::setSampleDiskSurface
void setSampleDiskSurface(const dictionary &dict)
Set the sample surface based on dictionary settings.
Definition: propellerInfo.C:333
Foam::functionObjects::readFields
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition: readFields.H:155
Foam::functionObjects::propellerInfo::setSampleDiskGeometry
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.
Definition: propellerInfo.C:230
Foam::functionObjects::propellerInfo::UpdateMesh
void UpdateMesh(const mapPolyMesh &mpm)
Definition: propellerInfo.C:912
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::functionObjects::propellerInfo::errorOnPointNotFound_
bool errorOnPointNotFound_
Definition: propellerInfo.H:364
Foam::functionObjects::propellerInfo::faces_
faceList faces_
Surface faces.
Definition: propellerInfo.H:367
Foam::functionObjects::propellerInfo::read
virtual bool read(const dictionary &)
Read the forces data.
Definition: propellerInfo.C:838
Foam::functionObjects::propellerInfo::nTheta_
label nTheta_
Number of surface divisions in theta direction.
Definition: propellerInfo.H:353
Foam::functionObjects::propellerInfo::URefPtr_
autoPtr< Function1< scalar > > URefPtr_
Reference velocity.
Definition: propellerInfo.H:326
Foam::functionObjects::propellerInfo::interpolate
tmp< Field< Type > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &psi, const Type &defaultValue) const
Interpolate from the mesh onto the sample surface.
Foam::functionObjects::propellerInfo::pointMask_
boolList pointMask_
List of participating points (parallel reduced)
Definition: propellerInfo.H:373
Foam::GeometricField< vector, fvPatchField, volMesh >
psi
const volScalarField & psi
Definition: createFieldRefs.H:1
Foam::functionObjects::propellerInfo::setRotationalSpeed
void setRotationalSpeed()
Set the rotational speed.
Definition: propellerInfo.C:137
Foam::coordinateSystem
Base class for coordinate system specification, the default coordinate system type is cartesian .
Definition: coordinateSystem.H:132
Foam::functionObjects::propellerInfo::rotationMode
rotationMode
Definition: propellerInfo.H:309
Enum.H