functionObjects::fieldAverage,turbulenceFields: derive from fvMeshFunctionObject
This commit is contained in:
parent
6ce303c79a
commit
e72a50cf47
@ -69,8 +69,6 @@ void Foam::functionObjects::fieldAverage::initialize()
|
||||
{
|
||||
resetFields();
|
||||
|
||||
Info<< type() << " " << name() << ":" << nl;
|
||||
|
||||
// Add mean fields to the field lists
|
||||
forAll(faItems_, fieldi)
|
||||
{
|
||||
@ -91,15 +89,14 @@ void Foam::functionObjects::fieldAverage::initialize()
|
||||
// ensure first averaging works unconditionally
|
||||
prevTimeIndex_ = -1;
|
||||
|
||||
Info<< endl;
|
||||
|
||||
initialised_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldAverage::restart()
|
||||
{
|
||||
Info<< " Restarting averaging at time " << obr_.time().timeName()
|
||||
if (log_) Info
|
||||
<< " Restarting averaging at time " << obr_.time().timeName()
|
||||
<< nl << endl;
|
||||
|
||||
totalIter_.clear();
|
||||
@ -137,9 +134,9 @@ void Foam::functionObjects::fieldAverage::calcAverages()
|
||||
periodIndex_++;
|
||||
}
|
||||
|
||||
Info<< type() << " " << name() << " output:" << nl;
|
||||
|
||||
Info<< " Calculating averages" << nl;
|
||||
if (log_) Info
|
||||
<< type() << " " << name() << " output:" << nl
|
||||
<< " Calculating averages" << nl;
|
||||
|
||||
addMeanSqrToPrime2Mean<scalar, scalar>();
|
||||
addMeanSqrToPrime2Mean<vector, symmTensor>();
|
||||
@ -158,18 +155,22 @@ void Foam::functionObjects::fieldAverage::calcAverages()
|
||||
totalIter_[fieldi]++;
|
||||
totalTime_[fieldi] += obr_.time().deltaTValue();
|
||||
}
|
||||
|
||||
if (log_) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::fieldAverage::writeAverages() const
|
||||
{
|
||||
Info<< " Writing average fields" << endl;
|
||||
if (log_) Info<< " Writing average fields" << endl;
|
||||
|
||||
writeFields<scalar>();
|
||||
writeFields<vector>();
|
||||
writeFields<sphericalTensor>();
|
||||
writeFields<symmTensor>();
|
||||
writeFields<tensor>();
|
||||
|
||||
if (log_) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -198,6 +199,8 @@ void Foam::functionObjects::fieldAverage::writeAveragingProperties() const
|
||||
}
|
||||
|
||||
propsDict.regIOobject::write();
|
||||
|
||||
if (log_) Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -209,7 +212,7 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
|
||||
totalTime_.clear();
|
||||
totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
|
||||
|
||||
if (restartOnRestart_ || restartOnOutput_)
|
||||
if ((restartOnRestart_ || restartOnOutput_) && log_)
|
||||
{
|
||||
Info<< " Starting averaging at time " << obr_.time().timeName()
|
||||
<< nl;
|
||||
@ -229,14 +232,17 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
|
||||
|
||||
if (!propsDictHeader.headerOk())
|
||||
{
|
||||
Info<< " Starting averaging at time " << obr_.time().timeName()
|
||||
<< nl;
|
||||
if (log_) Info
|
||||
<< " Starting averaging at time "
|
||||
<< obr_.time().timeName() << nl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
IOdictionary propsDict(propsDictHeader);
|
||||
|
||||
Info<< " Restarting averaging for fields:" << nl;
|
||||
if (log_) Info<< " Restarting averaging for fields:" << nl;
|
||||
|
||||
forAll(faItems_, fieldi)
|
||||
{
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
@ -246,7 +252,9 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
|
||||
|
||||
totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter"));
|
||||
totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime"));
|
||||
Info<< " " << fieldName
|
||||
|
||||
if (log_) Info
|
||||
<< " " << fieldName
|
||||
<< " iters = " << totalIter_[fieldi]
|
||||
<< " time = " << totalTime_[fieldi] << nl;
|
||||
}
|
||||
@ -260,18 +268,11 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
|
||||
Foam::functionObjects::fieldAverage::fieldAverage
|
||||
(
|
||||
const word& name,
|
||||
const Time& t,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
t.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
),
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
prevTimeIndex_(-1),
|
||||
restartOnRestart_(false),
|
||||
restartOnOutput_(false),
|
||||
@ -283,12 +284,6 @@ Foam::functionObjects::fieldAverage::fieldAverage
|
||||
totalTime_(),
|
||||
periodIndex_(1)
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -303,9 +298,11 @@ Foam::functionObjects::fieldAverage::~fieldAverage()
|
||||
|
||||
bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
initialised_ = false;
|
||||
|
||||
Info<< type() << " " << name() << ":" << nl;
|
||||
if (log_) Info<< type() << " " << name() << ":" << nl;
|
||||
|
||||
dict.readIfPresent("restartOnRestart", restartOnRestart_);
|
||||
dict.readIfPresent("restartOnOutput", restartOnOutput_);
|
||||
@ -319,7 +316,7 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
|
||||
readAveragingProperties();
|
||||
|
||||
Info<< endl;
|
||||
if (log_) Info<< endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -328,7 +325,6 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
bool Foam::functionObjects::fieldAverage::execute(const bool postProcess)
|
||||
{
|
||||
calcAverages();
|
||||
Info<< endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -344,8 +340,6 @@ bool Foam::functionObjects::fieldAverage::write(const bool postProcess)
|
||||
restart();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,7 @@ Note
|
||||
To employ the \c prime2Mean option, the \c mean option must be selecetd.
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObject
|
||||
|
||||
SourceFiles
|
||||
@ -121,17 +122,12 @@ SourceFiles
|
||||
#ifndef functionObjects_fieldAverage_H
|
||||
#define functionObjects_fieldAverage_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "Switch.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
@ -144,15 +140,12 @@ class fieldAverageItem;
|
||||
|
||||
class fieldAverage
|
||||
:
|
||||
public functionObject
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Time at last call, prevents repeated averaging
|
||||
label prevTimeIndex_;
|
||||
|
||||
@ -288,7 +281,7 @@ public:
|
||||
fieldAverage
|
||||
(
|
||||
const word& name,
|
||||
const Time& t,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
@ -36,7 +36,7 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi)
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
const word& meanFieldName = faItems_[fieldi].meanFieldName();
|
||||
|
||||
Info<< " Reading/initialising field " << meanFieldName << endl;
|
||||
if (log_) Info<< " Reading/initialising field " << meanFieldName << endl;
|
||||
|
||||
if (obr_.foundObject<Type>(meanFieldName))
|
||||
{
|
||||
@ -44,7 +44,8 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi)
|
||||
}
|
||||
else if (obr_.found(meanFieldName))
|
||||
{
|
||||
Info<< " Cannot allocate average field " << meanFieldName
|
||||
if (log_) Info
|
||||
<< " Cannot allocate average field " << meanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging for field." << endl;
|
||||
|
||||
@ -111,7 +112,8 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
|
||||
const word& meanFieldName = faItems_[fieldi].meanFieldName();
|
||||
const word& prime2MeanFieldName = faItems_[fieldi].prime2MeanFieldName();
|
||||
|
||||
Info<< " Reading/initialising field " << prime2MeanFieldName << nl;
|
||||
if (log_) Info
|
||||
<< " Reading/initialising field " << prime2MeanFieldName << nl;
|
||||
|
||||
if (obr_.foundObject<Type2>(prime2MeanFieldName))
|
||||
{
|
||||
@ -119,7 +121,8 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
|
||||
}
|
||||
else if (obr_.found(prime2MeanFieldName))
|
||||
{
|
||||
Info<< " Cannot allocate average field " << prime2MeanFieldName
|
||||
if (log_) Info
|
||||
<< " Cannot allocate average field " << prime2MeanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging for field." << nl;
|
||||
|
||||
|
@ -76,7 +76,7 @@ Description
|
||||
\endplaintable
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
@ -87,7 +87,7 @@ SourceFiles
|
||||
#ifndef functionObjects_turbulenceFields_H
|
||||
#define functionObjects_turbulenceFields_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "HashSet.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "volFieldsFwd.H"
|
||||
@ -96,10 +96,6 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
@ -109,7 +105,7 @@ namespace functionObjects
|
||||
|
||||
class turbulenceFields
|
||||
:
|
||||
public functionObject
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
public:
|
||||
|
||||
@ -144,9 +140,6 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Fields to load
|
||||
wordHashSet fieldSet_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user