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