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

Public Member Functions

ModelResult Initialize (SettingsBasin &basinSettings)
 
HydroUnit * AddHydroUnitFromSettings (HydroUnitSettings &unitSettings)
 
void SetNetworkProperties (const SubbasinSettings &subbasinSettings)
 
void SetId (int id)
 
int GetId () const
 
void SetDownstreamId (int id)
 
int GetDownstreamId () const
 
bool IsTerminal () const
 
void SetName (const string &name)
 
const string & GetName () const
 
void SetStructureId (int structureId)
 
int GetStructureId () const
 
double GetLocalArea () const
 
void SetDrainedArea (double area)
 
double GetDrainedArea () const
 
void SetHasUpstream (bool value)
 
bool HasUpstream () const
 
void SetReach (Reach *reach)
 
Reach * GetReach () const
 
void SetInflowVolume (double volume)
 
double GetInflowVolume () const
 
double GetLocalOutlet () const
 
double GetOutletVolume () const
 
double GetOutletDischarge () const
 
bool HasHydroUnit (int id) const
 
bool HasProperty (std::string_view name) const
 
double GetPropertyDouble (std::string_view name, std::string_view unit="") const
 
string GetPropertyString (std::string_view name) const
 
void BuildBasin (SettingsBasin &basinSettings)
 
void ReserveHydroUnits (size_t count)
 
void ReserveBricks (size_t count)
 
void ReserveSplitters (size_t count)
 
void ReserveInputConnectors (size_t count)
 
void ReserveOutputConnectors (size_t count)
 
void ReserveOutletFluxes (size_t count)
 
void ReserveLateralConnectionsForUnits (SettingsBasin &basinSettings)
 
ModelResult AssignFractions (SettingsBasin &basinSettings)
 
void Reset ()
 
void SaveAsInitialState ()
 
void RestoreInitialAreaFractions ()
 
bool IsValid (bool checkProcesses=true) const
 
void Validate () const
 
void AddBrick (std::unique_ptr< Brick > brick)
 
void AddSplitter (std::unique_ptr< Splitter > splitter)
 
void AddHydroUnit (std::unique_ptr< HydroUnit > unit)
 
int GetHydroUnitCount () const
 
void ResetForcingUpdates ()
 
HydroUnit * GetHydroUnit (size_t index) const
 
bool HasHydroUnits () const noexcept
 
HydroUnit * GetHydroUnitById (int id) const
 
vecInt GetHydroUnitIds () const
 
vecDouble GetHydroUnitAreas () const
 
vecInt GetHydroUnitStructureIds () const
 
int GetBrickCount () const
 
int GetSplitterCount () const
 
Brick * GetBrick (size_t index) const
 
bool HasBrick (std::string_view name) const
 
Brick * GetBrick (std::string_view name) const
 
Splitter * GetSplitter (size_t index) const
 
bool HasSplitter (std::string_view name) const
 
Splitter * GetSplitter (std::string_view name) const
 
bool HasIncomingFlow () const
 
void AddInputConnector (Connector *connector)
 
void AddOutputConnector (Connector *connector)
 
void AttachOutletFlux (Flux *pFlux)
 
double * GetValuePointer (std::string_view name)
 
bool ComputeOutletDischarge (double timeStepInDays)
 
double GetArea () const
 

Protected Attributes

int _id = 1
 
int _downstreamId = 0
 
string _name
 
int _structureId = 1
 
double _area
 
double _drainedArea = 0
 
bool _hasUpstream = false
 
Reach * _reach = nullptr
 
double _outletTotal
 
double _inflowVolume = 0
 
double _outletVolume = 0
 
double _outletDischarge = 0
 
double _reachInflow = 0
 
double _reachOutflow = 0
 
double _reachStorage = 0
 
std::vector< std::unique_ptr< HydroUnitProperty > > _properties
 
std::vector< std::unique_ptr< Brick > > _bricks
 
std::unordered_map< string, Brick * > _brickMap
 
std::vector< std::unique_ptr< Splitter > > _splitters
 
std::unordered_map< string, Splitter * > _splitterMap
 
std::vector< std::unique_ptr< HydroUnit > > _hydroUnits
 
std::unordered_map< int, HydroUnit * > _hydroUnitMap
 
