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

#include <SolverCrankNicolson.h>

Inheritance diagram for SolverCrankNicolson:
SolverSequential Solver

Protected Member Functions

void ComputeBrickRates (Brick *brick, double content, double inflow, double timeStepInDays, int iRateStart) override
 
- Protected Member Functions inherited from SolverSequential

Additional Inherited Members

- Public Member Functions inherited from SolverSequential
void InitializeContainers () override
 
bool Solve (double timeStepInDays) final
 
- Public Member Functions inherited from Solver
void Connect (Processor *processor)
 
- Static Public Member Functions inherited from Solver
static std::unique_ptr< SolverFactory (const SolverSettings &solverSettings)
 
- Static Protected Member Functions inherited from SolverSequential
static double TotalRateAt (Brick *brick, double *contentDelta, double offset)
 
static void StoreRatesAtCurrentContent (Brick *brick, vecDouble &rates)
 
- Protected Attributes inherited from SolverSequential
axd _rates
 
- Protected Attributes inherited from Solver
Processor_processor
 

Detailed Description

Sequential Crank-Nicolson (implicit trapezoidal) solver.

Each brick is advanced by solving the implicit equation

S(t+h) = S(t) + h (I - (Q(S(t)) + Q(S(t+h))) / 2)

where Q(S) is the total outflow rate of the brick's processes. The scalar equation is solved by bisection, which is robust because Q is non-decreasing in S. The applied rates are the average of the start- and end-of-step process rates, making the scheme second-order accurate and unconditionally stable (A-stable). For very stiff reservoirs (k h >> 1) it can produce a decaying oscillation where implicit Euler stays monotone.

Member Function Documentation

◆ ComputeBrickRates()

void SolverCrankNicolson::ComputeBrickRates ( Brick * brick,
double content,
double inflow,
double timeStepInDays,
int iRateStart )
overrideprotectedvirtual

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.

Implements SolverSequential.


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