Progress bar hook¶
-
class mdk::ProgressBar : public mdk::Hook, private mdk::SimulVar
A progress bar. Chiefly for convenience. Prints a status bar, current (internal and clock) time and total simulation span, and the current potential energy. Note: Because it flushes the output, care must be taken not to invoke it too often.
Public Functions
-
explicit ProgressBar(double totalTime, double updatePeriod, int width = 70)
Construct a
ProgressBar
object.- Parameters
totalTime – Total span of the simulation; used for normalizing the current time to display it as a percentage.
updatePeriod – How often to update the progrss bar.
width – Width of the progress bar in characters.
-
virtual void bind(Simulation &simulation) override
Bind an object to a simulation.
- Parameters
simulation – Simulation to bind the object to.
-
virtual void execute(int step_nr) override
Execute the hook.
- Parameters
step_nr – Number of the step of the simulation when the hook is activated.
Private Types
-
using time_point = std::chrono::high_resolution_clock::time_point
Private Members
-
Simulation *simul = nullptr
-
State *state = nullptr
-
time_point realTime0
Real (clock) time when the simulation was started.
-
double totalTime
-
double updatePeriod
-
double prevTime
-
int width
-
explicit ProgressBar(double totalTime, double updatePeriod, int width = 70)