Utopia  2
Framework for studying models of complex & adaptive systems.
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Utopia::Models::Geomorphology::Geomorphology Class Reference

A very simple geomorphology model. More...

#include <Geomorphology.hh>

Inheritance diagram for Utopia::Models::Geomorphology::Geomorphology:
Inheritance graph
[legend]
Collaboration diagram for Utopia::Models::Geomorphology::Geomorphology:
Collaboration graph
[legend]

Public Types

using Base = Model< Geomorphology, GeomorphologyTypes >
 The base model type. More...
 
using DataSet = typename Base::DataSet
 Data type for a dataset. More...
 
using GeomorphologyCellManager = CellManager< CellTraits, Geomorphology >
 The type of the cell manager. More...
 
using GeomorphologyCellType = GeomorphologyCellManager::Cell
 A cell in the geomorphology model. More...
 
using GeomorphologyCellIndexType = Utopia::IndexType
 The index type of the Geomorphology cell manager. More...
 
using GmorphCellContainer = Utopia::CellContainer< GeomorphologyCellType >
 The type of a cell container in the Geomorphology model. More...
 
using RuleFunc = typename GeomorphologyCellManager::RuleFunc
 Rule function type, extracted from CellManager. More...
 
- Public Types inherited from Utopia::Model< Geomorphology, GeomorphologyTypes >
using Config = typename ModelTypes::Config
 Data type that holds the configuration. More...
 
using DataManager = DataIO::Default::DefaultDataManager< Geomorphology >
 The data manager to use, specialized with the derived model. More...
 
using DataGroup = typename ModelTypes::DataGroup
 Data type that is used for storing datasets. More...
 
using DataSet = typename ModelTypes::DataSet
 Data type that is used for storing data. More...
 
using RNG = typename ModelTypes::RNG
 Data type of the shared RNG. More...
 
using Space = typename ModelTypes::Space
 Data type of the space this model resides in. More...
 
using Time = typename ModelTypes::Time
 Data type for the model time. More...
 
using Monitor = typename ModelTypes::Monitor
 Data type for the monitor. More...
 
using MonitorManager = typename ModelTypes::MonitorManager
 Data type for the monitor manager. More...
 
using Level = typename ModelTypes::Level
 Data type for the hierarchical level. More...
 

Public Member Functions

template<class ParentModel >
 Geomorphology (const std::string &name, ParentModel &parent_model, const DataIO::Config &custom_cfg={})
 Dataset of watercolumn. More...
 
void build_network ()
 The set of seperately applied rules to build the drainage network. More...
 
void perform_step ()
 Perform step. More...
 
void monitor ()
 Provide monitoring data: tree density and number of clusters. More...
 
void write_data ()
 Write the cell states (aka water content) More...
 
- Public Member Functions inherited from Utopia::Model< Geomorphology, GeomorphologyTypes >
 Model (const std::string &name, const ParentModel &parent_model, const Config &custom_cfg={}, std::tuple< WriterArgs... > w_args={}, const DataIO::Default::DefaultDecidermap< Geomorphology > &w_deciders=DataIO::Default::default_deciders< Geomorphology >, const DataIO::Default::DefaultTriggermap< Geomorphology > &w_triggers=DataIO::Default::default_triggers< Geomorphology >)
 Constructs a Model instance. More...
 
const std::shared_ptr< Space > & get_space () const
 Return the space this model resides in. More...
 
Time get_time () const
 Return the current time of this model. More...
 
Time get_time_max () const
 Return the maximum time possible for this model. More...
 
Config get_cfg () const
 Return the config node of this model. More...
 
std::string get_name () const
 Return the name of this model instance. More...
 
std::string get_full_name () const
 Return the full name of this model within the model hierarchy. More...
 
std::shared_ptr< DataGroupget_hdfgrp () const
 Return a pointer to the HDF group this model stores data in. More...
 
Time get_write_start () const
 Return the parameter that controls when write_data is called first. More...
 
Time get_write_every () const
 Return the parameter that controls how often write_data is called. More...
 
DataManager get_datamanager () const
 return the datamanager More...
 
hsize_t get_remaining_num_writes () const
 Return the number of remaining write_data calls this model will make. More...
 
