Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/pre_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Conda environment
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@main
with:
environment-file: environment.yml
- name: Run precommit
shell: bash -l {0}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
name: cpplint
entry: cpplint
language: system
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"]
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"]
- id: clang-format
name: clang-format
entry: clang-format
Expand Down
337 changes: 163 additions & 174 deletions flowy/include/models/mr_lava_loba.hpp

Large diffs are not rendered by default.

62 changes: 57 additions & 5 deletions flowy/include/simulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,51 @@
#include "flowy/include/config.hpp"
#include "flowy/include/definitions.hpp"
#include "flowy/include/lobe.hpp"
#include "flowy/include/models/mr_lava_loba.hpp"
#include "flowy/include/topography.hpp"
#include "flowy/include/topography_file.hpp"
#include <chrono>
#include <filesystem>
#include <memory>
#include <optional>
#include <random>
#include <vector>

namespace Flowy
{
class MrLavaLoba;

/**
* @brief Track the current state of the Simulation run
*
*/
struct SimulationState
{
std::chrono::time_point<std::chrono::high_resolution_clock> t_run_start{};
std::vector<Lobe> lobes{};

int n_lobes_processed = 0;
int n_lobes = 0;
int idx_flow = 0;
int idx_lobe = 0;

bool beginning_of_new_flow = true;
};

enum class FlowStatus
{
Finished,
Ongoing
};

enum class RunStatus
{
Finished,
Ongoing
};

class Simulation
{
public:
friend class MrLavaLoba;
Simulation( const Config::InputParams & input, std::optional<int> rng_seed );

Config::InputParams input;
Expand All @@ -39,20 +69,42 @@ class Simulation

void write_avg_thickness_file();

// Check if the dem has to be written (because of the input.write_dem_every_n_lobes_setting) and, if yes, writes the topography
void write_thickness_if_necessary(int n_lobes_processed);
// Check if the dem has to be written (because of the input.write_dem_every_n_lobes_setting) and, if yes, writes the
// topography
void write_thickness_if_necessary( int n_lobes_processed );

// Computes the topography_thickness field by substacting the initial topography and dividing by (1.0 - filling_parameter)
// Computes the topography_thickness field by subtracting the initial topography and dividing by (1.0 - filling_parameter)
void compute_topography_thickness();

std::unique_ptr<TopographyFile>
get_file_handle( const Topography & topography, OutputQuantity output_quantity ) const;

void save_post_run_output();

void run();

// Perform `n_steps` steps of the simulation (per step, a single lobe is added to the topography)
RunStatus steps( int n_steps );

void reset_simulation_state()
{
simulation_state = std::nullopt;
}

std::optional<SimulationState> get_simulation_state() const
{
return simulation_state;
}

private:
int rng_seed;
std::mt19937 gen{};
std::optional<SimulationState> simulation_state = std::nullopt;

void post_flow_hook( int idx_flow, std::vector<Lobe> & lobes );
void process_initial_lobe( int idx_flow, Lobe & lobe_cur, const CommonLobeDimensions & common_lobe_dimensions );
FlowStatus process_descendent_lobe(
int idx_lobe, std::vector<Lobe> & lobes, const CommonLobeDimensions & common_lobe_dimensions );
};

} // namespace Flowy
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ _sources = [
_deps = []
pdflib_dep = dependency('pdf_cpplib', fallback : ['pdf_cpplib', 'pdflib_dep'])

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