Cantera  3.2.0a2
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
23#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<Flow1D> Flow1DCabinet;
38template<> Flow1DCabinet* Flow1DCabinet::s_storage; // initialized elsewhere
39
40typedef Cabinet<Boundary1D> Boundary1DCabinet;
41template<> Boundary1DCabinet* Boundary1DCabinet::s_storage; // initialized elsewhere
42
43typedef Cabinet<Transport> TransportCabinet;
44template<> TransportCabinet* TransportCabinet::s_storage; // initialized elsewhere
45
46typedef Cabinet<Solution> SolutionCabinet;
47template<> SolutionCabinet* SolutionCabinet::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 int32_t domain_setBounds(int32_t handle, int32_t n, double lower, double upper)
138 {
139 // method: void Domain1D::setBounds(size_t, double, double)
140 try {
141 Domain1DCabinet::at(handle)->setBounds(n, lower, upper);
142 return 0;
143 } catch (...) {
144 return handleAllExceptions(-1, ERR);
145 }
146 }
147
148 double domain_lowerBound(int32_t handle, int32_t n)
149 {
150 // method: double Domain1D::lowerBound(size_t)
151 try {
152 return Domain1DCabinet::at(handle)->lowerBound(n);
153 } catch (...) {
154 return handleAllExceptions(DERR, DERR);
155 }
156 }
157
158 double domain_upperBound(int32_t handle, int32_t n)
159 {
160 // method: double Domain1D::upperBound(size_t)
161 try {
162 return Domain1DCabinet::at(handle)->upperBound(n);
163 } catch (...) {
164 return handleAllExceptions(DERR, DERR);
165 }
166 }
167
168 int32_t domain_setSteadyTolerances(int32_t handle, double rtol, double atol, int32_t n)
169 {
170 // method: void Domain1D::setSteadyTolerances(double, double, size_t)
171 try {
172 Domain1DCabinet::at(handle)->setSteadyTolerances(rtol, atol, n);
173 return 0;
174 } catch (...) {
175 return handleAllExceptions(-1, ERR);
176 }
177 }
178
179 int32_t domain_setTransientTolerances(int32_t handle, double rtol, double atol, int32_t n)
180 {
181 // method: void Domain1D::setTransientTolerances(double, double, size_t)
182 try {
183 Domain1DCabinet::at(handle)->setTransientTolerances(rtol, atol, n);
184 return 0;
185 } catch (...) {
186 return handleAllExceptions(-1, ERR);
187 }
188 }
189
190 double domain_rtol(int32_t handle, int32_t n)
191 {
192 // method: double Domain1D::rtol(size_t)
193 try {
194 return Domain1DCabinet::at(handle)->rtol(n);
195 } catch (...) {
196 return handleAllExceptions(DERR, DERR);
197 }
198 }
199
200 double domain_atol(int32_t handle, int32_t n)
201 {
202 // method: double Domain1D::atol(size_t)
203 try {
204 return Domain1DCabinet::at(handle)->atol(n);
205 } catch (...) {
206 return handleAllExceptions(DERR, DERR);
207 }
208 }
209
210 int32_t domain_setupGrid(int32_t handle, int32_t gridLen, const double* grid)
211 {
212 // setter: void Domain1D::setupGrid(const vector<double>&)
213 try {
214 const vector<double> grid_(grid, grid + gridLen);
215 Domain1DCabinet::at(handle)->setupGrid(grid_);
216 return 0;
217 } catch (...) {
218 return handleAllExceptions(-1, ERR);
219 }
220 }
221
222 int32_t domain_setupUniformGrid(int32_t handle, int32_t points, double length, double start)
223 {
224 // method: void Domain1D::setupUniformGrid(size_t, double, double)
225 try {
226 Domain1DCabinet::at(handle)->setupUniformGrid(points, length, start);
227 return 0;
228 } catch (...) {
229 return handleAllExceptions(-1, ERR);
230 }
231 }
232
233 int32_t domain_setID(int32_t handle, const char* s)
234 {
235 // setter: void Domain1D::setID(const string&)
236 try {
237 Domain1DCabinet::at(handle)->setID(s);
238 return 0;
239 } catch (...) {
240 return handleAllExceptions(-1, ERR);
241 }
242 }
243
244 int32_t domain_grid(int32_t handle, int32_t bufLen, double* buf)
245 {
246 // getter: vector<double>& Domain1D::grid()
247 try {
248 auto& obj = Domain1DCabinet::at(handle);
249 // no size checking specified
250 vector<double>& out = obj->grid();
251 std::copy(out.begin(), out.end(), buf);
252 return int(out.size());
253 } catch (...) {
254 return handleAllExceptions(-1, ERR);
255 }
256 }
257
258 int32_t bdry_setMdot(int32_t handle, double mdot)
259 {
260 // setter: virtual void Boundary1D::setMdot(double)
261 try {
262 Domain1DCabinet::as<Boundary1D>(handle)->setMdot(mdot);
263 return 0;
264 } catch (...) {
265 return handleAllExceptions(-1, ERR);
266 }
267 }
268
269 int32_t bdry_setTemperature(int32_t handle, double t)
270 {
271 // setter: virtual void Boundary1D::setTemperature(double)
272 try {
273 Domain1DCabinet::as<Boundary1D>(handle)->setTemperature(t);
274 return 0;
275 } catch (...) {
276 return handleAllExceptions(-1, ERR);
277 }
278 }
279
280 int32_t bdry_setSpreadRate(int32_t handle, double V0)
281 {
282 // setter: virtual void Boundary1D::setSpreadRate(double)
283 try {
284 Domain1DCabinet::as<Boundary1D>(handle)->setSpreadRate(V0);
285 return 0;
286 } catch (...) {
287 return handleAllExceptions(-1, ERR);
288 }
289 }
290
291 int32_t bdry_setMoleFractions(int32_t handle, const char* xin)
292 {
293 // setter: virtual void Boundary1D::setMoleFractions(const string&)
294 try {
295 Domain1DCabinet::as<Boundary1D>(handle)->setMoleFractions(xin);
296 return 0;
297 } catch (...) {
298 return handleAllExceptions(-1, ERR);
299 }
300 }
301
302 double bdry_mdot(int32_t handle)
303 {
304 // getter: virtual double Boundary1D::mdot()
305 try {
306 return Domain1DCabinet::as<Boundary1D>(handle)->mdot();
307 } catch (...) {
308 return handleAllExceptions(DERR, DERR);
309 }
310 }
311
312 double bdry_temperature(int32_t handle)
313 {
314 // getter: virtual double Boundary1D::temperature()
315 try {
316 return Domain1DCabinet::as<Boundary1D>(handle)->temperature();
317 } catch (...) {
318 return handleAllExceptions(DERR, DERR);
319 }
320 }
321
322 double bdry_spreadRate(int32_t handle)
323 {
324 // getter: virtual double Boundary1D::spreadRate()
325 try {
326 return Domain1DCabinet::as<Boundary1D>(handle)->spreadRate();
327 } catch (...) {
328 return handleAllExceptions(DERR, DERR);
329 }
330 }
331
332 double bdry_massFraction(int32_t handle, int32_t k)
333 {
334 // method: virtual double Boundary1D::massFraction(size_t)
335 try {
336 return Domain1DCabinet::as<Boundary1D>(handle)->massFraction(k);
337 } catch (...) {
338 return handleAllExceptions(DERR, DERR);
339 }
340 }
341
342 int32_t domain_setTransport(int32_t handle, int32_t trans)
343 {
344 // setter: virtual void Domain1D::setTransport(shared_ptr<Transport>)
345 try {
346 Domain1DCabinet::at(handle)->setTransport(TransportCabinet::at(trans));
347 return 0;
348 } catch (...) {
349 return handleAllExceptions(-1, ERR);
350 }
351 }
352
353 int32_t flow_enableSoret(int32_t handle, int32_t withSoret)
354 {
355 // setter: void Flow1D::enableSoret(bool)
356 try {
357 bool withSoret_ = (withSoret != 0);
358 Domain1DCabinet::as<Flow1D>(handle)->enableSoret(withSoret_);
359 return 0;
360 } catch (...) {
361 return handleAllExceptions(-1, ERR);
362 }
363 }
364
365 int32_t flow_setPressure(int32_t handle, double p)
366 {
367 // setter: void Flow1D::setPressure(double)
368 try {
369 Domain1DCabinet::as<Flow1D>(handle)->setPressure(p);
370 return 0;
371 } catch (...) {
372 return handleAllExceptions(-1, ERR);
373 }
374 }
375
376 double flow_pressure(int32_t handle)
377 {
378 // getter: double Flow1D::pressure()
379 try {
380 return Domain1DCabinet::as<Flow1D>(handle)->pressure();
381 } catch (...) {
382 return handleAllExceptions(DERR, DERR);
383 }
384 }
385
386 int32_t flow_setFixedTempProfile(int32_t handle, int32_t zfixedLen, double* zfixed, int32_t tfixedLen, double* tfixed)
387 {
388 // method: void Flow1D::setFixedTempProfile(vector<double>&, vector<double>&)
389 try {
390 vector<double> zfixed_(zfixed, zfixed + zfixedLen);
391 vector<double> tfixed_(tfixed, tfixed + tfixedLen);
392 Domain1DCabinet::as<Flow1D>(handle)->setFixedTempProfile(zfixed_, tfixed_);
393 return 0;
394 } catch (...) {
395 return handleAllExceptions(-1, ERR);
396 }
397 }
398
399 int32_t flow_solveEnergyEqn(int32_t handle, int32_t j)
400 {
401 // setter: void Flow1D::solveEnergyEqn(size_t)
402 try {
403 Domain1DCabinet::as<Flow1D>(handle)->solveEnergyEqn(j);
404 return 0;
405 } catch (...) {
406 return handleAllExceptions(-1, ERR);
407 }
408 }
409
410 int32_t reactingsurf_enableCoverageEquations(int32_t handle, int32_t docov)
411 {
412 // setter: void ReactingSurf1D::enableCoverageEquations(bool)
413 try {
414 bool docov_ = (docov != 0);
415 Domain1DCabinet::as<ReactingSurf1D>(handle)->enableCoverageEquations(docov_);
416 return 0;
417 } catch (...) {
418 return handleAllExceptions(-1, ERR);
419 }
420 }
421
422 int32_t domain_del(int32_t handle)
423 {
424 // destructor
425 try {
426 Domain1DCabinet::del(handle);
427 return 0;
428 } catch (...) {
429 return handleAllExceptions(-1, ERR);
430 }
431 }
432
434 {
435 // reserved CLib function: custom code
436 try {
437 // *************** begin custom code ***************
438 return Domain1DCabinet::size();
439 // **************** end custom code ****************
440 } catch (...) {
441 return handleAllExceptions(-1, ERR);
442 }
443 }
444
445 int32_t domain_parentHandle(int32_t handle)
446 {
447 // reserved CLib function: custom code
448 try {
449 // *************** begin custom code ***************
450 return Domain1DCabinet::parent(handle);
451 // **************** end custom code ****************
452 } catch (...) {
453 return handleAllExceptions(-1, ERR);
454 }
455 }
456
457} // extern "C"
Boundary objects for one-dimensional simulations.
Header file defining class TransportFactory (see TransportFactory)
CTDOMAIN - Generated CLib Cantera interface library.
int32_t domain_cabinetSize()
Return size of Domain1D storage.
Definition ctdomain.cpp:433
double bdry_spreadRate(int32_t handle)
Tangential velocity gradient [1/s] at this boundary.
Definition ctdomain.cpp:322
double domain_rtol(int32_t handle, int32_t n)
Relative tolerance of the nth component.
Definition ctdomain.cpp:190
double domain_atol(int32_t handle, int32_t n)
Absolute tolerance of the nth component.
Definition ctdomain.cpp:200
int32_t domain_setupUniformGrid(int32_t handle, int32_t points, double length, double start)
Set up uniform grid.
Definition ctdomain.cpp:222
double bdry_temperature(int32_t handle)
Temperature [K].
Definition ctdomain.cpp:312
int32_t domain_grid(int32_t handle, int32_t bufLen, double *buf)
Access the array of grid coordinates [m].
Definition ctdomain.cpp:244
int32_t domain_componentName(int32_t handle, int32_t n, int32_t bufLen, char *buf)
Name of component.
Definition ctdomain.cpp:115
int32_t flow_enableSoret(int32_t handle, int32_t withSoret)
Enable thermal diffusion, also known as Soret diffusion.
Definition ctdomain.cpp:353
int32_t flow_solveEnergyEqn(int32_t handle, int32_t j)
Specify that the energy equation should be solved at point.
Definition ctdomain.cpp:399
int32_t domain_setID(int32_t handle, const char *s)
Specify an identifying tag for this domain.
Definition ctdomain.cpp:233
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:158
int32_t domain_setTransientTolerances(int32_t handle, double rtol, double atol, int32_t n)
Set tolerances for time-stepping mode.
Definition ctdomain.cpp:179
int32_t bdry_setSpreadRate(int32_t handle, double V0)
Set tangential velocity gradient [1/s] at this boundary.
Definition ctdomain.cpp:280
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:386
double bdry_mdot(int32_t handle)
The total mass flow rate [kg/m2/s].
Definition ctdomain.cpp:302
int32_t domain_setupGrid(int32_t handle, int32_t gridLen, const double *grid)
Set up initial grid.
Definition ctdomain.cpp:210
int32_t domain_del(int32_t handle)
Delete Domain1D object.
Definition ctdomain.cpp:422
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:332
int32_t domain_parentHandle(int32_t handle)
Return handle to parent of Domain1D object.
Definition ctdomain.cpp:445
int32_t reactingsurf_enableCoverageEquations(int32_t handle, int32_t docov)
Set whether to solve the equations for the surface species coverages.
Definition ctdomain.cpp:410
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:269
double domain_lowerBound(int32_t handle, int32_t n)
Lower bound on the nth component.
Definition ctdomain.cpp:148
int32_t domain_setTransport(int32_t handle, int32_t trans)
Set transport model to existing instance.
Definition ctdomain.cpp:342
int32_t domain_type(int32_t handle, int32_t bufLen, char *buf)
String indicating the domain implemented.
Definition ctdomain.cpp:73
int32_t flow_setPressure(int32_t handle, double p)
Set the pressure.
Definition ctdomain.cpp:365
int32_t bdry_setMoleFractions(int32_t handle, const char *xin)
Set the mole fractions by specifying a string.
Definition ctdomain.cpp:291
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:168
double flow_pressure(int32_t handle)
The current pressure [Pa].
Definition ctdomain.cpp:376
int32_t bdry_setMdot(int32_t handle, double mdot)
Set the total mass flow rate [kg/m²/s].
Definition ctdomain.cpp:258
int32_t domain_componentIndex(int32_t handle, const char *name)
index of component with name
Definition ctdomain.cpp:127
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:137
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.