Cantera  3.2.0a4
Loading...
Searching...
No Matches
ctdomain.cpp
Go to the documentation of this file.
1/**
2 * CTDOMAIN - Generated CLib %Cantera interface library.
3 *
4 * @file ctdomain.cpp
5 *
6 * Generated CLib API for Cantera's Domain1D 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#include "cantera/oneD/Flow1D.h"
27
28using namespace Cantera;
29
30//! @cond
31//! Cabinet type definitions will be ignored by Doxygen
32
33// Define Cabinet<Domain1D> (single-instance object)
34typedef Cabinet<Domain1D> Domain1DCabinet;
35template<> Domain1DCabinet* Domain1DCabinet::s_storage = 0; // initialized here
36
37typedef Cabinet<Transport> TransportCabinet;
38template<> TransportCabinet* TransportCabinet::s_storage; // initialized elsewhere
39
40typedef Cabinet<Solution> SolutionCabinet;
41template<> SolutionCabinet* SolutionCabinet::s_storage; // initialized elsewhere
42
43typedef Cabinet<Flow1D> Flow1DCabinet;
44template<> Flow1DCabinet* Flow1DCabinet::s_storage; // initialized elsewhere
45
46typedef Cabinet<Boundary1D> Boundary1DCabinet;
47template<> Boundary1DCabinet* Boundary1DCabinet::s_storage; // initialized elsewhere
48
49//! @endcond
50
51extern "C" {
52
53 int32_t domain_newFlow1D(const char* domainType, int32_t solution, const char* id)
54 {
55 // constructor: shared_ptr<Flow1D> newFlow1D(const string&, shared_ptr<Solution>, const string&)
56 try {
57 return Domain1DCabinet::add(newFlow1D(domainType, SolutionCabinet::at(solution), id));
58 } catch (...) {
59 return handleAllExceptions(-2, ERR);
60 }
61 }
62
63 int32_t domain_newBoundary1D(const char* domainType, int32_t solution, const char* id)
64 {
65 // constructor: shared_ptr<Boundary1D> newBoundary1D(const string&, shared_ptr<Solution>, const string&)
66 try {
67 return Domain1DCabinet::add(newBoundary1D(domainType, SolutionCabinet::at(solution), id));
68 } catch (...) {
69 return handleAllExceptions(-2, ERR);
70 }
71 }
72
73 int32_t domain_type(int32_t handle, int32_t bufLen, char* buf)
74 {
75 // getter: string Domain1D::type()
76 try {
77 string out = Domain1DCabinet::at(handle)->type();
78 copyString(out, buf, bufLen);
79 return int(out.size()) + 1;
80 } catch (...) {
81 return handleAllExceptions(-1, ERR);
82 }
83 }
84
85 int32_t domain_index(int32_t handle, int32_t n, int32_t j)
86 {
87 // method: size_t Domain1D::index(size_t, size_t)
88 try {
89 return Domain1DCabinet::at(handle)->index(n, j);
90 } catch (...) {
91 return handleAllExceptions(ERR, ERR);
92 }
93 }
94
95 int32_t domain_nComponents(int32_t handle)
96 {
97 // getter: size_t Domain1D::nComponents()
98 try {
99 return Domain1DCabinet::at(handle)->nComponents();
100 } catch (...) {
101 return handleAllExceptions(ERR, ERR);
102 }
103 }
104
105 int32_t domain_nPoints(int32_t handle)
106 {
107 // getter: size_t Domain1D::nPoints()
108 try {
109 return Domain1DCabinet::at(handle)->nPoints();
110 } catch (...) {
111 return handleAllExceptions(ERR, ERR);
112 }
113 }
114
115 int32_t domain_componentName(int32_t handle, int32_t n, int32_t bufLen, char* buf)
116 {
117 // method: virtual string Domain1D::componentName(size_t)
118 try {
119 string out = Domain1DCabinet::at(handle)->componentName(n);
120 copyString(out, buf, bufLen);
121 return int(out.size()) + 1;
122 } catch (...) {
123 return handleAllExceptions(-1, ERR);
124 }
125 }
126
127 int32_t domain_componentIndex(int32_t handle, const char* name)
128 {
129 // method: virtual size_t Domain1D::componentIndex(const string&)
130 try {
131 return Domain1DCabinet::at(handle)->componentIndex(name);
132 } catch (...) {
133 return handleAllExceptions(ERR, ERR);
134 }
135 }
136
137 double domain_value(int32_t handle, const char* component)
138 {
139 // method: virtual double Domain1D::value(const string&)
140 try {
141 return Domain1DCabinet::at(handle)->value(component);
142 } catch (...) {
143 return handleAllExceptions(DERR, DERR);
144 }
145 }
146
147 int32_t domain_setValue(int32_t handle, const char* component, double value)
148 {
149 // method: virtual void Domain1D::setValue(const string&, double)
150 try {
151 Domain1DCabinet::at(handle)->setValue(component, value);
152 return 0;
153 } catch (...) {
154 return handleAllExceptions(-1, ERR);
155 }
156 }
157
158 int32_t domain_values(int32_t handle, const char* component, int32_t bufLen, double* buf)
159 {
160 // method: vector<double> Domain1D::values(const string&)
161 try {
162 vector<double> out = Domain1DCabinet::at(handle)->values(component);
163 std::copy(out.begin(), out.end(), buf);
164 return int(out.size());
165 } catch (...) {
166 return handleAllExceptions(-1, ERR);
167 }
168 }
169
170 int32_t domain_setValues(int32_t handle, const char* component, int32_t valuesLen, const double* values)
171 {
172 // method: virtual void Domain1D::setValues(const string&, const vector<double>&)
173 try {
174 const vector<double> values_(values, values + valuesLen);
175 Domain1DCabinet::at(handle)->setValues(component, values_);
176 return 0;
177 } catch (...) {
178 return handleAllExceptions(-1, ERR);
179 }
180 }
181
182 int32_t domain_residuals(int32_t handle, const char* component, int32_t bufLen, double* buf)
183 {
184 // method: vector<double> Domain1D::residuals(const string&)
185 try {
186 vector<double> out = Domain1DCabinet::at(handle)->residuals(component);
187 std::copy(out.begin(), out.end(), buf);
188 return int(out.size());
189 } catch (...) {
190 return handleAllExceptions(-1, ERR);
191 }
192 }
193
194 int32_t domain_setProfile(int32_t handle, const char* component, int32_t posLen, const double* pos, int32_t valuesLen, const double* values)
195 {
196 // method: virtual void Domain1D::setProfile(const string&, const vector<double>&, const vector<double>&)
197 try {
198 const vector<double> pos_(pos, pos + posLen);
199 const vector<double> values_(values, values + valuesLen);
200 Domain1DCabinet::at(handle)->setProfile(component, pos_, values_);
201 return 0;
202 } catch (...) {
203 return handleAllExceptions(-1, ERR);
204 }
205 }
206
207 int32_t domain_setFlatProfile(int32_t handle, const char* component, double value)
208 {
209 // method: virtual void Domain1D::setFlatProfile(const string&, double)
210 try {
211 Domain1DCabinet::at(handle)->setFlatProfile(component, value);
212 return 0;
213 } catch (...) {
214 return handleAllExceptions(-1, ERR);
215 }
216 }
217
218 int32_t domain_setBounds(int32_t handle, int32_t n, double lower, double upper)
219 {
220 // method: void Domain1D::setBounds(size_t, double, double)
221 try {
222 Domain1DCabinet::at(handle)->setBounds(n, lower, upper);
223 return 0;
224 } catch (...) {
225 return handleAllExceptions(-1, ERR);
226 }
227 }
228
229 double domain_lowerBound(int32_t handle, int32_t n)
230 {
231 // method: double Domain1D::lowerBound(size_t)
232 try {
233 return Domain1DCabinet::at(handle)->lowerBound(n);
234 } catch (...) {
235 return handleAllExceptions(DERR, DERR);
236 }
237 }
238
239 double domain_upperBound(int32_t handle, int32_t n)
240 {
241 // method: double Domain1D::upperBound(size_t)
242 try {
243 return Domain1DCabinet::at(handle)->upperBound(n);
244 } catch (...) {
245 return handleAllExceptions(DERR, DERR);
246 }
247 }
248
249 int32_t domain_setSteadyTolerances(int32_t handle, double rtol, double atol, int32_t n)
250 {
251 // method: void Domain1D::setSteadyTolerances(double, double, size_t)
252 try {
253 Domain1DCabinet::at(handle)->setSteadyTolerances(rtol, atol, n);
254 return 0;
255 } catch (...) {
256 return handleAllExceptions(-1, ERR);
257 }
258 }
259
260 int32_t domain_setTransientTolerances(int32_t handle, double rtol, double atol, int32_t n)
261 {
262 // method: void Domain1D::setTransientTolerances(double, double, size_t)
263 try {
264 Domain1DCabinet::at(handle)->setTransientTolerances(rtol, atol, n);
265 return 0;
266 } catch (...) {
267 return handleAllExceptions(-1, ERR);
268 }
269 }
270
271 double domain_rtol(int32_t handle, int32_t n)
272 {
273 // method: double Domain1D::rtol(size_t)
274 try {
275 return Domain1DCabinet::at(handle)->rtol(n);
276 } catch (...) {
277 return handleAllExceptions(DERR, DERR);
278 }
279 }
280
281 double domain_atol(int32_t handle, int32_t n)
282 {
283 // method: double Domain1D::atol(size_t)
284 try {
285 return Domain1DCabinet::at(handle)->atol(n);
286 } catch (...) {
287 return handleAllExceptions(DERR, DERR);
288 }
289 }
290
291 int32_t domain_setupGrid(int32_t handle, int32_t gridLen, const double* grid)
292 {
293 // setter: void Domain1D::setupGrid(const vector<double>&)
294 try {
295 const vector<double> grid_(grid, grid + gridLen);
296 Domain1DCabinet::at(handle)->setupGrid(grid_);
297 return 0;
298 } catch (...) {
299 return handleAllExceptions(-1, ERR);
300 }
301 }
302
303 int32_t domain_setupUniformGrid(int32_t handle, int32_t points, double length, double start)
304 {
305 // method: void Domain1D::setupUniformGrid(size_t, double, double)
306 try {
307 Domain1DCabinet::at(handle)->setupUniformGrid(points, length, start);
308 return 0;
309 } catch (...) {
310 return handleAllExceptions(-1, ERR);
311 }
312 }
313
314 int32_t domain_setID(int32_t handle, const char* s)
315 {
316 // setter: void Domain1D::setID(const string&)
317 try {
318 Domain1DCabinet::at(handle)->setID(s);
319 return 0;
320 } catch (...) {
321 return handleAllExceptions(-1, ERR);
322 }
323 }
324
325 int32_t domain_grid(int32_t handle, int32_t bufLen, double* buf)
326 {
327 // getter: vector<double>& Domain1D::grid()
328 try {
329 auto& obj = Domain1DCabinet::at(handle);
330 // no size checking specified
331 vector<double>& out = obj->grid();
332 std::copy(out.begin(), out.end(), buf);
333 return int(out.size());
334 } catch (...) {
335 return handleAllExceptions(-1, ERR);
336 }
337 }
338
339 int32_t bdry_setMdot(int32_t handle, double mdot)
340 {
341 // setter: virtual void Boundary1D::setMdot(double)
342 try {
343 Domain1DCabinet::as<Boundary1D>(handle)->setMdot(mdot);
344 return 0;
345 } catch (...) {
346 return handleAllExceptions(-1, ERR);
347 }
348 }
349
350 int32_t bdry_setTemperature(int32_t handle, double t)
351 {
352 // setter: virtual void Boundary1D::setTemperature(double)
353 try {
354 Domain1DCabinet::as<Boundary1D>(handle)->setTemperature(t);
355 return 0;
356 } catch (...) {
357 return handleAllExceptions(-1, ERR);
358 }
359 }
360
361 int32_t bdry_setSpreadRate(int32_t handle, double V0)
362 {
363 // setter: virtual void Boundary1D::setSpreadRate(double)
364 try {
365 Domain1DCabinet::as<Boundary1D>(handle)->setSpreadRate(V0);
366 return 0;
367 } catch (...) {
368 return handleAllExceptions(-1, ERR);
369 }
370 }
371
372 int32_t bdry_setMoleFractions(int32_t handle, const char* xin)
373 {
374 // setter: virtual void Boundary1D::setMoleFractions(const string&)
375 try {
376 Domain1DCabinet::as<Boundary1D>(handle)->setMoleFractions(xin);
377 return 0;
378 } catch (...) {
379 return handleAllExceptions(-1, ERR);
380 }
381 }
382
383 double bdry_mdot(int32_t handle)
384 {
385 // getter: virtual double Boundary1D::mdot()
386 try {
387 return Domain1DCabinet::as<Boundary1D>(handle)->mdot();
388 } catch (...) {
389 return handleAllExceptions(DERR, DERR);
390 }
391 }
392
393 double bdry_temperature(int32_t handle)
394 {
395 // getter: virtual double Boundary1D::temperature()
396 try {
397 return Domain1DCabinet::as<Boundary1D>(handle)->temperature();
398 } catch (...) {
399 return handleAllExceptions(DERR, DERR);
400 }
401 }
402
403 double bdry_spreadRate(int32_t handle)
404 {
405 // getter: virtual double Boundary1D::spreadRate()
406 try {
407 return Domain1DCabinet::as<Boundary1D>(handle)->spreadRate();
408 } catch (...) {
409 return handleAllExceptions(DERR, DERR);
410 }
411 }
412
413 double bdry_massFraction(int32_t handle, int32_t k)
414 {
415 // method: virtual double Boundary1D::massFraction(size_t)
416 try {
417 return Domain1DCabinet::as<Boundary1D>(handle)->massFraction(k);
418 } catch (...) {
419 return handleAllExceptions(DERR, DERR);
420 }
421 }
422
423 int32_t domain_setTransport(int32_t handle, int32_t trans)
424 {
425 // setter: virtual void Domain1D::setTransport(shared_ptr<Transport>)
426 try {
427 Domain1DCabinet::at(handle)->setTransport(TransportCabinet::at(trans));
428 return 0;
429 } catch (...) {
430 return handleAllExceptions(-1, ERR);
431 }
432 }
433
434 int32_t flow_enableSoret(int32_t handle, int32_t withSoret)
435 {
436 // setter: void Flow1D::enableSoret(bool)
437 try {
438 bool withSoret_ = (withSoret != 0);
439 Domain1DCabinet::as<Flow1D>(handle)->enableSoret(withSoret_);
440 return 0;
441 } catch (...) {
442 return handleAllExceptions(-1, ERR);
443 }
444 }
445
446 int32_t flow_setPressure(int32_t handle, double p)
447 {
448 // setter: void Flow1D::setPressure(double)
449 try {
450 Domain1DCabinet::as<Flow1D>(handle)->setPressure(p);
451 return 0;
452 } catch (...) {
453 return handleAllExceptions(-1, ERR);
454 }
455 }
456
457 double flow_pressure(int32_t handle)
458 {
459 // getter: double Flow1D::pressure()
460 try {
461 return Domain1DCabinet::as<Flow1D>(handle)->pressure();
462 } catch (...) {
463 return handleAllExceptions(DERR, DERR);
464 }
465 }
466
467 int32_t flow_setFixedTempProfile(int32_t handle, int32_t zfixedLen, double* zfixed, int32_t tfixedLen, double* tfixed)
468 {
469 // method: void Flow1D::setFixedTempProfile(vector<double>&, vector<double>&)
470 try {
471 vector<double> zfixed_(zfixed, zfixed + zfixedLen);
472 vector<double> tfixed_(tfixed, tfixed + tfixedLen);
473 Domain1DCabinet::as<Flow1D>(handle)->setFixedTempProfile(zfixed_, tfixed_);
474 return 0;
475 } catch (...) {
476 return handleAllExceptions(-1, ERR);
477 }
478 }
479
480 int32_t flow_solveEnergyEqn(int32_t handle, int32_t j)
481 {
482 // setter: void Flow1D::solveEnergyEqn(size_t)
483 try {
484 Domain1DCabinet::as<Flow1D>(handle)->solveEnergyEqn(j);
485 return 0;
486 } catch (...) {
487 return handleAllExceptions(-1, ERR);
488 }
489 }
490
491 int32_t reactingsurf_enableCoverageEquations(int32_t handle, int32_t docov)
492 {
493 // setter: void ReactingSurf1D::enableCoverageEquations(bool)
494 try {
495 bool docov_ = (docov != 0);
496 Domain1DCabinet::as<ReactingSurf1D>(handle)->enableCoverageEquations(docov_);
497 return 0;
498 } catch (...) {
499 return handleAllExceptions(-1, ERR);
500 }
501 }
502
503 int32_t domain_del(int32_t handle)
504 {
505 // destructor
506 try {
507 Domain1DCabinet::del(handle);
508 return 0;
509 } catch (...) {
510 return handleAllExceptions(-1, ERR);
511 }
512 }
513
515 {
516 // reserved CLib function: custom code
517 try {
518 // *************** begin custom code ***************
519 return Domain1DCabinet::size();
520 // **************** end custom code ****************
521 } catch (...) {
522 return handleAllExceptions(-1, ERR);
523 }
524 }
525
526} // extern "C"
Boundary objects for one-dimensional simulations.
Header file defining class TransportFactory (see TransportFactory)
Template for classes to hold pointers to objects.
Definition Cabinet.h:51
CTDOMAIN - Generated CLib Cantera interface library.
int32_t domain_cabinetSize()
Return size of Domain1D storage.
Definition ctdomain.cpp:514
double bdry_spreadRate(int32_t handle)
Tangential velocity gradient [1/s] at this boundary.
Definition ctdomain.cpp:403
double domain_rtol(int32_t handle, int32_t n)
Relative tolerance of the nth component.
Definition ctdomain.cpp:271
double domain_atol(int32_t handle, int32_t n)
Absolute tolerance of the nth component.
Definition ctdomain.cpp:281
int32_t domain_setupUniformGrid(int32_t handle, int32_t points, double length, double start)
Set up uniform grid.
Definition ctdomain.cpp:303
double bdry_temperature(int32_t handle)
Temperature [K].
Definition ctdomain.cpp:393
int32_t domain_grid(int32_t handle, int32_t bufLen, double *buf)
Access the array of grid coordinates [m].
Definition ctdomain.cpp:325
int32_t domain_componentName(int32_t handle, int32_t n, int32_t bufLen, char *buf)
Name of component n.
Definition ctdomain.cpp:115
int32_t domain_setProfile(int32_t handle, const char *component, int32_t posLen, const double *pos, int32_t valuesLen, const double *values)
Specify a profile for a component.
Definition ctdomain.cpp:194
int32_t flow_enableSoret(int32_t handle, int32_t withSoret)
Enable thermal diffusion, also known as Soret diffusion.
Definition ctdomain.cpp:434
double domain_value(int32_t handle, const char *component)
Set a single component value at a boundary.
Definition ctdomain.cpp:137
int32_t flow_solveEnergyEqn(int32_t handle, int32_t j)
Specify that the energy equation should be solved at point j.
Definition ctdomain.cpp:480
int32_t domain_setID(int32_t handle, const char *s)
Specify an identifying tag for this domain.
Definition ctdomain.cpp:314
int32_t domain_nPoints(int32_t handle)
Number of grid points in this domain.
Definition ctdomain.cpp:105
double domain_upperBound(int32_t handle, int32_t n)
Upper bound on the nth component.
Definition ctdomain.cpp:239
int32_t domain_setTransientTolerances(int32_t handle, double rtol, double atol, int32_t n)
Set tolerances for time-stepping mode.
Definition ctdomain.cpp:260
int32_t domain_setValues(int32_t handle, const char *component, int32_t valuesLen, const double *values)
Specify component values.
Definition ctdomain.cpp:170
int32_t bdry_setSpreadRate(int32_t handle, double V0)
Set tangential velocity gradient [1/s] at this boundary.
Definition ctdomain.cpp:361
int32_t flow_setFixedTempProfile(int32_t handle, int32_t zfixedLen, double *zfixed, int32_t tfixedLen, double *tfixed)
Sometimes it is desired to carry out the simulation using a specified temperature profile,...
Definition ctdomain.cpp:467
int32_t domain_residuals(int32_t handle, const char *component, int32_t bufLen, double *buf)
Retrieve internal work array values for a component.
Definition ctdomain.cpp:182
double bdry_mdot(int32_t handle)
The total mass flow rate [kg/m2/s].
Definition ctdomain.cpp:383
int32_t domain_setupGrid(int32_t handle, int32_t gridLen, const double *grid)
Set up initial grid.
Definition ctdomain.cpp:291
int32_t domain_del(int32_t handle)
Delete Domain1D object.
Definition ctdomain.cpp:503
int32_t domain_setValue(int32_t handle, const char *component, double value)
Set a single component value in a flow domain or at a boundary.
Definition ctdomain.cpp:147
int32_t domain_newBoundary1D(const char *domainType, int32_t solution, const char *id)
Create a Boundary1D object of the specified type.
Definition ctdomain.cpp:63
int32_t domain_nComponents(int32_t handle)
Number of components at each grid point.
Definition ctdomain.cpp:95
double bdry_massFraction(int32_t handle, int32_t k)
Mass fraction of species k.
Definition ctdomain.cpp:413
int32_t reactingsurf_enableCoverageEquations(int32_t handle, int32_t docov)
Set whether to solve the equations for the surface species coverages.
Definition ctdomain.cpp:491
int32_t domain_index(int32_t handle, int32_t n, int32_t j)
Returns the index of the solution vector, which corresponds to component n at grid point j.
Definition ctdomain.cpp:85
int32_t bdry_setTemperature(int32_t handle, double t)
Set the temperature.
Definition ctdomain.cpp:350
double domain_lowerBound(int32_t handle, int32_t n)
Lower bound on the nth component.
Definition ctdomain.cpp:229
int32_t domain_setTransport(int32_t handle, int32_t trans)
Set transport model to existing instance.
Definition ctdomain.cpp:423
int32_t domain_type(int32_t handle, int32_t bufLen, char *buf)
String indicating the domain implemented.
Definition ctdomain.cpp:73
int32_t domain_values(int32_t handle, const char *component, int32_t bufLen, double *buf)
Retrieve component values.
Definition ctdomain.cpp:158
int32_t flow_setPressure(int32_t handle, double p)
Set the pressure.
Definition ctdomain.cpp:446
int32_t bdry_setMoleFractions(int32_t handle, const char *xin)
Set the mole fractions by specifying a string.
Definition ctdomain.cpp:372
int32_t domain_newFlow1D(const char *domainType, int32_t solution, const char *id)
Create a Flow1D object of the specified type.
Definition ctdomain.cpp:53
int32_t domain_setSteadyTolerances(int32_t handle, double rtol, double atol, int32_t n)
Set tolerances for steady-state mode.
Definition ctdomain.cpp:249
double flow_pressure(int32_t handle)
The current pressure [Pa].
Definition ctdomain.cpp:457
int32_t bdry_setMdot(int32_t handle, double mdot)
Set the total mass flow rate [kg/m²/s].
Definition ctdomain.cpp:339
int32_t domain_componentIndex(int32_t handle, const char *name)
Index of component with name name.
Definition ctdomain.cpp:127
int32_t domain_setFlatProfile(int32_t handle, const char *component, double value)
Specify a flat profile for a component.
Definition ctdomain.cpp:207
int32_t domain_setBounds(int32_t handle, int32_t n, double lower, double upper)
Set the upper and lower bounds for a solution component, n.
Definition ctdomain.cpp:218
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< Flow1D > newFlow1D(const string &domainType, shared_ptr< Solution > solution, const string &id)
Create a Flow1D object of the specified type.
shared_ptr< Boundary1D > newBoundary1D(const string &domainType, shared_ptr< Solution > solution, const string &id)
Create a Boundary1D object of the specified type.
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.