/*---------------------------------------------------------------------------*\ ========= | \\ / 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 "Rosenbrock12.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(Rosenbrock12, 0); addToRunTimeSelectionTable(ODESolver, Rosenbrock12, dictionary); const scalar Rosenbrock12::gamma = 1 + 1.0/std::sqrt(2.0), Rosenbrock12::a21 = 1.0/gamma, Rosenbrock12::c2 = 1.0, Rosenbrock12::c21 = -2.0/gamma, Rosenbrock12::b1 = (3.0/2.0)/gamma, Rosenbrock12::b2 = (1.0/2.0)/gamma, Rosenbrock12::e1 = b1 - 1.0/gamma, Rosenbrock12::e2 = b2, Rosenbrock12::d1 = gamma, Rosenbrock12::d2 = -gamma; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::Rosenbrock12::Rosenbrock12(const ODESystem& ode, const dictionary& dict) : ODESolver(ode, dict), adaptiveSolver(ode, dict), k1_(n_), k2_(n_), err_(n_), dydx_(n_), dfdx_(n_), dfdy_(n_, n_), a_(n_, n_), pivotIndices_(n_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::Rosenbrock12::resize() { if (ODESolver::resize()) { adaptiveSolver::resize(n_); resizeField(k1_); resizeField(k2_); resizeField(err_); resizeField(dydx_); resizeField(dfdx_); resizeMatrix(dfdy_); resizeMatrix(a_); resizeField(pivotIndices_); return true; } return false; } Foam::scalar Foam::Rosenbrock12::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