adaptiveSolver.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::adaptiveSolver
26 
27 Description
28 
29 SourceFiles
30  adaptiveSolver.C
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef adaptiveSolver_H
35 #define adaptiveSolver_H
36 
37 #include "ODESolver.H"
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43 
44 /*---------------------------------------------------------------------------*\
45  Class adaptiveSolver Declaration
46 \*---------------------------------------------------------------------------*/
47 
48 class adaptiveSolver
49 {
50  // Private data
51 
52  //- Step-size adjustment controls
53  scalar safeScale_, alphaInc_, alphaDec_, minScale_, maxScale_;
54 
55  //- Cache for dydx at the initial time
56  mutable scalarField dydx0_;
57 
58  //- Temprorary for the test-step solution
59  mutable scalarField yTemp_;
60 
61 
62 public:
63 
64  // Constructors
65 
66  //- Construct from ODESystem
67  adaptiveSolver(const ODESystem& ode, const dictionary& dict);
68 
69 
70  //- Destructor
71  virtual ~adaptiveSolver()
72  {}
73 
74 
75  // Member Functions
76 
77  //- Solve a single step dx and return the error
78  virtual scalar solve
79  (
80  const scalar x0,
81  const scalarField& y0,
82  const scalarField& dydx0,
83  const scalar dx,
84  scalarField& y
85  ) const = 0;
86 
87  //- Solve the ODE system and the update the state
88  void solve
89  (
90  const ODESystem& ode,
91  scalar& x,
92  scalarField& y,
93  scalar& dxTry
94  ) const;
95 };
96 
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 } // End namespace Foam
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 #endif
105 
106 // ************************************************************************* //
virtual scalar solve(const scalar x0, const scalarField &y0, const scalarField &dydx0, const scalar dx, scalarField &y) const =0
Solve a single step dx and return the error.
dictionary dict
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:46
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual ~adaptiveSolver()
Destructor.
dimensionedScalar y0(const dimensionedScalar &ds)
An ODE solver for chemistry.
Definition: ode.H:50
adaptiveSolver(const ODESystem &ode, const dictionary &dict)
Construct from ODESystem.
scalar y
Namespace for OpenFOAM.