MPS-Basic
Loading...
Searching...
No Matches
simulation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "common.hpp"
4#include "loader.hpp"
5#include "mps.hpp"
6#include "saver.hpp"
7
8#include <chrono>
9#include <filesystem>
10#include <iomanip>
11#include <sstream>
12#include <string>
13
23public:
24 // TODO: The following members should be private.
25
29
30 std::chrono::system_clock::time_point realStartTime, realEndTime;
33 int timeStep = 0;
34
35 Simulation(std::filesystem::path& settingPath, std::filesystem::path& outputDirectory);
36
37 void run();
38
39private:
40 void startSimulation();
41
42 template <typename Rep, typename Period> std::string calHourMinuteSecond(std::chrono::duration<Rep, Period> d) {
43 auto h = std::chrono::duration_cast<std::chrono::hours>(d);
44 d -= h;
45 auto m = std::chrono::duration_cast<std::chrono::minutes>(d);
46 d -= m;
47 auto s = std::chrono::duration_cast<std::chrono::seconds>(d);
48
49 std::stringstream out;
50 out << h.count() << "h ";
51 out << std::setfill('0') << std::setw(2) << m.count() << "m " << s.count() << "s";
52 return out.str();
53 }
54
55 void endSimulation();
56
60 void timeStepReport(
61 const std::chrono::system_clock::time_point& timeStepStartTime,
62 const std::chrono::system_clock::time_point& timeStepEndTime
63 );
64
65 bool saveCondition();
66
67 // NOTE: If this function is also needed in other classes, it should be moved to a separate file.
68 std::string getCurrentTimeString();
69};
Class for loading setting file and particle file.
Definition loader.hpp:22
MPS simulation class.
Definition mps.hpp:25
void startSimulation()
void endSimulation()
Loader loader
std::chrono::system_clock::time_point realEndTime
std::string getCurrentTimeString()
std::string calHourMinuteSecond(std::chrono::duration< Rep, Period > d)
double outputPeriod
double time
std::chrono::system_clock::time_point realStartTime
void timeStepReport(const std::chrono::system_clock::time_point &timeStepStartTime, const std::chrono::system_clock::time_point &timeStepEndTime)
Report time step information to the console.
Simulation(std::filesystem::path &settingPath, std::filesystem::path &outputDirectory)
bool saveCondition()
double startTime
double endTime