#include <ProgressBarInterceptor.h>
|
void | onSimulationStart (Simulation &simulation) override |
| This function initalized the start time of the simulation and the previous time point. More...
|
|
void | operator() (size_t iteration, Simulation &simulation) override |
| This function is called on every nth iteration. It prints a progress bar to the console and updates the previous time point. More...
|
|
void | onSimulationEnd (size_t iteration, Simulation &simulation) override |
| This function is empty as the progress bar doesnt need to do anything at the end of the simulation. More...
|
|
| operator std::string () const override |
| The string representation of this interceptor. More...
|
|
void | logSummary (int depth) const override |
| Logs the summary of the progress bar. More...
|
|
virtual | ~SimulationInterceptor ()=default |
| Destroy the Simulation Interceptor object. More...
|
|
void | notify (size_t iteration, Simulation &simulation) |
| This function is called by the simulation loop on every iteration. Whenever the iteration is a multiple of every_nth_iteration, the operator() function is called. More...
|
|
Definition at line 7 of file ProgressBarInterceptor.h.
◆ logSummary()
void ProgressBarInterceptor::logSummary |
( |
int |
depth | ) |
const |
|
overridevirtual |
Logs the summary of the progress bar.
Implements SimulationInterceptor.
Definition at line 117 of file ProgressBarInterceptor.cpp.
118 std::string indent = std::string(depth * 2,
' ');
const std::string ansi_end
const std::string ansi_orange_bold
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
◆ onSimulationEnd()
void ProgressBarInterceptor::onSimulationEnd |
( |
size_t |
iteration, |
|
|
Simulation & |
simulation |
|
) |
| |
|
overridevirtual |
This function is empty as the progress bar doesnt need to do anything at the end of the simulation.
- Parameters
-
iteration | The current iteration |
simulation | The simulation object |
Implements SimulationInterceptor.
Definition at line 113 of file ProgressBarInterceptor.cpp.
void printProgress(const std::filesystem::path &input_file_path, size_t percentage, size_t iteration, size_t expected_iterations, int estimated_remaining_seconds=-1, double particle_updates_per_second=-1, bool finished=false)
size_t expected_iterations
std::filesystem::path input_file_path
Path to the input file of the simulation.
const SimulationParams & params
Reference to the simulation parameters object.
◆ onSimulationStart()
void ProgressBarInterceptor::onSimulationStart |
( |
Simulation & |
simulation | ) |
|
|
overridevirtual |
This function initalized the start time of the simulation and the previous time point.
- Parameters
-
simulation | The simulation object |
Implements SimulationInterceptor.
Definition at line 56 of file ProgressBarInterceptor.cpp.
57 t_start = std::chrono::high_resolution_clock::now();
64 const size_t percentage = std::min(100ul,
static_cast<size_t>(100.0 *
static_cast<double>(simulation.
params.
start_iteration) /
double last_particle_updates_per_second
std::chrono::high_resolution_clock::time_point t_start
double last_remaining_seconds
std::chrono::high_resolution_clock::time_point t_prev
size_t last_particle_count
size_t every_nth_iteration
double delta_t
Time step of a single simulation iteration.
size_t start_iteration
Start iteration of the simulation.
double end_time
End time of the simulation.
std::unique_ptr< ParticleContainer > particle_container
Reference to the ParticleContainer on whose content the simulation is performed.
◆ operator std::string()
ProgressBarInterceptor::operator std::string |
( |
| ) |
const |
|
explicitoverridevirtual |
◆ operator()()
void ProgressBarInterceptor::operator() |
( |
size_t |
iteration, |
|
|
Simulation & |
simulation |
|
) |
| |
|
overridevirtual |
This function is called on every nth iteration. It prints a progress bar to the console and updates the previous time point.
- Parameters
-
iteration | The current iteration |
simulation | The simulation object |
Implements SimulationInterceptor.
Definition at line 77 of file ProgressBarInterceptor.cpp.
79 auto t_now = std::chrono::high_resolution_clock::now();
80 const double seconds_since_last_write = std::chrono::duration<double>(t_now -
t_prev).count();
84 const int estimated_remaining_seconds = std::floor(seconds_since_last_write *
static_cast<double>(
expected_iterations - iteration) /
88 const size_t percentage =
89 std::min(100ul,
static_cast<size_t>(100.0 *
static_cast<double>(iteration) /
static_cast<double>(
expected_iterations)));
95 double particle_updates_per_second =
static_cast<double>(particle_updates) / seconds_since_last_write;
107 smoothed_particle_updates_per_second);
◆ expected_iterations
size_t ProgressBarInterceptor::expected_iterations |
|
private |
◆ last_iteration
size_t ProgressBarInterceptor::last_iteration = 0 |
|
private |
◆ last_particle_count
size_t ProgressBarInterceptor::last_particle_count = 0 |
|
private |
◆ last_particle_updates_per_second
double ProgressBarInterceptor::last_particle_updates_per_second = 0 |
|
private |
◆ last_remaining_seconds
double ProgressBarInterceptor::last_remaining_seconds = 0 |
|
private |
◆ t_end
std::chrono::high_resolution_clock::time_point ProgressBarInterceptor::t_end |
|
private |
◆ t_prev
std::chrono::high_resolution_clock::time_point ProgressBarInterceptor::t_prev |
|
private |
◆ t_start
std::chrono::high_resolution_clock::time_point ProgressBarInterceptor::t_start |
|
private |
The documentation for this class was generated from the following files: