STYLE: used guarded read in runTimeControl

This commit is contained in:
Mark Olesen
2019-01-24 10:03:33 +01:00
parent 1c85c64984
commit 1910ebc0ad
5 changed files with 14 additions and 24 deletions

View File

@ -70,9 +70,9 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
window_(dict.lookupOrDefault<scalar>("window", -1)),
windowType_
(
window_ > 0 ?
windowTypeNames.read(dict.lookup("windowType"))
: windowType::NONE
window_ > 0
? windowTypeNames.get("windowType", dict)
: windowType::NONE
),
totalTime_(fieldNames_.size(), scalar(0)),
resetOnRestart_(dict.lookupOrDefault<bool>("resetOnRestart", false)),

View File

@ -150,7 +150,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
}
// Set the action to perform when all conditions are satisfied
// - set to end fro backwards compatibility with v1806
// - set to end for backwards compatibility with v1806
satisfiedAction_ =
satisfiedActionNames.lookupOrDefault
(
@ -161,7 +161,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
if (satisfiedAction_ == satisfiedAction::SET_TRIGGER)
{
triggerIndex_ = readLabel(dict.lookup("trigger"));
triggerIndex_ = dict.get<label>("trigger");
}
return true;

View File

@ -105,18 +105,12 @@ bool Foam::functionObjects::setTimeStepFunctionObject::read
timeStepPtr_ = Function1<scalar>::New("deltaT", dict);
// Check that adjustTimeStep is active
const dictionary& controlDict = time_.controlDict();
Switch adjust;
if
(
!controlDict.readIfPresent<Switch>("adjustTimeStep", adjust)
|| !adjust
)
// Ensure that adjustTimeStep is active
if (!time_.controlDict().lookupOrDefault<bool>("adjustTimeStep", false))
{
FatalIOErrorInFunction(dict)
<< "Need to set 'adjustTimeStep' true to allow timestep control"
<< nl
<< exit(FatalIOError);
}

View File

@ -71,7 +71,6 @@ SourceFiles
#include "functionObject.H"
#include "Function1.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -136,15 +135,12 @@ public:
virtual bool adjustTimeStep();
//- Read and set the function object if its data have changed
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict);
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual executeControl behaviour and
// forces execution (used in post-processing mode)
//- Execute does nothing
virtual bool execute();
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual writeControl behaviour and
// forces writing always (used in post-processing mode)
//- Write does nothing
virtual bool write();
};