hydrobricks
Loading...
Searching...
No Matches
Process Class Referenceabstract
Inheritance diagram for Process:
ProcessET ProcessInfiltration ProcessLateral ProcessMelt ProcessOutflow ProcessSublimation ProcessTransform ProcessETExponential ProcessETGR4J ProcessETHBV ProcessETLinear ProcessETOpenWater ProcessETPowerLaw ProcessETSocont ProcessInterceptionGR4J ProcessInfiltrationGR4J ProcessInfiltrationHBV ProcessInfiltrationSocont ProcessLateralSnowRedistributionFrey ProcessLateralSnowSlide ProcessMeltCemaNeige ProcessMeltDegreeDay ProcessMeltDegreeDayAspect ProcessMeltTemperatureIndex ProcessCapillaryHBV ProcessInterceptionMenzel ProcessOutflowDirect ProcessOutflowLinear ProcessOutflowLinearThreshold ProcessOutflowOverflow ProcessOutflowRest ProcessOutflowSlowcomp ProcessOutflowSnowHolding ProcessOutflowSplit ProcessOutflowThreshold ProcessPercolationConstant ProcessPercolationGR4J ProcessPercolationPrevah ProcessProductionGR4J ProcessRoutingDelay ProcessRoutingGR4J ProcessRoutingGR6J ProcessRoutingHBV ProcessRunoffHBV ProcessRunoffSocont ProcessSublimationConstant ProcessSublimationPET ProcessSublimationPrevah ProcessRefreezeDegreeDay ProcessTransformSnowToIceConstant ProcessTransformSnowToIceSwat

Public Member Functions

 Process (WaterContainer *container)
 
virtual void Reset ()
 
virtual bool IsValid () const =0
 
virtual void Validate () const
 
const float * GetParameterValuePointer (const ProcessSettings &processSettings, std::string_view name)
 
void SetParentContext (HydroUnit *unit, Brick *brick)
 
virtual void SetHydroUnitProperties (HydroUnit *unit, Brick *brick)
 
virtual void SetParameters (const ProcessSettings &processSettings)
 
virtual void AttachForcing (Forcing *)
 
void AttachFluxOut (std::unique_ptr< Flux > flux)
 
int GetOutputFluxCount () const
 
Flux * GetOutputFlux (size_t index) const
 
virtual bool ToAtmosphere () const
 
virtual bool RequiresDailyTimeStep () const
 
virtual bool NeedsTargetBrickLinking () const
 
virtual bool NeedsGateBrickLinking () const
 
virtual bool HasConstraintPriority () const
 
virtual int GetConnectionCount () const =0
 
virtual const vecDouble & GetChangeRates ()
 
virtual void StoreInOutgoingFlux (double *rate, int index)
 
void ApplyChange (int connectionIndex, double rate, double timeStepInDays)
 
virtual void Finalize ()
 
virtual vecDoublePt GetStateVariables ()
 
virtual double * GetValuePointer (std::string_view name)
 
const string & GetName () const
 
void SetName (const string &name)
 
void SetTimeMachine (TimeMachine *timeMachine)
 
WaterContainer * GetWaterContainer () const
 
virtual void SetTargetBrick (Brick *)
 
virtual void AddGateBrick (Brick *)
 
virtual bool LinksMultipleTargets () const
 
virtual void AddTargetBrickWithWeights (Brick *, const std::vector< Brick * > &)
 
virtual bool IsLateralProcess () const noexcept
 
virtual bool HasLinearResponse () const
 
virtual double GetLinearResponseRate () const
 
virtual double GetLinearResponseOffset () const
 
bool HasOutputFluxes () const noexcept
 
bool HasWaterContainer () const noexcept
 

Static Public Member Functions

static std::unique_ptr< Process > Factory (const ProcessSettings &processSettings, Brick *brick)
 
static bool RegisterSettings (SettingsModel *modelSettings, const string &processType)
 
static bool HasParameter (const ProcessSettings &processSettings, std::string_view name)
 

Protected Member Functions

double GetForcingRate (Forcing *forcing) const
 
double GetTimeStepInDays () const
 
int GetCurrentDayOfYear () const
 
const vecDouble & StoreRates (std::initializer_list< double > rates)
 
double GetSumChangeRatesOtherProcesses () const
 
virtual const vecDouble & GetRates ()=0
 

Protected Attributes

string _name
 
WaterContainer * _container
 
TimeMachine * _timeMachine {nullptr}
 
