ENH: OutputFilter function object updates from internal development line

This commit is contained in:
Andrew Heather
2015-12-01 15:22:13 +00:00
parent f9a02bd412
commit 7fe531bde5
2 changed files with 31 additions and 5 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -47,10 +47,14 @@ void Foam::OutputFilterFunctionObject<OutputFilter>::readDict()
template<class OutputFilter> template<class OutputFilter>
bool Foam::OutputFilterFunctionObject<OutputFilter>::active() const bool Foam::OutputFilterFunctionObject<OutputFilter>::active() const
{ {
// The logic here mimics that of Time itself and uses 0.5*deltaT
// as the tolerance to account for numerical precision errors
// (see e.g. Time::run()) since the current time might be e.g.
// 0.3000000000001 instead of exactly 0.3.
return return
enabled_ enabled_
&& time_.value() >= timeStart_ && time_.value() >= (timeStart_ - 0.5*time_.deltaTValue())
&& time_.value() <= timeEnd_; && time_.value() <= (timeEnd_ + 0.5*time_.deltaTValue());
} }
@ -179,6 +183,13 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::execute
destroyFilter(); destroyFilter();
} }
} }
else if (enabled_ && time_.value() > timeEnd_)
{
// End early if the time is controlled by the user timeEnd entry
end();
enabled_ = false;
}
return true; return true;
} }
@ -196,7 +207,10 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::end()
ptr_->end(); ptr_->end();
if (outputControl_.output()) // Only write if
// - time within timeStart_ and timeEnd_
// - it is an output time
if (active() && outputControl_.output())
{ {
ptr_->write(); ptr_->write();
} }
@ -236,6 +250,9 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::adjustTimeStep()
const label outputTimeIndex = outputControl_.outputTimeLastDump(); const label outputTimeIndex = outputControl_.outputTimeLastDump();
const scalar writeInterval = outputControl_.writeInterval(); const scalar writeInterval = outputControl_.writeInterval();
// Logic mimics that of Time::adjustDeltaT() except we only allow
// making the time step lower.
scalar timeToNextWrite = max scalar timeToNextWrite = max
( (
0.0, 0.0,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,6 +34,15 @@ Note
writeInterval to be degrees crank angle, but the functionObject writeInterval to be degrees crank angle, but the functionObject
execution \a interval would still be in timestep. execution \a interval would still be in timestep.
The function object can be limited to operate within a time range using
the timeStart and timEnd options. All objects are read (and the
OutputFilter allocated) on construction. However, if a timeEnd is
supplied, the object will call the 'end' function of the filter
at the timeEnd time and destroy the filter.
Any other callback (execute(), write(), timeSet() etc) will only operate
if within the timeStart, timeEnd time range. Note that the time range
uses 0.5 * deltaT as a comparison tolerance to account for precision errors.
SourceFiles SourceFiles
OutputFilterFunctionObject.C OutputFilterFunctionObject.C