OutputFilterFunctionObject: Simplify construction

This commit is contained in:
Henry Weller
2016-05-11 14:40:55 +01:00
parent 8152652476
commit acdfa68116
2 changed files with 34 additions and 43 deletions

View File

@ -51,38 +51,6 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::active() const
} }
template<class OutputFilter>
bool Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
{
if (dictName_.size())
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new OutputFilter
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
return ptr_.valid();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class OutputFilter> template<class OutputFilter>
@ -108,7 +76,33 @@ Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject
evaluateControl_(t, dict, "evaluate") evaluateControl_(t, dict, "evaluate")
{ {
readDict(); readDict();
if (!allocateFilter())
if (dictName_.size())
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name,
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new OutputFilter
(
name,
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
if (!ptr_.valid())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Cannot construct " << OutputFilter::typeName << "Cannot construct " << OutputFilter::typeName
@ -192,9 +186,9 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::adjustTimeStep()
scalar nSteps = timeToNextWrite/deltaT - SMALL; scalar nSteps = timeToNextWrite/deltaT - SMALL;
// function objects modify deltaT inside nStepsToStartTimeChange range // functionObjects modify deltaT within nStepsToStartTimeChange
// NOTE: Potential problem if two function objects dump inside the same // NOTE: Potential problems arise if two function objects dump within
// interval // the same interval
if (nSteps < nStepsToStartTimeChange_) if (nSteps < nStepsToStartTimeChange_)
{ {
label nStepsToNextWrite = label(nSteps) + 1; label nStepsToNextWrite = label(nSteps) + 1;

View File

@ -103,10 +103,7 @@ class OutputFilterFunctionObject
//- Read relevant dictionary entries //- Read relevant dictionary entries
void readDict(); void readDict();
//- Creates most of the data associated with this object. //- Returns true if within time bounds
bool allocateFilter();
//- Returns true if active (enabled and within time bounds)
bool active() const; bool active() const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
@ -158,9 +155,9 @@ public:
// Function object control // Function object control
//- Called at each ++ or += of the time-loop. forceWrite overrides //- Called at each ++ or += of the time-loop.
// the usual outputControl behaviour and forces writing always // forceWrite overrides the usual outputControl behaviour and
// (used in post-processing mode) // forces writing (used in post-processing mode)
virtual bool execute(const bool forceWrite = false); virtual bool execute(const bool forceWrite = false);
//- Called when Time::run() determines that the time-loop exits //- Called when Time::run() determines that the time-loop exits