hydrobricks
Loading...
Searching...
No Matches
SolverSequential Class Referenceabstract

#include <SolverSequential.h>

Inheritance diagram for SolverSequential:
Solver SolverAnalyticLinear SolverCrankNicolson SolverExponentialEuler SolverImplicitEuler

Public Member Functions

void InitializeContainers () override
 
bool Solve (double timeStepInDays) final
 
- Public Member Functions inherited from Solver
void Connect (Processor *processor)
 

Protected Member Functions

virtual void ComputeBrickRates (Brick *brick, double content, double inflow, double timeStepInDays, int iRateStart)=0
 

Static Protected Member Functions

static double TotalRateAt (Brick *brick, double *contentDelta, double offset)
 
static double StoreRatesAndTotalAt (Brick *brick, double *contentDelta, double offset, vecDouble &rates)
 
static bool SumAffineResponse (Brick *brick, double &rate, double &offset)
 

Protected Attributes

axd _rates
 
- Protected Attributes inherited from Solver
Processor_processor
 

Additional Inherited Members

- Static Public Member Functions inherited from Solver
static std::unique_ptr< SolverFactory (const SolverSettings &solverSettings)
 

Detailed Description

Base class for the sequential solvers.

The bricks are processed one by one in declaration order (upstream before downstream). Each brick receives its inflows as a constant rate over the time step; the subclass computes the brick's average outflow rates over the step. The resulting rates go through the standard constraint and flux machinery, so water propagates through a cascade within the same step.

Member Function Documentation

◆ ComputeBrickRates()

virtual void SolverSequential::ComputeBrickRates ( Brick * brick,
double content,
double inflow,
double timeStepInDays,
int iRateStart )
protectedpure virtual

Compute the average outflow rates of the brick over the time step and store them in the _rates slice starting at iRateStart (one value per process connection, in process declaration order).

Parameters
brickThe brick to solve.
contentStart-of-step content [mm], including instantaneous deposits.
inflowInflows as a constant rate over the step [mm/d].
timeStepInDaysThe time step in days.
iRateStartIndex of the brick's first connection in _rates.

Implemented in SolverAnalyticLinear, SolverCrankNicolson, SolverExponentialEuler, and SolverImplicitEuler.

◆ InitializeContainers()

void SolverSequential::InitializeContainers ( )
overridevirtual

Allocate the internal rate and state buffers to the needed size. Must be called after Connect(), once the processor knows its connection and state counts.

Implements Solver.

◆ Solve()

bool SolverSequential::Solve ( double timeStepInDays)
finalvirtual

Apply the solver.

Parameters
timeStepInDaysThe time step in days.
Returns
True if success, false otherwise.

Implements Solver.

◆ StoreRatesAndTotalAt()

double SolverSequential::StoreRatesAndTotalAt ( Brick * brick,
double * contentDelta,
double offset,
vecDouble & rates )
staticprotected

Store the per-connection rates of the brick's processes, evaluated at the given content offset, and return their sum. The rates are computed once and used both for the total and for the per-connection values, which matters because this sits on the innermost solver loop.

Parameters
brickThe brick to evaluate.
contentDeltaPointer to the container's dynamic content change.
offsetContent offset from the start-of-step content [mm].
ratesThe vector receiving the rates.
Returns
the total outflow rate [mm/d].

◆ SumAffineResponse()

bool SolverSequential::SumAffineResponse ( Brick * brick,
double & rate,
double & offset )
staticprotected

Sum the affine response coefficients of the brick's processes, evaluated at the current content: every process must report an affine response (rate = k S - offset) on a single connection for the sum to be meaningful.

A process may be affine only over part of the content range (a threshold outflow is simply off below its threshold, an empty store produces no outflow at all), so a solution built from these coefficients is a candidate that still has to be checked against the real process rates.

Parameters
brickThe brick to inspect.
rateReceives the summed linear coefficient k [1/d].
offsetReceives the summed offset [mm/d].
Returns
true if every process of the brick reports an affine response.

◆ TotalRateAt()

double SolverSequential::TotalRateAt ( Brick * brick,
double * contentDelta,
double offset )
staticprotected

Sum the rates of all processes of the brick, evaluated at the given content offset. Temporarily writes the offset into the container's dynamic change; the caller must restore it to zero before the constraint pass.

Parameters
brickThe brick to evaluate.
contentDeltaPointer to the container's dynamic content change.
offsetContent offset from the start-of-step content [mm].
Returns
the total outflow rate [mm/d].

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