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

Public Member Functions

void Initialize (const SolverSettings &solverSettings)
 
void SetModel (ModelHydro *model)
 
void ConnectToElementsToSolve ()
 
int GetStateVariableCount () const
 
bool ProcessTimeStep (double timeStepInDays)
 
void GatherState (axd &state) const
 
void ScatterState (const axd &state)
 
void ResetState ()
 
void EvaluateRates (axd &rates, double timeStepInDays, bool applyConstraints=true)
 
void ConstrainRates (axd &rates, double timeStepInDays)
 
void EnforceConstraints (axd &rates, double timeStepInDays)
 
void ApplyRates (const axd &rates, double timeStepInDays)
 
void FinalizeTimeStep ()
 
int GetSolvableConnectionCount () const
 
const vector< Brick * > & GetSolvableBricks () const
 
int GetDirectConnectionCount () const
 

Protected Attributes

std::unique_ptr< Solver_solver
 
ModelHydro_model
 
int _solvableConnectionCount
 
int _directConnectionCount
 
vecDoublePt _stateVariableChanges
 
vector< Brick * > _iterableBricks
 
axd _changeRatesNoSolver
 
axd _ratesBeforeSweep
 

Member Function Documentation

◆ ApplyRates()

void Processor::ApplyRates ( const axd & rates,
double timeStepInDays )

Apply the provided change rates: transfer the water between the bricks and accumulate the resulting content changes over the time step.

Parameters
ratesThe change rate values to apply.
timeStepInDaysThe time step in days.

◆ ConnectToElementsToSolve()

void Processor::ConnectToElementsToSolve ( )

Connect the processor to the elements to solve.

◆ ConstrainRates()

void Processor::ConstrainRates ( axd & rates,
double timeStepInDays )

Link the provided rates to the outgoing fluxes and enforce the storage constraints, evaluated at the current state.

Parameters
ratesThe rate values to constrain (modified in place through the flux links).
timeStepInDaysThe time step in days.

◆ EnforceConstraints()

void Processor::EnforceConstraints ( axd & rates,
double timeStepInDays )

Sweep the brick storage constraints over the linked rates until they are stable (fixpoint iteration), so that the result does not depend on the brick iteration order. The fluxes must already be linked to the provided rates.

Parameters
ratesThe rate values to constrain (modified in place through the flux links).
timeStepInDaysThe time step in days.

◆ EvaluateRates()

void Processor::EvaluateRates ( axd & rates,
double timeStepInDays,
bool applyConstraints = true )

Evaluate the change rates of all solvable processes at the current state.

Rates are per day, independent of the time step. When applyConstraints is true, the rates are linked to the outgoing fluxes and the storage constraints (e.g., maximum capacity, no negative content) are enforced brick by brick during the sweep.

Parameters
ratesThe vector receiving the rates (sized to GetSolvableConnectionCount()); must outlive any subsequent constraint application, as fluxes keep pointers into it.
timeStepInDaysThe time step in days (used by the constraints).
applyConstraintsOption to apply the constraints.

◆ FinalizeTimeStep()

void Processor::FinalizeTimeStep ( )

Finalize the solvable bricks: commit the accumulated content changes.

◆ GatherState()

void Processor::GatherState ( axd & state) const

Gather the current state variable values into the provided vector.

The state variables are the dynamic content changes relative to the start of the time step (all zeros at step start, after the previous Finalize).

Parameters
stateThe vector to fill (sized to GetStateVariableCount()).

◆ GetDirectConnectionCount()

int Processor::GetDirectConnectionCount ( ) const
inline

Get the number of direct connections.

Returns
the number of direct connections.

◆ GetSolvableBricks()

const vector< Brick * > & Processor::GetSolvableBricks ( ) const
inline

Get the bricks handled by the solver, in processing (declaration) order.

Returns
the solvable bricks.

◆ GetSolvableConnectionCount()

int Processor::GetSolvableConnectionCount ( ) const
inline

Get the number of solvable connections.

Returns
the number of solvable connections.

◆ GetStateVariableCount()

int Processor::GetStateVariableCount ( ) const
nodiscard

Get the number of state variables.

Returns
the number of state variables.

◆ Initialize()

void Processor::Initialize ( const SolverSettings & solverSettings)

Initialize the processor with the solver settings.

Parameters
solverSettingssettings of the solver.

◆ ProcessTimeStep()

bool Processor::ProcessTimeStep ( double timeStepInDays)

Process the time step.

Parameters
timeStepInDaysThe time step in days.
Returns
true if the time step was processed successfully, false otherwise.

◆ ResetState()

void Processor::ResetState ( )

Reset all state variables to zero (the start-of-step state).

◆ ScatterState()

void Processor::ScatterState ( const axd & state)

Scatter the provided values into the state variables.

Parameters
stateThe state variable values to set (sized to GetStateVariableCount()).

◆ SetModel()

void Processor::SetModel ( ModelHydro * model)

Set the model.

Parameters
modelmodel to set.

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