55#include " flowy/include/config.hpp"
66#include " flowy/include/definitions.hpp"
77#include " flowy/include/lobe.hpp"
8+ #include " flowy/include/models/mr_lava_loba.hpp"
89#include " flowy/include/topography.hpp"
910#include " flowy/include/topography_file.hpp"
11+ #include < chrono>
1012#include < filesystem>
1113#include < memory>
14+ #include < optional>
1215#include < random>
1316#include < vector>
1417
1518namespace Flowy
1619{
17- class MrLavaLoba ;
20+
21+ /* *
22+ * @brief Track the current state of the Simulation run
23+ *
24+ */
25+ struct SimulationState
26+ {
27+ std::chrono::time_point<std::chrono::high_resolution_clock> t_run_start{};
28+ std::vector<Lobe> lobes{};
29+
30+ int n_lobes_processed = 0 ;
31+ int n_lobes = 0 ;
32+ int idx_flow = 0 ;
33+ int idx_lobe = 0 ;
34+
35+ bool beginning_of_new_flow = true ;
36+ };
37+
38+ enum class FlowStatus
39+ {
40+ Finished,
41+ Ongoing
42+ };
43+
44+ enum class RunStatus
45+ {
46+ Finished,
47+ Ongoing
48+ };
1849
1950class Simulation
2051{
2152public:
22- friend class MrLavaLoba ;
2353 Simulation ( const Config::InputParams & input, std::optional<int > rng_seed );
2454
2555 Config::InputParams input;
@@ -39,20 +69,42 @@ class Simulation
3969
4070 void write_avg_thickness_file ();
4171
42- // Check if the dem has to be written (because of the input.write_dem_every_n_lobes_setting) and, if yes, writes the topography
43- void write_thickness_if_necessary (int n_lobes_processed);
72+ // Check if the dem has to be written (because of the input.write_dem_every_n_lobes_setting) and, if yes, writes the
73+ // topography
74+ void write_thickness_if_necessary ( int n_lobes_processed );
4475
45- // Computes the topography_thickness field by substacting the initial topography and dividing by (1.0 - filling_parameter)
76+ // Computes the topography_thickness field by subtracting the initial topography and dividing by (1.0 - filling_parameter)
4677 void compute_topography_thickness ();
4778
4879 std::unique_ptr<TopographyFile>
4980 get_file_handle ( const Topography & topography, OutputQuantity output_quantity ) const ;
5081
82+ void save_post_run_output ();
83+
5184 void run ();
5285
86+ // Perform `n_steps` steps of the simulation (per step, a single lobe is added to the topography)
87+ RunStatus steps ( int n_steps );
88+
89+ void reset_simulation_state ()
90+ {
91+ simulation_state = std::nullopt ;
92+ }
93+
94+ std::optional<SimulationState> get_simulation_state () const
95+ {
96+ return simulation_state;
97+ }
98+
5399private:
54100 int rng_seed;
55101 std::mt19937 gen{};
102+ std::optional<SimulationState> simulation_state = std::nullopt ;
103+
104+ void post_flow_hook ( int idx_flow, std::vector<Lobe> & lobes );
105+ void process_initial_lobe ( int idx_flow, Lobe & lobe_cur, const CommonLobeDimensions & common_lobe_dimensions );
106+ FlowStatus process_descendent_lobe (
107+ int idx_lobe, std::vector<Lobe> & lobes, const CommonLobeDimensions & common_lobe_dimensions );
56108};
57109
58110} // namespace Flowy
0 commit comments