Cantera  2.1.2
refine.h
1 #ifndef CT_REFINE_H
2 #define CT_REFINE_H
3
4 #include "cantera/base/ct_defs.h"
5
6 namespace Cantera
7 {
8
9 class Domain1D;
10
11 //! Refine Domain1D grids so that profiles satisfy adaptation tolerances
12 //! @ingroup onedim
13 class Refiner
14 {
15 public:
16  Refiner(Domain1D& domain);
17  virtual ~Refiner() {}
18
19  //! Set grid refinement criteria
20  /*!
21  * @param ratio Maximum ratio between grid spacing at adjacent intervals.
22  * E.g. (x[j+1] - x[j]) / (x[j] - x[j-1]) < ratio
23  * @param slope Maximum fractional change in the value of each solution
24  * component between adjacent grid points
25  * @param curve Maximum fractional change in the derivative of each
26  * solution component between adjacent grid points.
27  * @param prune Threshold for removing unnecessary grid points. prune
28  * should be smaller than both slope and curve. Set prune <= 0
29  * to disable pruning.
30  */
31  void setCriteria(doublereal ratio = 10.0,
32  doublereal slope = 0.8,
33  doublereal curve = 0.8,
34  doublereal prune = -0.1) {
35  m_ratio = ratio;
36  m_slope = slope;
37  m_curve = curve;
38  m_prune = prune;
39  }
40  void setActive(int comp, bool state = true) {
41  m_active[comp] = state;
42  }
43
44  //! Set the maximum number of points allowed in the domain
45  void setMaxPoints(int npmax) {
46  m_npmax = npmax;
47  }
48
49  //! Set the minimum allowable spacing between adjacent grid points [m].
50  void setGridMin(double gridmin) {
51  m_gridmin = gridmin;
52  }
53
54  //! Returns the the minimum allowable spacing between adjacent
55  //! grid points [m].
56  double gridMin() const {
57  return m_gridmin;
58  }
59
60  int analyze(size_t n, const doublereal* z, const doublereal* x);
61  int getNewGrid(int n, const doublereal* z, int nn, doublereal* znew);
62  int nNewPoints() {
63  return static_cast<int>(m_loc.size());
64  }
65  void show();
66  bool newPointNeeded(size_t j) {
67  return m_loc.find(j) != m_loc.end();
68  }
69  bool keepPoint(size_t j) {
70  return (m_keep[j] != -1);
71  }
72  double value(const double* x, size_t i, size_t j);
73
74  double maxRatio() {
75  return m_ratio;
76  }
77  double maxDelta() {
78  return m_slope;
79  }
80  double maxSlope() {
81  return m_curve;
82  }
83  double prune() {
84  return m_prune;
85  }
86
87 protected:
88  std::map<size_t, int> m_loc;
89  std::map<size_t, int> m_keep;
90  std::map<std::string, int> m_c;
91  std::vector<bool> m_active;
92  doublereal m_ratio, m_slope, m_curve, m_prune;
93  doublereal m_min_range;
94  Domain1D* m_domain;
95  size_t m_nv, m_npmax;
96  doublereal m_thresh;
97  doublereal m_gridmin; //!< minimum grid spacing [m]
98 };
99
100 }
101
102 #endif
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
doublereal m_gridmin
minimum grid spacing [m]
Definition: refine.h:97
Base class for one-dimensional domains.
Definition: Domain1D.h:37
void setCriteria(doublereal ratio=10.0, doublereal slope=0.8, doublereal curve=0.8, doublereal prune=-0.1)
Set grid refinement criteria.
Definition: refine.h:31
void setMaxPoints(int npmax)
Set the maximum number of points allowed in the domain.
Definition: refine.h:45
void setGridMin(double gridmin)
Set the minimum allowable spacing between adjacent grid points [m].
Definition: refine.h:50
Refine Domain1D grids so that profiles satisfy adaptation tolerances.
Definition: refine.h:13
double gridMin() const
Returns the the minimum allowable spacing between adjacent grid points [m].
Definition: refine.h:56