54 maxErr =
max(maxErr,
mag(err[i])/tol);
94 if (odes_.nEqns() != n_)
96 if (odes_.nEqns() > maxN_)
99 <<
"Specified number of equations " << odes_.nEqns()
100 <<
" greater than maximum " << maxN_
106 resizeField(absTol_);
107 resizeField(relTol_);
150 stepState step(dxTry);
153 for (label nStep=0; nStep<maxSteps_; ++nStep)
156 scalar dxTry0 = step.dxTry;
161 if ((
x + step.dxTry - xEnd)*(
x + step.dxTry - xStart) > 0)
164 step.dxTry = xEnd -
x;
171 if ((
x - xEnd)*(xEnd - xStart) >= 0)
173 if (nStep > 0 && step.last)
188 step.prevReject =
true;
193 <<
"Integration steps greater than maximum " << maxSteps_ <<
nl
194 <<
" xStart = " << xStart <<
", xEnd = " << xEnd
195 <<
", x = " <<
x <<
", dxDid = " << step.dxDid <<
nl
Abstract base-class for ODE system solvers.
scalarField absTol_
Absolute convergence tolerance per step.
label nEqns() const noexcept
The number of equations to solve.
scalar normalizeError(const scalarField &y0, const scalarField &y, const scalarField &err) const
Return the nomalized scalar error.
scalarField relTol_
Relative convergence tolerance per step.
const label maxN_
Maximum size of the ODESystem.
ODESolver(const ODESolver &)=delete
No copy construct.
label n_
Size of the ODESystem (adjustable).
const ODESystem & odes_
Reference to ODESystem.
scalarField & absTol() noexcept
Access to the absolute tolerance field.
label maxSteps_
The maximum number of sub-steps allowed for the integration step.
virtual bool resize()=0
Resize the ODE solver.
static void resizeField(UList< Type > &f, const label n)
scalarField & relTol() noexcept
Access to the relative tolerance field.
virtual void solve(scalar &x, scalarField &y, scalar &dxTry) const
Solve the ODE system as far as possible up to dxTry.
Abstract base class for the systems of ordinary differential equations.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
An ODE solver for chemistry.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedScalar y0(const dimensionedScalar &ds)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define forAll(list, i)
Loop across all elements in list.