32 Foam::timeControl::timeControlNames_
48 Foam::label Foam::timeControl::roundDown(
const scalar t)
66 startTime_(time_.beginTime().value()),
68 beginTime_(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::adjustableRunTime:
134 case timeControls::runTime:
136 interval_ =
dict.
lookup<scalar>(intervalName, time_.userUnits());
141 max(time_.value(), startTime_)
143 - 0.5*time_.deltaTValue()
150 case timeControls::runTimes:
152 const word timesName(prefix_ +
"Times");
153 const word frequenciesName(prefix_ +
"Frequencies");
161 scalar(1
e-3*time_.userDeltaTValue())
172 const scalar userEndTime =
173 time_.timeToUserTime(time_.endTime().value());
183 const scalar frequenciesDuration =
184 frequencies.
last().first() - frequencies.
first().first();
189 while (times[i] < userEndTime)
197 + repeati*frequenciesDuration - timeDelta_
200 times(i + 1) = times[i] + frequencies[
pi].second();
212 <<
"Undefined " << timesName
213 <<
" or " << frequenciesName <<
" for output control: "
214 << timeControlNames_[timeControl_] <<
nl
222 int64_t((times_[i] + timeDelta_/2.0)/timeDelta_)
230 case timeControls::clockTime:
231 case timeControls::cpuTime:
233 interval_ =
dict.
lookup<scalar>(intervalName, time_.userUnits());
245 <<
"Undefined output control: "
246 << timeControlNames_[timeControl_] <<
nl
258 && time_.value() >= startTime_ - 0.5*time_.deltaTValue()
259 && time_.value() <= endTime_;
270 switch (timeControl_)
272 case timeControls::timeStep:
276 || time_.timeIndex() % intervalSteps_ == 0;
280 case timeControls::writeTime:
281 case timeControls::outputTime:
286 || time_.timeIndex() == time_.startTimeIndex()
291 || executionIndex_ % intervalSteps_ == 0;
298 case timeControls::runTime:
299 case timeControls::adjustableRunTime:
301 const label executionIndex =
307 + 0.5*time_.deltaTValue()
311 if (executionIndex > executionIndex_)
313 executionIndex_ = executionIndex;
319 case timeControls::runTimes:
321 return timeIndices_.found
323 (time_.userTimeValue() + timeDelta_/2)/timeDelta_
327 case timeControls::clockTime:
334 if (executionIndex > executionIndex_)
336 executionIndex_ = executionIndex;
342 case timeControls::cpuTime:
349 if (executionIndex > executionIndex_)
351 executionIndex_ = executionIndex;
365 <<
"Undefined output control: "
366 << timeControlNames_[timeControl_] <<
nl
378 if (time_.value() > endTime_)
return vGreat;
380 switch (timeControl_)
382 case timeControls::timeStep:
383 case timeControls::writeTime:
384 case timeControls::outputTime:
385 case timeControls::runTime:
386 case timeControls::clockTime:
387 case timeControls::cpuTime:
394 case timeControls::adjustableRunTime:
397 (executionIndex_ + 1)*interval_
398 - (time_.value() - beginTime_);
402 case timeControls::runTimes:
404 scalar realTimeToNextAction = vGreat;
410 time_.userTimeToTime(times_[i]) < startTime_
411 || time_.userTimeToTime(times_[i]) > endTime_
414 const scalar userTimeToThisAction =
415 times_[i] - time_.userTimeValue();
417 if (userTimeToThisAction > timeDelta_)
419 realTimeToNextAction =
422 realTimeToNextAction,
423 time_.userTimeToTime(userTimeToThisAction)
428 return realTimeToNextAction;
435 <<
"Undefined output control: "
436 << 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.
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.
T lookupOrDefault(const word &, const T &) const
Find and return a T, if not found return the given default.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
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.
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)
scalar roundDown(const scalar x, const scalar s)
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)
labelList first(const UList< labelPair > &p)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
List< Type > repeat(const UList< Type > &a, const UList< Type > &b)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)