hydrobricks
Loading...
Searching...
No Matches
HydroUnit Class Reference
Inheritance diagram for HydroUnit:

Public Types

enum  Types { Distributed , SemiDistributed , Lumped , Undefined }
 

Public Member Functions

 HydroUnit (double area=UNDEFINED, Types type=Undefined)
 
void Reset ()
 
void SaveAsInitialState ()
 
void SetProperties (HydroUnitSettings &unitSettings)
 
void AddProperty (std::unique_ptr< HydroUnitProperty > property)
 
double GetPropertyDouble (const string &name, const string &unit="") const
 
float GetPropertyFloat (const string &name, const string &unit="") const
 
string GetPropertyString (const string &name) const
 
void AddBrick (std::unique_ptr< Brick > brick)
 
void AddSplitter (std::unique_ptr< Splitter > splitter)
 
bool HasForcing (VariableType type)
 
void AddForcing (std::unique_ptr< Forcing > forcing)
 
ForcingGetForcing (VariableType type) const
 
void AddLateralConnection (HydroUnit *receiver, double fraction, const string &type="")
 
void ReserveBricks (size_t count)
 
void ReserveLandCoverBricks (size_t count)
 
void ReserveSplitters (size_t count)
 
void ReserveLateralConnections (size_t count)
 
void ReserveForcings (size_t count)
 
int GetBrickCount () const
 
int GetSplitterCount () const
 
BrickGetBrick (size_t index) const
 
bool HasBrick (const string &name) const
 
BrickGetBrick (const string &name) const
 
BrickTryGetBrick (const string &name) const
 
std::vector< Brick * > GetSnowpacks () const
 
LandCoverGetLandCover (const string &name) const
 
LandCoverTryGetLandCover (const string &name) const
 
SplitterGetSplitter (size_t index) const
 
bool HasSplitter (const string &name) const
 
SplitterGetSplitter (const string &name) const
 
SplitterTryGetSplitter (const string &name) const
 
bool IsValid (bool checkProcesses=true) const
 
void Validate () const
 
bool ChangeLandCoverAreaFraction (const string &name, double fraction)
 
bool FixLandCoverFractionsTotal ()
 
Types GetType () const
 
void SetId (int id)
 
double GetArea () const
 
int GetId () const
 
std::vector< HydroUnitLateralConnection * > GetLateralConnections () const
 

Protected Attributes

Types _type
 
int _id
 
double _area
 
std::vector< std::unique_ptr< HydroUnitProperty > > _properties
 
std::vector< std::unique_ptr< HydroUnitLateralConnection > > _lateralConnections
 
std::vector< std::unique_ptr< Brick > > _bricks
 
std::unordered_map< string, Brick * > _brickMap
 
std::vector< LandCover * > _landCoverBricks
 
std::unordered_map< string, LandCover * > _landCoverMap
 
std::vector< std::unique_ptr< Splitter > > _splitters
 
std::unordered_map< string, Splitter * > _splitterMap
 
std::vector< std::unique_ptr< Forcing > > _forcing
 
std::unordered_map< VariableType, Forcing * > _forcingMap
 

Member Function Documentation

◆ AddBrick()

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

Add a brick to the hydro unit.

Parameters
brickThe brick to add.

◆ AddForcing()

void HydroUnit::AddForcing ( std::unique_ptr< Forcing > forcing)

Attach a forcing to the hydro unit.

Parameters
forcingThe forcing to attach.

◆ AddLateralConnection()

void HydroUnit::AddLateralConnection ( HydroUnit * receiver,
double fraction,
const string & type = "" )

Add a lateral connection to the hydro unit.

Parameters
receiverThe hydro unit that receives the lateral connection.
fractionThe fraction of the flow that is transferred.
typeThe type of the lateral connection (optional). It is unused in the current implementation, but can be used for future extensions (for example, to differentiate between snow and groundwater).

◆ AddProperty()

void HydroUnit::AddProperty ( std::unique_ptr< HydroUnitProperty > property)

Add a property to the hydro unit.

Parameters
propertyThe property to add.

◆ AddSplitter()

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

Add a splitter to the hydro unit.

Parameters
splitterThe splitter to add.

◆ ChangeLandCoverAreaFraction()

bool HydroUnit::ChangeLandCoverAreaFraction ( const string & name,
double fraction )

Change the area fraction of a land cover in the hydro unit. Ensure that the sum of all land cover fractions is equal to 1.

Parameters
nameThe name of the land cover to change.
fractionThe new area fraction of the land cover.

◆ FixLandCoverFractionsTotal()

bool HydroUnit::FixLandCoverFractionsTotal ( )

Fix the land cover fractions to ensure that they sum to 1.

Returns
True if the fractions were fixed successfully, false otherwise.

◆ GetArea()

double HydroUnit::GetArea ( ) const
inlinenodiscard

Get the area of the hydro unit.

Returns
The area of the hydro unit [m²]

◆ GetBrick() [1/2]

Brick * HydroUnit::GetBrick ( const string & name) const

Get a brick by its name.

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

◆ GetBrick() [2/2]

Brick * HydroUnit::GetBrick ( size_t index) const

Get a brick by its index.

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

◆ GetBrickCount()

int HydroUnit::GetBrickCount ( ) const

Get the number of bricks in the hydro unit.

Returns
The number of bricks.

◆ GetForcing()

Forcing * HydroUnit::GetForcing ( VariableType type) const

