Cantera  3.2.0a2
Loading...
Searching...
No Matches
ctreactor.cpp
Go to the documentation of this file.
1/**
2 * CTREACTOR - Generated CLib %Cantera interface library.
3 *
4 * @file ctreactor.cpp
5 *
6 * Generated CLib API for Cantera's ReactorBase class.
7 *
8 * This file was generated by sourcegen. It will be re-generated by the
9 * %Cantera build process. Do not manually edit.
10 *
11 * @warning This module is an experimental part of the %Cantera API and
12 * may be changed without notice.
13 */
14
15// This file is part of Cantera. See License.txt in the top-level directory or
16// at https://cantera.org/license.txt for license and copyright information.
17
18#include "clib_utils.h"
20
25
26using namespace Cantera;
27
28//! @cond
29//! Cabinet type definitions will be ignored by Doxygen
30
31// Define Cabinet<ReactorBase> (single-instance object)
32typedef Cabinet<ReactorBase> ReactorBaseCabinet;
33template<> ReactorBaseCabinet* ReactorBaseCabinet::s_storage = 0; // initialized here
34
35typedef Cabinet<Solution> SolutionCabinet;
36template<> SolutionCabinet* SolutionCabinet::s_storage; // initialized elsewhere
37
38//! @endcond
39
40extern "C" {
41
42 int32_t reactor_new(const char* model, int32_t contents, const char* name)
43 {
44 // constructor: shared_ptr<ReactorBase> newReactorBase(const string&, shared_ptr<Solution>, const string&)
45 try {
46 return ReactorBaseCabinet::add(newReactorBase(model, SolutionCabinet::at(contents), name));
47 } catch (...) {
48 return handleAllExceptions(-2, ERR);
49 }
50 }
51
52 int32_t reactor_type(int32_t handle, int32_t bufLen, char* buf)
53 {
54 // getter: virtual string ReactorBase::type()
55 try {
56 string out = ReactorBaseCabinet::at(handle)->type();
57 copyString(out, buf, bufLen);
58 return int(out.size()) + 1;
59 } catch (...) {
60 return handleAllExceptions(-1, ERR);
61 }
62 }
63
64 int32_t reactor_name(int32_t handle, int32_t bufLen, char* buf)
65 {
66 // getter: string ReactorBase::name()
67 try {
68 string out = ReactorBaseCabinet::at(handle)->name();
69 copyString(out, buf, bufLen);
70 return int(out.size()) + 1;
71 } catch (...) {
72 return handleAllExceptions(-1, ERR);
73 }
74 }
75
76 int32_t reactor_setName(int32_t handle, const char* name)
77 {
78 // setter: void ReactorBase::setName(const string&)
79 try {
80 ReactorBaseCabinet::at(handle)->setName(name);
81 return 0;
82 } catch (...) {
83 return handleAllExceptions(-1, ERR);
84 }
85 }
86
87 int32_t reactor_setInitialVolume(int32_t handle, double vol)
88 {
89 // setter: virtual void ReactorBase::setInitialVolume(double)
90 try {
91 ReactorBaseCabinet::at(handle)->setInitialVolume(vol);
92 return 0;
93 } catch (...) {
94 return handleAllExceptions(-1, ERR);
95 }
96 }
97
98 int32_t reactor_setChemistry(int32_t handle, int32_t cflag)
99 {
100 // setter: virtual void ReactorBase::setChemistry(bool)
101 try {
102 bool cflag_ = (cflag != 0);
103 ReactorBaseCabinet::at(handle)->setChemistry(cflag_);
104 return 0;
105 } catch (...) {
106 return handleAllExceptions(-1, ERR);
107 }
108 }
109
110 int32_t reactor_setEnergy(int32_t handle, int32_t eflag)
111 {
112 // setter: virtual void ReactorBase::setEnergy(int)
113 try {
114 ReactorBaseCabinet::at(handle)->setEnergy(eflag);
115 return 0;
116 } catch (...) {
117 return handleAllExceptions(-1, ERR);
118 }
119 }
120
121 double reactor_mass(int32_t handle)
122 {
123 // getter: double ReactorBase::mass()
124 try {
125 return ReactorBaseCabinet::at(handle)->mass();
126 } catch (...) {
127 return handleAllExceptions(DERR, DERR);
128 }
129 }
130
131 double reactor_volume(int32_t handle)
132 {
133 // getter: double ReactorBase::volume()
134 try {
135 return ReactorBaseCabinet::at(handle)->volume();
136 } catch (...) {
137 return handleAllExceptions(DERR, DERR);
138 }
139 }
140
141 double reactor_density(int32_t handle)
142 {
143 // getter: double ReactorBase::density()
144 try {
145 return ReactorBaseCabinet::at(handle)->density();
146 } catch (...) {
147 return handleAllExceptions(DERR, DERR);
148 }
149 }
150
151 double reactor_temperature(int32_t handle)
152 {
153 // getter: double ReactorBase::temperature()
154 try {
155 return ReactorBaseCabinet::at(handle)->temperature();
156 } catch (...) {
157 return handleAllExceptions(DERR, DERR);
158 }
159 }
160
161 double reactor_enthalpy_mass(int32_t handle)
162 {
163 // getter: double ReactorBase::enthalpy_mass()
164 try {
165 return ReactorBaseCabinet::at(handle)->enthalpy_mass();
166 } catch (...) {
167 return handleAllExceptions(DERR, DERR);
168 }
169 }
170
171 double reactor_intEnergy_mass(int32_t handle)
172 {
173 // getter: double ReactorBase::intEnergy_mass()
174 try {
175 return ReactorBaseCabinet::at(handle)->intEnergy_mass();
176 } catch (...) {
177 return handleAllExceptions(DERR, DERR);
178 }
179 }
180
181 double reactor_pressure(int32_t handle)
182 {
183 // getter: double ReactorBase::pressure()
184 try {
185 return ReactorBaseCabinet::at(handle)->pressure();
186 } catch (...) {
187 return handleAllExceptions(DERR, DERR);
188 }
189 }
190
191 double reactor_massFraction(int32_t handle, int32_t k)
192 {
193 // method: double ReactorBase::massFraction(size_t)
194 try {
195 return ReactorBaseCabinet::at(handle)->massFraction(k);
196 } catch (...) {
197 return handleAllExceptions(DERR, DERR);
198 }
199 }
200
201 int32_t reactor_nSensParams(int32_t handle)
202 {
203 // getter: virtual size_t ReactorBase::nSensParams()
204 try {
205 return ReactorBaseCabinet::at(handle)->nSensParams();
206 } catch (...) {
207 return handleAllExceptions(ERR, ERR);
208 }
209 }
210
211 int32_t reactor_addSensitivityReaction(int32_t handle, int32_t rxn)
212 {
213 // setter: virtual void ReactorBase::addSensitivityReaction(size_t)
214 try {
215 ReactorBaseCabinet::at(handle)->addSensitivityReaction(rxn);
216 return 0;
217 } catch (...) {
218 return handleAllExceptions(-1, ERR);
219 }
220 }
221
222 int32_t reactor_addSurface(int32_t handle, int32_t surf)
223 {
224 // setter: void ReactorBase::addSurface(shared_ptr<ReactorBase>)
225 try {
226 ReactorBaseCabinet::at(handle)->addSurface(ReactorBaseCabinet::at(surf));
227 return 0;
228 } catch (...) {
229 return handleAllExceptions(-1, ERR);
230 }
231 }
232
233 int32_t reactor_setMassFlowRate(int32_t handle, double mdot)
234 {
235 // setter: void FlowReactor::setMassFlowRate(double)
236 try {
237 ReactorBaseCabinet::as<FlowReactor>(handle)->setMassFlowRate(mdot);
238 return 0;
239 } catch (...) {
240 return handleAllExceptions(-1, ERR);
241 }
242 }
243
244 double reactor_area(int32_t handle)
245 {
246 // getter: double FlowReactor::area()
247 try {
248 return ReactorBaseCabinet::as<FlowReactor>(handle)->area();
249 } catch (...) {
250 return handleAllExceptions(DERR, DERR);
251 }
252 }
253
254 int32_t reactor_setArea(int32_t handle, double area)
255 {
256 // setter: void FlowReactor::setArea(double)
257 try {
258 ReactorBaseCabinet::as<FlowReactor>(handle)->setArea(area);
259 return 0;
260 } catch (...) {
261 return handleAllExceptions(-1, ERR);
262 }
263 }
264
265 int32_t reactor_del(int32_t handle)
266 {
267 // destructor
268 try {
269 ReactorBaseCabinet::del(handle);
270 return 0;
271 } catch (...) {
272 return handleAllExceptions(-1, ERR);
273 }
274 }
275
277 {
278 // reserved CLib function: custom code
279 try {
280 // *************** begin custom code ***************
281 return ReactorBaseCabinet::size();
282 // **************** end custom code ****************
283 } catch (...) {
284 return handleAllExceptions(-1, ERR);
285 }
286 }
287
288 int32_t reactor_parentHandle(int32_t handle)
289 {
290 // reserved CLib function: custom code
291 try {
292 // *************** begin custom code ***************
293 return ReactorBaseCabinet::parent(handle);
294 // **************** end custom code ****************
295 } catch (...) {
296 return handleAllExceptions(-1, ERR);
297 }
298 }
299
300} // extern "C"
int32_t reactor_nSensParams(int32_t handle)
Number of sensitivity parameters associated with this reactor.
double reactor_volume(int32_t handle)
Returns the current volume (m^3) of the reactor.
int32_t reactor_parentHandle(int32_t handle)
Return handle to parent of ReactorBase object.
int32_t reactor_setName(int32_t handle, const char *name)
Set the name of this reactor.
Definition ctreactor.cpp:76
int32_t reactor_del(int32_t handle)
Delete ReactorBase object.
double reactor_enthalpy_mass(int32_t handle)
Returns the current enthalpy (J/kg) of the reactor's contents.
double reactor_pressure(int32_t handle)
Returns the current pressure (Pa) of the reactor.
int32_t reactor_addSurface(int32_t handle, int32_t surf)
Add a ReactorSurface object to a Reactor object.
double reactor_mass(int32_t handle)
Returns the mass (kg) of the reactor's contents.
int32_t reactor_setArea(int32_t handle, double area)
Sets the area of the reactor [m^2].
int32_t reactor_new(const char *model, int32_t contents, const char *name)
Create a ReactorBase object of the specified type and contents.
Definition ctreactor.cpp:42
int32_t reactor_setMassFlowRate(int32_t handle, double mdot)
Set the mass flow rate through the reactor [kg/s].
double reactor_area(int32_t handle)
The cross-sectional area of the reactor [m^2].
int32_t reactor_setEnergy(int32_t handle, int32_t eflag)
Set the energy equation on or off.
int32_t reactor_setInitialVolume(int32_t handle, double vol)
Set the initial reactor volume.
Definition ctreactor.cpp:87
double reactor_temperature(int32_t handle)
Returns the current temperature (K) of the reactor's contents.
int32_t reactor_setChemistry(int32_t handle, int32_t cflag)
Enable or disable changes in reactor composition due to chemical reactions.
Definition ctreactor.cpp:98
double reactor_massFraction(int32_t handle, int32_t k)
Return the mass fraction of the.
double reactor_intEnergy_mass(int32_t handle)
Returns the current internal energy (J/kg) of the reactor's contents.
int32_t reactor_addSensitivityReaction(int32_t handle, int32_t rxn)
Add a sensitivity parameter associated with the reaction number.
double reactor_density(int32_t handle)
Returns the current density (kg/m^3) of the reactor's contents.
int32_t reactor_type(int32_t handle, int32_t bufLen, char *buf)
String indicating the reactor model implemented.
Definition ctreactor.cpp:52
int32_t reactor_name(int32_t handle, int32_t bufLen, char *buf)
Return the name of this reactor.
Definition ctreactor.cpp:64
int32_t reactor_cabinetSize()
Return size of ReactorBase storage.
size_t copyString(const string &source, char *dest, size_t length)
Copy the contents of a string into a char array of a given length.
shared_ptr< ReactorBase > newReactorBase(const string &model, shared_ptr< Solution > contents, const string &name)
Create a ReactorBase object of the specified type and contents.
CTREACTOR - Generated CLib Cantera interface library.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Definition clib_utils.h:32
Contains declarations for string manipulation functions within Cantera.