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);
229 return turb.devRhoReff();
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");
273 <<
"No valid model for viscous stress calculation" 298 return rho()*laminarT.
nu();
300 else if (obr_.foundObject<
dictionary>(
"transportProperties"))
303 obr_.lookupObject<
dictionary>(
"transportProperties");
309 transportProperties.
lookup(
"nu")
317 <<
"No valid model for dynamic viscosity calculation" 327 if (rhoName_ ==
"rhoInf")
336 mesh_.time().timeName(),
359 if (rhoName_ !=
"rhoInf")
362 <<
"Dynamic pressure is expected but kinematic is provided." 382 force_[0][0] +=
sum(fN);
383 force_[1][0] +=
sum(fT);
384 force_[2][0] +=
sum(fP);
385 moment_[0][0] +=
sum(Md^fN);
386 moment_[1][0] +=
sum(Md^fT);
387 moment_[2][0] +=
sum(Md^fP);
395 label bini =
min(
max(floor(dd[i]/binDx_), 0), force_[0].size() - 1);
397 force_[0][bini] += fN[i];
398 force_[1][bini] += fT[i];
399 force_[2][bini] += fP[i];
400 moment_[0][bini] += Md[i]^fN[i];
401 moment_[1][bini] += Md[i]^fT[i];
402 moment_[2][bini] += Md[i]^fP[i];
411 <<
" sum of forces:" <<
nl 412 <<
" pressure : " <<
sum(force_[0]) <<
nl 413 <<
" viscous : " <<
sum(force_[1]) <<
nl 414 <<
" porous : " <<
sum(force_[2]) <<
nl 415 <<
" sum of moments:" <<
nl 416 <<
" pressure : " <<
sum(moment_[0]) <<
nl 417 <<
" viscous : " <<
sum(moment_[1]) <<
nl 418 <<
" porous : " <<
sum(moment_[2])
421 writeTime(file(MAIN_FILE));
422 file(MAIN_FILE) <<
tab <<
setw(1) <<
'(' 423 <<
sum(force_[0]) <<
setw(1) <<
' ' 424 <<
sum(force_[1]) <<
setw(1) <<
' ' 425 <<
sum(force_[2]) <<
setw(3) <<
") (" 426 <<
sum(moment_[0]) <<
setw(1) <<
' ' 427 <<
sum(moment_[1]) <<
setw(1) <<
' ' 428 <<
sum(moment_[2]) <<
setw(1) <<
')' 433 vectorField localForceN(coordSys_.localVector(force_[0]));
434 vectorField localForceT(coordSys_.localVector(force_[1]));
435 vectorField localForceP(coordSys_.localVector(force_[2]));
436 vectorField localMomentN(coordSys_.localVector(moment_[0]));
437 vectorField localMomentT(coordSys_.localVector(moment_[1]));
438 vectorField localMomentP(coordSys_.localVector(moment_[2]));
440 writeTime(file(MAIN_FILE));
441 file(MAIN_FILE) <<
tab <<
setw(1) <<
'(' 442 <<
sum(localForceN) <<
setw(1) <<
' ' 443 <<
sum(localForceT) <<
setw(1) <<
' ' 444 <<
sum(localForceP) <<
setw(3) <<
") (" 445 <<
sum(localMomentN) <<
setw(1) <<
' ' 446 <<
sum(localMomentT) <<
setw(1) <<
' ' 447 <<
sum(localMomentP) <<
setw(1) <<
')' 467 f[0][i] += f[0][i-1];
468 f[1][i] += f[1][i-1];
469 f[2][i] += f[2][i-1];
471 m[0][i] += m[0][i-1];
472 m[1][i] += m[1][i-1];
473 m[2][i] += m[2][i-1];
477 writeTime(file(BINS_FILE));
483 << f[0][i] <<
setw(1) <<
' ' 484 << f[1][i] <<
setw(1) <<
' ' 485 << f[2][i] <<
setw(3) <<
") (" 486 << m[0][i] <<
setw(1) <<
' ' 487 << m[1][i] <<
setw(1) <<
' ' 488 << m[2][i] <<
setw(1) <<
')';
495 lf[0] = coordSys_.localVector(force_[0]);
496 lf[1] = coordSys_.localVector(force_[1]);
497 lf[2] = coordSys_.localVector(force_[2]);
498 lm[0] = coordSys_.localVector(moment_[0]);
499 lm[1] = coordSys_.localVector(moment_[1]);
500 lm[2] = coordSys_.localVector(moment_[2]);
506 lf[0][i] += lf[0][i-1];
507 lf[1][i] += lf[1][i-1];
508 lf[2][i] += lf[2][i-1];
509 lm[0][i] += lm[0][i-1];
510 lm[1][i] += lm[1][i-1];
511 lm[2][i] += lm[2][i-1];
519 << lf[0][i] <<
setw(1) <<
' ' 520 << lf[1][i] <<
setw(1) <<
' ' 521 << lf[2][i] <<
setw(3) <<
") (" 522 << lm[0][i] <<
setw(1) <<
' ' 523 << lm[1][i] <<
setw(1) <<
' ' 524 << lm[2][i] <<
setw(1) <<
')';
528 file(BINS_FILE) <<
endl;
549 directForceDensity_(
false),
561 binCumulative_(
true),
565 resetNames(createFileNames(dict));
584 directForceDensity_(
false),
596 binCumulative_(
true),
600 resetNames(createFileNames(dict));
616 initialised_ =
false;
620 directForceDensity_ = dict.
lookupOrDefault(
"directForceDensity",
false);
626 if (directForceDensity_)
639 if (rhoName_ ==
"rhoInf")
641 dict.
lookup(
"rhoInf") >> rhoRef_;
661 Log <<
" Including porosity effects" <<
endl;
665 Log <<
" Not including porosity effects" <<
endl;
668 if (dict.
found(
"binData"))
671 binDict.
lookup(
"nBin") >> nBin_;
676 <<
"Number of bins (nBin) must be zero or greater" 679 else if ((nBin_ == 0) || (nBin_ == 1))
684 force_[i].setSize(1);
685 moment_[i].setSize(1);
691 binDict.lookup(
"direction") >> binDir_;
692 binDir_ /=
mag(binDir_);
695 scalar binMax = -GREAT;
701 binMin_ =
min(
min(d), binMin_);
702 binMax =
max(
max(d), binMax);
709 binMax = 1.0001*(binMax - binMin_) + binMin_;
711 binDx_ = (binMax - binMin_)/scalar(nBin_);
714 binPoints_.setSize(nBin_);
717 binPoints_[i] = (i + 0.5)*binDir_*binDx_;
720 binDict.lookup(
"cumulative") >> binCumulative_;
725 force_[i].setSize(nBin_);
726 moment_[i].setSize(nBin_);
734 force_[0].setSize(1);
735 force_[1].setSize(1);
736 force_[2].setSize(1);
737 moment_[0].setSize(1);
738 moment_[1].setSize(1);
739 moment_[2].setSize(1);
758 if (directForceDensity_)
762 const surfaceVectorField::Boundary& Sfb =
771 mesh_.C().boundaryField()[
patchi] - coordSys_.origin()
791 applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[
patchi]);
798 const surfaceVectorField::Boundary& Sfb =
802 const volSymmTensorField::Boundary& devRhoReffb
803 = tdevRhoReff().boundaryField();
814 mesh_.C().boundaryField()[
patchi] - coordSys_.origin()
826 applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[
patchi]);
842 <<
"Porosity effects requested, but no porosity models found " 858 label zoneI = cellZoneIDs[i];
859 const cellZone& cZone = mesh_.cellZones()[zoneI];
867 applyBins(Md, fDummy, fDummy, fP, d);
881 return sum(force_[0]) +
sum(force_[1]) +
sum(force_[2]);
887 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.
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
compressible::turbulenceModel & turb
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...
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)
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< 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.
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.