HydroUnit * _hydroUnit {nullptr}
 
string _parentBrickName
 
std::vector< std::unique_ptr< Flux > > _outputs
 
vecDouble _changeRates
 

Member Function Documentation

◆ AddGateBrick()

virtual void Process::AddGateBrick ( Brick * )
inlinevirtual

Add a gate brick to the process (read-only state access; no flux). Called once per gate brick; a process reading several aggregates their states.

Parameters
brickgate brick.

Reimplemented in ProcessETWetSurfacePrevah, and ProcessPercolationPrevah.

◆ AddTargetBrickWithWeights()

virtual void Process::AddTargetBrickWithWeights ( Brick * ,
const std::vector< Brick * > &  )
inlinevirtual

Add a target brick together with the bricks whose area fractions weight the flux toward it (used by processes that fan out to several targets).

Parameters
targetthe target brick.
weightSourcesthe bricks (land covers) whose area fractions weight the flux.

Reimplemented in ProcessCapillaryHBV.

◆ ApplyChange()

void Process::ApplyChange ( int connectionIndex,
double rate,
double timeStepInDays )

Apply the change rates to the process.

Parameters
connectionIndexindex of the connection.
ratechange rates.
timeStepInDaystime step in days.

◆ AttachFluxOut()

void Process::AttachFluxOut ( std::unique_ptr< Flux > flux)
inline

Attach outgoing flux.

Parameters
fluxoutgoing flux (ownership transferred)

◆ AttachForcing()

◆ Factory()

std::unique_ptr< Process > Process::Factory ( const ProcessSettings & processSettings,
Brick * brick )
static

Factory method to create a process.

Parameters
processSettingssettings of the process.
brickthe related brick.
Returns
the created process.

◆ Finalize()

virtual void Process::Finalize ( )
inlinevirtual

◆ GetChangeRates()

const vecDouble & Process::GetChangeRates ( )
nodiscardvirtual

Get the change rates of the process.

The returned reference points to a reusable per-process buffer that is overwritten on the next call; consume it before calling again.

Returns
vector of change rates.

Reimplemented in ProcessOutflowSplit, ProcessRoutingDelay, ProcessRoutingGR6J, and ProcessRoutingHBV.

◆ GetConnectionCount()

virtual int Process::GetConnectionCount ( ) const
nodiscardpure virtual

Get the number of connections to the process.

Returns
number of connections to the process.

Implemented in ProcessET, ProcessInfiltration, ProcessLateral, ProcessMelt, ProcessOutflow, ProcessSublimation, and ProcessTransform.

◆ GetCurrentDayOfYear()

int Process::GetCurrentDayOfYear ( ) const
nodiscardprotected

Get the day of the year (1-366) of the current simulation date.

Requires a timer: a process that must also run without one (unit tests) checks _timeMachine itself and applies its own fallback.

Returns
current day of the year.

◆ GetForcingRate()

double Process::GetForcingRate ( Forcing * forcing) const
nodiscardprotected

Read a forcing as the daily rate the processes work with.

A cumulative forcing (precipitation, PET) is given as the amount that falls or is demanded during one time step, so it is divided by the step length; the two coincide at a daily step, which is why this only matters for sub-daily runs. A non-cumulative one (temperature, radiation) is returned untouched: dividing it would be meaningless, and the forcing's own type decides here so that a caller cannot get it wrong.

Parameters
forcingthe forcing to read.
Returns
the value as a rate [unit/d] for a cumulative forcing, the value itself otherwise.

◆ GetLinearResponseOffset()

virtual double Process::GetLinearResponseOffset ( ) const
inlinenodiscardvirtual

Get the constant term of the affine response (rate = k × S − offset), for the reservoirs that drain the content above a threshold θ (offset = k × θ). It is zero for a plain linear reservoir. Only valid when HasLinearResponse() returns true.

Returns
the offset of the linear response [mm/d].

Reimplemented in ProcessOutflowLinearThreshold.

◆ GetLinearResponseRate()

virtual double Process::GetLinearResponseRate ( ) const
inlinenodiscardvirtual

Get the linear response coefficient k of the process (rate = k × S − offset). Only valid when HasLinearResponse() returns true.

Returns
the linear response coefficient [1/d].

Reimplemented in ProcessOutflowLinear, and ProcessOutflowLinearThreshold.

◆ GetName()

const string & Process::GetName ( ) const
inline

Get the name of the process.

Returns
name of the process.

