37 namespace functionObjects
58 if (dict.
found(
"binData"))
64 names.
append(forceType +
"_bins");
78 writeHeader(file(i),
"Forces");
79 writeHeaderValue(file(i),
"CofR", coordSys_.origin());
80 writeCommented(file(i),
"Time");
83 <<
"forces(pressure viscous porous) " 84 <<
"moment(pressure viscous porous)";
90 <<
"localForces(pressure,viscous,porous) " 91 <<
"localMoments(pressure,viscous,porous)";
98 writeHeader(file(i),
"Force bins");
99 writeHeaderValue(file(i),
"bins", nBin_);
100 writeHeaderValue(file(i),
"start", binMin_);
101 writeHeaderValue(file(i),
"delta", binDx_);
102 writeHeaderValue(file(i),
"direction", binDir_);
105 writeCommented(file(i),
"x co-ords :");
108 binPoints[pointi] = (binMin_ + (pointi + 1)*binDx_)*binDir_;
109 file(i) <<
tab << binPoints[pointi].x();
113 writeCommented(file(i),
"y co-ords :");
116 file(i) <<
tab << binPoints[pointi].y();
120 writeCommented(file(i),
"z co-ords :");
123 file(i) <<
tab << binPoints[pointi].z();
127 writeCommented(file(i),
"Time");
129 for (
label j = 0; j < nBin_; j++)
132 const word f(
"forces" + jn +
"[pressure,viscous,porous]");
133 const word m(
"moments" + jn +
"[pressure,viscous,porous]");
135 file(i)<<
tab << f <<
tab << m;
139 for (
label j = 0; j < nBin_; j++)
142 const word f(
"localForces" + jn +
"[pressure,viscous,porous]");
143 const word m(
"localMoments" + jn +
"[pressure,viscous,porous]");
145 file(i)<<
tab << f <<
tab << m;
152 <<
"Unhandled file index: " << i
167 if (directForceDensity_)
172 <<
"Could not find " << fDName_ <<
" in database." 186 <<
"Could not find " << UName_ <<
", " << pName_
197 <<
"Could not find " << rhoName_
212 if (obr_.foundObject<cmpTurbModel>(cmpTurbModel::propertiesName))
214 const cmpTurbModel&
turb =
215 obr_.lookupObject<cmpTurbModel>(cmpTurbModel::propertiesName);
217 return turb.devRhoReff();
219 else if (obr_.foundObject<icoTurbModel>(icoTurbModel::propertiesName))
222 obr_.lookupObject<icoTurbModel>(icoTurbModel::propertiesName);
247 else if (obr_.foundObject<
dictionary>(
"transportProperties"))
250 obr_.lookupObject<
dictionary>(
"transportProperties");
261 <<
"No valid model for viscous stress calculation" 286 return rho()*laminarT.
nu();
288 else if (obr_.foundObject<
dictionary>(
"transportProperties"))
291 obr_.lookupObject<
dictionary>(
"transportProperties");
297 transportProperties.
lookup(
"nu")
305 <<
"No valid model for dynamic viscosity calculation" 315 if (rhoName_ ==
"rhoInf")
317 const fvMesh&
mesh = refCast<const fvMesh>(obr_);
349 if (rhoName_ !=
"rhoInf")
352 <<
"Dynamic pressure is expected but kinematic is provided." 372 force_[0][0] +=
sum(fN);
373 force_[1][0] +=
sum(fT);
374 force_[2][0] +=
sum(fP);
375 moment_[0][0] +=
sum(Md^fN);
376 moment_[1][0] +=
sum(Md^fT);
377 moment_[2][0] +=
sum(Md^fP);
385 label bini =
min(
max(floor(dd[i]/binDx_), 0), force_[0].size() - 1);
387 force_[0][bini] += fN[i];
388 force_[1][bini] += fT[i];
389 force_[2][bini] += fP[i];
390 moment_[0][bini] += Md[i]^fN[i];
391 moment_[1][bini] += Md[i]^fT[i];
392 moment_[2][bini] += Md[i]^fP[i];
401 <<
" sum of forces:" <<
nl 402 <<
" pressure : " <<
sum(force_[0]) <<
nl 403 <<
" viscous : " <<
sum(force_[1]) <<
nl 404 <<
" porous : " <<
sum(force_[2]) <<
nl 405 <<
" sum of moments:" <<
nl 406 <<
" pressure : " <<
sum(moment_[0]) <<
nl 407 <<
" viscous : " <<
sum(moment_[1]) <<
nl 408 <<
" porous : " <<
sum(moment_[2])
412 file(0) <<
tab <<
setw(1) <<
'(' 413 <<
sum(force_[0]) <<
setw(1) <<
' ' 414 <<
sum(force_[1]) <<
setw(1) <<
' ' 415 <<
sum(force_[2]) <<
setw(3) <<
") (" 416 <<
sum(moment_[0]) <<
setw(1) <<
' ' 417 <<
sum(moment_[1]) <<
setw(1) <<
' ' 418 <<
sum(moment_[2]) <<
setw(1) <<
')' 423 vectorField localForceN(coordSys_.localVector(force_[0]));
424 vectorField localForceT(coordSys_.localVector(force_[1]));
425 vectorField localForceP(coordSys_.localVector(force_[2]));
426 vectorField localMomentN(coordSys_.localVector(moment_[0]));
427 vectorField localMomentT(coordSys_.localVector(moment_[1]));
428 vectorField localMomentP(coordSys_.localVector(moment_[2]));
431 file(0) <<
tab <<
setw(1) <<
'(' 432 <<
sum(localForceN) <<
setw(1) <<
' ' 433 <<
sum(localForceT) <<
setw(1) <<
' ' 434 <<
sum(localForceP) <<
setw(3) <<
") (" 435 <<
sum(localMomentN) <<
setw(1) <<
' ' 436 <<
sum(localMomentT) <<
setw(1) <<
' ' 437 <<
sum(localMomentP) <<
setw(1) <<
')' 457 f[0][i] += f[0][i-1];
458 f[1][i] += f[1][i-1];
459 f[2][i] += f[2][i-1];
461 m[0][i] += m[0][i-1];
462 m[1][i] += m[1][i-1];
463 m[2][i] += m[2][i-1];
473 << f[0][i] <<
setw(1) <<
' ' 474 << f[1][i] <<
setw(1) <<
' ' 475 << f[2][i] <<
setw(3) <<
") (" 476 << m[0][i] <<
setw(1) <<
' ' 477 << m[1][i] <<
setw(1) <<
' ' 478 << m[2][i] <<
setw(1) <<
')';
485 lf[0] = coordSys_.localVector(force_[0]);
486 lf[1] = coordSys_.localVector(force_[1]);
487 lf[2] = coordSys_.localVector(force_[2]);
488 lm[0] = coordSys_.localVector(moment_[0]);
489 lm[1] = coordSys_.localVector(moment_[1]);
490 lm[2] = coordSys_.localVector(moment_[2]);
496 lf[0][i] += lf[0][i-1];
497 lf[1][i] += lf[1][i-1];
498 lf[2][i] += lf[2][i-1];
499 lm[0][i] += lm[0][i-1];
500 lm[1][i] += lm[1][i-1];
501 lm[2][i] += lm[2][i-1];
509 << lf[0][i] <<
setw(1) <<
' ' 510 << lf[1][i] <<
setw(1) <<
' ' 511 << lf[2][i] <<
setw(3) <<
") (" 512 << lm[0][i] <<
setw(1) <<
' ' 513 << lm[1][i] <<
setw(1) <<
' ' 514 << lm[2][i] <<
setw(1) <<
')';
538 directForceDensity_(
false),
550 binCumulative_(
true),
553 if (!isA<fvMesh>(obr_))
560 resetNames(createFileNames(dict));
578 directForceDensity_(
false),
590 binCumulative_(
true),
593 if (!isA<fvMesh>(obr_))
600 resetNames(createFileNames(dict));
616 initialised_ =
false;
620 directForceDensity_ = dict.
lookupOrDefault(
"directForceDensity",
false);
622 const fvMesh&
mesh = refCast<const fvMesh>(obr_);
627 if (directForceDensity_)
640 if (rhoName_ ==
"rhoInf")
662 Log <<
" Including porosity effects" <<
endl;
666 Log <<
" Not including porosity effects" <<
endl;
669 if (dict.
found(
"binData"))
672 binDict.
lookup(
"nBin") >> nBin_;
677 <<
"Number of bins (nBin) must be zero or greater" 680 else if ((nBin_ == 0) || (nBin_ == 1))
685 force_[i].setSize(1);
686 moment_[i].setSize(1);
692 binDict.lookup(
"direction") >> binDir_;
693 binDir_ /=
mag(binDir_);
696 scalar binMax = -GREAT;
702 binMin_ =
min(
min(d), binMin_);
703 binMax =
max(
max(d), binMax);
710 binMax = 1.0001*(binMax - binMin_) + binMin_;
712 binDx_ = (binMax - binMin_)/scalar(nBin_);
715 binPoints_.setSize(nBin_);
718 binPoints_[i] = (i + 0.5)*binDir_*binDx_;
721 binDict.lookup(
"cumulative") >> binCumulative_;
726 force_[i].setSize(nBin_);
727 moment_[i].setSize(nBin_);
735 force_[0].setSize(1);
736 force_[1].setSize(1);
737 force_[2].setSize(1);
738 moment_[0].setSize(1);
739 moment_[1].setSize(1);
740 moment_[2].setSize(1);
759 if (directForceDensity_)
765 const surfaceVectorField::Boundary& Sfb =
766 mesh.Sf().boundaryField();
774 mesh.C().boundaryField()[
patchi] - coordSys_.origin()
794 applyBins(Md, fN, fT, fP, mesh.C().boundaryField()[
patchi]);
804 const surfaceVectorField::Boundary& Sfb =
805 mesh.Sf().boundaryField();
808 const volSymmTensorField::Boundary& devRhoReffb
809 = tdevRhoReff().boundaryField();
820 mesh.C().boundaryField()[
patchi] - coordSys_.origin()
832 applyBins(Md, fN, fT, fP, mesh.C().boundaryField()[
patchi]);
850 <<
"Porosity effects requested, but no porosity models found " 866 label zoneI = cellZoneIDs[i];
875 applyBins(Md, fDummy, fDummy, fP, d);
889 return sum(force_[0]) +
sum(force_[1]) +
sum(force_[2]);
895 return sum(moment_[0]) +
sum(moment_[1]) +
sum(moment_[2]);
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)
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].
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.
functionObject base class for writing files
const word dictName() const
Return the local dictionary name (final part of scoped name)
void size(const label)
Override size to be inconsistent with allocated storage.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
virtual vector forceEff() const
Return the total force.
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu)
Return the force over the cell zone(s)
const dimensionSet dimViscosity
compressible::turbulenceModel & turb
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
const volVectorField & C() const
Return cell centres as volVectorField.
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.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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)
tmp< volSymmTensorField > devRhoReff() const
Return the effective viscous stress (laminar + turbulent).
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Templated abstract base class for single-phase incompressible turbulence models.
tmp< volScalarField > mu() const
Dynamic viscosity field.
virtual bool execute()
Execute, currently does nothing.
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Calculate the gradient of the given field.
A class for handling words, derived from string.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Fundamental fluid thermodynamic properties.
dimensionedScalar jn(const int n, const dimensionedScalar &ds)
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
static const word null
An empty word.
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.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
virtual void calcForcesMoment()
Calculate the forces and moments.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
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)
bool empty() const
Return true if the hash table is empty.
label readLabel(Istream &is)
const dimensionSet & dimensions() const
Return dimensions.
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
forces(const forces &)
Disallow default bitwise copy construct.
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)
virtual vector momentEff() const
Return the total moment.
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 > devReff() const
Return the effective stress tensor.
const cellZoneMesh & cellZones() const
Return cell zone mesh.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
#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.
const Mesh & mesh() const
Return mesh.
Base-class for all transport models used by the incompressible turbulence models. ...
addToRunTimeSelectionTable(functionObject, blendingFactor, dictionary)
Mesh data needed to do the Finite Volume discretisation.
virtual bool write()
Write function.
#define Log
Report write to Foam::Info if the local log switch is true.
dimensioned< scalar > mag(const dimensioned< Type > &)
Omanip< int > setw(const int i)
const vectorField::subField faceCentres() const
Return face centres.
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.
const labelList & cellZoneIDs() const
Return const access to the cell zone IDs.
virtual ~forces()
Destructor.
tmp< volScalarField > rho() const
Return rho if specified otherwise rhoRef.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
wordList createFileNames(const dictionary &dict) const
Create file names for forces and bins.
Top level model for porosity models.
virtual bool write()
Write the forces.
const Time & time() const
Return the top-level database.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.