std::vector< Connector * > _inConnectors
 
std::vector< Connector * > _outConnectors
 
std::vector< Flux * > _outletFluxes
 

Member Function Documentation

◆ AddBrick()

void Subbasin::AddBrick ( std::unique_ptr< Brick > brick)

Add a brick to the subbasin.

Parameters
brickThe brick to add (ownership transferred).

◆ AddHydroUnit()

void Subbasin::AddHydroUnit ( std::unique_ptr< HydroUnit > unit)

Add a hydro unit to the subbasin.

Parameters
unitThe hydro unit to add (ownership transferred).

◆ AddHydroUnitFromSettings()

HydroUnit * Subbasin::AddHydroUnitFromSettings ( HydroUnitSettings & unitSettings)

Create a hydro unit from its settings and add it to the subbasin.

Parameters
unitSettingsThe settings of the hydro unit.
Returns
the created hydro unit (owned by the subbasin).

◆ AddInputConnector()

void Subbasin::AddInputConnector ( Connector * connector)

Add an input connector to the subbasin.

Parameters
connectorThe input connector to add.

◆ AddOutputConnector()

void Subbasin::AddOutputConnector ( Connector * connector)

Add an output connector to the subbasin.

Parameters
connectorThe output connector to add.

◆ AddSplitter()

void Subbasin::AddSplitter ( std::unique_ptr< Splitter > splitter)

Add a splitter to the subbasin.

Parameters
splitterThe splitter to add (ownership transferred).

◆ AssignFractions()

ModelResult Subbasin::AssignFractions ( SettingsBasin & basinSettings)
nodiscard

Assign the fractions of the basin.

Parameters
basinSettingsThe settings to assign the fractions with.
Returns
True if the assignment was successful, false otherwise.

◆ AttachOutletFlux()

void Subbasin::AttachOutletFlux ( Flux * pFlux)

Attach an outlet flux to the subbasin.

Parameters
pFluxThe outlet flux to attach.

◆ BuildBasin()

void Subbasin::BuildBasin ( SettingsBasin & basinSettings)

Build the basin with the given settings.

Parameters
basinSettingsThe settings to build the basin with.

◆ ComputeOutletDischarge()

bool Subbasin::ComputeOutletDischarge ( double timeStepInDays)
nodiscard

Compute the outlet discharge of the current time step: the subbasin's own runoff, routed through half of its reach when the channel routing does so, plus the volume already routed from upstream.

Parameters
timeStepInDaysThe time step [days].
Returns
true on success.

◆ GetArea()

double Subbasin::GetArea ( ) const
inlinenodiscard

Get the area of the subbasin.

Returns
The area of the subbasin in square meters.

◆ GetBrick() [1/2]

Brick * Subbasin::GetBrick ( size_t index) const
nodiscard

Get a brick by its index.

Parameters
indexThe index of the brick to get.
Returns
The brick at the specified index.

◆ GetBrick() [2/2]

Brick * Subbasin::GetBrick ( std::string_view name) const
nodiscard

Get a brick by its name.

Parameters
nameThe name of the brick to get.
Returns
The brick with the specified name.

◆ GetBrickCount()

int Subbasin::GetBrickCount ( ) const
nodiscard

Get the number of bricks in the subbasin.

Returns
The number of bricks.

◆ GetDownstreamId()

int Subbasin::GetDownstreamId ( ) const
inlinenodiscard

Get the ID of the downstream subbasin (0: terminal outlet of the network).

Returns
the downstream subbasin ID.

◆ GetDrainedArea()

double Subbasin::GetDrainedArea ( ) const
inlinenodiscard

Get the area drained at the subbasin outlet [m2]: the local area plus the area of every upstream subbasin. Set by the river network; equals the local area for a single subbasin.

Returns
the drained area.

◆ GetHydroUnit()

HydroUnit * Subbasin::GetHydroUnit ( size_t index) const
nodiscard

Get a hydro unit by its index.

Parameters
indexThe index of the hydro unit to get.
Returns
The hydro unit at the specified index.

◆ GetHydroUnitAreas()

vecDouble Subbasin::GetHydroUnitAreas ( ) const
nodiscard