Get a forcing of a specific type.

Parameters
typeThe type of forcing to get.
Returns
The forcing of the specified type.

◆ GetId()

int HydroUnit::GetId ( ) const
inlinenodiscard

Get the ID of the hydro unit.

Returns
The ID of the hydro unit.

◆ GetLandCover()

LandCover * HydroUnit::GetLandCover ( const string & name) const

Get a land cover by its name.

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

◆ GetLateralConnections()

std::vector< HydroUnitLateralConnection * > HydroUnit::GetLateralConnections ( ) const
nodiscard

Get the lateral connections of the hydro unit.

Returns
A vector of lateral connections associated with the hydro unit.

◆ GetPropertyDouble()

double HydroUnit::GetPropertyDouble ( const string & name,
const string & unit = "" ) const

Get a numeric property of the hydro unit.

Parameters
nameThe name of the property to get.
unitThe unit of the property to get.
Returns
The value of the property.

◆ GetPropertyFloat()

float HydroUnit::GetPropertyFloat ( const string & name,
const string & unit = "" ) const

Get a float property of the hydro unit.

Parameters
nameThe name of the property to get.
unitThe unit of the property to get.
Returns
The value of the property.

◆ GetPropertyString()

string HydroUnit::GetPropertyString ( const string & name) const

Get a property of the hydro unit as a string.

Parameters
nameThe name of the property to get.
Returns
The value of the property as a string.

◆ GetSnowpacks()

std::vector< Brick * > HydroUnit::GetSnowpacks ( ) const
inlinenodiscard

Get a vector of all snowpack bricks in the hydro unit.

Returns
A vector of pointers to the snowpack bricks.

◆ GetSplitter() [1/2]

Splitter * HydroUnit::GetSplitter ( const string & name) const

Get a splitter by its name.

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

◆ GetSplitter() [2/2]

Splitter * HydroUnit::GetSplitter ( size_t index) const

Get a splitter by its index.

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

◆ GetSplitterCount()

int HydroUnit::GetSplitterCount ( ) const

Get the number of splitters in the hydro unit.

Returns
The number of splitters.

◆ GetType()

Types HydroUnit::GetType ( ) const
inline

Get the type of the hydro unit.

Returns
The type of the hydro unit.

◆ HasBrick()

bool HydroUnit::HasBrick ( const string & name) const
nodiscard

Check if the hydro unit has a brick with a specific name.

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

◆ HasForcing()

bool HydroUnit::HasForcing ( VariableType type)
nodiscard

Check if the hydro unit has a forcing of a specific type.

Parameters
typeThe type of forcing to check for.
Returns
True if the hydro unit has the forcing, false otherwise.

◆ HasSplitter()

bool HydroUnit::HasSplitter ( const string & name) const
nodiscard

Check if the hydro unit has a splitter with a specific name.

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

◆ IsValid()

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

Check if the hydro unit is properly configured.

Returns
True if everything is correctly defined, false otherwise.

◆ ReserveBricks()

void HydroUnit::ReserveBricks ( size_t count)

Reserve space for a number of bricks in the hydro unit.

Parameters
countThe number of bricks to reserve space for.

◆ ReserveForcings()

void HydroUnit::ReserveForcings ( size_t count)

Reserve space for a number of forcings in the hydro unit.

Parameters
countThe number of forcings to reserve space for.

◆ ReserveLandCoverBricks()

void HydroUnit::ReserveLandCoverBricks ( size_t count)

Reserve space for a number of land cover bricks in the hydro unit.

Parameters
countThe number of land cover bricks to reserve space for.

◆ ReserveLateralConnections()

void HydroUnit::ReserveLateralConnections ( size_t count)

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

Parameters
countThe number of lateral connections to reserve space for.

◆ ReserveSplitters()

void HydroUnit::ReserveSplitters ( size_t count)

Reserve space for a number of splitters in the hydro unit.

Parameters
countThe number of splitters to reserve space for.

◆ Reset()

void HydroUnit::Reset ( )

Reset the hydro unit to its initial state.

◆ SaveAsInitialState()

void HydroUnit::SaveAsInitialState ( )

Save the current state of the hydro unit as the initial state.

◆ SetId()

void HydroUnit::SetId ( int id)
inline

Set the ID of the hydro unit.

Parameters
idThe ID to set.

◆ SetProperties()

void HydroUnit::SetProperties ( HydroUnitSettings & unitSettings)

Set the properties of the hydro unit.

Parameters
unitSettingsThe settings to set.

◆ TryGetBrick()

Brick * HydroUnit::TryGetBrick ( const string & name) const

Try to get a brick by its name without throwing.

Parameters
nameThe name of the brick to get.
Returns
The brick with the specified name, or nullptr if not found.

◆ TryGetLandCover()

LandCover * HydroUnit::TryGetLandCover ( const string & name) const

Try to get a land cover brick by its name without throwing.

Parameters
nameThe name of the land cover to get.
Returns
The land cover with the specified name, or nullptr if not found.

◆ TryGetSplitter()

Splitter * HydroUnit::TryGetSplitter ( const string & name) const

Try to get a splitter by its name without throwing.

Parameters
nameThe name of the splitter to get.
Returns
The splitter with the specified name, or nullptr if not found.

◆ Validate()

void HydroUnit::Validate ( ) const

Validate that the hydro unit is properly configured. Throws an exception if validation fails.

Exceptions
ModelConfigErrorif validation fails.

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