32 Foam::timeControl::timeControlNames_
52 && time_.
value() <= endTime_;
68 startTime_(time_.beginTime().value()),
92 word controlName(prefix_ +
"Control");
93 word intervalName(prefix_ +
"Interval");
97 if (prefix_ ==
"write" &&
dict.
found(
"outputControl"))
100 <<
"Using deprecated 'outputControl'" <<
nl
101 <<
" Please use 'writeControl' with 'writeInterval'"
105 controlName =
"outputControl";
106 intervalName =
"outputInterval";
111 timeControl_ = timeControlNames_.read(
dict.
lookup(controlName));
115 timeControl_ = timeControls::timeStep;
118 switch (timeControl_)
120 case timeControls::timeStep:
126 case timeControls::writeTime:
127 case timeControls::outputTime:
133 case timeControls::clockTime:
134 case timeControls::runTime:
135 case timeControls::cpuTime:
136 case timeControls::adjustableRunTime:
138 interval_ =
dict.
lookup<scalar>(intervalName, time_.userUnits());
140 if (timeControl_ == timeControls::adjustableRunTime)
142 executionIndex_ =
max
146 ((time_.value() - startTime_) + 0.5*time_.deltaTValue())
155 && startTime_ != time_.beginTime().value()
158 executionIndex_ = -1;
165 case timeControls::runTimes:
167 const word timesName(prefix_ +
"Times");
168 const word frequenciesName(prefix_ +
"Frequencies");
176 1
e-3*time_.userDeltaTValue()
187 const scalar userEndTime =
188 time_.timeToUserTime(time_.endTime().value());
198 const scalar frequenciesDuration =
199 frequencies.
last().first() - frequencies.
first().first();
204 while (times[i] < userEndTime)
212 + repeati*frequenciesDuration - timeDelta_
215 times(i + 1) = times[i] + frequencies[
pi].second();
227 <<
"Undefined " << timesName
228 <<
" or " << frequenciesName <<
" for output control: "
229 << timeControlNames_[timeControl_] <<
nl
237 int64_t((times_[i] + timeDelta_/2.0)/timeDelta_)
260 switch (timeControl_)
262 case timeControls::timeStep:
266 (intervalSteps_ <= 1)
267 || !(time_.timeIndex() % intervalSteps_)
272 case timeControls::writeTime:
273 case timeControls::outputTime:
275 if (time_.writeTime())
278 return !(executionIndex_ % intervalSteps_);
283 case timeControls::runTime:
284 case timeControls::adjustableRunTime:
288 ((time_.value() - startTime_) + 0.5*time_.deltaTValue())
292 if (executionIndex > executionIndex_)
294 executionIndex_ = executionIndex;
300 case timeControls::runTimes:
302 return timeIndices_.found
304 (time_.userTimeValue() + timeDelta_/2)/timeDelta_
310 case timeControls::cpuTime:
317 if (executionIndex > executionIndex_)
319 executionIndex_ = executionIndex;
325 case timeControls::clockTime:
332 if (executionIndex > executionIndex_)
334 executionIndex_ = executionIndex;
340 case timeControls::none:
348 <<
"Undefined output control: "
349 << timeControlNames_[timeControl_] <<
nl
361 switch (timeControl_)
363 case timeControls::timeStep:
364 case timeControls::writeTime:
365 case timeControls::outputTime:
366 case timeControls::runTime:
367 case timeControls::cpuTime:
368 case timeControls::clockTime:
369 case timeControls::none:
375 case timeControls::adjustableRunTime:
377 if (time_.value() < startTime_)
379 return startTime_ - time_.value();
381 else if (time_.value() > endTime_)
390 (executionIndex_ + 1)*interval_
391 - (time_.value() - startTime_)
397 case timeControls::runTimes:
399 scalar realTimeToNextAction = vGreat;
403 const scalar userTimeToThisAction =
404 times_[i] - time_.userTimeValue();
406 if (userTimeToThisAction > timeDelta_)
408 realTimeToNextAction =
411 realTimeToNextAction,
412 time_.userTimeToTime(userTimeToThisAction)
417 return realTimeToNextAction;
424 <<
"Undefined output control: "
425 << timeControlNames_[timeControl_] <<
nl
Inter-processor communication reduction functions.
#define forAll(list, i)
Loop across all elements in list.
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
Initialise the NamedEnum HashTable from the static list of names.
scalar deltaTValue() const
Return time step value.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
T & first()
Return the first element of the list.
T & last()
Return the last element of the list.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
T lookupOrDefault(const word &, const T &, const bool writeDefault=writeOptionalEntries > 0) const
Find and return a T, if not found return the given default.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
const Type & value() const
Return const reference to value.
timeControls
The time control options.
void read(const dictionary &)
Read from dictionary.
~timeControl()
Destructor.
bool active() const
Returns true the time is within the start to end period.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
labelList second(const UList< labelPair > &p)
const unitConversion unitNone
labelList first(const UList< labelPair > &p)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
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)
List< Type > repeat(const UList< Type > &a, const UList< Type > &b)