1#ifndef RUNTIME_PROGRESS_TOOL_H
2#define RUNTIME_PROGRESS_TOOL_H
12#include "../../src/GenericManagingModule.h"
13#include "../../src/ModuleFactory.h"
43 static bool m_registered;
44 int iteration_interval;
46 std::string m_ini_filepath{
"tools/RuntimeProgressTool.ini"};
47 std::chrono::time_point<std::chrono::high_resolution_clock> start_time;
48 std::chrono::time_point<std::chrono::high_resolution_clock> last_call_time;
50 void _calculate_iteration_time();
55 bool exec(std::string_view
param)
override;
57 bool init()
override {
return true; };
72 return std::make_shared<RuntimeProgressTool<T>>(
sim);
74 static std::string
getName() {
return "RuntimeProgressTool"; };
75 std::string_view
getNameLocal()
const override {
return "RuntimeProgressTool"; };
87 this->sim->m_simulation_config.getStringParameters(
"ini_folder_path")};
93 std::cerr <<
e.what() <<
'\n';
101 iteration_interval = this->ini_file_data.getDoubleParameters(
"iteration_interval");
103 std::ceil(this->sim->m_simulation_config.getDoubleParameters(
"time_max")
104 /
this->sim->m_simulation_config.getDoubleParameters(
"time_delta"));
105 start_time = std::chrono::high_resolution_clock::now();
106 last_call_time = start_time;
114 if (
param ==
"InitChain")
118 if (
param ==
"PreTimeStepChain")
120 return preTimeStep();
122 if (
param ==
"PostNonLinIterChain")
124 return postNonLinIter();
126 if (
param ==
"PostTimeStepChain")
128 return postTimeStep();
130 if (
param ==
"OutputChain")
148 std::chrono::time_point
current_time{std::chrono::high_resolution_clock::now()};
150 std::chrono::duration_cast<std::chrono::milliseconds>(
current_time - start_time)};
152 std::chrono::duration_cast<std::chrono::milliseconds>(
current_time - last_call_time)};
156 std::cout <<
"\033[32m[RuntimeProgressTool] Time steps: " << this->sim->time_step <<
"/"
157 << total_time_steps <<
"\033[0m\n";
165 std::cout <<
"\033[32m[RuntimeProgress] Simulation speed of "
167 <<
" it/s for the last interval. Simulation speed of "
169 <<
" it/s since start.\033[0m\n";
182 if (this->sim->time_step % iteration_interval == 0)
184 _calculate_iteration_time();
191 if (this->sim->my_rank == 0)
201 if (this->sim->my_rank == 0)
211 if (this->sim->my_rank != 0)
215 std::chrono::time_point
current_time{std::chrono::high_resolution_clock::now()};
217 std::chrono::duration_cast<std::chrono::milliseconds>(
current_time - start_time)};
218 std::cout <<
"\033[32m[RuntimeProgress] Total runtime of "
220 <<
" seconds since start.\033[0m\n";
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:35
CsrSparseMatrix()
Constructor for an empty CsrSparseMatrix object. Leaves all storage arrays empty but sets the flag to...
Definition CsrMatrix.h:92
Abstract base class for the managing modules. Managing modules are the highest tier of modules and ar...
Definition GenericManagingModule.h:29
InputManager ini_file_data
Definition GenericManagingModule.h:38
SimulationClassBase< T > * sim
Definition GenericManagingModule.h:31
std::vector< std::string > m_generic_submodules
Definition GenericManagingModule.h:36
static constexpr bool registerModule(std::string name, creation_method module) noexcept
Function that adds a module to the module registry map.
Definition ModuleFactory.h:68