37 template<
class AlphaFieldType,
class RhoFieldType>
38 void Foam::fv::actuationDiskSource::calc
40 const AlphaFieldType&
alpha,
41 const RhoFieldType&
rho,
47 case forceMethodType::FROUDE:
53 case forceMethodType::VARIABLE_SCALING:
55 calcVariableScalingMethod(
alpha,
rho, eqn);
65 template<
class AlphaFieldType,
class RhoFieldType>
66 void Foam::fv::actuationDiskSource::calcFroudeMethod
68 const AlphaFieldType&
alpha,
69 const RhoFieldType&
rho,
80 label szMonitorCells = monitorCells_.size();
82 for (
const label celli : monitorCells_)
85 rhoRef = rhoRef +
rho[celli];
87 reduce(Uref, sumOp<vector>());
88 reduce(rhoRef, sumOp<scalar>());
89 reduce(szMonitorCells, sumOp<label>());
91 if (szMonitorCells == 0)
94 <<
"No cell is available for incoming velocity monitoring." 98 Uref /= szMonitorCells;
99 rhoRef /= szMonitorCells;
101 const scalar Ct = sink_*UvsCtPtr_->value(
mag(Uref));
102 const scalar
Cp = sink_*UvsCpPtr_->value(
mag(Uref));
104 if (
Cp <= VSMALL || Ct <= VSMALL)
107 <<
"Cp and Ct must be greater than zero." <<
nl 108 <<
"Cp = " <<
Cp <<
", Ct = " << Ct
113 const scalar a = 1.0 -
Cp/Ct;
114 const scalar
T = 2.0*rhoRef*diskArea_*
magSqr(Uref & diskDir_)*a*(1 - a);
116 for (
const label celli : cells_)
118 Usource[celli] += ((cellsV[celli]/V())*
T)*diskDir_;
123 mesh_.time().timeOutputValue() >= writeFileStart_
124 && mesh_.time().timeOutputValue() <= writeFileEnd_
127 Ostream&
os = file();
128 writeCurrentTime(
os);
136 template<
class AlphaFieldType,
class RhoFieldType>
137 void Foam::fv::actuationDiskSource::calcVariableScalingMethod
139 const AlphaFieldType&
alpha,
140 const RhoFieldType&
rho,
141 fvMatrix<vector>& eqn
151 label szMonitorCells = monitorCells_.size();
153 for (
const label celli : monitorCells_)
156 rhoRef = rhoRef +
rho[celli];
158 reduce(Uref, sumOp<vector>());
159 reduce(rhoRef, sumOp<scalar>());
160 reduce(szMonitorCells, sumOp<label>());
162 if (szMonitorCells == 0)
165 <<
"No cell is available for incoming velocity monitoring." 169 Uref /= szMonitorCells;
170 const scalar magUref =
mag(Uref);
171 rhoRef /= szMonitorCells;
175 scalar rhoDisk = 0.0;
178 for (
const label celli : cells_)
180 Udisk +=
U[celli]*cellsV[celli];
181 rhoDisk +=
rho[celli]*cellsV[celli];
182 totalV += cellsV[celli];
184 reduce(Udisk, sumOp<vector>());
185 reduce(rhoDisk, sumOp<scalar>());
186 reduce(totalV, sumOp<scalar>());
191 <<
"No cell in the actuator disk." 196 const scalar magUdisk =
mag(Udisk);
199 if (
mag(Udisk) < SMALL)
202 <<
"Velocity spatial-averaged on actuator disk is zero." <<
nl 203 <<
"Please check if the initial U field is zero." 208 const scalar Ct = sink_*UvsCtPtr_->value(magUref);
209 const scalar
Cp = sink_*UvsCpPtr_->value(magUref);
211 if (
Cp <= VSMALL || Ct <= VSMALL)
214 <<
"Cp and Ct must be greater than zero." <<
nl 215 <<
"Cp = " <<
Cp <<
", Ct = " << Ct
220 const scalar CtStar = Ct*
sqr(magUref/magUdisk);
221 const scalar CpStar =
Cp*
pow3(magUref/magUdisk);
224 const scalar
T = 0.5*rhoRef*diskArea_*
magSqr(Udisk & diskDir_)*CtStar;
225 const scalar P = 0.5*rhoRef*diskArea_*
pow3(
mag(Udisk & diskDir_))*CpStar;
227 for (
const label celli : cells_)
229 Usource[celli] += (cellsV[celli]/totalV*
T)*diskDir_;
234 mesh_.time().timeOutputValue() >= writeFileStart_
235 && mesh_.time().timeOutputValue() <= writeFileEnd_
238 Ostream&
os = file();
239 writeCurrentTime(
os);
242 << Udisk <<
tab << CpStar <<
tab << CtStar <<
tab <<
T <<
tab << P
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr char tab
The tab '\t' character(0x09)
enum forceMethodType forceMethod_
The type of the force computation method.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const volScalarField & Cp
OBJstream os(runTime.globalPath()/outputName)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensionedScalar pow3(const dimensionedScalar &ds)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
Field< vector > vectorField
Specialisation of Field<T> for vector.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0)