std::shared_ptr< RNGget_rng () const
 Return a pointer to the shared RNG. More...
 
std::shared_ptr< spdlog::logger > get_logger () const
 Return a pointer to the logger of this model. More...
 
Monitor get_monitor () const
 Return the monitor of this model. More...
 
std::shared_ptr< MonitorManagerget_monitor_manager () const
 Get the monitor manager of the root model. More...
 
Level get_level () const
 Return the hierarchical level within the model hierarchy. More...
 
virtual void prolog ()
 A function that is called before starting model iteration. More...
 
virtual void epilog ()
 A function that is called after the last iteration of a model. More...
 
void iterate ()
 Iterate one (time) step of this model. More...
 
void run ()
 Run the model from the current time to the maximum time. More...
 
std::shared_ptr< DataSetcreate_dset (const std::string name, const std::shared_ptr< DataGroup > &hdfgrp, std::vector< hsize_t > add_write_shape, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={})
 Create a new dataset within the given group. More...
 
std::shared_ptr< DataSetcreate_dset (const std::string name, const std::vector< hsize_t > add_write_shape, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={})
 Create a new dataset within the model's base data group. More...
 
std::shared_ptr< DataSetcreate_cm_dset (const std::string name, const CellManager &cm, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={})
 Create a dataset storing data from a CellManager. More...
 
std::shared_ptr< DataSetcreate_am_dset (const std::string name, const AgentManager &am, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={})
 Create a dataset storing data from a AgentManager. More...
 

Private Member Functions

bool check_eq (const double &a, const double &b)
 Compare two floats for equality. More...
 
template<typename Cell >
bool check_eq_waterline (const Cell &a, const Cell &b)
 Compare the waterline of two cells. More...
 
void _initialize_cells ()
 The initialization of the cells. More...
 
template<typename Cell >
Cell _lowest_grid_neighbor (const Cell &cell)
 Return the lowest cell of the grid-Neighborhood, including cell itself. More...
 
GmorphCellContainer update_lakesites (GmorphCellContainer &lake, GmorphCellContainer &shore)
 Update the CellContainer of lake and shore clls. More...
 

Private Attributes

GeomorphologyCellManager _cm
 The cell manager for the forest fire model. More...
 
std::normal_distribution _uplift
 The random uplift as normal distribution. More...
 
double _stream_power_coef
 The stream power coefficient. More...
 
double _toppling_frequency
 The frequency of possible toppling events per cell. More...
 
double _toppling_critical_height
 The critical height difference to trigget a toppling event. More...
 
double _toppling_slope_reduction_factor
 The factor by which to reduce the slope in a toppling event. More...
 
std::unordered_map< GeomorphologyCellIndexType, std::shared_ptr< GeomorphologyCellType > > _lowest_neighbors
 
const double _float_precision
 
std::uniform_real_distribution _prob_dist
 precision when comparing floats More...
 
std::shared_ptr< DataSet_dset_height
 
std::shared_ptr< DataSet_dset_drainage_area
 Dataset of rock height. More...
 
std::shared_ptr< DataSet_dset_watercolumn
 Dataset of drainage area. More...
 
RuleFunc uplift_rule
 The rule how to uplift. More...
 
RuleFunc erode
 The rule how to erode with stream power. More...
 
RuleFunc toppling
 The rule how to topple / landslide. More...
 
RuleFunc reset_network
 The rule to reset the drainage network. More...
 
RuleFunc connect_cells
 Build a rudimentary network. More...
 
RuleFunc build_lake
 Fill a sink with water. More...
 
RuleFunc pass_drainage_area
 Make a drainage process from this cell. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Utopia::Model< Geomorphology, GeomorphologyTypes >
void __perform_step ()
 Perform the computation of a step. More...
 
void __monitor ()
 Monitor information in the terminal. More...
 
void __write_data ()
 Write data; calls the implementation's write_data method. More...
 
void __write_initial_state ()
 Write the initial state. More...
 
void increment_time (const Time dt=1)
 Increment time. More...
 
void __prolog ()
 The default prolog of a model. More...
 
void __epilog ()
 The default epilog of a model. More...
 
Geomorphology & impl ()
 cast to the derived class More...
 
const Geomorphology & impl () const
 const cast to the derived interface More...
 