Get the areas of all hydro units in the subbasin.

Returns
A vector of hydro unit areas.

◆ GetHydroUnitById()

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

Get a hydro unit by its ID.

Parameters
idThe ID of the hydro unit to get.
Returns
The hydro unit with the specified ID.

◆ GetHydroUnitCount()

int Subbasin::GetHydroUnitCount ( ) const
nodiscard

Get the number of hydro units in the subbasin.

Returns
The number of hydro units.

◆ GetHydroUnitIds()

vecInt Subbasin::GetHydroUnitIds ( ) const
nodiscard

Get the IDs of all hydro units in the subbasin.

Returns
A vector of hydro unit IDs.

◆ GetHydroUnitStructureIds()

vecInt Subbasin::GetHydroUnitStructureIds ( ) const
nodiscard

Get the model-structure ID of each hydro unit in the subbasin.

Returns
A vector of hydro unit structure IDs (defaults to 1).

◆ GetLocalArea()

double Subbasin::GetLocalArea ( ) const
inlinenodiscard

Get the area of the subbasin's own hydro units [m2] (same as GetArea()).

Returns
the local area.

◆ GetLocalOutlet()

double Subbasin::GetLocalOutlet ( ) const
inlinenodiscard

Get the subbasin's own runoff of the current time step [mm over the local area].

Returns
the local outlet total.

◆ GetOutletDischarge()

double Subbasin::GetOutletDischarge ( ) const
inlinenodiscard

Get the outlet discharge of the current time step [mm over the drained area]. Equals the local outlet total for a subbasin without upstream inflow.

Returns
the outlet discharge.

◆ GetOutletVolume()

double Subbasin::GetOutletVolume ( ) const
inlinenodiscard

Get the volume leaving the subbasin outlet in the current time step [m3]: the local runoff plus the routed upstream inflow.

Returns
the outlet volume.

◆ GetPropertyDouble()

double Subbasin::GetPropertyDouble ( std::string_view name,
std::string_view unit = "" ) const
nodiscard

Get a numeric property of the subbasin (e.g. the reach length).

Parameters
nameThe property name.
unitThe unit to convert the value to (optional).
Returns
the property value.

◆ GetPropertyString()

string Subbasin::GetPropertyString ( std::string_view name) const
nodiscard

Get a string property of the subbasin.

Parameters
nameThe property name.
Returns
the property value.

◆ GetSplitter() [1/2]

Splitter * Subbasin::GetSplitter ( size_t index) const
nodiscard

Get a splitter by its index.

Parameters
indexThe index of the splitter to get.
Returns
The splitter at the specified index.

◆ GetSplitter() [2/2]

Splitter * Subbasin::GetSplitter ( std::string_view name) const
nodiscard

Get a splitter by its name.

Parameters
nameThe name of the splitter to get.
Returns
The splitter with the specified name.

◆ GetSplitterCount()

int Subbasin::GetSplitterCount ( ) const
nodiscard

Get the number of splitters in the subbasin.

Returns
The number of splitters.

◆ GetValuePointer()

double * Subbasin::GetValuePointer ( std::string_view name)

Get the value pointer for a specific variable.

Parameters
nameThe name of the variable to get the pointer for.
Returns
A pointer to the variable's value.

◆ HasBrick()

bool Subbasin::HasBrick ( std::string_view name) const
nodiscard

Check if the subbasin has a brick with a specific name.

Parameters
nameThe name of the brick to check for.
Returns
True if the subbasin has the brick, false otherwise.

◆ HasHydroUnit()

bool Subbasin::HasHydroUnit ( int id) const
inlinenodiscard

Check if a hydro unit with the given ID belongs to this subbasin.

Parameters
idThe hydro unit ID.
Returns
true if the unit is in this subbasin.

◆ HasHydroUnits()

bool Subbasin::HasHydroUnits ( ) const
inlinenodiscardnoexcept

Check if the subbasin has any hydro units.

Returns
True if the subbasin has hydro units, false otherwise.

◆ HasIncomingFlow()

bool Subbasin::HasIncomingFlow ( ) const
nodiscard

Check if the subbasin has an incoming flow.

Returns
True if the subbasin has an incoming flow, false otherwise.

◆ HasProperty()

