Commit c9db7cf2 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: used guarded read in runTimeControl

parent d962d2e8
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,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) 2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -64,7 +64,7 @@ void Foam::functionObjects::timeControl::readControls() ...@@ -64,7 +64,7 @@ void Foam::functionObjects::timeControl::readControls()
if (dict_.readIfPresent("triggerStart", triggerStart_)) if (dict_.readIfPresent("triggerStart", triggerStart_))
{ {
dict_.readIfPresent("triggerEnd", triggerEnd_); dict_.readIfPresent("triggerEnd", triggerEnd_);
controlMode_ = controlModeNames_.read(dict_.lookup("controlMode")); controlMode_ = controlModeNames_.get("controlMode", dict_);
} }
deltaTCoeff_ = GREAT; deltaTCoeff_ = GREAT;
......
...@@ -70,9 +70,9 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition ...@@ -70,9 +70,9 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
window_(dict.lookupOrDefault<scalar>("window", -1)), window_(dict.lookupOrDefault<scalar>("window", -1)),
windowType_ windowType_
( (
window_ > 0 ? window_ > 0
windowTypeNames.read(dict.lookup("windowType")) ? windowTypeNames.get("windowType", dict)
: windowType::NONE : windowType::NONE
), ),
totalTime_(fieldNames_.size(), scalar(0)), totalTime_(fieldNames_.size(), scalar(0)),
resetOnRestart_(dict.lookupOrDefault<bool>("resetOnRestart", false)), resetOnRestart_(dict.lookupOrDefault<bool>("resetOnRestart", false)),
......
...@@ -150,7 +150,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read ...@@ -150,7 +150,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
} }
// Set the action to perform when all conditions are satisfied // 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_ = satisfiedAction_ =
satisfiedActionNames.lookupOrDefault satisfiedActionNames.lookupOrDefault
( (
...@@ -161,7 +161,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read ...@@ -161,7 +161,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
if (satisfiedAction_ == satisfiedAction::SET_TRIGGER) if (satisfiedAction_ == satisfiedAction::SET_TRIGGER)
{ {
triggerIndex_ = readLabel(dict.lookup("trigger")); triggerIndex_ = dict.get<label>("trigger");
} }
return true; return true;
......
...@@ -105,18 +105,12 @@ bool Foam::functionObjects::setTimeStepFunctionObject::read ...@@ -105,18 +105,12 @@ bool Foam::functionObjects::setTimeStepFunctionObject::read
timeStepPtr_ = Function1<scalar>::New("deltaT", dict); timeStepPtr_ = Function1<scalar>::New("deltaT", dict);
// Check that adjustTimeStep is active // Ensure that adjustTimeStep is active
const dictionary& controlDict = time_.controlDict(); if (!time_.controlDict().lookupOrDefault<bool>("adjustTimeStep", false))
Switch adjust;
if
(
!controlDict.readIfPresent<Switch>("adjustTimeStep", adjust)
|| !adjust
)
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< "Need to set 'adjustTimeStep' true to allow timestep control" << "Need to set 'adjustTimeStep' true to allow timestep control"
<< nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
......
...@@ -71,7 +71,6 @@ SourceFiles ...@@ -71,7 +71,6 @@ SourceFiles
#include "functionObject.H" #include "functionObject.H"
#include "Function1.H" #include "Function1.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...@@ -136,15 +135,12 @@ public: ...@@ -136,15 +135,12 @@ public:
virtual bool adjustTimeStep(); virtual bool adjustTimeStep();
//- Read and set the function object if its data have changed //- 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. //- Execute does nothing
// postProcess overrides the usual executeControl behaviour and
// forces execution (used in post-processing mode)
virtual bool execute(); virtual bool execute();
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual writeControl behaviour and //- Write does nothing
// forces writing always (used in post-processing mode)
virtual bool write(); virtual bool write();
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment