37 namespace functionObjects
60 if (dict.
found(
"binData"))
67 names.
append(forceType +
"_bins");
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;
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);
144 file(i)<<
tab << f <<
tab << m;
148 for (
label j = 0; j < nBin_; j++)
151 const word f(
"localForces" + jn + binForceTypes);
152 const word m(
"localMoments" + jn + binForceTypes);
154 file(i)<<
tab << f <<
tab << m;
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")
341 mesh_.time().timeName(),
364 if (rhoName_ !=
"rhoInf")
367 <<
"Dynamic pressure is expected but kinematic is provided." 387 force_[0][0] +=
sum(fN);
388 force_[1][0] +=
sum(fT);
389 force_[2][0] +=
sum(fP);
390 moment_[0][0] +=
sum(Md^fN);
391 moment_[1][0] +=
sum(Md^fT);
392 moment_[2][0] +=
sum(Md^fP);
400 label bini =
min(
max(floor(dd[i]/binDx_), 0), force_[0].size() - 1);
402 force_[0][bini] += fN[i];
403 force_[1][bini] += fT[i];
404 force_[2][bini] += fP[i];
405 moment_[0][bini] += Md[i]^fN[i];
406 moment_[1][bini] += Md[i]^fT[i];
407 moment_[2][bini] += Md[i]^fP[i];
416 <<
" sum of forces:" <<
nl 417 <<
" pressure : " <<
sum(force_[0]) <<
nl 418 <<
" viscous : " <<
sum(force_[1]) <<
nl 419 <<
" porous : " <<
sum(force_[2]) <<
nl 420 <<
" sum of moments:" <<
nl 421 <<
" pressure : " <<
sum(moment_[0]) <<
nl 422 <<
" viscous : " <<
sum(moment_[1]) <<
nl 423 <<
" porous : " <<
sum(moment_[2])
426 writeTime(file(MAIN_FILE));
428 file(MAIN_FILE) <<
tab <<
setw(1) <<
'(' 429 <<
sum(force_[0]) <<
setw(1) <<
' ' 430 <<
sum(force_[1]) <<
setw(1) <<
' ' 431 <<
sum(force_[2]) <<
setw(3) <<
") (" 432 <<
sum(moment_[0]) <<
setw(1) <<
' ' 433 <<
sum(moment_[1]) <<
setw(1) <<
' ' 434 <<
sum(moment_[2]) <<
setw(1) <<
')';
438 vectorField localForceN(coordSys_.localVector(force_[0]));
439 vectorField localForceT(coordSys_.localVector(force_[1]));
440 vectorField localForceP(coordSys_.localVector(force_[2]));
441 vectorField localMomentN(coordSys_.localVector(moment_[0]));
442 vectorField localMomentT(coordSys_.localVector(moment_[1]));
443 vectorField localMomentP(coordSys_.localVector(moment_[2]));
445 file(MAIN_FILE) <<
tab <<
setw(1) <<
'(' 446 <<
sum(localForceN) <<
setw(1) <<
' ' 447 <<
sum(localForceT) <<
setw(1) <<
' ' 448 <<
sum(localForceP) <<
setw(3) <<
") (" 449 <<
sum(localMomentN) <<
setw(1) <<
' ' 450 <<
sum(localMomentT) <<
setw(1) <<
' ' 451 <<
sum(localMomentP) <<
setw(1) <<
')';
454 file(MAIN_FILE) <<
endl;
472 f[0][i] += f[0][i-1];
473 f[1][i] += f[1][i-1];
474 f[2][i] += f[2][i-1];
476 m[0][i] += m[0][i-1];
477 m[1][i] += m[1][i-1];
478 m[2][i] += m[2][i-1];
482 writeTime(file(BINS_FILE));
488 << f[0][i] <<
setw(1) <<
' ' 489 << f[1][i] <<
setw(1) <<
' ' 490 << f[2][i] <<
setw(3) <<
") (" 491 << m[0][i] <<
setw(1) <<
' ' 492 << m[1][i] <<
setw(1) <<
' ' 493 << m[2][i] <<
setw(1) <<
')';
500 lf[0] = coordSys_.localVector(force_[0]);
501 lf[1] = coordSys_.localVector(force_[1]);
502 lf[2] = coordSys_.localVector(force_[2]);
503 lm[0] = coordSys_.localVector(moment_[0]);
504 lm[1] = coordSys_.localVector(moment_[1]);
505 lm[2] = coordSys_.localVector(moment_[2]);
511 lf[0][i] += lf[0][i-1];
512 lf[1][i] += lf[1][i-1];
513 lf[2][i] += lf[2][i-1];
514 lm[0][i] += lm[0][i-1];
515 lm[1][i] += lm[1][i-1];
516 lm[2][i] += lm[2][i-1];
524 << lf[0][i] <<
setw(1) <<
' ' 525 << lf[1][i] <<
setw(1) <<
' ' 526 << lf[2][i] <<
setw(3) <<
") (" 527 << lm[0][i] <<
setw(1) <<
' ' 528 << lm[1][i] <<
setw(1) <<
' ' 529 << lm[2][i] <<
setw(1) <<
')';
533 file(BINS_FILE) <<
endl;
554 directForceDensity_(
false),
566 binCumulative_(
true),
570 resetNames(createFileNames(dict));
589 directForceDensity_(
false),
601 binCumulative_(
true),
605 resetNames(createFileNames(dict));
621 initialised_ =
false;
625 directForceDensity_ = dict.
lookupOrDefault(
"directForceDensity",
false);
631 if (directForceDensity_)
644 if (rhoName_ ==
"rhoInf")
646 dict.
lookup(
"rhoInf") >> rhoRef_;
666 Log <<
" Including porosity effects" <<
endl;
670 Log <<
" Not including porosity effects" <<
endl;
673 if (dict.
found(
"binData"))
676 binDict.
lookup(
"nBin") >> nBin_;
681 <<
"Number of bins (nBin) must be zero or greater" 684 else if ((nBin_ == 0) || (nBin_ == 1))
689 force_[i].setSize(1);
690 moment_[i].setSize(1);
696 binDict.lookup(
"direction") >> binDir_;
697 binDir_ /=
mag(binDir_);
700 scalar binMax = -great;
706 binMin_ =
min(
min(d), binMin_);
707 binMax =
max(
max(d), binMax);
714 binMax = 1.0001*(binMax - binMin_) + binMin_;
716 binDx_ = (binMax - binMin_)/scalar(nBin_);
719 binPoints_.setSize(nBin_);
722 binPoints_[i] = (i + 0.5)*binDir_*binDx_;
725 binDict.lookup(
"cumulative") >> binCumulative_;
730 force_[i].setSize(nBin_);
731 moment_[i].setSize(nBin_);
739 force_[0].setSize(1);
740 force_[1].setSize(1);
741 force_[2].setSize(1);
742 moment_[0].setSize(1);
743 moment_[1].setSize(1);
744 moment_[2].setSize(1);
763 if (directForceDensity_)
767 const surfaceVectorField::Boundary& Sfb =
776 mesh_.C().boundaryField()[
patchi] - coordSys_.origin()
796 applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[
patchi]);
803 const surfaceVectorField::Boundary& Sfb =
807 const volSymmTensorField::Boundary& devRhoReffb
808 = tdevRhoReff().boundaryField();
819 mesh_.C().boundaryField()[
patchi] - coordSys_.origin()
831 applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[
patchi]);
847 <<
"Porosity effects requested, but no porosity models found " 863 label zoneI = cellZoneIDs[i];
864 const cellZone& cZone = mesh_.cellZones()[zoneI];
872 applyBins(Md, fDummy, fDummy, fP, d);
886 return sum(force_[0]) +
sum(force_[1]) +
sum(force_[2]);
892 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.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
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)
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
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)
forces(const forces &)
Disallow default bitwise copy construct.
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)
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
word name(const complex &)
Return a string representation of a complex.
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. ...
#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)
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
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.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
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.
addToRunTimeSelectionTable(functionObject, add, dictionary)
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.