mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ODE: Renamed to ODESystem
Also some additional documentation
This commit is contained in:
@ -27,7 +27,7 @@ Description
|
|||||||
|
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "IOmanip.H"
|
#include "IOmanip.H"
|
||||||
#include "ODE.H"
|
#include "ODESystem.H"
|
||||||
#include "ODESolver.H"
|
#include "ODESolver.H"
|
||||||
#include "RK.H"
|
#include "RK.H"
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ using namespace Foam;
|
|||||||
|
|
||||||
class testODE
|
class testODE
|
||||||
:
|
:
|
||||||
public ODE
|
public ODESystem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -107,9 +107,13 @@ int main(int argc, char *argv[])
|
|||||||
argList::validArgs.append("ODESolver");
|
argList::validArgs.append("ODESolver");
|
||||||
argList args(argc, argv);
|
argList args(argc, argv);
|
||||||
|
|
||||||
|
// Create the ODE system
|
||||||
testODE ode;
|
testODE ode;
|
||||||
|
|
||||||
|
// Create the selected ODE system solver
|
||||||
autoPtr<ODESolver> odeSolver = ODESolver::New(args[1], ode);
|
autoPtr<ODESolver> odeSolver = ODESolver::New(args[1], ode);
|
||||||
|
|
||||||
|
// Initialise the ODE system fields
|
||||||
scalar xStart = 1.0;
|
scalar xStart = 1.0;
|
||||||
scalarField yStart(ode.nEqns());
|
scalarField yStart(ode.nEqns());
|
||||||
yStart[0] = ::Foam::j0(xStart);
|
yStart[0] = ::Foam::j0(xStart);
|
||||||
@ -117,6 +121,7 @@ int main(int argc, char *argv[])
|
|||||||
yStart[2] = ::Foam::jn(2, xStart);
|
yStart[2] = ::Foam::jn(2, xStart);
|
||||||
yStart[3] = ::Foam::jn(3, xStart);
|
yStart[3] = ::Foam::jn(3, xStart);
|
||||||
|
|
||||||
|
// Print the evolution of the solution and the time-step
|
||||||
scalarField dyStart(ode.nEqns());
|
scalarField dyStart(ode.nEqns());
|
||||||
ode.derivatives(xStart, yStart, dyStart);
|
ode.derivatives(xStart, yStart, dyStart);
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ const scalar
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::KRR4::KRR4(const ODE& ode)
|
Foam::KRR4::KRR4(const ODESystem& ode)
|
||||||
:
|
:
|
||||||
ODESolver(ode),
|
ODESolver(ode),
|
||||||
yTemp_(n_, 0.0),
|
yTemp_(n_, 0.0),
|
||||||
@ -76,7 +76,7 @@ Foam::KRR4::KRR4(const ODE& ode)
|
|||||||
|
|
||||||
void Foam::KRR4::solve
|
void Foam::KRR4::solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
scalar& x,
|
scalar& x,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
scalarField& dydx,
|
scalarField& dydx,
|
||||||
@ -168,7 +168,7 @@ void Foam::KRR4::solve
|
|||||||
(
|
(
|
||||||
"void Foam::KRR4::solve"
|
"void Foam::KRR4::solve"
|
||||||
"("
|
"("
|
||||||
"const ODE&, "
|
"const ODESystem&, "
|
||||||
"scalar&, "
|
"scalar&, "
|
||||||
"scalarField&, "
|
"scalarField&, "
|
||||||
"scalarField&, "
|
"scalarField&, "
|
||||||
@ -206,7 +206,7 @@ void Foam::KRR4::solve
|
|||||||
(
|
(
|
||||||
"void Foam::KRR4::solve"
|
"void Foam::KRR4::solve"
|
||||||
"("
|
"("
|
||||||
"const ODE&, "
|
"const ODESystem&, "
|
||||||
"scalar&, "
|
"scalar&, "
|
||||||
"scalarField&, "
|
"scalarField&, "
|
||||||
"scalarField&, "
|
"scalarField&, "
|
||||||
|
|||||||
@ -88,14 +88,14 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from ODE
|
//- Construct from ODE
|
||||||
KRR4(const ODE& ode);
|
KRR4(const ODESystem& ode);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
void solve
|
void solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
scalar& x,
|
scalar& x,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
scalarField& dydx,
|
scalarField& dydx,
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::ODESolver::ODESolver(const ODE& ode)
|
Foam::ODESolver::ODESolver(const ODESystem& ode)
|
||||||
:
|
:
|
||||||
n_(ode.nEqns()),
|
n_(ode.nEqns()),
|
||||||
yScale_(n_),
|
yScale_(n_),
|
||||||
@ -48,7 +48,7 @@ Foam::ODESolver::ODESolver(const ODE& ode)
|
|||||||
|
|
||||||
void Foam::ODESolver::solve
|
void Foam::ODESolver::solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
const scalar xStart,
|
const scalar xStart,
|
||||||
const scalar xEnd,
|
const scalar xEnd,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
@ -102,7 +102,7 @@ void Foam::ODESolver::solve
|
|||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"ODESolver::solve"
|
"ODESolver::solve"
|
||||||
"(const ODE& ode, const scalar xStart, const scalar xEnd,"
|
"(const ODESystem& ode, const scalar xStart, const scalar xEnd,"
|
||||||
"scalarField& yStart, const scalar eps, scalar& hEst) const"
|
"scalarField& yStart, const scalar eps, scalar& hEst) const"
|
||||||
) << "Too many integration steps"
|
) << "Too many integration steps"
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,7 +25,7 @@ Class
|
|||||||
Foam::ODESolver
|
Foam::ODESolver
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Selection for ODE solver
|
Abstract base-class for ODE system solvers
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
ODESolver.C
|
ODESolver.C
|
||||||
@ -35,7 +35,7 @@ SourceFiles
|
|||||||
#ifndef ODESolver_H
|
#ifndef ODESolver_H
|
||||||
#define ODESolver_H
|
#define ODESolver_H
|
||||||
|
|
||||||
#include "ODE.H"
|
#include "ODESystem.H"
|
||||||
#include "typeInfo.H"
|
#include "typeInfo.H"
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
autoPtr,
|
autoPtr,
|
||||||
ODESolver,
|
ODESolver,
|
||||||
ODE,
|
ODE,
|
||||||
(const ODE& ode),
|
(const ODESystem& ode),
|
||||||
(ode)
|
(ode)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct for given ODE
|
//- Construct for given ODE
|
||||||
ODESolver(const ODE& ode);
|
ODESolver(const ODESystem& ode);
|
||||||
|
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
static autoPtr<ODESolver> New
|
static autoPtr<ODESolver> New
|
||||||
(
|
(
|
||||||
const word& ODESolverTypeName,
|
const word& ODESolverTypeName,
|
||||||
const ODE& ode
|
const ODESystem& ode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ public:
|
|||||||
|
|
||||||
virtual void solve
|
virtual void solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
scalar& x,
|
scalar& x,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
scalarField& dydx,
|
scalarField& dydx,
|
||||||
@ -126,7 +126,7 @@ public:
|
|||||||
|
|
||||||
virtual void solve
|
virtual void solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
const scalar xStart,
|
const scalar xStart,
|
||||||
const scalar xEnd,
|
const scalar xEnd,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
|
|||||||
@ -30,7 +30,7 @@ License
|
|||||||
Foam::autoPtr<Foam::ODESolver> Foam::ODESolver::New
|
Foam::autoPtr<Foam::ODESolver> Foam::ODESolver::New
|
||||||
(
|
(
|
||||||
const Foam::word& ODESolverTypeName,
|
const Foam::word& ODESolverTypeName,
|
||||||
const Foam::ODE& ode
|
const Foam::ODESystem& ode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "Selecting ODE solver " << ODESolverTypeName << endl;
|
Info<< "Selecting ODE solver " << ODESolverTypeName << endl;
|
||||||
@ -42,7 +42,7 @@ Foam::autoPtr<Foam::ODESolver> Foam::ODESolver::New
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"ODESolver::New(const word& ODESolverTypeName, const ODE& ode)"
|
"ODESolver::New(const word& ODESolverTypeName, const ODESystem& ode)"
|
||||||
) << "Unknown ODESolver type "
|
) << "Unknown ODESolver type "
|
||||||
<< ODESolverTypeName << nl << nl
|
<< ODESolverTypeName << nl << nl
|
||||||
<< "Valid ODESolvers are : " << endl
|
<< "Valid ODESolvers are : " << endl
|
||||||
|
|||||||
@ -54,7 +54,7 @@ const scalar
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::RK::RK(const ODE& ode)
|
Foam::RK::RK(const ODESystem& ode)
|
||||||
:
|
:
|
||||||
ODESolver(ode),
|
ODESolver(ode),
|
||||||
yTemp_(n_, 0.0),
|
yTemp_(n_, 0.0),
|
||||||
@ -72,7 +72,7 @@ Foam::RK::RK(const ODE& ode)
|
|||||||
|
|
||||||
void Foam::RK::solve
|
void Foam::RK::solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
const scalar x,
|
const scalar x,
|
||||||
const scalarField& y,
|
const scalarField& y,
|
||||||
const scalarField& dydx,
|
const scalarField& dydx,
|
||||||
@ -142,7 +142,7 @@ void Foam::RK::solve
|
|||||||
|
|
||||||
void Foam::RK::solve
|
void Foam::RK::solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
scalar& x,
|
scalar& x,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
scalarField& dydx,
|
scalarField& dydx,
|
||||||
|
|||||||
@ -81,14 +81,14 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from ODE
|
//- Construct from ODE
|
||||||
RK(const ODE& ode);
|
RK(const ODESystem& ode);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
void solve
|
void solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
const scalar x,
|
const scalar x,
|
||||||
const scalarField& y,
|
const scalarField& y,
|
||||||
const scalarField& dydx,
|
const scalarField& dydx,
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
|
|
||||||
void solve
|
void solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
scalar& x,
|
scalar& x,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
scalarField& dydx,
|
scalarField& dydx,
|
||||||
|
|||||||
@ -47,7 +47,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::SIBS::SIBS(const ODE& ode)
|
Foam::SIBS::SIBS(const ODESystem& ode)
|
||||||
:
|
:
|
||||||
ODESolver(ode),
|
ODESolver(ode),
|
||||||
a_(iMaxX_, 0.0),
|
a_(iMaxX_, 0.0),
|
||||||
@ -70,7 +70,7 @@ Foam::SIBS::SIBS(const ODE& ode)
|
|||||||
|
|
||||||
void Foam::SIBS::solve
|
void Foam::SIBS::solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
scalar& x,
|
scalar& x,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
scalarField& dydx,
|
scalarField& dydx,
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class SIBS
|
|||||||
|
|
||||||
void SIMPR
|
void SIMPR
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
const scalar xStart,
|
const scalar xStart,
|
||||||
const scalarField& y,
|
const scalarField& y,
|
||||||
const scalarField& dydx,
|
const scalarField& dydx,
|
||||||
@ -110,14 +110,14 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from ODE
|
//- Construct from ODE
|
||||||
SIBS(const ODE& ode);
|
SIBS(const ODESystem& ode);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
void solve
|
void solve
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
scalar& x,
|
scalar& x,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
scalarField& dydx,
|
scalarField& dydx,
|
||||||
|
|||||||
@ -29,7 +29,7 @@ License
|
|||||||
|
|
||||||
void Foam::SIBS::SIMPR
|
void Foam::SIBS::SIMPR
|
||||||
(
|
(
|
||||||
const ODE& ode,
|
const ODESystem& ode,
|
||||||
const scalar xStart,
|
const scalar xStart,
|
||||||
const scalarField& y,
|
const scalarField& y,
|
||||||
const scalarField& dydx,
|
const scalarField& dydx,
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -22,15 +22,15 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::ODE
|
Foam::ODESystem
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Abstract base class for the ODE solvers.
|
Abstract base class for the systems of ordinary differential equations.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef ODE_H
|
#ifndef ODESystem_H
|
||||||
#define ODE_H
|
#define ODESystem_H
|
||||||
|
|
||||||
#include "scalarField.H"
|
#include "scalarField.H"
|
||||||
#include "scalarMatrices.H"
|
#include "scalarMatrices.H"
|
||||||
@ -41,30 +41,32 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class ODE Declaration
|
Class ODESystem Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class ODE
|
class ODESystem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null8
|
||||||
ODE()
|
ODESystem()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~ODE()
|
virtual ~ODESystem()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the number of equations in the system
|
||||||
virtual label nEqns() const = 0;
|
virtual label nEqns() const = 0;
|
||||||
|
|
||||||
|
//- Calculate the derivatives in dydx
|
||||||
virtual void derivatives
|
virtual void derivatives
|
||||||
(
|
(
|
||||||
const scalar x,
|
const scalar x,
|
||||||
@ -72,7 +74,8 @@ public:
|
|||||||
scalarField& dydx
|
scalarField& dydx
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
|
//- Calculate the Jacobian of the system
|
||||||
|
// Need by the stiff-system solvers
|
||||||
virtual void jacobian
|
virtual void jacobian
|
||||||
(
|
(
|
||||||
const scalar x,
|
const scalar x,
|
||||||
@ -36,7 +36,7 @@ Foam::chemistryModel<CompType, ThermoType>::chemistryModel
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
CompType(mesh),
|
CompType(mesh),
|
||||||
ODE(),
|
ODESystem(),
|
||||||
Y_(this->thermo().composition().Y()),
|
Y_(this->thermo().composition().Y()),
|
||||||
reactions_
|
reactions_
|
||||||
(
|
(
|
||||||
|
|||||||
@ -39,7 +39,7 @@ SourceFiles
|
|||||||
#define chemistryModel_H
|
#define chemistryModel_H
|
||||||
|
|
||||||
#include "Reaction.H"
|
#include "Reaction.H"
|
||||||
#include "ODE.H"
|
#include "ODESystem.H"
|
||||||
#include "volFieldsFwd.H"
|
#include "volFieldsFwd.H"
|
||||||
#include "simpleMatrix.H"
|
#include "simpleMatrix.H"
|
||||||
#include "DimensionedField.H"
|
#include "DimensionedField.H"
|
||||||
@ -60,7 +60,7 @@ template<class CompType, class ThermoType>
|
|||||||
class chemistryModel
|
class chemistryModel
|
||||||
:
|
:
|
||||||
public CompType,
|
public CompType,
|
||||||
public ODE
|
public ODESystem
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ solidChemistryModel
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
CompType(mesh),
|
CompType(mesh),
|
||||||
ODE(),
|
ODESystem(),
|
||||||
Ys_(this->solidThermo().composition().Y()),
|
Ys_(this->solidThermo().composition().Y()),
|
||||||
reactions_
|
reactions_
|
||||||
(
|
(
|
||||||
|
|||||||
@ -40,7 +40,7 @@ SourceFiles
|
|||||||
#define solidChemistryModel_H
|
#define solidChemistryModel_H
|
||||||
|
|
||||||
#include "Reaction.H"
|
#include "Reaction.H"
|
||||||
#include "ODE.H"
|
#include "ODESystem.H"
|
||||||
#include "volFieldsFwd.H"
|
#include "volFieldsFwd.H"
|
||||||
#include "DimensionedField.H"
|
#include "DimensionedField.H"
|
||||||
#include "simpleMatrix.H"
|
#include "simpleMatrix.H"
|
||||||
@ -61,7 +61,7 @@ template<class CompType, class SolidThermo>
|
|||||||
class solidChemistryModel
|
class solidChemistryModel
|
||||||
:
|
:
|
||||||
public CompType,
|
public CompType,
|
||||||
public ODE
|
public ODESystem
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user