Cantera  2.0
MultiNewton.h
Go to the documentation of this file.
1 /**
2  * @file MultiNewton.h
3  */
4 
5 /*
6  * Copyright 2002 California Institute of Technology
7  */
8 
9 #ifndef CT_MULTINEWTON_H
10 #define CT_MULTINEWTON_H
11 
12 #include "MultiJac.h"
13 
14 namespace Cantera
15 {
16 
17 /**
18  * Newton iterator for multi-domain, one-dimensional problems.
19  * Used by class OneDim.
20  */
22 {
23 
24 public:
25 
26  MultiNewton(int sz);
27  virtual ~MultiNewton();
28 
29  size_t size() {
30  return m_n;
31  }
32 
33  /// Compute undamped step
34  void step(doublereal* x, doublereal* step,
35  OneDim& r, MultiJac& jac, int loglevel);
36 
37  /// Compute factor to keep all components in bounds.
38  doublereal boundStep(const doublereal* x0, const doublereal* step0,
39  const OneDim& r, int loglevel);
40 
41  int dampStep(const doublereal* x0, const doublereal* step0,
42  doublereal* x1, doublereal* step1, doublereal& s1,
43  OneDim& r, MultiJac& jac, int loglevel, bool writetitle);
44 
45  doublereal norm2(const doublereal* x, const doublereal* step,
46  OneDim& r) const;
47 
48  int solve(doublereal* x0, doublereal* x1, OneDim& r, MultiJac& jac,
49  int loglevel);
50 
51  /// Set options.
52  void setOptions(int maxJacAge = 5) {
53  m_maxAge = maxJacAge;
54  }
55 
56  /// Change the problem size.
57  void resize(size_t points);
58 
59 
60 protected:
61 
62  doublereal* getWorkArray();
63  void releaseWorkArray(doublereal* work);
64  std::vector<doublereal*> m_workarrays;
65  int m_maxAge;
66  size_t m_nv, m_np, m_n;
67  doublereal m_elapsed;
68 
69 private:
70 
71  char m_buf[100];
72 };
73 }
74 
75 #endif
76 
77