40 namespace functionObjects
58 const word forceType(
dict.lookup(
"type"));
63 if (
dict.found(
"binData"))
83 ?
"(pressure viscous porous)"
84 :
"(pressure viscous)"
89 case fileID::mainFile:
94 writeHeaderValue(
file(i),
"CofR", coordSys_.origin());
95 writeCommented(
file(i),
"Time");
98 <<
"forces" << forceTypes <<
tab
99 <<
"moments" << forceTypes;
105 <<
"localForces" << forceTypes <<
tab
106 <<
"localMoments" << forceTypes;
111 case fileID::binsFile:
116 writeHeaderValue(
file(i),
"bins", nBin_);
117 writeHeaderValue(
file(i),
"start", binMin_);
118 writeHeaderValue(
file(i),
"delta", binDx_);
119 writeHeaderValue(
file(i),
"direction", binDir_);
122 writeCommented(
file(i),
"x co-ords :");
125 binPoints[pointi] = (binMin_ + (pointi + 1)*binDx_)*binDir_;
126 file(i) <<
tab << binPoints[pointi].x();
130 writeCommented(
file(i),
"y co-ords :");
133 file(i) <<
tab << binPoints[pointi].y();
137 writeCommented(
file(i),
"z co-ords :");
140 file(i) <<
tab << binPoints[pointi].z();
144 writeCommented(
file(i),
"Time");
146 for (
label j = 0; j < nBin_; j++)
149 const word f(
"forces" +
jn + forceTypes);
150 const word m(
"moments" +
jn + forceTypes);
156 for (
label j = 0; j < nBin_; j++)
159 const word f(
"localForces" +
jn + forceTypes);
160 const word m(
"localMoments" +
jn + forceTypes);
171 <<
"Unhandled file index: " << i
187 if (directForceDensity_)
192 <<
"Could not find " << fDName_ <<
" in database."
206 <<
"Could not find " << UName_ <<
", " << pName_
217 <<
"Could not find " << rhoName_
234 const word& modelName = momentumTransportModel::typeName;
235 const word phaseModelName =
240 if (obr_.foundObject<icoModel>(modelName))
243 obr_.lookupObject<icoModel>(modelName);
247 else if (obr_.foundObject<cmpModel>(modelName))
249 const cmpModel& model =
250 obr_.lookupObject<cmpModel>(modelName);
252 return alpha()*model.devTau();
254 else if (obr_.foundObject<phaseIcoModel>(phaseModelName))
256 const phaseIcoModel& model =
257 obr_.lookupObject<phaseIcoModel>(phaseModelName);
259 return rho()*model.devSigma();
261 else if (obr_.foundObject<phaseCmpModel>(phaseModelName))
263 const phaseCmpModel& model =
264 obr_.lookupObject<phaseCmpModel>(phaseModelName);
266 return model.devTau();
268 else if (obr_.foundObject<
dictionary>(
"physicalProperties"))
273 obr_.lookupObject<
dictionary>(
"physicalProperties");
289 <<
"No valid model for viscous stress calculation"
304 const word& modelName = momentumTransportModel::typeName;
305 const word phaseModelName =
310 if (obr_.foundObject<icoModel>(modelName))
313 obr_.lookupObject<icoModel>(modelName);
315 return rho()*model.
nu();
317 else if (obr_.foundObject<cmpModel>(modelName))
319 const cmpModel& model =
320 obr_.lookupObject<cmpModel>(modelName);
322 return model.rho()*model.nu();
324 else if (obr_.foundObject<phaseIcoModel>(phaseModelName))
326 const phaseIcoModel& model =
327 obr_.lookupObject<phaseIcoModel>(phaseModelName);
329 return rho()*model.nu();
331 else if (obr_.foundObject<phaseCmpModel>(phaseModelName))
333 const phaseCmpModel& model =
334 obr_.lookupObject<phaseCmpModel>(phaseModelName);
336 return model.rho()*model.nu();
338 else if (obr_.foundObject<
dictionary>(
"physicalProperties"))
343 obr_.lookupObject<
dictionary>(
"physicalProperties");
357 <<
"No valid model for dynamic viscosity calculation"
367 if (rhoName_ ==
"rhoInf")
391 if (rhoName_ !=
"rhoInf")
394 <<
"Dynamic pressure is expected but kinematic is provided."
441 ).boundaryField()[
patchi];
457 force_[0][0] +=
sum(fN);
458 force_[1][0] +=
sum(fT);
459 force_[2][0] +=
sum(fP);
460 moment_[0][0] +=
sum(Md^fN);
461 moment_[1][0] +=
sum(Md^fT);
462 moment_[2][0] +=
sum(Md^fP);
470 label bini =
min(
max(floor(dd[i]/binDx_), 0), force_[0].size() - 1);
472 force_[0][bini] += fN[i];
473 force_[1][bini] += fT[i];
474 force_[2][bini] += fP[i];
475 moment_[0][bini] += Md[i]^fN[i];
476 moment_[1][bini] += Md[i]^fT[i];
477 moment_[2][bini] += Md[i]^fP[i];
486 <<
" sum of forces:" <<
nl
487 <<
" pressure : " <<
sum(force_[0]) <<
nl
488 <<
" viscous : " <<
sum(force_[1]) <<
nl
489 <<
" porous : " <<
sum(force_[2]) <<
nl
490 <<
" sum of moments:" <<
nl
491 <<
" pressure : " <<
sum(moment_[0]) <<
nl
492 <<
" viscous : " <<
sum(moment_[1]) <<
nl
493 <<
" porous : " <<
sum(moment_[2])
496 writeTime(
file(fileID::mainFile));
501 <<
sum(force_[0]) <<
setw(1) <<
' '
502 <<
sum(force_[1]) <<
setw(1) <<
' '
503 <<
sum(force_[2]) <<
setw(3) <<
") ("
504 <<
sum(moment_[0]) <<
setw(1) <<
' '
505 <<
sum(moment_[1]) <<
setw(1) <<
' '
506 <<
sum(moment_[2]) <<
setw(1) <<
')';
511 <<
sum(force_[0]) <<
setw(1) <<
' '
512 <<
sum(force_[1]) <<
setw(3) <<
") ("
513 <<
sum(moment_[0]) <<
setw(1) <<
' '
514 <<
sum(moment_[1]) <<
setw(1) <<
')';
522 <<
sum(coordSys_.localVector(force_[0])) <<
setw(1) <<
' '
523 <<
sum(coordSys_.localVector(force_[1])) <<
setw(1) <<
' '
524 <<
sum(coordSys_.localVector(force_[2])) <<
setw(3) <<
") ("
525 <<
sum(coordSys_.localVector(moment_[0])) <<
setw(1) <<
' '
526 <<
sum(coordSys_.localVector(moment_[1])) <<
setw(1) <<
' '
527 <<
sum(coordSys_.localVector(moment_[2])) <<
setw(1) <<
')';
532 <<
sum(coordSys_.localVector(force_[0])) <<
setw(1) <<
' '
533 <<
sum(coordSys_.localVector(force_[1])) <<
setw(3) <<
") ("
534 <<
sum(coordSys_.localVector(moment_[0])) <<
setw(1) <<
' '
535 <<
sum(coordSys_.localVector(moment_[1])) <<
setw(1) <<
')';
555 for (
label i = 1; i <
f[0].size(); i++)
557 f[0][i] +=
f[0][i-1];
558 f[1][i] +=
f[1][i-1];
559 f[2][i] +=
f[2][i-1];
561 m[0][i] += m[0][i-1];
562 m[1][i] += m[1][i-1];
563 m[2][i] += m[2][i-1];
567 writeTime(
file(fileID::binsFile));
574 file(fileID::binsFile)
576 <<
f[0][i] <<
setw(1) <<
' '
577 <<
f[1][i] <<
setw(1) <<
' '
578 <<
f[2][i] <<
setw(3) <<
") ("
579 << m[0][i] <<
setw(1) <<
' '
580 << m[1][i] <<
setw(1) <<
' '
581 << m[2][i] <<
setw(1) <<
')';
585 file(fileID::binsFile)
587 <<
f[0][i] <<
setw(1) <<
' '
588 <<
f[1][i] <<
setw(3) <<
") ("
589 << m[0][i] <<
setw(1) <<
' '
590 << m[1][i] <<
setw(1) <<
')';
598 lf[0] = coordSys_.localVector(force_[0]);
599 lf[1] = coordSys_.localVector(force_[1]);
600 lf[2] = coordSys_.localVector(force_[2]);
601 lm[0] = coordSys_.localVector(moment_[0]);
602 lm[1] = coordSys_.localVector(moment_[1]);
603 lm[2] = coordSys_.localVector(moment_[2]);
609 lf[0][i] += lf[0][i-1];
610 lf[1][i] += lf[1][i-1];
611 lf[2][i] += lf[2][i-1];
612 lm[0][i] += lm[0][i-1];
613 lm[1][i] += lm[1][i-1];
614 lm[2][i] += lm[2][i-1];
622 file(fileID::binsFile)
624 << lf[0][i] <<
setw(1) <<
' '
625 << lf[1][i] <<
setw(1) <<
' '
626 << lf[2][i] <<
setw(3) <<
") ("
627 << lm[0][i] <<
setw(1) <<
' '
628 << lm[1][i] <<
setw(1) <<
' '
629 << lm[2][i] <<
setw(1) <<
')';
633 file(fileID::binsFile)
635 << lf[0][i] <<
setw(1) <<
' '
636 << lf[1][i] <<
setw(3) <<
") ("
637 << lm[0][i] <<
setw(1) <<
' '
638 << lm[1][i] <<
setw(1) <<
')';
663 rhoName_(
word::null),
664 phaseName_(
word::null),
665 directForceDensity_(false),
677 binCumulative_(true),
698 rhoName_(
word::null),
699 phaseName_(
word::null),
700 directForceDensity_(false),
712 binCumulative_(true),
731 initialised_ =
false;
735 directForceDensity_ =
dict.lookupOrDefault(
"directForceDensity",
false);
741 if (directForceDensity_)
744 fDName_ =
dict.lookupOrDefault<
word>(
"fD",
"fD");
772 if (rhoName_ ==
"rhoInf")
774 dict.lookup(
"rhoInf") >> rhoRef_;
778 pRef_ =
dict.lookupOrDefault<scalar>(
"pRef", 0.0);
783 if (
dict.found(
"CofR"))
786 localSystem_ =
false;
794 dict.readIfPresent(
"porosity", porosity_);
797 Log <<
" Including porosity effects" <<
endl;
801 Log <<
" Not including porosity effects" <<
endl;
804 if (
dict.found(
"binData"))
807 binDict.
lookup(
"nBin") >> nBin_;
812 <<
"Number of bins (nBin) must be zero or greater"
815 else if ((nBin_ == 0) || (nBin_ == 1))
820 force_[i].setSize(1);
821 moment_[i].setSize(1);
827 binDict.
lookup(
"direction") >> binDir_;
828 binDir_ /=
mag(binDir_);
831 scalar binMax = -great;
837 binMin_ =
min(
min(d), binMin_);
838 binMax =
max(
max(d), binMax);
845 binMax = 1.0001*(binMax - binMin_) + binMin_;
847 binDx_ = (binMax - binMin_)/scalar(nBin_);
850 binPoints_.setSize(nBin_);
853 binPoints_[i] = (i + 0.5)*binDir_*binDx_;
856 binDict.
lookup(
"cumulative") >> binCumulative_;
861 force_[i].setSize(nBin_);
862 moment_[i].setSize(nBin_);
870 force_[0].setSize(1);
871 force_[1].setSize(1);
872 force_[2].setSize(1);
873 moment_[0].setSize(1);
874 moment_[1].setSize(1);
875 moment_[2].setSize(1);
878 resetNames(createFileNames(
dict));
896 if (directForceDensity_)
901 mesh_.Sf().boundaryField();
909 mesh_.C().boundaryField()[
patchi] - coordSys_.origin()
929 applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[
patchi]);
937 mesh_.Sf().boundaryField();
941 tdevTau().boundaryField();
944 const scalar pRef = pRef_/
rho(
p);
952 mesh_.C().boundaryField()[
patchi] - coordSys_.origin()
960 *(
p.boundaryField()[
patchi] - pRef)
967 applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[
patchi]);
983 <<
"Porosity effects requested, but no porosity models found "
998 const label zoneI = cellZoneIDs[i];
999 const cellZone& cZone = mesh_.cellZones()[zoneI];
1007 applyBins(Md, fDummy, fDummy, fP, d);
1021 return sum(force_[0]) +
sum(force_[1]) +
sum(force_[2]);
1027 return sum(moment_[0]) +
sum(moment_[1]) +
sum(moment_[2]);
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Macros for easy insertion into run-time selection tables.
Generic GeometricBoundaryField class.
Generic GeometricField class.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &)
Return a temporary field constructed from name,.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
static const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
An STL-conforming hash table.
bool empty() const
Return true if the hash table is empty.
static word groupName(Name name, const word &group)
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static bool master(const label communicator=0)
Am I the master process.
Base class for single-phase compressible turbulence models.
Base class for other coordinate system specifications.
A list of keyword definitions, which are a keyword followed by any number of values (e....
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Abstract base-class for Time/database functionObjects.
Calculates the forces and moments by integrating the pressure and skin-friction forces over a given l...
virtual ~forces()
Destructor.
tmp< volScalarField > alpha() const
Get the volume fraction field.
void initialise()
Initialise the fields.
forces(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
tmp< volSymmTensorField > devTau() const
Return the effective viscous stress (laminar + turbulent).
void applyBins(const vectorField &Md, const vectorField &fN, const vectorField &fT, const vectorField &fP, const vectorField &d)
Accumulate bin data.
tmp< volScalarField > mu() const
Dynamic viscosity field.
virtual void calcForcesMoment()
Calculate the forces and moments.
virtual vector forceEff() const
Return the total force.
virtual vector momentEff() const
Return the total moment.
void writeBins()
Helper function to write bin data.
virtual void writeFileHeader(const label i)
Output file header information.
void writeForces()
Helper function to write force data.
tmp< volScalarField > rho() const
Return rho if specified otherwise rhoRef.
fileID
Enumeration for ensuring the right file is accessed.
virtual bool execute()
Execute, currently does nothing.
virtual bool write()
Write the forces.
virtual bool read(const dictionary &)
Read the forces data.
wordList createFileNames(const dictionary &dict) const
Create file names for forces and bins.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
const wordList & names() const
Return const access to the names.
virtual bool write()
Write function.
virtual bool read(const dictionary &)
Read optional controls.
Base class for single-phase incompressible turbulence models.
virtual tmp< volSymmTensorField > devSigma() const
Return the effective stress tensor.
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
Registry of regIOobjects.
Templated abstract base class for multiphase compressible turbulence models.
Templated abstract base class for multiphase incompressible turbulence models.
An abstract base class for physical properties.
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.
A patch is a list of labels that address the faces in the global face list.
const vectorField::subField faceCentres() const
Return face centres.
Top level model for porosity models.
const labelList & cellZoneIDs() const
Return const access to the cell zone IDs.
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu) const
Return the force over the cell zone(s)
A class for managing temporary objects.
A class for handling words, derived from string.
static const word null
An empty word.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Calculate the gradient of the given field.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
#define WarningInFunction
Report a warning using Foam::Warning.
#define Log
Report write to Foam::Info if the local log switch is true.
const dimensionedScalar mu
Atomic mass unit.
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
const dimensionSet dimViscosity
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const dimensionSet dimPressure
Ostream & endl(Ostream &os)
Add newline and flush stream.
Omanip< int > setw(const int i)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
errorManip< error > abort(error &err)
const dimensionSet dimless
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Vector< scalar > vector
A scalar version of the templated Vector.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const dimensionSet dimDensity
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar jn(const int n, const dimensionedScalar &ds)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
List< wordRe > wordReList
A List of wordRe (word or regular expression)
word name(const complex &)
Return a string representation of a complex.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.