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