adaptiveSolver.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2019 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  //- Resize the ODE solver
78  bool resize(const label n);
79 
80  //- Solve a single step dx and return the error
81  virtual scalar solve
82  (
83  const scalar x0,
84  const scalarField& y0,
85  const scalarField& dydx0,
86  const scalar dx,
87  scalarField& y
88  ) const = 0;
89 
90  //- Solve the ODE system and the update the state
91  void solve
92  (
93  const ODESystem& ode,
94  scalar& x,
95  scalarField& y,
96  scalar& dxTry
97  ) const;
98 };
99 
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 } // End namespace Foam
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 #endif
108 
109 // ************************************************************************* //
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
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
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:158
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
bool resize(const label n)
Resize the ODE solver.
label n
Namespace for OpenFOAM.