34 const char* NamedEnum<timeControl::timeControls, 9>::
50 Foam::timeControl::timeControlNames_;
84 word controlName(prefix_ +
"Control");
85 word intervalName(prefix_ +
"Interval");
89 if (prefix_ ==
"write" &&
dict.
found(
"outputControl"))
92 <<
"Using deprecated 'outputControl'" <<
nl
93 <<
" Please use 'writeControl' with 'writeInterval'"
97 controlName =
"outputControl";
98 intervalName =
"outputInterval";
103 timeControl_ = timeControlNames_.read(
dict.
lookup(controlName));
107 timeControl_ = timeControls::timeStep;
110 switch (timeControl_)
112 case timeControls::timeStep:
118 case timeControls::writeTime:
119 case timeControls::outputTime:
125 case timeControls::clockTime:
126 case timeControls::runTime:
127 case timeControls::cpuTime:
128 case timeControls::adjustableRunTime:
130 interval_ =
dict.
lookup<scalar>(intervalName, time_.userUnits());
132 if (timeControl_ == timeControls::adjustableRunTime)
134 executionIndex_ =
label
137 (time_.value() - time_.beginTime().value())
138 + 0.5*time_.deltaTValue()
147 case timeControls::runTimes:
149 const word timesName(prefix_ +
"Times");
150 const word frequenciesName(prefix_ +
"Frequencies");
158 1
e-3*time_.userDeltaTValue()
176 {time_.endTime().value(), frequencies.
last().second()}
180 const scalar frequenciesDuration =
181 frequencies.
last().first() - frequencies.
first().first();
186 while (times[i] < time_.endTime().value())
194 + repeati*frequenciesDuration - timeDelta_
197 times(i + 1) = times[i] + frequencies[
pi].second();
209 <<
"Undefined " << timesName
210 <<
" or " << frequenciesName <<
" for output control: "
211 << timeControlNames_[timeControl_] <<
nl
219 int64_t((times_[i] + timeDelta_/2.0)/timeDelta_)
237 switch (timeControl_)
239 case timeControls::timeStep:
243 (intervalSteps_ <= 1)
244 || !(time_.timeIndex() % intervalSteps_)
249 case timeControls::writeTime:
250 case timeControls::outputTime:
252 if (time_.writeTime())
255 return !(executionIndex_ % intervalSteps_);
260 case timeControls::runTime:
261 case timeControls::adjustableRunTime:
266 (time_.value() - time_.beginTime().value())
267 + 0.5*time_.deltaTValue()
272 if (executionIndex > executionIndex_)
274 executionIndex_ = executionIndex;
280 case timeControls::runTimes:
282 return timeIndices_.found
284 (time_.userTimeValue() + timeDelta_/2)/timeDelta_
290 case timeControls::cpuTime:
297 if (executionIndex > executionIndex_)
299 executionIndex_ = executionIndex;
305 case timeControls::clockTime:
312 if (executionIndex > executionIndex_)
314 executionIndex_ = executionIndex;
320 case timeControls::none:
328 <<
"Undefined output control: "
329 << timeControlNames_[timeControl_] <<
nl
341 switch (timeControl_)
343 case timeControls::timeStep:
344 case timeControls::writeTime:
345 case timeControls::outputTime:
346 case timeControls::runTime:
347 case timeControls::cpuTime:
348 case timeControls::clockTime:
349 case timeControls::none:
355 case timeControls::adjustableRunTime:
361 (executionIndex_ + 1)*interval_
362 - (time_.value() - time_.beginTime().value())
367 case timeControls::runTimes:
369 if (time_.userTimeValue() + timeDelta_ < times_.last())
373 if (times_[i] > time_.userTimeValue() + timeDelta_)
375 return time_.userTimeToTime
377 times_[i] - time_.userTimeValue()
391 <<
"Undefined output control: "
392 << 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 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, 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 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.
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.
const unitConversion unitNone
labelList first(const UList< labelPair > &p)
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)