Cantera  2.0
refine.h
1 #ifndef CT_REFINE_H
2 #define CT_REFINE_H
3 
4 namespace Cantera
5 {
6 
7 class Domain1D;
8 
9 class Refiner
10 {
11 
12 public:
13 
14  Refiner(Domain1D& domain);
15  virtual ~Refiner() {}
16 
17  void setCriteria(doublereal ratio = 10.0,
18  doublereal slope = 0.8,
19  doublereal curve = 0.8,
20  doublereal prune = -0.1) {
21  m_ratio = ratio;
22  m_slope = slope;
23  m_curve = curve;
24  m_prune = prune;
25  }
26  void setActive(int comp, bool state = true) {
27  m_active[comp] = state;
28  }
29  void setMaxPoints(int npmax) {
30  m_npmax = npmax;
31  }
32 
33  //! Set the minimum allowable spacing between adjacent grid points [m].
34  void setGridMin(double gridmin) {
35  m_gridmin = gridmin;
36  }
37 
38  //! Returns the the minimum allowable spacing between adjacent
39  //! grid points [m].
40  double gridMin() const {
41  return m_gridmin;
42  }
43 
44  int analyze(size_t n, const doublereal* z, const doublereal* x);
45  int getNewGrid(int n, const doublereal* z, int nn, doublereal* znew);
46  //int getNewSoln(int n, const doublereal* x, doublereal* xnew);
47  int nNewPoints() {
48  return static_cast<int>(m_loc.size());
49  }
50  void show();
51  bool newPointNeeded(size_t j) {
52  return m_loc.find(j) != m_loc.end();
53  }
54  bool keepPoint(size_t j) {
55  return (m_keep[j] != -1); // m_keep.find(j) != m_keep.end();
56  }
57  double value(const double* x, size_t i, size_t j);
58  double maxRatio() {
59  return m_ratio;
60  }
61  double maxDelta() {
62  return m_slope;
63  }
64  double maxSlope() {
65  return m_curve;
66  }
67  double prune() {
68  return m_prune;
69  }
70 
71 protected:
72 
73  std::map<size_t, int> m_loc;
74  std::map<size_t, int> m_keep;
75  std::map<std::string, int> m_c;
76  std::vector<bool> m_active;
77  doublereal m_ratio, m_slope, m_curve, m_prune;
78  doublereal m_min_range;
79  Domain1D* m_domain;
80  size_t m_nv, m_npmax;
81  doublereal m_thresh;
82  doublereal m_gridmin; //!< minimum grid spacing [m]
83 
84 };
85 
86 }
87 
88 #endif