34 const char* NamedEnum<timeControl::timeControls, 9>::
50 Foam::timeControl::timeControlNames_;
84 word controlName(prefix_ +
"Control");
85 word intervalName(prefix_ +
"Interval");
86 const word timesName(prefix_ +
"Times");
90 if (prefix_ ==
"write" &&
dict.
found(
"outputControl"))
93 <<
"Using deprecated 'outputControl'" <<
nl
94 <<
" Please use 'writeControl' with 'writeInterval'"
98 controlName =
"outputControl";
99 intervalName =
"outputInterval";
104 timeControl_ = timeControlNames_.read(
dict.
lookup(controlName));
108 timeControl_ = timeControls::timeStep;
111 switch (timeControl_)
113 case timeControls::timeStep:
119 case timeControls::writeTime:
120 case timeControls::outputTime:
126 case timeControls::clockTime:
127 case timeControls::runTime:
128 case timeControls::cpuTime:
129 case timeControls::adjustableRunTime:
131 interval_ = time_.userTimeToTime(
dict.
lookup<scalar>(intervalName));
133 if (timeControl_ == timeControls::adjustableRunTime)
135 executionIndex_ =
label
138 (time_.value() - time_.beginTime().value())
139 + 0.5*time_.deltaTValue()
148 case timeControls::runTimes:
157 int64_t((times_[i] + timeDelta_/2.0)/timeDelta_)
175 switch (timeControl_)
177 case timeControls::timeStep:
181 (intervalSteps_ <= 1)
182 || !(time_.timeIndex() % intervalSteps_)
187 case timeControls::writeTime:
188 case timeControls::outputTime:
190 if (time_.writeTime())
193 return !(executionIndex_ % intervalSteps_);
198 case timeControls::runTime:
199 case timeControls::adjustableRunTime:
204 (time_.value() - time_.beginTime().value())
205 + 0.5*time_.deltaTValue()
210 if (executionIndex > executionIndex_)
212 executionIndex_ = executionIndex;
218 case timeControls::runTimes:
220 return timeIndices_.found
222 (time_.userTimeValue() + timeDelta_/2)/timeDelta_
228 case timeControls::cpuTime:
235 if (executionIndex > executionIndex_)
237 executionIndex_ = executionIndex;
243 case timeControls::clockTime:
250 if (executionIndex > executionIndex_)
252 executionIndex_ = executionIndex;
258 case timeControls::none:
266 <<
"Undefined output control: "
267 << timeControlNames_[timeControl_] <<
nl
279 switch (timeControl_)
281 case timeControls::timeStep:
282 case timeControls::writeTime:
283 case timeControls::outputTime:
284 case timeControls::runTime:
285 case timeControls::cpuTime:
286 case timeControls::clockTime:
287 case timeControls::none:
293 case timeControls::adjustableRunTime:
299 (executionIndex_ + 1)*interval_
300 - (time_.value() - time_.beginTime().value())
305 case timeControls::runTimes:
307 if (time_.userTimeValue() + timeDelta_ < times_.last())
311 if (times_[i] > time_.userTimeValue() + timeDelta_)
313 return time_.userTimeToTime
315 times_[i] - time_.userTimeValue()
329 <<
"Undefined output control: "
330 << timeControlNames_[timeControl_] <<
nl
Inter-processor communication reduction functions.
#define forAll(list, i)
Loop across all elements in list.
Initialise the NamedEnum HashTable from the static list of names.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A list of keyword definitions, which are a keyword followed by any number of values (e....
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
timeControls
The time control options.
void read(const dictionary &)
Read from dictionary.
~timeControl()
Destructor.
scalar timeToNextAction()
Return the time to the next write.
bool execute()
Flag to indicate whether to execute.
timeControl(const Time &, const dictionary &, const word &prefix)
Construct from Time object and dictionary.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)