Skip to content
Snippets Groups Projects
Commit 49ed79d5 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: improve some timeControl handling

- synchronize the scalar interval value with the integer version.
  This ensures that the interval() method returns the correct
  representative value.

- added clear() method to reset to 'always' (pass-through)
parent b502086a
No related branches found
No related tags found
No related merge requests found
...@@ -62,8 +62,8 @@ Foam::timeControl::timeControl ...@@ -62,8 +62,8 @@ Foam::timeControl::timeControl
time_(runTime), time_(runTime),
prefix_(prefix), prefix_(prefix),
timeControl_(ocAlways), timeControl_(ocAlways),
intervalSteps_(0), intInterval_(0),
interval_(-1), interval_(0),
executionIndex_(0) executionIndex_(0)
{} {}
...@@ -100,8 +100,8 @@ bool Foam::timeControl::entriesPresent ...@@ -100,8 +100,8 @@ bool Foam::timeControl::entriesPresent
void Foam::timeControl::clear() void Foam::timeControl::clear()
{ {
timeControl_ = ocAlways; timeControl_ = ocAlways;
intervalSteps_ = 0; intInterval_ = 0;
interval_ = -1; interval_ = 0;
executionIndex_ = 0; executionIndex_ = 0;
} }
...@@ -110,6 +110,8 @@ void Foam::timeControl::read(const dictionary& dict) ...@@ -110,6 +110,8 @@ void Foam::timeControl::read(const dictionary& dict)
{ {
// Default is timeStep // Default is timeStep
timeControl_ = ocTimeStep; timeControl_ = ocTimeStep;
intInterval_ = 0;
interval_ = 0;
word controlName(prefix_ + "Control"); word controlName(prefix_ + "Control");
word intervalName(prefix_ + "Interval"); word intervalName(prefix_ + "Interval");
...@@ -142,7 +144,8 @@ void Foam::timeControl::read(const dictionary& dict) ...@@ -142,7 +144,8 @@ void Foam::timeControl::read(const dictionary& dict)
case ocTimeStep: case ocTimeStep:
case ocWriteTime: case ocWriteTime:
{ {
intervalSteps_ = dict.getOrDefault<label>(intervalName, 0); intInterval_ = dict.getOrDefault<label>(intervalName, 0);
interval_ = intInterval_; // Mirrored as scalar (for output)
break; break;
} }
...@@ -184,8 +187,8 @@ bool Foam::timeControl::execute() ...@@ -184,8 +187,8 @@ bool Foam::timeControl::execute()
{ {
return return
( (
(intervalSteps_ <= 1) (intInterval_ <= 1)
|| !(time_.timeIndex() % intervalSteps_) || !(time_.timeIndex() % intInterval_)
); );
break; break;
} }
...@@ -197,8 +200,8 @@ bool Foam::timeControl::execute() ...@@ -197,8 +200,8 @@ bool Foam::timeControl::execute()
++executionIndex_; ++executionIndex_;
return return
( (
(intervalSteps_ <= 1) (intInterval_ <= 1)
|| !(executionIndex_ % intervalSteps_) || !(executionIndex_ % intInterval_)
); );
} }
break; break;
......
...@@ -97,7 +97,7 @@ private: ...@@ -97,7 +97,7 @@ private:
//- Execution interval steps (timeStep | writeTime). //- Execution interval steps (timeStep | writeTime).
// A value <= 1 means execute at every time-step or writeTime. // A value <= 1 means execute at every time-step or writeTime.
label intervalSteps_; label intInterval_;
//- Execution interval (clockTime | runTime | cpuTime | adjustable) //- Execution interval (clockTime | runTime | cpuTime | adjustable)
scalar interval_; scalar interval_;
......
...@@ -57,7 +57,7 @@ inline bool Foam::timeControl::always() const ...@@ -57,7 +57,7 @@ inline bool Foam::timeControl::always() const
return return
( (
(timeControls::ocAlways == timeControl_) (timeControls::ocAlways == timeControl_)
|| (timeControls::ocTimeStep == timeControl_ && intervalSteps_ <= 1) || (timeControls::ocTimeStep == timeControl_ && intInterval_ <= 1)
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment