Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CVodeInt.h
Go to the documentation of this file.
1 /**
2  * @file CVodeInt.h
3  */
4 // Copyright 2001 California Institute of Technology
5 
6 #ifndef CT_CVODEINT_H
7 #define CT_CVODEINT_H
8 
12 #include "cantera/base/ct_defs.h"
13 #include "../../ext/cvode/include/nvector.h"
14 
15 namespace Cantera
16 {
17 
18 /**
19  * Exception thrown when a CVODE error is encountered.
20  */
21 class CVodeErr : public CanteraError
22 {
23 public:
24  explicit CVodeErr(const std::string& msg) : CanteraError("CVodeInt", msg) {}
25 };
26 
27 /**
28  * Wrapper class for 'CVODE' integrator from LLNL.
29  * The unmodified CVODE code is in directory ext/cvode.
30  *
31  * @see FuncEval.h. Classes that use CVodeInt:
32  * ImplicitChem, ImplicitSurfChem, Reactor
33  */
34 class CVodeInt : public Integrator
35 {
36 public:
37  /*!
38  * Constructor. Default settings: dense Jacobian, no user-supplied
39  * Jacobian function, Newton iteration.
40  */
41  CVodeInt();
42  virtual ~CVodeInt();
43  virtual void setTolerances(double reltol, size_t n, double* abstol);
44  virtual void setTolerances(double reltol, double abstol);
45  virtual void setProblemType(int probtype);
46  virtual void initialize(double t0, FuncEval& func);
47  virtual void reinitialize(double t0, FuncEval& func);
48  virtual void integrate(double tout);
49  virtual doublereal step(double tout);
50  virtual double& solution(size_t k);
51  virtual double* solution();
52  virtual int nEquations() const {
53  return m_neq;
54  }
55  virtual int nEvals() const;
56  virtual void setMaxOrder(int n) {
57  m_maxord = n;
58  }
59  virtual void setMethod(MethodType t);
60  virtual void setIterator(IterType t);
61  virtual void setMaxStepSize(double hmax);
62  virtual void setMinStepSize(double hmin);
63  virtual void setMaxSteps(int nmax);
64  virtual void setMaxErrTestFails(int nmax) {}
65 
66 private:
67  int m_neq;
68  void* m_cvode_mem;
69  double m_t0;
70  N_Vector m_y, m_abstol;
71  int m_type;
72  int m_itol;
73  int m_method;
74  int m_iter;
75  int m_maxord;
76  double m_reltol;
77  double m_abstols;
78  int m_nabs;
79  double m_hmax, m_hmin;
80  int m_maxsteps;
81 
82  vector_fp m_ropt;
83  long int* m_iopt;
84  void* m_data;
85 };
86 
87 } // namespace
88 
89 #endif // CT_CVODE
Exception thrown when a CVODE error is encountered.
Definition: CVodeInt.h:21
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
virtual void setMaxErrTestFails(int nmax)
Set the maximum permissible number of error test failures.
Definition: CVodeInt.h:64
virtual double * solution()
The current value of the solution of the system of equations.
Definition: CVodeInt.cpp:118
virtual void setMethod(MethodType t)
Set the solution method.
Definition: CVodeInt.cpp:151
virtual void integrate(double tout)
Integrate the system of equations.
Definition: CVodeInt.cpp:291
Wrapper class for 'CVODE' integrator from LLNL.
Definition: CVodeInt.h:34
virtual void setMaxOrder(int n)
Set the maximum integration order that will be used.
Definition: CVodeInt.h:56
Abstract base class for ODE system integrators.
Definition: Integrator.h:52
virtual void setIterator(IterType t)
Set the linear iterator.
Definition: CVodeInt.cpp:180
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
virtual int nEvals() const
The number of function evaluations.
Definition: CVodeInt.cpp:312
virtual void setProblemType(int probtype)
Set the problem type.
Definition: CVodeInt.cpp:146
CanteraError()
Protected default constructor discourages throwing errors containing no information.
Definition: ctexceptions.h:132
virtual void setTolerances(double reltol, size_t n, double *abstol)
Set or reset the number of equations.
Definition: CVodeInt.cpp:123
virtual void initialize(double t0, FuncEval &func)
Initialize the integrator for a new problem.
Definition: CVodeInt.cpp:191
virtual void setMaxStepSize(double hmax)
Set the maximum step size.
Definition: CVodeInt.cpp:162
IterType
Specifies the method used for iteration.
Definition: Integrator.h:40
virtual void setMinStepSize(double hmin)
Set the minimum step size.
Definition: CVodeInt.cpp:168
virtual int nEquations() const
The number of equations.
Definition: CVodeInt.h:52
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
Virtual base class for ODE right-hand-side function evaluators.
Definition: FuncEval.h:23
virtual doublereal step(double tout)
Integrate the system of equations.
Definition: CVodeInt.cpp:301
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
MethodType
Specifies the method used to integrate the system of equations.
Definition: Integrator.h:31