Molecular Dynamics Simulation  1.0
ParticleUpdateCounterInterceptor.cpp
Go to the documentation of this file.
2 
3 #include <chrono>
4 
5 #include "io/logger/Logger.h"
6 
9  t_start = std::chrono::high_resolution_clock::now();
10 
12 }
13 
14 void ParticleUpdateCounterInterceptor::operator()(size_t iteration, Simulation& simulation) {
15  particle_updates += simulation.particle_container->size();
16 }
17 
19  t_end = std::chrono::high_resolution_clock::now();
20  t_diff = std::chrono::duration_cast<std::chrono::milliseconds>(t_end - t_start).count();
21 
22  particle_updates_per_second = 1000.0 * static_cast<double>(particle_updates) / static_cast<double>(t_diff);
23 }
24 
26 
28  std::string indent = std::string(depth * 2, ' ');
29 
30  Logger::logger->info("{}╟┤{}ParticleUpdateCounter: {}", indent, ansi_orange_bold, ansi_end);
31  Logger::logger->info("{}║ ├Enabled", indent);
32 }
33 
34 ParticleUpdateCounterInterceptor::operator std::string() const {
35  return "ParticleUpdateCalculator: " + std::to_string(particle_updates_per_second) + " particle updates per second";
36 }
const std::string ansi_end
Definition: Logger.h:13
const std::string ansi_orange_bold
Definition: Logger.h:10
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Definition: Logger.h:35
double getParticleUpdatesPerSecond() const
Get the particle updates per second.
void logSummary(int depth) const override
Logs the summary of the particle update counter.
void operator()(size_t iteration, Simulation &simulation) override
This function is called on every nth iteration. It counts the number of particle updates which have b...
void onSimulationStart(Simulation &simulation) override
This function is sets the particle_updates to 0 and initializes the start time of the simulation.
std::chrono::high_resolution_clock::time_point t_end
void onSimulationEnd(size_t iteration, Simulation &simulation) override
This function is empty as the thermostat doesnt need to do anything at the end of the simulation.
std::chrono::high_resolution_clock::time_point t_start
Class to run a simulation.
Definition: Simulation.h:20
std::unique_ptr< ParticleContainer > particle_container
Reference to the ParticleContainer on whose content the simulation is performed.
Definition: Simulation.h:50
std::string to_string(const Container &container, const std::string &delimiter=", ", const std::array< std::string, 2 > &surround={"[", "]"})
Definition: ArrayUtils.h:97