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