forces Class Reference

Calculates the forces and moments by integrating the pressure and skin-friction forces over a given list of patches. More...

Inheritance diagram for forces:
Collaboration diagram for forces:

Public Member Functions

 TypeName ("forces")
 Runtime type information. More...
 
 forces (const word &name, const Time &runTime, const dictionary &dict)
 Construct from Time and dictionary. More...
 
 forces (const word &name, const objectRegistry &obr, const dictionary &)
 Construct from objectRegistry and dictionary. More...
 
 forces (const forces &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~forces ()
 Destructor. More...
 
virtual bool read (const dictionary &)
 Read the forces data. More...
 
virtual wordList fields () const
 Return the list of fields required. More...
 
virtual void calcForcesMoment ()
 Calculate the forces and moments. More...
 
virtual vector forceEff () const
 Return the total force. More...
 
virtual vector momentEff () const
 Return the total moment. More...
 
virtual bool execute ()
 Execute, currently does nothing. More...
 
virtual bool write ()
 Write the forces. More...
 
void operator= (const forces &)=delete
 Disallow default bitwise assignment. More...
 
- Public Member Functions inherited from fvMeshFunctionObject
 TypeName ("fvMeshFunctionObject")
 Runtime type information. More...
 
 fvMeshFunctionObject (const word &name, const Time &runTime, const dictionary &dict)
 Construct from Time and dictionary. More...
 
 fvMeshFunctionObject (const word &name, const objectRegistry &obr, const dictionary &dict)
 Construct from the region objectRegistry and dictionary. More...
 
 fvMeshFunctionObject (const fvMeshFunctionObject &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~fvMeshFunctionObject ()
 Destructor. More...
 
void operator= (const fvMeshFunctionObject &)=delete
 Disallow default bitwise assignment. More...
 
- Public Member Functions inherited from regionFunctionObject
 TypeName ("regionFunctionObject")
 Runtime type information. More...
 
 regionFunctionObject (const word &name, const Time &runTime, const dictionary &dict)
 Construct from Time and dictionary. More...
 
 regionFunctionObject (const word &name, const objectRegistry &obr, const dictionary &dict)
 Construct from the region objectRegistry and dictionary. More...
 
 regionFunctionObject (const regionFunctionObject &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~regionFunctionObject ()
 Destructor. More...
 
void operator= (const regionFunctionObject &)=delete
 Disallow default bitwise assignment. More...
 
- Public Member Functions inherited from functionObject
 ClassName ("functionObject")
 
virtual const wordtype () const =0
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, functionObject, dictionary,(const word &name, const Time &runTime, const dictionary &dict),(name, runTime, dict))
 
 functionObject (const word &name, const Time &runTime)
 Construct from components. More...
 
autoPtr< functionObjectclone () const
 Return clone. More...
 
 functionObject (const functionObject &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~functionObject ()
 Destructor. More...
 
const wordname () const
 Return the name of this functionObject. More...
 
virtual bool executeAtStart () const
 Return true if the functionObject should be executed at the start. More...
 
virtual bool end ()
 Called when Time::run() determines that the time-loop exits. More...
 
virtual scalar timeToNextAction ()
 Called by Time::adjustTimeStep(). Allows the functionObject to. More...
 
virtual void movePoints (const polyMesh &mesh)
 Update topology using the given map. More...
 
virtual void topoChange (const polyTopoChangeMap &map)
 Update topology using the given map. More...
 
virtual void mapMesh (const polyMeshMap &)
 Update from another mesh using the given map. More...
 
virtual void distribute (const polyDistributionMap &)
 Redistribute or update using the given distribution map. More...
 
void operator= (const functionObject &)=delete
 Disallow default bitwise assignment. More...
 
- Public Member Functions inherited from logFiles
 logFiles (const objectRegistry &obr, const word &prefix)
 Construct from objectRegistry and prefix. More...
 
 logFiles (const logFiles &)=delete
 Disallow default bitwise copy construction. More...
 
virtual ~logFiles ()
 Destructor. More...
 
const wordListnames () const
 Return const access to the names. More...
 
PtrList< OFstream > & files ()
 Return access to the files. More...
 
OFstreamfile ()
 Return access to the file (if only 1) More...
 
OFstreamfile (const label i)
 Return file 'i'. More...
 
void operator= (const logFiles &)=delete
 Disallow default bitwise assignment. More...
 
- Public Member Functions inherited from writeFile
 writeFile (const objectRegistry &obr, const word &prefix)
 Construct from objectRegistry and prefix. More...
 
 writeFile (const writeFile &)=delete
 Disallow default bitwise copy construction. More...
 
 ~writeFile ()
 Destructor. More...
 
void initStream (Ostream &os) const
 Initialise the output stream for writing. More...
 
fileName baseFileDir () const
 Return the base directory for output. More...
 
fileName baseTimeDir () const
 Return the base directory for the current time value. More...
 
Omanip< int > valueWidth (const label offset=0) const
 Return the value width when writing to stream with optional offset. More...
 
void writeCommented (Ostream &os, const string &str) const
 Write a commented string to stream. More...
 
void writeTabbed (Ostream &os, const string &str) const
 Write a tabbed string to stream. More...
 
void writeHeader (Ostream &os, const string &str) const
 Write a commented header to stream. More...
 
void writeTime (Ostream &os) const
 Write the current time to stream. More...
 
template<class Type >
void writeHeaderValue (Ostream &os, const string &property, const Type &value) const
 Write a (commented) header property and value pair. More...
 
label charWidth () const
 Return width of character stream output. More...
 
void operator= (const writeFile &)=delete
 Disallow default bitwise assignment. More...
 

Protected Types

enum class  fileID { mainFile = 0 , binsFile = 1 }
 Enumeration for ensuring the right file is accessed. More...
 

Protected Member Functions

Ostreamfile (const fileID fid)
 
wordList createFileNames (const dictionary &dict) const
 Create file names for forces and bins. More...
 
virtual void writeFileHeader (const label i)
 Output file header information. More...
 
void initialise ()
 Initialise the fields. More...
 
tmp< volSymmTensorFielddevTau () const
 Return the effective viscous stress (laminar + turbulent). More...
 
tmp< volScalarFieldmu () const
 Dynamic viscosity field. More...
 
tmp< volScalarFieldrho () const
 Return rho if specified otherwise rhoRef. More...
 
scalar rho (const volScalarField &p) const
 Return rhoRef if the pressure field is dynamic, i.e. p/rho. More...
 
tmp< volScalarFieldalpha () const
 Get the volume fraction field. More...
 
tmp< scalarFieldalpha (const label patchi) const
 Get the volume fraction field on a patch. More...
 
void applyBins (const vectorField &Md, const vectorField &fN, const vectorField &fT, const vectorField &fP, const vectorField &d)
 Accumulate bin data. More...
 
void writeForces ()
 Helper function to write force data. More...
 
void writeBins ()
 Helper function to write bin data. More...
 
OFstreamfile ()
 Return access to the file (if only 1) More...
 
OFstreamfile (const label i)
 Return file 'i'. More...
 
- Protected Member Functions inherited from regionFunctionObject
template<class ObjectType >
bool foundObject (const word &fieldName) const
 Find field in the objectRegistry. More...
 
template<class ObjectType >
void cannotFindObject (const word &fieldName)
 Prints a warning message that fieldName cannot be found. More...
 
void cannotFindObject (const word &fieldName)
 Prints a warning message that fieldName cannot be found. More...
 
template<class ObjectType >
const ObjectType & lookupObject (const word &fieldName) const
 Lookup object from the objectRegistry. More...
 
template<class ObjectType >
ObjectType & lookupObjectRef (const word &fieldName)
 Lookup non-const object reference from the objectRegistry. More...
 
template<class ObjectType >
bool store (const tmp< ObjectType > &tfield)
 Store the given field in the objectRegistry. More...
 
template<class ObjectType >
bool store (const word &fieldName, const tmp< ObjectType > &tfield, bool cacheable=false)
 Store the given field in the objectRegistry under the given name. More...
 
bool writeObject (const word &fieldName)
 Write field if present in objectRegistry. More...
 
bool clearObject (const word &fieldName)
 Clear field from the objectRegistry if present. More...
 
- Protected Member Functions inherited from logFiles
virtual void createFiles ()
 Create the output file. More...
 
virtual void resetNames (const wordList &names)
 Reset the list of names from a wordList. More...
 
virtual void resetName (const word &name)
 Reset the list of names to a single name entry. More...
 

Protected Attributes

List< Field< vector > > force_
 Pressure, viscous and porous force per bin. More...
 
List< Field< vector > > moment_
 Pressure, viscous and porous moment per bin. More...
 
labelHashSet patchSet_
 Patches to integrate forces over. More...
 
word pName_
 Name of pressure field. More...
 
word UName_
 Name of velocity field. More...
 
word rhoName_
 Name of density field (optional) More...
 
word phaseName_
 The name of the phase (optional) More...
 
Switch directForceDensity_
 Is the force density being supplied directly? More...
 
word fDName_
 The name of the force density (fD) field. More...
 
scalar rhoRef_
 Reference density needed for incompressible calculations. More...
 
scalar pRef_
 Reference pressure. More...
 
coordinateSystem coordSys_
 Coordinate system used when evaluating forces/moments. More...
 
bool localSystem_
 Flag to indicate whether we are using a local co-ordinate sys. More...
 
bool porosity_
 Flag to include porosity effects. More...
 
label nBin_
 Number of bins. More...
 
vector binDir_
 Direction used to determine bin orientation. More...
 
scalar binDx_
 Distance between bin divisions. More...
 
scalar binMin_
 Minimum bin bounds. More...
 
List< pointbinPoints_
 Bin positions along binDir. More...
 
bool binCumulative_
 Should bin data be cumulative? More...
 
bool initialised_
 Initialised flag. More...
 
- Protected Attributes inherited from fvMeshFunctionObject
const fvMeshmesh_
 Reference to the fvMesh. More...
 
- Protected Attributes inherited from regionFunctionObject
const objectRegistryobr_
 Reference to the region objectRegistry. More...
 
- Protected Attributes inherited from functionObject
const Timetime_
 Reference to time. More...
 
- Protected Attributes inherited from logFiles
wordList names_
 File names. More...
 
PtrList< OFstreamfilePtrs_
 File pointer. More...
 
- Protected Attributes inherited from writeFile
const objectRegistryfileObr_
 Reference to the region objectRegistry. More...
 
const word prefix_
 Prefix. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from functionObject
static autoPtr< functionObjectNew (const word &name, const Time &, const dictionary &)
 Select from dictionary, based on its "type" entry. More...
 
- Public Attributes inherited from functionObject
Switch log
 Switch write log to Info. More...
 
Switch executeAtStart_
 Switch write log to Info. More...
 
- Static Public Attributes inherited from functionObject
static bool postProcess
 Global post-processing mode switch. More...
 
- Static Public Attributes inherited from writeFile
static const word outputPrefix
 Directory prefix. More...
 
static label addChars = 8
 Additional characters for writing. More...
 

Detailed Description

Calculates the forces and moments by integrating the pressure and skin-friction forces over a given list of patches.

Member function forces::write() calculates the forces/moments and writes the forces/moments into the file <timeDir>/forces.dat and bin data (if selected) to the file <timeDir>/forces_bin.dat

Example of function object specification:

forces1
{
    type        forces;
    libs        ("libforces.so");
    ...
    log         yes;
    patches     (walls);

    binData
    {
        nBin        20;
        direction   (1 0 0);
        cumulative  yes;
    }
}
Usage
Property Description Required Default value
type Type name: forces yes
log Write force data to standard output no no
patches Patches included in the forces calculation yes
p Pressure field name no p
U Velocity field name no U
rho Density field name (see below) no rho
phase Phase name for phase-fraction no
CofR Centre of rotation (see below) no
directForceDensity Force density supplied directly (see below) no no
fD Name of force density field (see below) no fD

Bin data is optional, but if the dictionary is present, the entries must be defined according o

nBin number of data bins yes
direction direction along which bins are defined yes
cumulative bin data accumulated with increasing distance yes

Note

  • For incompressible cases, set rho to rhoInf and provide a rhoInf value corresponding to the free-stream constant density.
  • If the phase name is specified the corresponding phase-fraction field alpha.<phase> is used to filter the surface force field before integration.
  • If the force density is supplied directly, set the directForceDensity flag to 'yes', and supply the force density field using the fDName entry
  • The centre of rotation (CofR) for moment calculations can either be specified by an CofR entry, or be taken from origin of the local coordinate system. For example,
              CofR        (0 0 0);
    or
              origin (0 0 0);
              coordinateRotation
              {
                  type axesRotation;
                  e1 (1 0 0);
                  e3 (0 0 1);
              }
See also
Foam::functionObject Foam::functionObjects::fvMeshFunctionObject Foam::functionObjects::logFiles Foam::functionObjects::timeControl Foam::forceCoeffs
Source files

Definition at line 204 of file forces.H.

Member Enumeration Documentation

◆ fileID

enum fileID
strongprotected

Enumeration for ensuring the right file is accessed.

Enumerator
mainFile 
binsFile 

Definition at line 215 of file forces.H.

Constructor & Destructor Documentation

◆ forces() [1/3]

forces ( const word name,
const Time runTime,
const dictionary dict 
)

Construct from Time and dictionary.

Definition at line 649 of file forces.C.

References dict, and forces::read().

Here is the call graph for this function:

◆ forces() [2/3]

forces ( const word name,
const objectRegistry obr,
const dictionary dict 
)

Construct from objectRegistry and dictionary.

Definition at line 684 of file forces.C.

References dict, and forces::read().

Here is the call graph for this function:

◆ forces() [3/3]

forces ( const forces )
delete

Disallow default bitwise copy construction.

◆ ~forces()

~forces ( )
virtual

Destructor.

Definition at line 721 of file forces.C.

Member Function Documentation

◆ file() [1/3]

Ostream& file ( const fileID  fid)
inlineprotected

Definition at line 296 of file forces.H.

References logFiles::file().

Here is the call graph for this function:

◆ createFileNames()

Foam::wordList createFileNames ( const dictionary dict) const
protected

Create file names for forces and bins.

Definition at line 51 of file forces.C.

References List< T >::append(), dict, dictionary::lookup(), and logFiles::names().

Here is the call graph for this function:

◆ writeFileHeader()

void writeFileHeader ( const label  i)
protectedvirtual

Output file header information.

Implements logFiles.

Reimplemented in forceCoeffs.

Definition at line 78 of file forces.C.

References Foam::abort(), Foam::endl(), f(), Foam::FatalError, FatalErrorInFunction, Foam::file, forAll, Foam::jn(), Foam::name(), Foam::nl, Foam::tab, and Foam::vtkWriteOps::writeHeader().

Here is the call graph for this function:

◆ initialise()

void initialise ( )
protected

Initialise the fields.

Definition at line 180 of file forces.C.

References Foam::exit(), Foam::FatalError, and FatalErrorInFunction.

Here is the call graph for this function:

◆ devTau()

◆ mu()

Foam::tmp< Foam::volScalarField > mu ( ) const
protected

◆ rho() [1/2]

Foam::tmp< Foam::volScalarField > rho ( ) const
protected

Return rho if specified otherwise rhoRef.

Definition at line 365 of file forces.C.

References Foam::dimDensity, and GeometricField< Type, PatchField, GeoMesh >::New().

Here is the call graph for this function:

◆ rho() [2/2]

Foam::scalar rho ( const volScalarField p) const
protected

Return rhoRef if the pressure field is dynamic, i.e. p/rho.

otherwise return 1

Definition at line 383 of file forces.C.

References Foam::dimPressure, Foam::exit(), Foam::FatalError, FatalErrorInFunction, and p.

Here is the call graph for this function:

◆ alpha() [1/2]

Foam::tmp< Foam::volScalarField > alpha ( ) const
protected

Get the volume fraction field.

Definition at line 403 of file forces.C.

References Foam::dimless, IOobject::groupName(), GeometricField< Type, PatchField, GeoMesh >::New(), and word::null.

Here is the call graph for this function:

◆ alpha() [2/2]

Foam::tmp< Foam::scalarField > alpha ( const label  patchi) const
protected

Get the volume fraction field on a patch.

Definition at line 424 of file forces.C.

References IOobject::groupName(), word::null, and patchi.

Here is the call graph for this function:

◆ applyBins()

void applyBins ( const vectorField Md,
const vectorField fN,
const vectorField fT,
const vectorField fP,
const vectorField d 
)
protected

Accumulate bin data.

Definition at line 446 of file forces.C.

References forAll, Foam::max(), Foam::min(), and Foam::sum().

Here is the call graph for this function:

◆ writeForces()

void writeForces ( )
protected

Helper function to write force data.

Definition at line 483 of file forces.C.

References Foam::endl(), Foam::file, Log, Foam::name(), Foam::nl, Foam::setw(), Foam::sum(), Foam::tab, and Foam::type().

Here is the call graph for this function:

◆ writeBins()

void writeBins ( )
protected

Helper function to write bin data.

Definition at line 543 of file forces.C.

References Foam::endl(), f(), Foam::file, forAll, Foam::setw(), List< T >::size(), and Foam::tab.

Here is the call graph for this function:

◆ TypeName()

TypeName ( "forces"  )

Runtime type information.

◆ read()

bool read ( const dictionary dict)
virtual

Read the forces data.

Reimplemented from regionFunctionObject.

Reimplemented in forceCoeffs.

Definition at line 727 of file forces.C.

References dict, Foam::endl(), Foam::exit(), polyPatch::faceCentres(), Foam::FatalIOError, FatalIOErrorInFunction, forAll, forAllConstIter, IOobject::groupName(), Log, dictionary::lookup(), Foam::mag(), Foam::max(), Foam::min(), Foam::name(), Foam::nl, word::null, patchi, polyBoundaryMesh::patchSet(), regionFunctionObject::read(), Foam::reduce(), and Foam::type().

Referenced by forces::forces(), and forceCoeffs::read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fields()

virtual wordList fields ( ) const
inlinevirtual

Return the list of fields required.

Implements functionObject.

Definition at line 384 of file forces.H.

References List< word >::null().

Here is the call graph for this function:

◆ calcForcesMoment()

void calcForcesMoment ( )
virtual

◆ forceEff()

Foam::vector forceEff ( ) const
virtual

Return the total force.

Definition at line 1019 of file forces.C.

References Foam::sum().

Here is the call graph for this function:

◆ momentEff()

Foam::vector momentEff ( ) const
virtual

Return the total moment.

Definition at line 1025 of file forces.C.

References Foam::sum().

Here is the call graph for this function:

◆ execute()

bool execute ( )
virtual

Execute, currently does nothing.

Implements functionObject.

Reimplemented in forceCoeffs.

Definition at line 1031 of file forces.C.

◆ write()

bool write ( )
virtual

Write the forces.

Reimplemented from logFiles.

Reimplemented in forceCoeffs.

Definition at line 1037 of file forces.C.

References Foam::endl(), Log, UPstream::master(), and logFiles::write().

Here is the call graph for this function:

◆ operator=()

void operator= ( const forces )
delete

Disallow default bitwise assignment.

◆ file() [2/3]

Foam::OFstream & file
protected

Return access to the file (if only 1)

Definition at line 116 of file logFiles.C.

References WarningInFunction.

Referenced by forceCoeffs::writeFileHeader().

Here is the caller graph for this function:

◆ file() [3/3]

Foam::OFstream & file
protected

Return file 'i'.

Definition at line 119 of file logFiles.C.

Member Data Documentation

◆ force_

List<Field<vector> > force_
protected

Pressure, viscous and porous force per bin.

Definition at line 222 of file forces.H.

◆ moment_

List<Field<vector> > moment_
protected

Pressure, viscous and porous moment per bin.

Definition at line 225 of file forces.H.

◆ patchSet_

labelHashSet patchSet_
protected

Patches to integrate forces over.

Definition at line 231 of file forces.H.

◆ pName_

word pName_
protected

Name of pressure field.

Definition at line 234 of file forces.H.

◆ UName_

word UName_
protected

Name of velocity field.

Definition at line 237 of file forces.H.

◆ rhoName_

word rhoName_
protected

Name of density field (optional)

Definition at line 240 of file forces.H.

◆ phaseName_

word phaseName_
protected

The name of the phase (optional)

Definition at line 243 of file forces.H.

◆ directForceDensity_

Switch directForceDensity_
protected

Is the force density being supplied directly?

Definition at line 246 of file forces.H.

◆ fDName_

word fDName_
protected

The name of the force density (fD) field.

Definition at line 249 of file forces.H.

◆ rhoRef_

scalar rhoRef_
protected

Reference density needed for incompressible calculations.

Definition at line 252 of file forces.H.

◆ pRef_

scalar pRef_
protected

Reference pressure.

Definition at line 255 of file forces.H.

◆ coordSys_

coordinateSystem coordSys_
protected

Coordinate system used when evaluating forces/moments.

Definition at line 258 of file forces.H.

Referenced by forceCoeffs::writeFileHeader().

◆ localSystem_

bool localSystem_
protected

Flag to indicate whether we are using a local co-ordinate sys.

Definition at line 261 of file forces.H.

◆ porosity_

bool porosity_
protected

Flag to include porosity effects.

Definition at line 264 of file forces.H.

◆ nBin_

label nBin_
protected

Number of bins.

Definition at line 270 of file forces.H.

Referenced by forceCoeffs::writeFileHeader().

◆ binDir_

vector binDir_
protected

Direction used to determine bin orientation.

Definition at line 273 of file forces.H.

Referenced by forceCoeffs::writeFileHeader().

◆ binDx_

scalar binDx_
protected

Distance between bin divisions.

Definition at line 276 of file forces.H.

Referenced by forceCoeffs::writeFileHeader().

◆ binMin_

scalar binMin_
protected

Minimum bin bounds.

Definition at line 279 of file forces.H.

Referenced by forceCoeffs::writeFileHeader().

◆ binPoints_

List<point> binPoints_
protected

Bin positions along binDir.

Definition at line 282 of file forces.H.

◆ binCumulative_

bool binCumulative_
protected

Should bin data be cumulative?

Definition at line 285 of file forces.H.

◆ initialised_

bool initialised_
protected

Initialised flag.

Definition at line 289 of file forces.H.


The documentation for this class was generated from the following files: