Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Integrator.h
Go to the documentation of this file.
1 /**
2  * @file Integrator.h
3  */
4 
5 /**
6  * @defgroup odeGroup ODE Integrators
7  */
8 
9 // Copyright 2001 California Institute of Technology
10 
11 #ifndef CT_INTEGRATOR_H
12 #define CT_INTEGRATOR_H
13 #include "FuncEval.h"
14 
15 #include "cantera/base/global.h"
16 
17 namespace Cantera
18 {
19 
20 const int DIAG = 1;
21 const int DENSE = 2;
22 const int NOJAC = 4;
23 const int JAC = 8;
24 const int GMRES =16;
25 const int BAND =32;
26 
27 /**
28  * Specifies the method used to integrate the system of equations.
29  * Not all methods are supported by all integrators.
30  */
31 enum MethodType {
32  BDF_Method, /**< Backward Differentiation */
33  Adams_Method /**< Adams */
34 };
35 
36 //! Specifies the method used for iteration.
37 /*!
38  * Not all methods are supported by all integrators.
39  */
40 enum IterType {
41  //! Newton Iteration
43  //! Functional Iteration
45 };
46 
47 
48 //! Abstract base class for ODE system integrators.
49 /*!
50  * @ingroup odeGroup
51  */
53 {
54 public:
55  //! Default Constructor
57  }
58 
59  //! Destructor
60  virtual ~Integrator() {
61  }
62 
63  /** Set or reset the number of equations. */
64  //virtual void resize(int n)=0;
65 
66  //! Set error tolerances.
67  /*!
68  * @param reltol scalar relative tolerance
69  * @param n Number of equations
70  * @param abstol array of N absolute tolerance values
71  */
72  virtual void setTolerances(doublereal reltol, size_t n,
73  doublereal* abstol) {
74  warn("setTolerances");
75  }
76 
77  //! Set error tolerances.
78  /*!
79  * @param reltol scalar relative tolerance
80  * @param abstol scalar absolute tolerance
81  */
82  virtual void setTolerances(doublereal reltol, doublereal abstol) {
83  warn("setTolerances");
84  }
85 
86  //! Set the sensitivity error tolerances
87  /*!
88  * @param reltol scalar relative tolerance
89  * @param abstol scalar absolute tolerance
90  */
91  virtual void setSensitivityTolerances(doublereal reltol, doublereal abstol)
92  { }
93 
94  //! Set the problem type.
95  /*!
96  * @param probtype Type of the problem
97  */
98  virtual void setProblemType(int probtype) {
99  warn("setProblemType");
100  }
101 
102  /**
103  * Initialize the integrator for a new problem. Call after
104  * all options have been set.
105  * @param t0 initial time
106  * @param func RHS evaluator object for system of equations.
107  */
108  virtual void initialize(doublereal t0, FuncEval& func) {
109  warn("initialize");
110  }
111 
112  virtual void reinitialize(doublereal t0, FuncEval& func) {
113  warn("reinitialize");
114  }
115 
116  //! Integrate the system of equations.
117  /*!
118  * @param tout Integrate to this time. Note that this is the
119  * absolute time value, not a time interval.
120  */
121  virtual void integrate(doublereal tout) {
122  warn("integrate");
123  }
124 
125  /**
126  * Integrate the system of equations.
127  * @param tout integrate to this time. Note that this is the
128  * absolute time value, not a time interval.
129  */
130  virtual doublereal step(doublereal tout) {
131  warn("step");
132  return 0.0;
133  }
134 
135  /** The current value of the solution of equation k. */
136  virtual doublereal& solution(size_t k) {
137  warn("solution");
138  return m_dummy;
139  }
140 
141  /** The current value of the solution of the system of equations. */
142  virtual doublereal* solution() {
143  warn("solution");
144  return 0;
145  }
146 
147  /** The number of equations. */
148  virtual int nEquations() const {
149  warn("nEquations");
150  return 0;
151  }
152 
153  /** The number of function evaluations. */
154  virtual int nEvals() const {
155  warn("nEvals");
156  return 0;
157  }
158 
159  /** Set the maximum integration order that will be used. **/
160  virtual void setMaxOrder(int n) {
161  warn("setMaxorder");
162  }
163 
164  /** Set the solution method */
165  virtual void setMethod(MethodType t) {
166  warn("setMethodType");
167  }
168 
169  /** Set the linear iterator. */
170  virtual void setIterator(IterType t) {
171  warn("setInterator");
172  }
173 
174  /** Set the maximum step size */
175  virtual void setMaxStepSize(double hmax) {
176  warn("setMaxStepSize");
177  }
178 
179  /** Set the minimum step size */
180  virtual void setMinStepSize(double hmin) {
181  warn("setMinStepSize");
182  }
183 
184  //! Set the maximum permissible number of error test failures
185  virtual void setMaxErrTestFails(int n) {
186  warn("setMaxErrTestFails");
187  }
188 
189  virtual void setMaxSteps(int nmax) {
190  warn("setMaxStep");
191  }
192 
193  virtual void setBandwidth(int N_Upper, int N_Lower) {
194  warn("setBandwidth");
195  }
196 
197  virtual int nSensParams() {
198  warn("nSensParams()");
199  return 0;
200  }
201 
202  virtual double sensitivity(size_t k, size_t p) {
203  warn("sensitivity");
204  return 0.0;
205  }
206 
207 private:
208 
209  doublereal m_dummy;
210  void warn(const std::string& msg) const {
211  writelog(">>>> Warning: method "+msg+" of base class "
212  +"Integrator called. Nothing done.\n");
213  }
214 
215 };
216 
217 // defined in ODE_integrators.cpp
218 Integrator* newIntegrator(const std::string& itype);
219 
220 } // namespace
221 
222 #endif
Backward Differentiation.
Definition: Integrator.h:32
virtual void setMaxStepSize(double hmax)
Set the maximum step size.
Definition: Integrator.h:175
virtual void integrate(doublereal tout)
Integrate the system of equations.
Definition: Integrator.h:121
virtual void setTolerances(doublereal reltol, doublereal abstol)
Set error tolerances.
Definition: Integrator.h:82
virtual void setTolerances(doublereal reltol, size_t n, doublereal *abstol)
Set or reset the number of equations.
Definition: Integrator.h:72
virtual ~Integrator()
Destructor.
Definition: Integrator.h:60
virtual void setMaxOrder(int n)
Set the maximum integration order that will be used.
Definition: Integrator.h:160
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, (see Input File Handling, Diagnostic Output, and Writing messages to the screen).
virtual void initialize(doublereal t0, FuncEval &func)
Initialize the integrator for a new problem.
Definition: Integrator.h:108
Functional Iteration.
Definition: Integrator.h:44
virtual void setProblemType(int probtype)
Set the problem type.
Definition: Integrator.h:98
virtual doublereal * solution()
The current value of the solution of the system of equations.
Definition: Integrator.h:142
virtual void setMinStepSize(double hmin)
Set the minimum step size.
Definition: Integrator.h:180
Abstract base class for ODE system integrators.
Definition: Integrator.h:52
Integrator()
Default Constructor.
Definition: Integrator.h:56
virtual int nEvals() const
The number of function evaluations.
Definition: Integrator.h:154
virtual void setSensitivityTolerances(doublereal reltol, doublereal abstol)
Set the sensitivity error tolerances.
Definition: Integrator.h:91
IterType
Specifies the method used for iteration.
Definition: Integrator.h:40
virtual int nEquations() const
The number of equations.
Definition: Integrator.h:148
virtual doublereal & solution(size_t k)
The current value of the solution of equation k.
Definition: Integrator.h:136
Newton Iteration.
Definition: Integrator.h:42
virtual doublereal step(doublereal tout)
Integrate the system of equations.
Definition: Integrator.h:130
virtual void setMaxErrTestFails(int n)
Set the maximum permissible number of error test failures.
Definition: Integrator.h:185
Virtual base class for ODE right-hand-side function evaluators.
Definition: FuncEval.h:23
void writelog(const std::string &msg)
Write a message to the screen.
Definition: global.cpp:33
virtual void setIterator(IterType t)
Set the linear iterator.
Definition: Integrator.h:170
virtual void setMethod(MethodType t)
Set the solution method.
Definition: Integrator.h:165
MethodType
Specifies the method used to integrate the system of equations.
Definition: Integrator.h:31