Go to the documentation of this file.
56 if (writeToFile() && !forceFilePtr_.valid())
58 forceFilePtr_ = createFile(
"force");
59 writeIntegratedHeader(
"Force", forceFilePtr_());
60 momentFilePtr_ = createFile(
"moment");
61 writeIntegratedHeader(
"Moment", momentFilePtr_());
65 forceBinFilePtr_ = createFile(
"forceBin");
66 writeBinHeader(
"Force", forceBinFilePtr_());
67 momentBinFilePtr_ = createFile(
"momentBin");
68 writeBinHeader(
"Moment", momentBinFilePtr_());
73 localForceFilePtr_ = createFile(
"localForce");
74 writeIntegratedHeader(
"Force", localForceFilePtr_());
75 localMomentFilePtr_ = createFile(
"localMoment");
76 writeIntegratedHeader(
"Moment", localMomentFilePtr_());
80 localForceBinFilePtr_ = createFile(
"localForceBin");
81 writeBinHeader(
"Force", localForceBinFilePtr_());
82 localMomentBinFilePtr_ = createFile(
"localMomentBin");
83 writeBinHeader(
"Moment", localMomentBinFilePtr_());
96 writeHeader(os, header);
97 writeHeaderValue(os,
"CofR", coordSys_.origin());
99 writeCommented(os,
"Time");
100 writeTabbed(os,
"(total_x total_y total_z)");
101 writeTabbed(os,
"(pressure_x pressure_y pressure_z)");
102 writeTabbed(os,
"(viscous_x viscous_y viscous_z)");
106 writeTabbed(os,
"(porous_x porous_y porous_z)");
115 writeHeader(os, header +
" bins");
116 writeHeaderValue(os,
"bins", nBin_);
117 writeHeaderValue(os,
"start", binMin_);
118 writeHeaderValue(os,
"delta", binDx_);
119 writeHeaderValue(os,
"direction", binDir_);
122 writeCommented(os,
"x co-ords :");
125 binPoints[pointI] = (binMin_ + (pointI + 1)*binDx_)*binDir_;
126 os <<
tab << binPoints[pointI].x();
130 writeCommented(os,
"y co-ords :");
133 os <<
tab << binPoints[pointI].y();
137 writeCommented(os,
"z co-ords :");
140 os <<
tab << binPoints[pointI].z();
145 writeCommented(os,
"Time");
147 for (
label j = 0; j < nBin_; j++)
150 os <<
tab <<
jn <<
"(total_x total_y total_z)"
151 <<
tab <<
jn <<
"(pressure_x pressure_y pressure_z)"
152 <<
tab <<
jn <<
"(viscous_x viscous_y viscous_z)";
156 os <<
tab <<
jn <<
"(porous_x porous_y porous_z)";
166 if (initialised_ || !active_)
171 if (directForceDensity_)
177 <<
"Could not find " << fDName_ <<
" in database." <<
nl
178 <<
" De-activating forces."
197 <<
"Could not find " << UName_ <<
", " << pName_;
199 if (rhoName_ !=
"rhoInf")
201 Info<<
" or " << rhoName_;
204 Info<<
" in database." <<
nl
205 <<
" De-activating forces." <<
endl;
224 const fvMesh&
mesh = refCast<const fvMesh>(obr_);
229 scalar binMax = -GREAT;
232 label patchI = iter.key();
235 binMin_ =
min(
min(d), binMin_);
236 binMax =
max(
max(d), binMax);
254 label zoneI = cellZoneIDs[i];
257 binMin_ =
min(
min(d), binMin_);
258 binMax =
max(
max(d), binMax);
268 binMax = 1.0001*(binMax - binMin_) + binMin_;
270 binDx_ = (binMax - binMin_)/scalar(nBin_);
273 binPoints_.setSize(nBin_);
276 binPoints_[i] = (i + 0.5)*binDir_*binDx_;
282 force_[i].setSize(nBin_);
283 moment_[i].setSize(nBin_);
325 if (obr_.foundObject<cmpTurbModel>(cmpTurbModel::propertiesName))
327 const cmpTurbModel&
turb =
328 obr_.lookupObject<cmpTurbModel>(cmpTurbModel::propertiesName);
330 return turb.devRhoReff();
332 else if (obr_.foundObject<icoTurbModel>(icoTurbModel::propertiesName))
335 obr_.lookupObject<icoTurbModel>(icoTurbModel::propertiesName);
339 else if (obr_.foundObject<
fluidThermo>(fluidThermo::typeName))
342 obr_.lookupObject<
fluidThermo>(fluidThermo::typeName);
360 else if (obr_.foundObject<
dictionary>(
"transportProperties"))
363 obr_.lookupObject<
dictionary>(
"transportProperties");
374 <<
"No valid model for viscous stress calculation"
399 return rho()*laminarT.
nu();
401 else if (obr_.foundObject<
dictionary>(
"transportProperties"))
404 obr_.lookupObject<
dictionary>(
"transportProperties");
413 <<
"No valid model for dynamic viscosity calculation"
423 if (rhoName_ ==
"rhoInf")
425 const fvMesh&
mesh = refCast<const fvMesh>(obr_);
457 if (rhoName_ !=
"rhoInf")
460 <<
"Dynamic pressure is expected but kinematic is provided."
480 force_[0][0] +=
sum(fN);
481 force_[1][0] +=
sum(fT);
482 force_[2][0] +=
sum(fP);
483 moment_[0][0] +=
sum(Md^fN);
484 moment_[1][0] +=
sum(Md^fT);
485 moment_[2][0] +=
sum(Md^fP);
493 label bini =
min(
max(floor(dd[i]/binDx_), 0), force_[0].size() - 1);
495 force_[0][bini] += fN[i];
496 force_[1][bini] += fT[i];
497 force_[2][bini] += fP[i];
498 moment_[0][bini] += Md[i]^fN[i];
499 moment_[1][bini] += Md[i]^fT[i];
500 moment_[2][bini] += Md[i]^fP[i];
568 label cellI = cellIDs[i];
569 force[cellI] += fN[i] + fT[i] + fP[i];
570 moment[cellI] += Md[i];
577 const string& descriptor,
587 vector total = pressure + viscous + porous;
591 Info<<
" Sum of " << descriptor.c_str() <<
nl
592 <<
" Total : " << total <<
nl
593 <<
" Pressure : " << pressure <<
nl
594 <<
" Viscous : " << viscous <<
nl;
598 Info<<
" Porous : " << porous <<
nl;
606 os << obr_.time().value()
623 if (log_)
Info <<
type() <<
" " << name_ <<
" output:" <<
nl;
625 writeIntegratedForceMoment
634 writeIntegratedForceMoment
645 writeIntegratedForceMoment
648 coordSys_.localVector(force_[0]),
649 coordSys_.localVector(force_[1]),
650 coordSys_.localVector(force_[2]),
654 writeIntegratedForceMoment
657 coordSys_.localVector(moment_[0]),
658 coordSys_.localVector(moment_[1]),
659 coordSys_.localVector(moment_[2]),
674 if ((nBin_ == 1) || !writeToFile())
685 f[0][i] +=
f[0][i-1];
686 f[1][i] +=
f[1][i-1];
687 f[2][i] +=
f[2][i-1];
697 vector total =
f[0][i] +
f[1][i] +
f[2][i];
705 os <<
tab <<
f[2][i];
715 writeBinnedForceMoment(force_, forceBinFilePtr_);
716 writeBinnedForceMoment(moment_, momentBinFilePtr_);
722 lf[0] = coordSys_.localVector(force_[0]);
723 lf[1] = coordSys_.localVector(force_[1]);
724 lf[2] = coordSys_.localVector(force_[2]);
725 lm[0] = coordSys_.localVector(moment_[0]);
726 lm[1] = coordSys_.localVector(moment_[1]);
727 lm[2] = coordSys_.localVector(moment_[2]);
729 writeBinnedForceMoment(lf, localForceBinFilePtr_);
730 writeBinnedForceMoment(lm, localMomentBinFilePtr_);
742 const bool loadFromFiles,
756 localForceFilePtr_(),
757 localMomentFilePtr_(),
758 localForceBinFilePtr_(),
759 localMomentBinFilePtr_(),
764 directForceDensity_(
false),
776 binCumulative_(
true),
781 if (setActive<fvMesh>())
815 localForceFilePtr_(),
816 localMomentFilePtr_(),
817 localForceBinFilePtr_(),
818 localMomentBinFilePtr_(),
823 directForceDensity_(
false),
835 binCumulative_(
true),
840 writeToFile_ =
false;
844 force_[i].setSize(nBin_);
845 moment_[i].setSize(nBin_);
867 initialised_ =
false;
871 if (log_)
Info <<
type() <<
" " << name_ <<
":" <<
nl;
875 const fvMesh&
mesh = refCast<const fvMesh>(obr_);
880 if (directForceDensity_)
912 if (log_)
Info <<
" Including porosity effects" <<
endl;
916 if (log_)
Info <<
" Not including porosity effects" <<
endl;
922 binDict.
lookup(
"nBin") >> nBin_;
927 <<
"Number of bins (nBin) must be zero or greater"
936 binDict.
lookup(
"cumulative") >> binCumulative_;
937 binDict.
lookup(
"direction") >> binDir_;
938 binDir_ /=
mag(binDir_);
947 force_[i].setSize(1);
948 moment_[i].setSize(1);
956 if (log_)
Info <<
" Fields will be written" <<
endl;
975 obr_.store(tforce.
ptr());
994 obr_.store(tmoment.
ptr());
1026 setResult(
"normalForce",
sum(force_[0]));
1027 setResult(
"tangentialForce",
sum(force_[1]));
1028 setResult(
"porousForce",
sum(force_[2]));
1030 setResult(
"normalMoment",
sum(moment_[0]));
1031 setResult(
"tangentialMoment",
sum(moment_[1]));
1032 setResult(
"porousMoment",
sum(moment_[2]));
1080 if (directForceDensity_)
1091 label patchI = iter.key();
1115 addToFields(patchI, Md, fN, fT, fP);
1132 = tdevRhoReff().boundaryField();
1139 label patchI = iter.key();
1148 rho(
p)*Sfb[patchI]*(
p.boundaryField()[patchI] -
pRef)
1151 vectorField fT(Sfb[patchI] & devRhoReffb[patchI]);
1155 addToFields(patchI, Md, fN, fT, fP);
1175 <<
"Porosity effects requested, but no porosity models found "
1176 <<
"in the database"
1191 label zoneI = cellZoneIDs[i];
1200 addToFields(cZone, Md, fDummy, fDummy, fP);
1202 applyBins(Md, fDummy, fDummy, fP, d);
1216 return sum(force_[0]) +
sum(force_[1]) +
sum(force_[2]);
1222 return sum(moment_[0]) +
sum(moment_[1]) +
sum(moment_[2]);
void createFiles()
Create the output files.
const dimensionSet dimPressure
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
void writeBinnedForceMoment(const List< Field< vector > > &fm, autoPtr< OFstream > &osPtr) const
Helper function to write binned forces and moments.
A class for handling words, derived from string.
const labelList & cellZoneIDs() const
Return const access to the cell zone IDs.
virtual ~forces()
Destructor.
virtual tmp< volScalarField > nu() const =0
Return the laminar viscosity.
Base class for function objects, adding functionality to read/write state information (data required ...
const dimensionedScalar mu
Atomic mass unit.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
#define forAll(list, i)
Loop across all elements in list.
A class for managing temporary objects.
const dimensionSet dimDensity
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
static const word dictName
bool read(const char *, int32_t &)
dimensionedScalar jn(const int n, const dimensionedScalar &ds)
void applyBins(const vectorField &Md, const vectorField &fN, const vectorField &fT, const vectorField &fP, const vectorField &d)
Accumulate bin data.
List< wordRe > wordReList
A List of wordRe (word or regular expression)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
void writeIntegratedHeader(const word &header, Ostream &os) const
Write header for integrated data.
word fieldName(const word &name) const
Create a field name.
Fundamental fluid thermodynamic properties.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
const cellZoneMesh & cellZones() const
Return cell zone mesh.
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
void read(const dictionary &dict)
Read.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void write()
Write the forces.
virtual vector forceEff() const
Return the total force.
dimensioned< scalar > mag(const dimensioned< Type > &)
const dimensionSet dimForce
This function object reads fields from the time directories and adds them to the mesh database for fu...
virtual void end()
Execute at the final time-loop, currently does nothing.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Registry of regIOobjects.
void resetFields()
Reset the fields prior to accumulation of force/moments.
void writeBins()
Write binned data.
void initialiseBins()
Initialise the collection bins.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu)
Return the force over the cell zone(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.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Pre-declare SubField and related Field type.
virtual void execute()
Execute, currently does nothing.
void writeForces()
Write force data.
bool empty() const
Return true if the hash table is empty.
A patch is a list of labels that address the faces in the global face list.
virtual const word & name() const
Return name of the set of forces.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Generic dimensioned Type class.
const surfaceVectorField & Sf() const
Return cell face area vectors.
Mesh data needed to do the Finite Volume discretisation.
virtual void calcForcesMoment()
Calculate the forces and moments.
T * ptr() const
Return tmp pointer for reuse.
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
void writeIntegratedForceMoment(const string &descriptor, const vectorField &fm0, const vectorField &fm1, const vectorField &fm2, autoPtr< OFstream > &osPtr) const
Helper function to write integrated forces and moments.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Base-class for all transport models used by the incompressible turbulence models.
static bool master(const label communicator=0)
Am I the master process.
An STL-conforming hash table.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
void addToFields(const label patchI, const vectorField &Md, const vectorField &fN, const vectorField &fT, const vectorField &fP)
Add patch contributions to force and moment fields.
Top level model for porosity models.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const volVectorField & C() const
Return cell centres as volVectorField.
tmp< volScalarField > mu() const
Dynamic viscosity field.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
const vectorField::subField faceCentres() const
Return face centres.
virtual vector momentEff() const
Return the total moment.
const word name_
Name of model.
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Calculate the gradient of the given field.
Base class for output file data handling.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
static const word null
An empty word.
virtual void read(const dictionary &)
Read the forces data.
const Time & time() const
Return the top-level database.
void writeBinHeader(const word &header, Ostream &os) const
Write header for binned data.
Templated abstract base class for single-phase incompressible turbulence models.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
void initialise()
Initialise the fields.
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.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Generic GeometricField class.
compressible::turbulenceModel & turb
tmp< volSymmTensorField > devRhoReff() const
Return the effective viscous stress (laminar + turbulent).
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
#define WarningInFunction
Report a warning using Foam::Warning.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
tmp< volScalarField > rho() const
Return rho if rhoName is specified otherwise rhoRef.
word name(const complex &)
Return a string representation of a complex.
forces(const forces &)
Disallow default bitwise copy construct.
Base class for other coordinate system specifications.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)