actuationDisk.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) 2011-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 
26 #include "actuationDisk.H"
27 #include "fvMesh.H"
28 #include "fvMatrix.H"
29 #include "geometricOneField.H"
30 #include "meshSearch.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace fv
38 {
42  (
43  fvModel,
45  dictionary,
46  actuationDiskSource,
47  "actuationDiskSource"
48  );
49 }
50 }
51 
52 
53 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
54 
55 void Foam::fv::actuationDisk::readCoeffs(const dictionary& dict)
56 {
57  phaseName_ = dict.lookupOrDefault<word>("phase", word::null);
58 
59  UName_ =
60  dict.lookupOrDefault<word>
61  (
62  "U",
64  );
65 
66  diskDir_ = dict.lookup<vector>("diskDir");
67  if (mag(diskDir_) < vSmall)
68  {
70  << "disk direction vector is approximately zero"
71  << exit(FatalIOError);
72  }
73 
74  Cp_ = dict.lookup<scalar>("Cp");
75  Ct_ = dict.lookup<scalar>("Ct");
76  if (Cp_ <= vSmall || Ct_ <= vSmall)
77  {
79  << "Cp and Ct must be greater than zero"
80  << exit(FatalIOError);
81  }
82 
83  diskArea_ = dict.lookup<scalar>("diskArea");
84  if (magSqr(diskArea_) <= vSmall)
85  {
87  << "diskArea is approximately zero"
88  << exit(FatalIOError);
89  }
90 
91  upstreamPoint_ = dict.lookup<point>("upstreamPoint");
93  if (returnReduce(upstreamCellId_, maxOp<label>()) == -1)
94  {
96  << "upstream location " << upstreamPoint_ << " not found in mesh"
97  << exit(FatalIOError);
98  }
99 }
100 
101 
102 template<class AlphaFieldType, class RhoFieldType>
103 void Foam::fv::actuationDisk::addActuationDiskAxialInertialResistance
104 (
105  vectorField& Usource,
106  const labelList& cells,
107  const scalarField& Vcells,
108  const AlphaFieldType& alpha,
109  const RhoFieldType& rho,
110  const vectorField& U
111 ) const
112 {
113  const scalar a = 1 - Cp_/Ct_;
114  const vector dHat(diskDir_/mag(diskDir_));
115 
116  scalar dHatUo(vGreat);
117  if (upstreamCellId_ != -1)
118  {
119  dHatUo = dHat & U[upstreamCellId_];
120  }
121  reduce(dHatUo, minOp<scalar>());
122 
123  const vector T = 2*diskArea_*sqr(dHatUo)*a*(1 - a)*dHat;
124 
125  forAll(cells, i)
126  {
127  Usource[cells[i]] +=
128  (alpha[cells[i]]*rho[cells[i]]*(Vcells[cells[i]]/zone_.V()))*T;
129  }
130 }
131 
132 
133 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
134 
136 (
137  const word& name,
138  const word& modelType,
139  const fvMesh& mesh,
140  const dictionary& dict
141 )
142 :
143  fvModel(name, modelType, mesh, dict),
144  zone_(mesh, coeffs(dict)),
145  phaseName_(word::null),
146  UName_(word::null),
147  diskDir_(vector::uniform(NaN)),
148  Cp_(NaN),
149  Ct_(NaN),
150  diskArea_(NaN),
151  upstreamPoint_(vector::uniform(NaN)),
152  upstreamCellId_(-1)
153 {
154  readCoeffs(coeffs(dict));
155 }
156 
157 
158 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
159 
161 {
162  return wordList(1, UName_);
163 }
164 
165 
167 (
168  const volVectorField& U,
169  fvMatrix<vector>& eqn
170 ) const
171 {
172  addActuationDiskAxialInertialResistance
173  (
174  eqn.source(),
175  zone_.zone(),
176  mesh().V(),
179  U
180  );
181 }
182 
183 
185 (
186  const volScalarField& rho,
187  const volVectorField& U,
188  fvMatrix<vector>& eqn
189 ) const
190 {
191  addActuationDiskAxialInertialResistance
192  (
193  eqn.source(),
194  zone_.zone(),
195  mesh().V(),
197  rho,
198  U
199  );
200 }
201 
202 
204 (
205  const volScalarField& alpha,
206  const volScalarField& rho,
207  const volVectorField& U,
208  fvMatrix<vector>& eqn
209 ) const
210 {
211  addActuationDiskAxialInertialResistance
212  (
213  eqn.source(),
214  zone_.zone(),
215  mesh().V(),
216  alpha,
217  rho,
218  U
219  );
220 }
221 
222 
224 {
225  zone_.movePoints();
226  return true;
227 }
228 
229 
231 {
232  zone_.topoChange(map);
233 }
234 
235 
237 {
238  zone_.mapMesh(map);
239 }
240 
241 
243 {
244  zone_.distribute(map);
245 }
246 
247 
249 {
250  if (fvModel::read(dict))
251  {
252  zone_.read(coeffs(dict));
253  readCoeffs(coeffs(dict));
254  return true;
255  }
256  else
257  {
258  return false;
259  }
260 }
261 
262 
263 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
static word groupName(Name name, const word &group)
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Field< Type > & source()
Definition: fvMatrix.H:307
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Finite volume model abstract base class.
Definition: fvModel.H:60
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
Definition: fvModelI.H:31
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvModel.C:196
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
Actuation disk source.
virtual bool movePoints()
Update for mesh motion.
virtual void addSup(const volVectorField &U, fvMatrix< vector > &eqn) const
Source term to momentum equation.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
scalar Cp_
Power coefficient.
word UName_
Name of the velocity field.
word phaseName_
The name of the phase to which this fvModel applies.
vector diskDir_
Disk area normal.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read dictionary.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
point upstreamPoint_
Upstream point sample.
actuationDisk(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
label upstreamCellId_
Upstream cell ID.
scalar diskArea_
Disk area.
scalar Ct_
Thrust coefficient.
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
label findCell(const point &p, const pointInCellShapes=pointInCellShapes::tets) const
Find the cell containing the given point.
Definition: meshSearch.C:173
static const meshSearch & New(const polyMesh &mesh, const pointInCellShapes=pointInCellShapes::tets)
Lookup or construct from mesh and cell decomposition option.
Definition: meshSearch.C:61
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:78
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
const cellShapeList & cells
U
Definition: pEqn.H:72
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
addBackwardCompatibleToRunTimeSelectionTable(fvConstraint, fixedTemperature, dictionary, fixedTemperatureConstraint, "fixedTemperatureConstraint")
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
List< word > wordList
A List of words.
Definition: fileName.H:54
List< label > labelList
A List of labels.
Definition: labelList.H:56
vector point
Point is a vector.
Definition: point.H:41
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
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
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Field< vector > vectorField
Specialisation of Field<T> for vector.
IOerror FatalIOError
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)
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
labelList fv(nPoints)
dictionary dict