|
hydrobricks
|
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 (std::string_view name, std::string_view unit="") const |
| float | GetPropertyFloat (std::string_view name, std::string_view unit="") const |
| string | GetPropertyString (std::string_view name) const |
| bool | HasProperty (std::string_view name) const |
| void | SetParameterOverride (const string &key, float value) |
| bool | HasParameterOverride (const string &key) const |
| const float * | GetParameterOverridePointer (const string &key) const |
| void | SetParameterOverrideMonthly (const string &key, const vecFloat &values) |
| vector< std::pair< float *, const vecFloat * > > | GetMonthlyParameterOverrides () |
| void | AddBrick (std::unique_ptr< Brick > brick) |
| void | AddSplitter (std::unique_ptr< Splitter > splitter) |
| bool | HasForcing (VariableType type) const |
| void | AddForcing (std::unique_ptr< Forcing > forcing) |
| Forcing * | GetForcing (VariableType type) const |
| void | ResetForcingUpdates () |
| 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 |
| Brick * | GetBrick (size_t index) const |
| bool | HasBrick (std::string_view name) const |
| Brick * | GetBrick (std::string_view name) const |
| Brick * | TryGetBrick (std::string_view name) const |
| std::vector< Brick * > | GetSnowpacks () const |
| double | GetSnowCoverFraction (double sweThreshold=0.1) const |
| double | GetSnowAlbedo (double albedoLand, double sweThreshold=0.1) const |
| LandCover * | GetLandCover (std::string_view name) const |
| LandCover * | TryGetLandCover (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 |
| Splitter * | TryGetSplitter (std::string_view name) const |
| bool | IsValid (bool checkProcesses=true) const |
| void | Validate () const |
| bool | ChangeLandCoverAreaFraction (std::string_view name, double fraction) |
| bool | FixLandCoverFractionsTotal () |
| void | RestoreInitialAreaFractions () |
| LandCover * | GetGenericLandCover () const |
| Types | GetType () const |
| void | SetId (int id) |
| double | GetArea () const |
| int | GetId () const |
| void | SetStructureId (int structureId) |
| int | GetStructureId () const |
| std::vector< HydroUnitLateralConnection * > | GetLateralConnections () const |
Protected Attributes | |
| Types | _type |
| int | _id |
| int | _structureId = 1 |
| 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 |
| std::unordered_map< string, float > | _paramOverrides |
| std::unordered_map< string, vecFloat > | _paramOverridesMonthly |
| void HydroUnit::AddBrick | ( | std::unique_ptr< Brick > | brick | ) |
Add a brick to the hydro unit.
| brick | The brick to add. |
| void HydroUnit::AddForcing | ( | std::unique_ptr< Forcing > | forcing | ) |
Attach a forcing to the hydro unit.
| forcing | The forcing to attach. |
| void HydroUnit::AddLateralConnection | ( | HydroUnit * | receiver, |
| double | fraction, | ||
| const string & | type = "" ) |
Add a lateral connection to the hydro unit.
| receiver | The hydro unit that receives the lateral connection. |
| fraction | The fraction of the flow that is transferred. |
| type | The 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). |
| void HydroUnit::AddProperty | ( | std::unique_ptr< HydroUnitProperty > | property | ) |
Add a property to the hydro unit.
| property | The property to add. |
| void HydroUnit::AddSplitter | ( | std::unique_ptr< Splitter > | splitter | ) |
Add a splitter to the hydro unit.
| splitter | The splitter to add. |
| bool HydroUnit::ChangeLandCoverAreaFraction | ( | std::string_view | 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.
| name | The name of the land cover to change. |
| fraction | The new area fraction of the land cover. |
| bool HydroUnit::FixLandCoverFractionsTotal | ( | ) |
Fix the land cover fractions to ensure that they sum to 1.
|
inlinenodiscard |
Get the area of the hydro unit.
|
nodiscard |
Get a brick by its index.
| index | The index of the brick to get. |
|
nodiscard |
Get a brick by its name.
| name | The name of the brick to get. |
|
nodiscard |
Get the number of bricks in the hydro unit.
|
nodiscard |
Get a forcing of a specific type.
| type | The type of forcing to get. |
|
nodiscard |
Get the generic land cover that absorbs area changes ('open', or its 'ground'/'generic'/'generic_land_cover' aliases).
|
inlinenodiscard |
Get the ID of the hydro unit.
|
nodiscard |
Get a land cover by its name.
| name | The name of the land cover to get. |
|
nodiscard |
Get the lateral connections of the hydro unit.
|
nodiscard |
Get the per-unit monthly parameter overrides, as pairs of the value to write and the 12 monthly values to pick from. Registered with the ParametersUpdater.
|
nodiscard |
Get a stable pointer to a per-unit parameter override value (for the brick/process to read live). The key must exist (HasParameterOverride).
| key | The override key ("<brickName>:<paramName>"). |
|
nodiscard |
Get a numeric property of the hydro unit.
| name | The name of the property to get. |
| unit | The unit of the property to get. |
|
nodiscard |
Get a float property of the hydro unit.
| name | The name of the property to get. |
| unit | The unit of the property to get. |
|
nodiscard |
Get a property of the hydro unit as a string.
| name | The name of the property to get. |
|
nodiscard |
Get the area-weighted surface albedo of the hydro unit for the PREVAH ET reduction: the snow-covered snowpacks contribute their (age-dependent) snow albedo weighted by their parent land-cover fraction, the rest of the unit contributes the snow-free ground albedo: albedo = albedoLand * (1 - snowfrac) + sum_c fraction_c * snowAlbedo_c
| albedoLand | the snow-free ground albedo [-]. |
| sweThreshold | snow water equivalent above which a snowpack counts as snow-covered [mm]. |
|
nodiscard |
Get the snow-covered area fraction of the hydro unit: the sum of the parent land-cover fractions of the snowpacks currently holding snow (used e.g. by the PREVAH snow-albedo ET reduction).
| sweThreshold | snow water equivalent above which a snowpack counts as snow-covered [mm]. |
|
inlinenodiscard |
Get a vector of all snowpack bricks in the hydro unit.
|
nodiscard |
Get a splitter by its index.
| index | The index of the splitter to get. |
|
nodiscard |
Get a splitter by its name.
| name | The name of the splitter to get. |
|
nodiscard |
Get the number of splitters in the hydro unit.
|
inlinenodiscard |
Get the model-structure ID used by this hydro unit.
|
inline |
Get the type of the hydro unit.
|
nodiscard |
Check if the hydro unit has a brick with a specific name.
| name | The name of the brick to check for. |
|
nodiscard |
Check if the hydro unit has a forcing of a specific type.
| type | The type of forcing to check for. |
|
nodiscard |
Check whether a per-unit parameter override exists for a given key.
| key | The override key ("<brickName>:<paramName>"). |
|
nodiscard |
Check whether the hydro unit has a numeric or string property with a given name.
| name | The name of the property to look for. |
|
nodiscard |
Check if the hydro unit has a splitter with a specific name.
| name | The name of the splitter to check for. |
|
nodiscard |
Check if the hydro unit is properly configured.
| void HydroUnit::ReserveBricks | ( | size_t | count | ) |
Reserve space for a number of bricks in the hydro unit.
| count | The number of bricks to reserve space for. |
| void HydroUnit::ReserveForcings | ( | size_t | count | ) |
Reserve space for a number of forcings in the hydro unit.
| count | The number of forcings to reserve space for. |
| void HydroUnit::ReserveLandCoverBricks | ( | size_t | count | ) |
Reserve space for a number of land cover bricks in the hydro unit.
| count | The number of land cover bricks to reserve space for. |
| void HydroUnit::ReserveLateralConnections | ( | size_t | count | ) |
Reserve space for a number of lateral connections in the hydro unit.
| count | The number of lateral connections to reserve space for. |
| void HydroUnit::ReserveSplitters | ( | size_t | count | ) |
Reserve space for a number of splitters in the hydro unit.
| count | The number of splitters to reserve space for. |
| void HydroUnit::Reset | ( | ) |
Reset the hydro unit to its initial state.
| void HydroUnit::ResetForcingUpdates | ( | ) |
Reset all dynamic forcing overrides set during the current timestep.
| void HydroUnit::RestoreInitialAreaFractions | ( | ) |
Restore the area fractions of all land covers to their initial extents without touching the stored contents (used after the spin-up phase).
| void HydroUnit::SaveAsInitialState | ( | ) |
Save the current state of the hydro unit as the initial state.
|
inline |
Set the ID of the hydro unit.
| id | The ID to set. |
| void HydroUnit::SetParameterOverride | ( | const string & | key, |
| float | value ) |
Set a per-unit override value for a model parameter, keyed by "<brickName>:<paramName>". Used for spatial (per-unit) parameters: the brick or process reads this value instead of the shared settings value.
| key | The override key ("<brickName>:<paramName>"). |
| value | The per-unit parameter value. |
| void HydroUnit::SetParameterOverrideMonthly | ( | const string & | key, |
| const vecFloat & | values ) |
Set the 12 monthly values of a per-unit parameter override, keyed by "<brickName>:<paramName>". Used for parameters that are both spatial and monthly (e.g. a field capacity built from a per-unit soil map and a monthly rooting depth). The value the brick reads is seeded with the annual mean and is then rewritten at every month change by the ParametersUpdater.
| key | The override key ("<brickName>:<paramName>"). |
| values | The 12 monthly values (January to December). |
| void HydroUnit::SetProperties | ( | HydroUnitSettings & | unitSettings | ) |
Set the properties of the hydro unit.
| unitSettings | The settings to set. |
|
inline |
Set the model-structure ID used by this hydro unit. Units sharing the same subsurface use the same structure; an exclusive land cover (e.g. a lake) can place a unit on a different structure variant. Defaults to 1.
| structureId | The model-structure ID to use when building this unit. |
|
nodiscard |
Try to get a brick by its name without throwing.
| name | The name of the brick to get. |
|
nodiscard |
Try to get a land cover brick by its name without throwing.
| name | The name of the land cover to get. |
|
nodiscard |
Try to get a splitter by its name without throwing.
| name | The name of the splitter to get. |
| void HydroUnit::Validate | ( | ) | const |
Validate that the hydro unit is properly configured. Throws an exception if validation fails.
| ModelConfigError | if validation fails. |