Cantera  2.0
MultiJac.h
Go to the documentation of this file.
1 /**
2  * @file MultiJac.h
3  */
4 
5 /*
6  * Copyright 2002 California Institute of Technology
7  */
8 
9 #ifndef CT_MULTIJAC_H
10 #define CT_MULTIJAC_H
11 
13 #include "OneDim.h"
14 #include "time.h"
15 
16 namespace Cantera
17 {
18 
19 /**
20  * Class MultiJac evaluates the Jacobian of a system of equations
21  * defined by a residual function supplied by an instance of class
22  * 'OneDim.' The residual function may consist of several linked
23  * 1D domains, with different variables in each domain.
24  */
25 class MultiJac : public BandMatrix
26 {
27 
28 public:
29 
30  /**
31  * Constructor.
32  */
33  MultiJac(OneDim& r);
34 
35  /// Destructor. Does nothing.
36  virtual ~MultiJac() {}
37 
38  /**
39  * Evaluate the Jacobian at x0. The unperturbed residual
40  * function is resid0, which must be supplied on input. The
41  * third parameter 'rdt' is the reciprocal of the time
42  * step. If zero, the steady-state Jacobian is evaluated.
43  */
44  void eval(doublereal* x0, doublereal* resid0, double rdt);
45 
46  /**
47  * Elapsed CPU time spent computing the Jacobian.
48  */
49  doublereal elapsedTime() const {
50  return m_elapsed;
51  }
52 
53  /// Number of Jacobian evaluations.
54  int nEvals() const {
55  return m_nevals;
56  }
57 
58  /**
59  * Number of times 'incrementAge' has been called since the
60  * last evaluation
61  */
62  int age() const {
63  return m_age;
64  }
65 
66  /**
67  * Increment the Jacobian age.
68  */
69  void incrementAge() {
70  m_age++;
71  }
72 
73  void updateTransient(doublereal rdt, integer* mask);
74 
75  /// Set the age.
76  void setAge(int age) {
77  m_age = age;
78  }
79 
80  vector_int& transientMask() {
81  return m_mask;
82  }
83 
84  void incrementDiagonal(int j, doublereal d);
85 
86 protected:
87 
88  //! Residual evaluator for this jacobian
89  /*!
90  * This is a pointer to the residual evaluator. This
91  * object isn't owned by this jacobian object.
92  */
94 
95  vector_fp m_r1;
96  doublereal m_rtol, m_atol;
97  doublereal m_elapsed;
98  vector_fp m_ssdiag;
99  vector_int m_mask;
100  int m_nevals;
101  int m_age;
102  size_t m_size;
103  size_t m_points;
104 };
105 }
106 
107 #endif
108 
109