ENH: forces FO updated following update to use functionObjectState

Properties stored in state dictionary:
- normalForce
- tangentialForce
- porousForce
- normalMoment
- tangentialMoment
- porousMoment
This commit is contained in:
Andrew Heather 2015-10-07 13:02:44 +01:00
parent 137668ba81
commit bc00be2c9a
2 changed files with 16 additions and 27 deletions

View File

@ -743,10 +743,9 @@ Foam::forces::forces
const bool readFields
)
:
functionObjectState(obr, name),
functionObjectFile(obr, name),
name_(name),
obr_(obr),
active_(true),
log_(true),
force_(3),
moment_(3),
@ -779,29 +778,14 @@ Foam::forces::forces
initialised_(false)
{
// Check if the available mesh is an fvMesh otherise deactivate
if (isA<fvMesh>(obr_))
if (setActive<fvMesh>())
{
if (readFields)
{
read(dict);
Info<< endl;
if (log_) Info << endl;
}
}
else
{
active_ = false;
WarningIn
(
"Foam::forces::forces"
"("
"const word&, "
"const objectRegistry&, "
"const dictionary&, "
"const bool"
")"
) << "No fvMesh available, deactivating " << name_
<< endl;
}
}
@ -818,9 +802,9 @@ Foam::forces::forces
const coordinateSystem& coordSys
)
:
functionObjectState(obr, name),
functionObjectFile(obr, name),
obr_(obr),
active_(true),
log_(true),
force_(3),
moment_(3),
@ -1040,6 +1024,14 @@ void Foam::forces::execute()
if (log_) Info << endl;
}
// write state/results information
setResult("normalForce", sum(force_[0]));
setResult("tangentialForce", sum(force_[1]));
setResult("porousForce", sum(force_[2]));
setResult("normalMoment", sum(moment_[0]));
setResult("tangentialMoment", sum(moment_[1]));
setResult("porousMoment", sum(moment_[2]));
}

View File

@ -117,6 +117,7 @@ Note
SeeAlso
Foam::functionObject
Foam::functionObjectFile
Foam::functionObjectState
Foam::OutputFilterFunctionObject
Foam::forceCoeffs
@ -129,6 +130,7 @@ SourceFiles
#ifndef forces_H
#define forces_H
#include "functionObjectState.H"
#include "functionObjectFile.H"
#include "coordinateSystem.H"
#include "coordinateSystems.H"
@ -156,21 +158,16 @@ class mapPolyMesh;
class forces
:
public functionObjectState,
public functionObjectFile
{
protected:
// Protected data
//- Name of this set of forces,
// Also used as the name of the probes directory.
word name_;
//- Reference to the database
const objectRegistry& obr_;
//- On/off switch
bool active_;
//- Switch to send output to Info as well as to file
Switch log_;