◆ GetOutputFlux()

Flux * Process::GetOutputFlux ( size_t index) const
inline

Get an outgoing flux by its index.

Parameters
indexindex of the flux.
Returns
pointer to the flux.

◆ GetOutputFluxCount()

int Process::GetOutputFluxCount ( ) const
inline

Get the number of outgoing fluxes.

Returns
number of outgoing fluxes.

◆ GetParameterValuePointer()

const float * Process::GetParameterValuePointer ( const ProcessSettings & processSettings,
std::string_view name )

Get the value pointer of a parameter. If the process's hydro unit carries a per-unit (spatial) override for this parameter (keyed by the parent brick), the override pointer is returned instead of the shared settings value.

Parameters
processSettingssettings of the process containing the parameters.
namename of the parameter to get.
Returns
pointer to the value of the parameter.

◆ GetRates()

virtual const vecDouble & Process::GetRates ( )
nodiscardprotectedpure virtual

◆ GetStateVariables()

virtual vecDoublePt Process::GetStateVariables ( )
inlinevirtual

Get pointers to the state variables.

Returns
vector of pointers to the state variables.

◆ GetSumChangeRatesOtherProcesses()

double Process::GetSumChangeRatesOtherProcesses ( ) const
nodiscardprotected

Get the sum of change rates from other processes.

Returns
sum of change rates from other processes.

◆ GetTimeStepInDays()

double Process::GetTimeStepInDays ( ) const
nodiscardprotected

Get the current time step in days.

Falls back on the daily step when no timer is attached (a process built outside a model, as in the unit tests) or when the timer is not initialized yet (it is set up after the structure is built).

Returns
the time step length [d].

◆ GetValuePointer()

double * Process::GetValuePointer ( std::string_view name)
nodiscardvirtual

Get the value pointer for a given element.

Parameters
namename of the element to get.
Returns
pointer to the value of the given element.

Reimplemented in ProcessET, ProcessInfiltration, ProcessLateral, ProcessMelt, ProcessOutflow, ProcessRoutingDelay, ProcessRoutingGR4J, ProcessRoutingGR6J, ProcessRoutingHBV, ProcessSublimation, and ProcessTransform.

◆ GetWaterContainer()

WaterContainer * Process::GetWaterContainer ( ) const
inline

Get the water container associated with the process.

Returns
pointer to the water container.

◆ HasConstraintPriority()

virtual bool Process::HasConstraintPriority ( ) const
inlinenodiscardvirtual

Check if the process takes its demand from the water container with priority when the container cannot satisfy all outgoing rates. Non-priority processes then share the remaining water proportionally. Mirrors sequential (operator-split) reference models such as PREVAH, where snow evaporation is served at the full potential rate before melt.

Returns
true if the process has priority on the container constraints.

Reimplemented in ProcessSublimationPrevah.

◆ HasLinearResponse()

virtual bool Process::HasLinearResponse ( ) const
inlinenodiscardvirtual

Check if the process rate is affine in the container content (rate = k × S − offset). Processes reporting a linear response can be integrated exactly by the analytic solver.

Returns
true if the process rate is linear in the content.

Reimplemented in ProcessOutflowLinear, and ProcessOutflowLinearThreshold.

◆ HasOutputFluxes()

bool Process::HasOutputFluxes ( ) const
inlinenodiscardnoexcept

Check if the process has any output fluxes.

Returns
true if the process has at least one output flux.

◆ HasParameter()

bool Process::HasParameter ( const ProcessSettings & processSettings,
std::string_view name )
staticnodiscard

Check if the process has a parameter with the provided name.

Parameters
processSettingssettings of the process containing the parameters.
namename of the parameter to check.
Returns
true if the process has a parameter with the provided name.

◆ HasWaterContainer()

bool Process::HasWaterContainer ( ) const
inlinenodiscardnoexcept

Check if the process has a water container.

Returns
true if the process has a water container.

◆ IsLateralProcess()

virtual bool Process::IsLateralProcess ( ) const
inlinenodiscardvirtualnoexcept

Check if the process is a lateral process.

Returns
true if the process is a lateral process.

Reimplemented in ProcessLateral, ProcessLateralSnowRedistributionFrey, and ProcessLateralSnowSlide.

◆ IsValid()

◆ LinksMultipleTargets()

virtual bool Process::LinksMultipleTargets ( ) const
inlinenodiscardvirtual

Check if the process links several target bricks (instead of a single one).

