propellerDiskAdjustment.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 void Foam::fv::propellerDiskAdjustment::readCoeffs(const dictionary& dict)
31 {
32  forces_ = new functionObjects::forces
33  (
34  "forces",
36  dict.subDict("forces")
37  );
38 
39  deltaTStar_ = dict.lookup<scalar>("deltaTStar");
40  Tmin_ = dict.lookup<scalar>("Tmin");
41  sfc_ = dict.lookup<scalar>("sfc");
42  startTime_ = dict.lookup<scalar>("startTime");
43  nFraction_ = dict.lookup<scalar>("nFraction");
45  dict.lookupOrDefault<scalar>("resistanceFraction", 1.0);
46  resistanceDirection_ = dict.lookupOrDefault<vector>
47  (
48  "resistanceDirection",
50  );
51 }
52 
53 
54 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
55 
57 {
58  forces_->calcForcesMoments();
59  return -resistanceFraction_*(forces_->forceEff() & resistanceDirection_);
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64 
66 (
67  const propellerDisk& pd,
68  const dictionary& dict
69 )
70 :
71  propellerDisk_(pd),
72  n_
73  (
74  IOobject
75  (
76  propellerDisk_.typedName("n"),
77  propellerDisk_.mesh().time().name(),
78  propellerDisk_.mesh(),
79  IOobject::READ_IF_PRESENT,
80  IOobject::AUTO_WRITE
81  ),
82  dimensionedScalar("n", dimless/dimTime, mag(dict.lookup<scalar>("n")))
83  )
84 {
85  readCoeffs(dict);
86 }
87 
88 
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 
92 {
93  const fvMesh& mesh = propellerDisk_.mesh();
94 
95  if (mesh.time().value() > startTime_)
96  {
97  const scalar& n = n_.value();
98 
99  const fvCellZone& zone = propellerDisk_.zone_;
100  const labelList& zoneCells = zone.zone();
101 
102  // Average propeller disk density
103  const scalarField zoneCellVolumes(mesh.cellVolumes(), zoneCells);
104  const scalarField zoneRho(forces_->rho(), zoneCells);
105  const scalar rho = gSum(zoneCellVolumes*zoneRho)/zone.V();
106 
107  // Get ship resistance
108  const scalar res = resistance();
109 
110  const scalar beta = max(Tmin_, T*rho)/(sqr(n));
111  const scalar diffForce = (res - sfc_ - T*rho);
112 
113  scalar deltaN =
114  mesh.time().deltaT().value()*(diffForce/(2*beta*n*deltaTStar_));
115  const scalar magDeltaN = min(mag(deltaN), nFraction_*n);
116  deltaN = sign(deltaN)*magDeltaN;
117 
118  n_ = n_.oldTime() + dimensionedScalar(dimRate, deltaN);
119  }
120 }
121 
122 
123 // ************************************************************************* //
label n
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
dimensionedScalar deltaT() const
Return time step.
Definition: TimeStateI.H:46
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const Type & value() const
Return const reference to value.
cellZone selection or generation class with caching of zone volume
Definition: fvCellZone.H:94
scalar V() const
Return const access to the total cell volume.
Definition: fvCellZoneI.H:34
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:433
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
scalar nFraction_
Maximum fractional change of rotation speed.
const propellerDisk & propellerDisk_
Reference to the propellerDisk fvModel.
scalar sfc_
Skin friction correction for model-scale ship [N].
autoPtr< functionObjects::forces > forces_
Function object to calculate the resistance force.
propellerDiskAdjustment(const propellerDisk &, const dictionary &dict)
Construct from components.
scalar deltaTStar_
Relaxation time scale for rotation speed adjustment.
vector resistanceDirection_
Resistance force direction.
scalar Tmin_
Minimum thrust for beta [N].
scalar resistanceFraction_
Resistance fraction for multi-propulsor configurations.
scalar startTime_
Start time for rotation speed adjustment.
scalar resistance() const
Return the ship resistance (for self-propulsion correction)
void correctn(const scalar T) const
Correct the rotation speed from the current propulsion force.
Disk momentum source which approximates a propeller based on a given propeller curve.
vector normal_
Propeller disk normal direction.
const cellZone & zone() const
Return const access to the cell set.
const scalarField & cellVolumes() const
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
rho
Definition: pEqn.H:1
const dimensionSet time
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
const dimensionSet & dimless
Definition: dimensions.C:138
dimensionedScalar sign(const dimensionedScalar &ds)
Type gSum(const UList< Type > &f, const label comm)
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
const dimensionSet & dimTime
Definition: dimensions.C:142
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:188
const dimensionSet & dimRate
Definition: dimensions.C:152
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dictionary dict