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

STYLE: used guarded read in runTimeControl

parent d962d2e8
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -64,7 +64,7 @@ void Foam::functionObjects::timeControl::readControls()
if (dict_.readIfPresent("triggerStart", triggerStart_))
{
dict_.readIfPresent("triggerEnd", triggerEnd_);
controlMode_ = controlModeNames_.read(dict_.lookup("controlMode"));
controlMode_ = controlModeNames_.get("controlMode", dict_);
}
deltaTCoeff_ = GREAT;
......
......@@ -70,8 +70,8 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
window_(dict.lookupOrDefault<scalar>("window", -1)),
windowType_
(
window_ > 0 ?
windowTypeNames.read(dict.lookup("windowType"))
window_ > 0
? windowTypeNames.get("windowType", dict)
: windowType::NONE
),
totalTime_(fieldNames_.size(), scalar(0)),
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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();
};
......
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