- Protected Attributes inherited from Utopia::Model< Geomorphology, GeomorphologyTypes >
const std::string _name
 Name of the model instance. More...
 
const std::string _full_name
 The full name within the model hierarchy. More...
 
const Level _level
 The level within the model hierarchy. More...
 
const Config _cfg
 Config node belonging to this model instance. More...
 
const std::shared_ptr< RNG_rng
 The RNG shared between models. More...
 
const std::shared_ptr< spdlog::logger > _log
 The (model) logger. More...
 
std::shared_ptr< Space_space
 The space this model resides in. More...
 
Time _time
 Model-internal current time stamp. More...
 
const Time _time_max
 Model-internal maximum time stamp. More...
 
const std::shared_ptr< DataGroup_hdfgrp
 The HDF group this model instance should write its data to. More...
 
const Time _write_start
 First time at which write_data is called. More...
 
const Time _write_every
 How often to call write_data from iterate. More...
 
Monitor _monitor
 The monitor. More...
 
DataManager _datamanager
 Manager object for handling data output; see DataManager. More...
 
- Static Protected Attributes inherited from Utopia::Model< Geomorphology, GeomorphologyTypes >
static constexpr WriteMode _write_mode
 Which data-writing mode the base model should use. More...
 

Detailed Description

A very simple geomorphology model.

Member Typedef Documentation

◆ Base

The base model type.

◆ DataSet

Data type for a dataset.

◆ GeomorphologyCellIndexType

The index type of the Geomorphology cell manager.

◆ GeomorphologyCellManager

The type of the cell manager.

◆ GeomorphologyCellType

A cell in the geomorphology model.

◆ GmorphCellContainer

The type of a cell container in the Geomorphology model.

◆ RuleFunc

Rule function type, extracted from CellManager.

Constructor & Destructor Documentation

◆ Geomorphology()

template<class ParentModel >
Utopia::Models::Geomorphology::Geomorphology::Geomorphology ( const std::string &  name,
ParentModel &  parent_model,
const DataIO::Config custom_cfg = {} 
)
inline

Dataset of watercolumn.

Construct the Geomorphology model

Parameters
nameName of this model instance; is used to extract the configuration from the parent model and set up a HDFGroup for this instance
parent_modelThe parent model this model instance resides in
custom_cfgA custom configuration to use instead of the one extracted from the parent model using the instance name

Member Function Documentation

◆ _initialize_cells()

void Utopia::Models::Geomorphology::Geomorphology::_initialize_cells ( )
inlineprivate

The initialization of the cells.

Adds the inclination to the cells initial rock height.

Defines the outflow boundary.

Initializes the drainage network and lakes

◆ _lowest_grid_neighbor()

template<typename Cell >
Cell Utopia::Models::Geomorphology::Geomorphology::_lowest_grid_neighbor ( const Cell cell)
inlineprivate

Return the lowest cell of the grid-Neighborhood, including cell itself.

◆ build_network()

void Utopia::Models::Geomorphology::Geomorphology::build_network ( )
inline

The set of seperately applied rules to build the drainage network.

  1. Reset network
  2. Connect cells to basic netork
  3. Fill sinks with water, completing the network
  4. Calculate the drainage area on every cell

◆ check_eq()

bool Utopia::Models::Geomorphology::Geomorphology::check_eq ( const double &  a,
const double &  b 
)
inlineprivate

Compare two floats for equality.

◆ check_eq_waterline()

template<typename Cell >
bool Utopia::Models::Geomorphology::Geomorphology::check_eq_waterline ( const Cell a,
const Cell b 
)
inlineprivate

Compare the waterline of two cells.

◆ monitor()

void Utopia::Models::Geomorphology::Geomorphology::monitor ( )
inline

Provide monitoring data: tree density and number of clusters.

◆ perform_step()

void Utopia::Models::Geomorphology::Geomorphology::perform_step ( )
inline

Perform step.

◆ update_lakesites()

GmorphCellContainer Utopia::Models::Geomorphology::Geomorphology::update_lakesites ( GmorphCellContainer lake,
GmorphCellContainer shore 
)
inlineprivate

Update the CellContainer of lake and shore clls.

