hydrobricks
Loading...
Searching...
No Matches
RiverNetwork Class Reference

#include <RiverNetwork.h>

Public Member Functions

ModelResult Initialize (SettingsBasin &basinSettings)
 
int GetSubbasinCount () const
 
Subbasin * GetSubbasin (size_t index) const
 
Subbasin * GetSubbasinById (int id) const
 
Subbasin * GetOutlet () const
 
const std::vector< Subbasin * > & GetProcessingOrder () const
 
const std::vector< Subbasin * > & GetUpstreamSubbasins (const Subbasin *subbasin) const
 
void TransferInflow (Subbasin *subbasin, double timeStepInDays)
 
void SetChannelRouting (const ChannelRoutingSettings &settings)
 
ModelResult AssignFractions (SettingsBasin &basinSettings)
 
void Reset ()
 
void SaveAsInitialState ()
 
Reach * GetReach (size_t index) const
 
HydroUnit * GetHydroUnitById (int id) const
 
int GetHydroUnitCount () const
 
vecInt GetSubbasinIds () const
 
vecInt GetSubbasinDownstreamIds () const
 
vecDouble GetSubbasinLocalAreas () const
 
vecDouble GetSubbasinDrainedAreas () const
 
double GetTotalArea () const
 

Protected Attributes

std::vector< std::unique_ptr< Subbasin > > _subbasins
 
std::unordered_map< int, Subbasin * > _subbasinMap
 
std::unordered_map< int, HydroUnit * > _hydroUnitMap
 
std::vector< Subbasin * > _order
 
Subbasin * _outlet = nullptr
 
std::vector< std::unique_ptr< Reach > > _reaches
 
std::unordered_map< const Subbasin *, std::vector< Subbasin * > > _upstream
 

Detailed Description

The river network: the tree of subbasins of a catchment. Each subbasin drains into at most one downstream subbasin; exactly one subbasin (the outlet) is terminal. A model without declared subbasins gets a network of one implicit subbasin holding every hydro unit.

The network owns the subbasins and their reaches, keeps the subbasins in processing order (upstream first) and knows the drained area at every outlet. Within a time step, the subbasins are processed in that order: before a subbasin is processed, the outlet volumes of its upstream neighbours (computed earlier in the same step) are routed through its reach and deposited as its inflow (TransferInflow).

Member Function Documentation

◆ AssignFractions()

ModelResult RiverNetwork::AssignFractions ( SettingsBasin & basinSettings)
nodiscard

Assign the land cover fractions of every hydro unit from the basin settings.

Parameters
basinSettingsThe basin settings.
Returns
an empty result on success, else the error message.

◆ GetHydroUnitById()

HydroUnit * RiverNetwork::GetHydroUnitById ( int id) const
nodiscard

Get a hydro unit by ID, searching every subbasin.

Parameters
idThe ID of the hydro unit.
Returns
the hydro unit, or nullptr if the ID is unknown.

◆ GetHydroUnitCount()

int RiverNetwork::GetHydroUnitCount ( ) const
nodiscard

Get the number of hydro units over all the subbasins.

Returns
the number of hydro units.

◆ GetOutlet()

Subbasin * RiverNetwork::GetOutlet ( ) const
inlinenodiscard

Get the terminal subbasin (the catchment outlet).

Returns
the outlet subbasin (nullptr before initialization).

◆ GetProcessingOrder()

const std::vector< Subbasin * > & RiverNetwork::GetProcessingOrder ( ) const
inlinenodiscard

Get the subbasins in processing order: every subbasin comes after all the subbasins draining into it.

Returns
the subbasins, upstream first.

◆ GetReach()

Reach * RiverNetwork::GetReach ( size_t index) const
nodiscard

Get the reach of a subbasin by index, in declaration order.

Parameters
indexThe index of the subbasin.
Returns
the reach.

◆ GetSubbasin()

Subbasin * RiverNetwork::GetSubbasin ( size_t index) const
nodiscard

Get a subbasin by index, in declaration order.

Parameters
indexThe index of the subbasin.
Returns
the subbasin.

◆ GetSubbasinById()

Subbasin * RiverNetwork::GetSubbasinById ( int id) const
nodiscard

Get a subbasin by ID.

Parameters
idThe ID of the subbasin.
Returns
the subbasin, or nullptr if the ID is unknown.

◆ GetSubbasinCount()

int RiverNetwork::GetSubbasinCount ( ) const
inlinenodiscard

Get the number of subbasins.

Returns
the number of subbasins.

◆ GetSubbasinDownstreamIds()

vecInt RiverNetwork::GetSubbasinDownstreamIds ( ) const
nodiscard

Get the downstream subbasin IDs (0: the outlet), in declaration order.

Returns
the downstream subbasin IDs.

◆ GetSubbasinDrainedAreas()

vecDouble RiverNetwork::GetSubbasinDrainedAreas ( ) const
nodiscard

Get the areas drained at the subbasin outlets (own plus upstream) [m2], in declaration order.

Returns
the drained areas.

◆ GetSubbasinIds()

vecInt RiverNetwork::GetSubbasinIds ( ) const
nodiscard

Get the subbasin IDs, in declaration order.

Returns
the subbasin IDs.

◆ GetSubbasinLocalAreas()

vecDouble RiverNetwork::GetSubbasinLocalAreas ( ) const
nodiscard

Get the local areas of the subbasins (their own hydro units) [m2], in declaration order.

Returns
the local areas.

◆ GetTotalArea()

double RiverNetwork::GetTotalArea ( ) const
nodiscard

Get the total area of the catchment [m2] (the area drained at the outlet).

Returns
the total area.

◆ GetUpstreamSubbasins()

const std::vector< Subbasin * > & RiverNetwork::GetUpstreamSubbasins ( const Subbasin * subbasin) const
nodiscard

Get the subbasins draining directly into the given one.

Parameters
subbasinThe receiving subbasin.
Returns
its upstream neighbours (empty for a headwater).

◆ Initialize()

ModelResult RiverNetwork::Initialize ( SettingsBasin & basinSettings)
nodiscard

Build the subbasins and their hydro units from the basin settings, then the processing order and the drained areas. Validates the network first.

Parameters
basinSettingsThe basin settings.
Returns
an empty result on success, else the error message.

◆ Reset()

void RiverNetwork::Reset ( )

Reset the reaches (the subbasins are reset by the model).

◆ SaveAsInitialState()

void RiverNetwork::SaveAsInitialState ( )

Save the state of the reaches as the initial state restored by Reset().

◆ SetChannelRouting()

void RiverNetwork::SetChannelRouting ( const ChannelRoutingSettings & settings)

Set the channel routing scheme and parameters of every reach.

Parameters
settingsThe channel routing settings of the model.

◆ TransferInflow()

void RiverNetwork::TransferInflow ( Subbasin * subbasin,
double timeStepInDays )

Route the outlet volumes of the upstream subbasins through the reach of the given subbasin and set the result as its inflow for the current time step. Must be called before the subbasin is processed and after its upstream neighbours were.

Parameters
subbasinThe receiving subbasin.
timeStepInDaysThe time step [days].

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