37 namespace functionObjects
60 if (dict.
found(
"binData"))
67 names.
append(forceType +
"_bins");
79 case fileID::mainFile:
83 writeHeader(
file(i),
"Forces");
84 writeHeaderValue(
file(i),
"CofR", coordSys_.origin());
85 writeCommented(
file(i),
"Time");
87 const word forceTypes(
"(pressure viscous porous)");
89 <<
"forces" << forceTypes <<
tab 90 <<
"moments" << forceTypes;
96 <<
"localForces" << forceTypes <<
tab 97 <<
"localMoments" << forceTypes;
102 case fileID::binsFile:
106 writeHeader(
file(i),
"Force bins");
107 writeHeaderValue(
file(i),
"bins", nBin_);
108 writeHeaderValue(
file(i),
"start", binMin_);
109 writeHeaderValue(
file(i),
"delta", binDx_);
110 writeHeaderValue(
file(i),
"direction", binDir_);
113 writeCommented(
file(i),
"x co-ords :");
116 binPoints[pointi] = (binMin_ + (pointi + 1)*binDx_)*binDir_;
117 file(i) <<
tab << binPoints[pointi].x();
121 writeCommented(
file(i),
"y co-ords :");
124 file(i) <<
tab << binPoints[pointi].y();
128 writeCommented(
file(i),
"z co-ords :");
131 file(i) <<
tab << binPoints[pointi].z();
135 writeCommented(
file(i),
"Time");
137 const word binForceTypes(
"[pressure,viscous,porous]");
138 for (
label j = 0; j < nBin_; j++)
141 const word f(
"forces" + jn + binForceTypes);
142 const word m(
"moments" + jn + binForceTypes);
148 for (
label j = 0; j < nBin_; j++)
151 const word f(
"localForces" + jn + binForceTypes);
152 const word m(
"localMoments" + jn + binForceTypes);
163 <<
"Unhandled file index: " << i
179 if (directForceDensity_)
184 <<
"Could not find " << fDName_ <<
" in database." 198 <<
"Could not find " << UName_ <<
", " << pName_
209 <<
"Could not find " << rhoName_
224 if (obr_.foundObject<cmpTurbModel>(cmpTurbModel::propertiesName))
226 const cmpTurbModel& turb =
227 obr_.lookupObject<cmpTurbModel>(cmpTurbModel::propertiesName);
231 else if (obr_.foundObject<icoTurbModel>(icoTurbModel::propertiesName))
234 obr_.lookupObject<icoTurbModel>(icoTurbModel::propertiesName);
259 else if (obr_.foundObject<
dictionary>(
"transportProperties"))
262 obr_.lookupObject<
dictionary>(
"transportProperties");
268 transportProperties.
lookup(
"nu")
278 <<
"No valid model for viscous stress calculation" 303 return rho()*laminarT.
nu();
305 else if (obr_.foundObject<
dictionary>(
"transportProperties"))
308 obr_.lookupObject<
dictionary>(
"transportProperties");
314 transportProperties.
lookup(
"nu")
322 <<
"No valid model for dynamic viscosity calculation" 332 if (rhoName_ ==
"rhoInf")
356 if (rhoName_ !=
"rhoInf")
359 <<
"Dynamic pressure is expected but kinematic is provided." 379 force_[0][0] +=
sum(fN);
380 force_[1][0] +=
sum(fT);
381 force_[2][0] +=
sum(fP);
382 moment_[0][0] +=
sum(Md^fN);
383 moment_[1][0] +=
sum(Md^fT);
384 moment_[2][0] +=
sum(Md^fP);
392 label bini =
min(
max(floor(dd[i]/binDx_), 0), force_[0].size() - 1);
394 force_[0][bini] += fN[i];
395 force_[1][bini] += fT[i];
396 force_[2][bini] += fP[i];
397 moment_[0][bini] += Md[i]^fN[i];
398 moment_[1][bini] += Md[i]^fT[i];
399 moment_[2][bini] += Md[i]^fP[i];
408 <<
" sum of forces:" <<
nl 409 <<
" pressure : " <<
sum(force_[0]) <<
nl 410 <<
" viscous : " <<
sum(force_[1]) <<
nl 411 <<
" porous : " <<
sum(force_[2]) <<
nl 412 <<
" sum of moments:" <<
nl 413 <<
" pressure : " <<
sum(moment_[0]) <<
nl 414 <<
" viscous : " <<
sum(moment_[1]) <<
nl 415 <<
" porous : " <<
sum(moment_[2])
418 writeTime(
file(fileID::mainFile));
421 <<
sum(force_[0]) <<
setw(1) <<
' ' 422 <<
sum(force_[1]) <<
setw(1) <<
' ' 423 <<
sum(force_[2]) <<
setw(3) <<
") (" 424 <<
sum(moment_[0]) <<
setw(1) <<
' ' 425 <<
sum(moment_[1]) <<
setw(1) <<
' ' 426 <<
sum(moment_[2]) <<
setw(1) <<
')';
430 vectorField localForceN(coordSys_.localVector(force_[0]));
431 vectorField localForceT(coordSys_.localVector(force_[1]));
432 vectorField localForceP(coordSys_.localVector(force_[2]));
433 vectorField localMomentN(coordSys_.localVector(moment_[0]));
434 vectorField localMomentT(coordSys_.localVector(moment_[1]));
435 vectorField localMomentP(coordSys_.localVector(moment_[2]));
438 <<
sum(localForceN) <<
setw(1) <<
' ' 439 <<
sum(localForceT) <<
setw(1) <<
' ' 440 <<
sum(localForceP) <<
setw(3) <<
") (" 441 <<
sum(localMomentN) <<
setw(1) <<
' ' 442 <<
sum(localMomentT) <<
setw(1) <<
' ' 443 <<
sum(localMomentP) <<
setw(1) <<
')';
464 f[0][i] += f[0][i-1];
465 f[1][i] += f[1][i-1];
466 f[2][i] += f[2][i-1];
468 m[0][i] += m[0][i-1];
469 m[1][i] += m[1][i-1];
470 m[2][i] += m[2][i-1];
474 writeTime(
file(fileID::binsFile));
478 file(fileID::binsFile)
480 << f[0][i] <<
setw(1) <<
' ' 481 << f[1][i] <<
setw(1) <<
' ' 482 << f[2][i] <<
setw(3) <<
") (" 483 << m[0][i] <<
setw(1) <<
' ' 484 << m[1][i] <<
setw(1) <<
' ' 485 << m[2][i] <<
setw(1) <<
')';
492 lf[0] = coordSys_.localVector(force_[0]);
493 lf[1] = coordSys_.localVector(force_[1]);
494 lf[2] = coordSys_.localVector(force_[2]);
495 lm[0] = coordSys_.localVector(moment_[0]);
496 lm[1] = coordSys_.localVector(moment_[1]);
497 lm[2] = coordSys_.localVector(moment_[2]);
503 lf[0][i] += lf[0][i-1];
504 lf[1][i] += lf[1][i-1];
505 lf[2][i] += lf[2][i-1];
506 lm[0][i] += lm[0][i-1];
507 lm[1][i] += lm[1][i-1];
508 lm[2][i] += lm[2][i-1];
514 file(fileID::binsFile)
516 << lf[0][i] <<
setw(1) <<
' ' 517 << lf[1][i] <<
setw(1) <<
' ' 518 << lf[2][i] <<
setw(3) <<
") (" 519 << lm[0][i] <<
setw(1) <<
' ' 520 << lm[1][i] <<
setw(1) <<
' ' 521 << lm[2][i] <<
setw(1) <<
')';
546 directForceDensity_(
false),
558 binCumulative_(
true),
562 resetNames(createFileNames(dict));
581 directForceDensity_(
false),
593 binCumulative_(
true),
597 resetNames(createFileNames(dict));
613 initialised_ =
false;
617 directForceDensity_ = dict.
lookupOrDefault(
"directForceDensity",
false);
623 if (directForceDensity_)
636 if (rhoName_ ==
"rhoInf")
638 dict.
lookup(
"rhoInf") >> rhoRef_;
658 Log <<
" Including porosity effects" <<
endl;
662 Log <<
" Not including porosity effects" <<
endl;
665 if (dict.
found(
"binData"))
668 binDict.
lookup(
"nBin") >> nBin_;
673 <<
"Number of bins (nBin) must be zero or greater" 676 else if ((nBin_ == 0) || (nBin_ == 1))
681 force_[i].setSize(1);
682 moment_[i].setSize(1);
688 binDict.lookup(
"direction") >> binDir_;
689 binDir_ /=
mag(binDir_);
692 scalar binMax = -great;
698 binMin_ =
min(
min(d), binMin_);
699 binMax =
max(
max(d), binMax);
706 binMax = 1.0001*(binMax - binMin_) + binMin_;
708 binDx_ = (binMax - binMin_)/scalar(nBin_);
711 binPoints_.setSize(nBin_);
714 binPoints_[i] = (i + 0.5)*binDir_*binDx_;
717 binDict.lookup(
"cumulative") >> binCumulative_;
722 force_[i].setSize(nBin_);
723 moment_[i].setSize(nBin_);
731 force_[0].setSize(1);
732 force_[1].setSize(1);
733 force_[2].setSize(1);
734 moment_[0].setSize(1);
735 moment_[1].setSize(1);
736 moment_[2].setSize(1);
755 if (directForceDensity_)
759 const surfaceVectorField::Boundary& Sfb =
768 mesh_.C().boundaryField()[
patchi] - coordSys_.origin()
788 applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[
patchi]);
795 const surfaceVectorField::Boundary& Sfb =
799 const volSymmTensorField::Boundary& devRhoReffb
800 = tdevRhoReff().boundaryField();
811 mesh_.C().boundaryField()[
patchi] - coordSys_.origin()
823 applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[
patchi]);
839 <<
"Porosity effects requested, but no porosity models found " 855 label zoneI = cellZoneIDs[i];
856 const cellZone& cZone = mesh_.cellZones()[zoneI];
864 applyBins(Md, fDummy, fDummy, fP, d);
878 return sum(force_[0]) +
sum(force_[1]) +
sum(force_[2]);
884 return sum(moment_[0]) +
sum(moment_[1]) +
sum(moment_[2]);
virtual vector momentEff() const
Return the total moment.
Base class for other coordinate system specifications.
virtual void writeFileHeader(const label i)
Output file header information.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
#define forAll(list, i)
Loop across all elements in list.
virtual tmp< volScalarField > mu() const =0
Dynamic viscosity of mixture [kg/m/s].
virtual bool write()
Write function.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
forces(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void size(const label)
Override size to be inconsistent with allocated storage.
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu)
Return the force over the cell zone(s)
bool empty() const
Return true if the hash table is empty.
const dimensionSet dimViscosity
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
virtual vector forceEff() const
Return the total force.
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
rhoReactionThermo & thermo
const labelList & cellZoneIDs() const
Return const access to the cell zone IDs.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch IDs corresponding to the given names.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
virtual bool read(const dictionary &)
Read the forces data.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Macros for easy insertion into run-time selection tables.
void writeBins()
Helper function to write bin data.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const word dictName() const
Return the local dictionary name (final part of scoped name)
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, const Mesh &, const dimensionSet &, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
Return a temporary field constructed from name, mesh, dimensionSet.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Templated abstract base class for single-phase incompressible turbulence models.
virtual bool execute()
Execute, currently does nothing.
const dimensionSet & dimensions() const
Return dimensions.
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Calculate the gradient of the given field.
A class for handling words, derived from string.
tmp< volScalarField > mu() const
Dynamic viscosity field.
Fundamental fluid thermodynamic properties.
dimensionedScalar jn(const int n, const dimensionedScalar &ds)
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
static const word null
An empty word.
virtual void calcForcesMoment()
Calculate the forces and moments.
tmp< volScalarField > rho() const
Return rho if specified otherwise rhoRef.
void applyBins(const vectorField &Md, const vectorField &fN, const vectorField &fT, const vectorField &fP, const vectorField &d)
Accumulate bin data.
An STL-conforming hash table.
const dimensionSet dimPressure
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
label readLabel(Istream &is)
virtual tmp< volSymmTensorField > devReff() const
Return the effective stress tensor.
tmp< volSymmTensorField > devRhoReff() const
Return the effective viscous stress (laminar + turbulent).
virtual tmp< volScalarField > nu() const =0
Return the laminar viscosity.
void initialise()
Initialise the fields.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const complex &)
Return a string representation of a complex.
defineTypeNameAndDebug(Qdot, 0)
const dimensionSet dimDensity
static const GeometricField< symmTensor, fvPatchField, volMesh > & null()
Return a null geometric field.
void writeForces()
Helper function to write force data.
const dimensionedScalar mu
Atomic mass unit.
virtual tmp< volSymmTensorField > devRhoReff() const
Return the effective stress tensor.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Base-class for all transport models used by the incompressible turbulence models. ...
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
#define Log
Report write to Foam::Info if the local log switch is true.
dimensioned< scalar > mag(const dimensioned< Type > &)
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Omanip< int > setw(const int i)
List< wordRe > wordReList
A List of wordRe (word or regular expression)
A class for managing temporary objects.
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
virtual ~forces()
Destructor.
fileID
Enumeration for ensuring the right file is accessed.
Top level model for porosity models.
virtual bool write()
Write the forces.
wordList createFileNames(const dictionary &dict) const
Create file names for forces and bins.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
const vectorField::subField faceCentres() const
Return face centres.