Parameters
lakeReference to a Container of lake cells. Lake: cells of equal waterline.
shoreReference to the Cells neighboring the lake
Returns
CellContainer of all cells connected and of same waterline as the given lake Container.

\Note updates the shore Container to match the new lake

◆ write_data()

void Utopia::Models::Geomorphology::Geomorphology::write_data ( )
inline

Write the cell states (aka water content)

The cell height is currently not written out as in the current implementation it does not change over time (erosion is not yet included).

Member Data Documentation

◆ _cm

GeomorphologyCellManager Utopia::Models::Geomorphology::Geomorphology::_cm
private

The cell manager for the forest fire model.

◆ _dset_drainage_area

std::shared_ptr<DataSet> Utopia::Models::Geomorphology::Geomorphology::_dset_drainage_area
private

Dataset of rock height.

◆ _dset_height

std::shared_ptr<DataSet> Utopia::Models::Geomorphology::Geomorphology::_dset_height
private

◆ _dset_watercolumn

std::shared_ptr<DataSet> Utopia::Models::Geomorphology::Geomorphology::_dset_watercolumn
private

Dataset of drainage area.

◆ _float_precision

const double Utopia::Models::Geomorphology::Geomorphology::_float_precision
private

◆ _lowest_neighbors

std::unordered_map<GeomorphologyCellIndexType, std::shared_ptr<GeomorphologyCellType> > Utopia::Models::Geomorphology::Geomorphology::_lowest_neighbors
private

◆ _prob_dist

std::uniform_real_distribution Utopia::Models::Geomorphology::Geomorphology::_prob_dist
private

precision when comparing floats

A re-usable uniform real distribution to evaluate probabilities

◆ _stream_power_coef

double Utopia::Models::Geomorphology::Geomorphology::_stream_power_coef
private

The stream power coefficient.

◆ _toppling_critical_height

double Utopia::Models::Geomorphology::Geomorphology::_toppling_critical_height
private

The critical height difference to trigget a toppling event.

The probability of a toppling event is given as \( p = \Delta h / h_{crit} \), where \( \Delta h \) is the difference in height between a target cell and its highest neighbor.

◆ _toppling_frequency

double Utopia::Models::Geomorphology::Geomorphology::_toppling_frequency
private

The frequency of possible toppling events per cell.

◆ _toppling_slope_reduction_factor

double Utopia::Models::Geomorphology::Geomorphology::_toppling_slope_reduction_factor
private

The factor by which to reduce the slope in a toppling event.

The difference in height between the source and target cell of the toppling event is divided by this factor. This amount of rock is removed from the source and added to the target site.

default value: 3.

◆ _uplift

std::normal_distribution Utopia::Models::Geomorphology::Geomorphology::_uplift
private

The random uplift as normal distribution.

◆ build_lake

RuleFunc Utopia::Models::Geomorphology::Geomorphology::build_lake
private

Fill a sink with water.

such that there is a shore cell to the resulting lake that is either outflow or lower than the lakes waterline.

Updates the _lowest_neighbors map for all lake cells to point to the outflow alias a Cell within lake neighboring the lower shore cell.

Note
Must be updated in an asynchronous way. No shuffle needed.

◆ connect_cells

RuleFunc Utopia::Models::Geomorphology::Geomorphology::connect_cells
private
Initial value:
= [this](const auto& cell) {
if (cell->state.is_outflow) {
_lowest_neighbors[cell->id()] = cell;
return cell->state;
}
_lowest_neighbors[cell->id()] = this->_lowest_grid_neighbor(cell);
return cell->state;
}
Cell _lowest_grid_neighbor(const Cell &cell)
Return the lowest cell of the grid-Neighborhood, including cell itself.
Definition: Geomorphology.hh:327
std::unordered_map< GeomorphologyCellIndexType, std::shared_ptr< GeomorphologyCellType > > _lowest_neighbors
Definition: Geomorphology.hh:135

Build a rudimentary network.

Create map: cells to their lowest_neighbor (random choice if multiple). Sinks (no lower neighbor or outflow) map to themselfes.

◆ erode

