Cantera  2.2.1
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
36  void setActive(int comp, bool state = true) {
37  m_active[comp] = state;
38  }
39
40  //! Set the maximum number of points allowed in the domain
41  void setMaxPoints(int npmax) {
42  m_npmax = npmax;
43  }
44
45  //! Set the minimum allowable spacing between adjacent grid points [m].
46  void setGridMin(double gridmin) {
47  m_gridmin = gridmin;
48  }
49
50  //! Returns the the minimum allowable spacing between adjacent
51  //! grid points [m].
52  double gridMin() const {
53  return m_gridmin;
54  }
55
56  int analyze(size_t n, const doublereal* z, const doublereal* x);
57  int getNewGrid(int n, const doublereal* z, int nn, doublereal* znew);
58  int nNewPoints() {
59  return static_cast<int>(m_loc.size());
60  }
61  void show();
62  bool newPointNeeded(size_t j) {
63  return m_loc.find(j) != m_loc.end();
64  }
65  bool keepPoint(size_t j) {
66  return (m_keep[j] != -1);
67  }
68  double value(const double* x, size_t i, size_t j);
69
70  double maxRatio() {
71  return m_ratio;
72  }
73  double maxDelta() {
74  return m_slope;
75  }
76  double maxSlope() {
77  return m_curve;
78  }
79  double prune() {
80  return m_prune;
81  }
82
83 protected:
84  std::map<size_t, int> m_loc;
85  std::map<size_t, int> m_keep;
86  std::map<std::string, int> m_c;
87  std::vector<bool> m_active;
88  doublereal m_ratio, m_slope, m_curve, m_prune;
89  doublereal m_min_range;
90  Domain1D* m_domain;
91  size_t m_nv, m_npmax;
92  doublereal m_thresh;
93  doublereal m_gridmin; //!< minimum grid spacing [m]
94 };
95
96 }
97
98 #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:93
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.cpp:19
void setMaxPoints(int npmax)
Set the maximum number of points allowed in the domain.
Definition: refine.h:41
void setGridMin(double gridmin)
Set the minimum allowable spacing between adjacent grid points [m].
Definition: refine.h:46
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:52