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; };
61 bool output()
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"; };
86 std::string ini_folder_path{
93 std::cerr << e.
what() <<
'\n';
100 this->setSubmodules(all_submodules);
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")
146 std::chrono::time_point current_time{std::chrono::high_resolution_clock::now()};
147 std::chrono::duration passed_time_since_start{
148 std::chrono::duration_cast<std::chrono::milliseconds>(current_time - start_time)};
149 std::chrono::duration passed_time_since_last_call{
150 std::chrono::duration_cast<std::chrono::milliseconds>(current_time - last_call_time)};
154 std::cout <<
"\033[32m[RuntimeProgressTool] Time steps: " << this->sim->time_step <<
"/"
155 << total_time_steps <<
"\033[0m\n";
157 if (passed_time_since_last_call.count() == 0)
163 std::cout <<
"\033[32m[RuntimeProgress] Simulation speed of "
164 << (iteration_interval * 1000 / passed_time_since_last_call.count())
165 <<
" it/s for the last interval. Simulation speed of "
166 << (this->sim->time_step * 1000 / passed_time_since_start.count())
167 <<
" it/s since start.\033[0m\n";
169 last_call_time = current_time;
175 if (this->sim->time_step % iteration_interval == 0)
177 _calculate_iteration_time();
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
Abstract base class for the submodules. Submodules are below managing modules and will only be run by...
Definition GenericSubmodule.h:25
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
Definition SimulationClassBase.h:15
InputManager m_simulation_config
Definition SimulationClassBase.h:24