Returns
true if the process links several target bricks.

Reimplemented in ProcessCapillaryHBV.

◆ NeedsGateBrickLinking()

virtual bool Process::NeedsGateBrickLinking ( ) const
inlinenodiscardvirtual

Check if the process needs to link a gate brick (a brick whose state modulates the process rate without receiving its flux, e.g. the soil moisture store gating the PREVAH percolation).

Returns
true if the process needs to link a gate brick.

Reimplemented in ProcessETWetSurfacePrevah, and ProcessPercolationPrevah.

◆ NeedsTargetBrickLinking()

virtual bool Process::NeedsTargetBrickLinking ( ) const
inlinenodiscardvirtual

Check if the process needs to link the target brick.

Returns
true if the process needs to link the target brick.

Reimplemented in ProcessCapillaryHBV, and ProcessInfiltration.

◆ RegisterSettings()

bool Process::RegisterSettings ( SettingsModel * modelSettings,
const string & processType )
staticnodiscard

Register the parameters and the needed forcing for the process.

Parameters
modelSettingssettings of the model.
processTypetype of process.
Returns
true if everything is correctly defined.

◆ RequiresDailyTimeStep()

virtual bool Process::RequiresDailyTimeStep ( ) const
inlinenodiscardvirtual

Check whether the process is a discrete daily formulation, which a shorter time step would not refine but simply misread. The GR4J and GR6J routines are such cases: they work on the water volume of a step and advance their unit hydrograph by one slot per step, so their parameters mean days only. A model holding one of these is rejected at initialization unless the time step is a day.

Returns
true if the process only makes sense on a daily time step.

Reimplemented in ProcessETGR4J, ProcessInfiltrationGR4J, ProcessInterceptionGR4J, ProcessPercolationGR4J, ProcessProductionGR4J, ProcessRoutingGR4J, and ProcessRoutingGR6J.

◆ Reset()

void Process::Reset ( )
virtual

◆ SetHydroUnitProperties()

void Process::SetHydroUnitProperties ( HydroUnit * unit,
Brick * brick )
virtual

Set the properties of the hydro unit.

Parameters
unitthe related hydro unit.
brickthe related brick.

Reimplemented in ProcessLateralSnowRedistributionFrey, ProcessLateralSnowSlide, ProcessMeltDegreeDayAspect, and ProcessRunoffSocont.

◆ SetName()

void Process::SetName ( const string & name)
inline

Set the name of the process.

Parameters
namename of the process.

◆ SetParameters()

◆ SetParentContext()

void Process::SetParentContext ( HydroUnit * unit,
Brick * brick )

Set the parent context (hydro unit and owning brick) of the process. Called by the model builder before SetParameters so per-unit (spatial) parameter overrides can be resolved. Non-virtual so subclass SetHydroUnitProperties overrides cannot bypass it.

Parameters
unitthe related hydro unit (may be null for sub-basin processes).
brickthe brick owning this process.

◆ SetTargetBrick()

virtual void Process::SetTargetBrick ( Brick * )
inlinevirtual

Set the target brick for the process.

Parameters
bricktarget brick.

Reimplemented in ProcessInfiltration.

◆ SetTimeMachine()

void Process::SetTimeMachine ( TimeMachine * timeMachine)
inline

Set the time machine (non-owning reference). Required by processes that depend on the current simulation date.

Parameters
timeMachinepointer to the time machine.

◆ StoreInOutgoingFlux()

void Process::StoreInOutgoingFlux ( double * rate,
int index )
virtual

Store the water corresponding to the change rates in the outgoing fluxes.

Parameters
ratechange rates.
indexindex of the flux.

Reimplemented in ProcessOutflowOverflow.

◆ StoreRates()

const vecDouble & Process::StoreRates ( std::initializer_list< double > rates)
inlineprotected

Store change rates in the reusable buffer and return a reference to it.

Reuses the buffer's capacity (no heap allocation after the first call), which matters because this is on the per-timestep solver hot path.

Parameters
ratesthe change rates to store.
Returns
reference to the reusable buffer holding the rates.

◆ ToAtmosphere()

virtual bool Process::ToAtmosphere ( ) const
inlinenodiscardvirtual

Check if the process sends water to the atmosphere.

Returns
true if the process sends water to the atmosphere.

Reimplemented in ProcessET, and ProcessSublimation.

◆ Validate()

void Process::Validate ( ) const
virtual

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

Exceptions
ModelConfigErrorif validation fails.

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