1#ifndef RUNTIME_PROGRESS_TOOL_H
2#define RUNTIME_PROGRESS_TOOL_H
4#define RUNTIME_PROGRESS_TOOL_VERSION "8"
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 <<
"[RuntimeProgressTool]: " <<
e.what() <<
'\n';
94 throw BadInput(
static_cast<std::string
>(
"[RuntimeProgressTool]: ")
95 +
static_cast<std::string
>(
e.what()));
105 iteration_interval = this->ini_file_data.getDoubleParameters(
"iteration_interval");
107 std::ceil(this->sim->m_simulation_config.getDoubleParameters(
"time_max")
108 /
this->sim->m_simulation_config.getDoubleParameters(
"time_delta"));
109 start_time = std::chrono::high_resolution_clock::now();
110 last_call_time = start_time;
114 std::cerr <<
"[RuntimeProgressTool]: " <<
e.what() <<
'\n';
115 throw BadInput(
static_cast<std::string
>(
"[RuntimeProgressTool]: ")
116 +
static_cast<std::string
>(
e.what()));
124 if (
param ==
"InitChain")
128 if (
param ==
"PreTimeStepChain")
130 return preTimeStep();
132 if (
param ==
"PostNonLinIterChain")
134 return postNonLinIter();
136 if (
param ==
"PostTimeStepChain")
138 return postTimeStep();
140 if (
param ==
"OutputChain")
158 std::chrono::time_point
current_time{std::chrono::high_resolution_clock::now()};
160 std::chrono::duration_cast<std::chrono::milliseconds>(
current_time - start_time)};
162 std::chrono::duration_cast<std::chrono::milliseconds>(
current_time - last_call_time)};
166 std::cout <<
"\033[32m[RuntimeProgressTool]: Time steps: " << this->sim->time_step <<
"/"
167 << total_time_steps <<
"\033[0m\n";
175 std::cout <<
"\033[32m[RuntimeProgressTool]: Simulation speed of "
177 <<
" it/s for the last interval. Simulation speed of "
179 <<
" it/s since start.\033[0m\n";
192 if (this->sim->time_step % iteration_interval == 0)
194 _calculate_iteration_time();
201 if (this->sim->my_rank == 0)
211 if (this->sim->my_rank == 0)
221 if (this->sim->my_rank != 0)
225 std::chrono::time_point
current_time{std::chrono::high_resolution_clock::now()};
227 std::chrono::duration_cast<std::chrono::milliseconds>(
current_time - start_time)};
228 std::cout <<
"\033[32m[RuntimeProgress] Total runtime of "
230 <<
" seconds since start.\033[0m\n";
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37
CsrSparseMatrix()
Constructor for an empty CsrSparseMatrix object. Leaves all storage arrays empty but sets the flag to...
Definition CsrMatrix.h:94
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:76