Skip to content

Commit e15e0ea

Browse files
authored
Merge pull request #37 from flowy-code/stepper_func
Stepper func
2 parents 8520829 + afdb90a commit e15e0ea

8 files changed

Lines changed: 451 additions & 325 deletions

File tree

.github/workflows/pre_commit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v3
1111
- name: Install Conda environment
12-
uses: mamba-org/provision-with-micromamba@main
12+
uses: mamba-org/setup-micromamba@main
13+
with:
14+
environment-file: environment.yml
1315
- name: Run precommit
1416
shell: bash -l {0}
1517
run: |

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repos:
1818
name: cpplint
1919
entry: cpplint
2020
language: system
21-
args: ["--exclude=thirdparty/", "--filter=-whitespace/comments,-runtime/references,-whitespace/indent,-whitespace/parens,-whitespace/braces,-whitespace/line_length,-whitespace/newline,-build/include_order,-readability/todo,-build/namespaces"]
21+
args: ["--exclude=thirdparty/", "--filter=-whitespace/comments,-runtime/references,-whitespace/indent,-whitespace/parens,-whitespace/braces,-whitespace/line_length,-whitespace/newline,-build/include_order,-readability/todo,-build/namespaces,-build/c++11"]
2222
- id: clang-format
2323
name: clang-format
2424
entry: clang-format

flowy/include/models/mr_lava_loba.hpp

Lines changed: 163 additions & 174 deletions
Large diffs are not rendered by default.

flowy/include/simulation.hpp

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,51 @@
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

1518
namespace 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

1950
class Simulation
2051
{
2152
public:
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+
5399
private:
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

meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ _sources = [
3939
_deps = []
4040
pdflib_dep = dependency('pdf_cpplib', fallback : ['pdf_cpplib', 'pdflib_dep'])
4141

42+
with_netcdf = get_option('with_netcdf')
4243
## Netcdf
43-
if get_option('with_netcdf')
44+
if with_netcdf
4445
# On windows the conda-forge netcdf pkg-config file tells us to link against a mysterious debug.lib
4546
# Therefore, we use cmake as the preferred method, which does not make problems
4647
netcdf_dep = dependency('netcdf', language : 'cpp', method: 'cmake', required: false)

0 commit comments

Comments
 (0)