bool Subbasin::HasProperty ( std::string_view name) const
nodiscard

Check if the subbasin has a property with the given name.

Parameters
nameThe property name.
Returns
true if the property exists.

◆ HasSplitter()

bool Subbasin::HasSplitter ( std::string_view name) const
nodiscard

Check if the subbasin has a splitter with a specific name.

Parameters
nameThe name of the splitter to check for.
Returns
True if the subbasin has the splitter, false otherwise.

◆ Initialize()

ModelResult Subbasin::Initialize ( SettingsBasin & basinSettings)
nodiscard

Initialize the subbasin with the given settings.

Parameters
basinSettingsThe settings to initialize the subbasin with.
Returns
True if the initialization was successful, false otherwise.

◆ IsValid()

bool Subbasin::IsValid ( bool checkProcesses = true) const
nodiscard

Check if the subbasin is correctly defined.

Returns
True if everything is correctly defined, false otherwise.

◆ ReserveBricks()

void Subbasin::ReserveBricks ( size_t count)
inline

Reserve space for a number of bricks in the subbasin.

Parameters
countThe number of bricks to reserve space for.

◆ ReserveHydroUnits()

void Subbasin::ReserveHydroUnits ( size_t count)
inline

Reserve space for a number of hydro units in the subbasin.

Parameters
countThe number of hydro units to reserve space for.

◆ ReserveInputConnectors()

void Subbasin::ReserveInputConnectors ( size_t count)
inline

Reserve space for a number of input connectors in the subbasin.

Parameters
countThe number of input connectors to reserve space for.

◆ ReserveLateralConnectionsForUnits()

void Subbasin::ReserveLateralConnectionsForUnits ( SettingsBasin & basinSettings)

Reserve space for a number of lateral connections for hydro units in the subbasin.

Parameters
basinSettingsThe settings to reserve the lateral connections with.

◆ ReserveOutletFluxes()

void Subbasin::ReserveOutletFluxes ( size_t count)
inline

Reserve space for a number of outlet fluxes in the subbasin.

Parameters
countThe number of outlet fluxes to reserve space for.

◆ ReserveOutputConnectors()

void Subbasin::ReserveOutputConnectors ( size_t count)
inline

Reserve space for a number of output connectors in the subbasin.

Parameters
countThe number of output connectors to reserve space for.

◆ ReserveSplitters()

void Subbasin::ReserveSplitters ( size_t count)
inline

Reserve space for a number of splitters in the subbasin.

Parameters
countThe number of splitters to reserve space for.

◆ Reset()

void Subbasin::Reset ( )

Reset the subbasin to its initial state.

◆ ResetForcingUpdates()

void Subbasin::ResetForcingUpdates ( )

Reset all dynamic forcing overrides in all hydro units.

◆ RestoreInitialAreaFractions()

void Subbasin::RestoreInitialAreaFractions ( )

Restore the area fractions of all land covers to their initial extents without touching the stored contents (used after the spin-up phase).

◆ SaveAsInitialState()

void Subbasin::SaveAsInitialState ( )

Save the current state of the subbasin as the initial state.

◆ SetHasUpstream()

void Subbasin::SetHasUpstream ( bool value)
inline

Declare whether other subbasins drain into this one (set by the river network). With an upstream inflow, the outlet discharge is expressed over the drained area instead of the local one.

◆ SetInflowVolume()

void Subbasin::SetInflowVolume ( double volume)
inline

Set the volume routed from the upstream subbasins for the current time step [m3].

Parameters
volumeThe routed inflow volume.

◆ SetNetworkProperties()

void Subbasin::SetNetworkProperties ( const SubbasinSettings & subbasinSettings)

Set the network properties of the subbasin (ID, downstream link, name, properties).

Parameters
subbasinSettingsThe settings of the subbasin.

◆ SetStructureId()

void Subbasin::SetStructureId ( int structureId)
inline

Set the model-structure variant used to build the subbasin-level components (bricks, splitters).

Parameters
structureIdThe structure ID (1 = the primary structure).

◆ Validate()

void Subbasin::Validate ( ) const

Validate that the subbasin is correctly defined. Throws an exception if validation fails.

Exceptions
ModelConfigErrorif validation fails.

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