RuleFunc Utopia::Models::Geomorphology::Geomorphology::erode
private
Initial value:
= [this](const auto& cell) {
auto state = cell->state;
double slope = state.waterline();
if (not state.is_outflow) {
slope -= _lowest_neighbors[cell->id()]->state.waterline();
}
double stream_power = ( _stream_power_coef * slope
* std::sqrt(state.drainage_area));
state.rock -= std::min(stream_power, state.rock);
return state;
}
double _stream_power_coef
The stream power coefficient.
Definition: Geomorphology.hh:111

The rule how to erode with stream power.

◆ pass_drainage_area

RuleFunc Utopia::Models::Geomorphology::Geomorphology::pass_drainage_area
private
Initial value:
= [this](auto& cell) {
auto state = cell->state;
state.was_drained = true;
if (not state.is_outflow and _lowest_neighbors[cell->id()] == cell) {
throw std::runtime_error("No recipient assigned to a cell!");
}
if (state.is_outflow) {
return state;
}
auto downstream_cell = _lowest_neighbors[cell->id()];
downstream_cell->state.drainage_area += state.drainage_area;
while(not downstream_cell->state.is_outflow and
downstream_cell->state.was_drained)
{
downstream_cell = _lowest_neighbors[downstream_cell->id()];
downstream_cell->state.drainage_area += state.drainage_area;
if (downstream_cell->state.drainage_area > size(this->_cm.cells()))
{
throw std::runtime_error("Drainage network has loop!");
}
}
return state;
}
const CellContainer< Cell > & cells() const
Return const reference to the managed CA cells.
Definition: cell_manager.hh:219
GeomorphologyCellManager _cm
The cell manager for the forest fire model.
Definition: Geomorphology.hh:102

Make a drainage process from this cell.

Pass the cells drainage area through the already drained downstream cells up to an outflow or not already drained cell.

Note
Must be updated in an asynchronous way. No shuffle needed.

◆ reset_network

RuleFunc Utopia::Models::Geomorphology::Geomorphology::reset_network
private
Initial value:
= [](const auto& cell) {
auto state = cell->state;
state.drainage_area = 1.;
state.was_drained = false;
state.watercolumn = 0.;
return state;
}

The rule to reset the drainage network.

◆ toppling

RuleFunc Utopia::Models::Geomorphology::Geomorphology::toppling
private
Initial value:
= [this](const auto& cell) {
auto state = cell->state;
if (_toppling_frequency == 0. or
_toppling_frequency < this->_prob_dist(*(this->_rng))
) {
return state;
}
auto nbrs = this->_cm.neighbors_of(cell);
auto heighest_neighbor = cell;
for (auto& nb : nbrs) {
if (nb->state.waterline() > heighest_neighbor->state.waterline())
{
heighest_neighbor = nb;
}
}
double relief = ( heighest_neighbor->state.waterline()
- state.waterline());
double failure_prob = relief / _toppling_critical_height;
if (this->_prob_dist(*(this->_rng)) < failure_prob) {
heighest_neighbor->state.rock -= relief / factor;
state.rock += relief / factor;
}
return state;
}
CellContainer< Cell > neighbors_of(const Cell &cell) const
Retrieve the given cell's neighbors.
Definition: cell_manager.hh:458
const std::shared_ptr< RNG > _rng
The RNG shared between models.
Definition: model.hh:161
double _toppling_critical_height
The critical height difference to trigget a toppling event.
Definition: Geomorphology.hh:121
double _toppling_slope_reduction_factor
The factor by which to reduce the slope in a toppling event.
Definition: Geomorphology.hh:131
double _toppling_frequency
The frequency of possible toppling events per cell.
Definition: Geomorphology.hh:114
std::uniform_real_distribution _prob_dist
precision when comparing floats
Definition: Geomorphology.hh:141

The rule how to topple / landslide.

Note
Only evaluated with _toppling_frequency per cell

Failure of slope occurs with p = (h_i - h_j) / h_c

On failure slope is reduced to 1/3. of its initial value.

◆ uplift_rule

RuleFunc Utopia::Models::Geomorphology::Geomorphology::uplift_rule
private
Initial value:
= [this](const auto& cell) {
auto state = cell->state;
state.rock += this->_uplift(*(this->_rng));
return state;
}
std::normal_distribution _uplift
The random uplift as normal distribution.
Definition: Geomorphology.hh:108

The rule how to uplift.


The documentation for this class was generated from the following file: