Cantera  2.1.2
ThirdBodyMgr.h
Go to the documentation of this file.
1 /**
2  * @file ThirdBodyMgr.h
3  */
4 
5 // Copyright 2001 California Institute of Technology
6 
7 
8 #ifndef CT_THIRDBODY_MGR_H
9 #define CT_THIRDBODY_MGR_H
10 
11 #include <algorithm>
12 
13 #include "cantera/base/ct_defs.h"
14 #include "cantera/base/utilities.h"
15 #include "Enhanced3BConc.h"
16 
17 
18 namespace Cantera
19 {
20 
21 template<class _E>
22 class ThirdBodyMgr
23 {
24 
25 public:
26 
27  ThirdBodyMgr<_E>() : m_n(0) {}
28 
29  void install(size_t rxnNumber, const std::map<size_t, doublereal>& enhanced,
30  doublereal dflt=1.0) {
31  m_n++;
32  m_reaction_index.push_back(rxnNumber);
33  m_concm.push_back(_E(static_cast<int>(enhanced.size()),
34  enhanced, dflt));
35  }
36 
37  void update(const vector_fp& conc, doublereal ctot, doublereal* work) {
38  typename std::vector<_E>::const_iterator b = m_concm.begin();
39  //doublereal* v = m_values.begin();
40  for (; b != m_concm.end(); ++b, ++work) {
41  *work = b->update(conc, ctot);
42  }
43  }
44 
45  void multiply(doublereal* output, const doublereal* work) {
46  scatter_mult(work, work + m_n,
47  output, m_reaction_index.begin());
48  }
49 
50  size_t workSize() {
51  return m_concm.size();
52  }
53  bool contains(int rxnNumber) {
54  return (find(m_reaction_index.begin(),
55  m_reaction_index.end(), rxnNumber)
56  != m_reaction_index.end());
57  }
58 
59 protected:
60 
61  int m_n;
62  std::vector<size_t> m_reaction_index;
63  std::vector<_E> m_concm;
64 };
65 
66 }
67 
68 #endif
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
void scatter_mult(InputIter mult_begin, InputIter mult_end, RandAccessIter data, IndexIter index)
Multiply selected elements in an array by a contiguous sequence of multipliers.
Definition: utilities.h:466
void multiply(const DenseMatrix &A, const double *const b, double *const prod)
Multiply A*b and return the result in prod. Uses BLAS routine DGEMV.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165