/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "rodas23.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(rodas23, 0); addToRunTimeSelectionTable(ODESolver, rodas23, dictionary); const scalar rodas23::c3 = 1, rodas23::d1 = 1.0/2.0, rodas23::d2 = 3.0/2.0, rodas23::a31 = 2, rodas23::a41 = 2, rodas23::c21 = 4, rodas23::c31 = 1, rodas23::c32 = -1, rodas23::c41 = 1, rodas23::c42 = -1, rodas23::c43 = -8.0/3.0, rodas23::gamma = 1.0/2.0; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::rodas23::rodas23(const ODESystem& ode, const dictionary& dict) : ODESolver(ode, dict), adaptiveSolver(ode, dict), k1_(n_), k2_(n_), k3_(n_), dy_(n_), err_(n_), dydx_(n_), dfdx_(n_), dfdy_(n_, n_), a_(n_, n_), pivotIndices_(n_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::rodas23::resize() { if (ODESolver::resize()) { adaptiveSolver::resize(n_); resizeField(k1_); resizeField(k2_); resizeField(k3_); resizeField(dy_); resizeField(err_); resizeField(dydx_); resizeField(dfdx_); resizeMatrix(dfdy_); resizeMatrix(a_); resizeField(pivotIndices_); return true; } return false; } Foam::scalar Foam::rodas23::solve ( const scalar x0, const scalarField& y0, const scalarField& dydx0, const scalar dx, scalarField& y ) const { odes_.jacobian(x0, y0, dfdx_, dfdy_); for (label i=0; i