Cantera  3.2.0a2
Loading...
Searching...
No Matches
ct.cpp
Go to the documentation of this file.
1/**
2 * CT - Generated CLib %Cantera interface library.
3 *
4 * @file ct.cpp
5 *
6 * The main library of the generated CLib API contains Cantera service functions.
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"
19#include "cantera_clib/ct.h"
20
22#include "cantera/base/global.h"
23#include "cantera/base/ExternalLogger.h"
26#include "cantera/zeroD/Wall.h"
33#include "cantera/oneD/Sim1D.h"
43
44using namespace Cantera;
45
46//! @cond
47//! Cabinet type definitions will be ignored by Doxygen
48
49typedef Cabinet<ConnectorNode> ConnectorNodeCabinet;
50template<> ConnectorNodeCabinet* ConnectorNodeCabinet::s_storage; // initialized elsewhere
51
52typedef Cabinet<Domain1D> Domain1DCabinet;
53template<> Domain1DCabinet* Domain1DCabinet::s_storage; // initialized elsewhere
54
55typedef Cabinet<Func1> Func1Cabinet;
56template<> Func1Cabinet* Func1Cabinet::s_storage; // initialized elsewhere
57
58typedef Cabinet<Kinetics> KineticsCabinet;
59template<> KineticsCabinet* KineticsCabinet::s_storage; // initialized elsewhere
60
61typedef Cabinet<MultiPhase> MultiPhaseCabinet;
62template<> MultiPhaseCabinet* MultiPhaseCabinet::s_storage; // initialized elsewhere
63
64typedef Cabinet<Sim1D> Sim1DCabinet;
65template<> Sim1DCabinet* Sim1DCabinet::s_storage; // initialized elsewhere
66
67typedef Cabinet<ReactionPathDiagram> ReactionPathDiagramCabinet;
68template<> ReactionPathDiagramCabinet* ReactionPathDiagramCabinet::s_storage; // initialized elsewhere
69
70typedef Cabinet<ReactorBase> ReactorBaseCabinet;
71template<> ReactorBaseCabinet* ReactorBaseCabinet::s_storage; // initialized elsewhere
72
73typedef Cabinet<ReactorNet> ReactorNetCabinet;
74template<> ReactorNetCabinet* ReactorNetCabinet::s_storage; // initialized elsewhere
75
76typedef Cabinet<Reaction> ReactionCabinet;
77template<> ReactionCabinet* ReactionCabinet::s_storage; // initialized elsewhere
78
79typedef Cabinet<Solution> SolutionCabinet;
80template<> SolutionCabinet* SolutionCabinet::s_storage; // initialized elsewhere
81
82typedef Cabinet<ThermoPhase> ThermoPhaseCabinet;
83template<> ThermoPhaseCabinet* ThermoPhaseCabinet::s_storage; // initialized elsewhere
84
85typedef Cabinet<Transport> TransportCabinet;
86template<> TransportCabinet* TransportCabinet::s_storage; // initialized elsewhere
87
88//! @endcond
89
90extern "C" {
91
92 int32_t ct_version(int32_t bufLen, char* buf)
93 {
94 // function: string version()
95 try {
96 string out = version();
97 copyString(out, buf, bufLen);
98 return int(out.size()) + 1;
99 } catch (...) {
100 return handleAllExceptions(-1, ERR);
101 }
102 }
103
104 int32_t ct_gitCommit(int32_t bufLen, char* buf)
105 {
106 // function: string gitCommit()
107 try {
108 string out = gitCommit();
109 copyString(out, buf, bufLen);
110 return int(out.size()) + 1;
111 } catch (...) {
112 return handleAllExceptions(-1, ERR);
113 }
114 }
115
116 int32_t ct_addDataDirectory(const char* dir)
117 {
118 // function: void addDirectory(const string&)
119 try {
120 addDirectory(dir);
121 return 0;
122 } catch (...) {
123 return handleAllExceptions(-1, ERR);
124 }
125 }
126
127 int32_t ct_getDataDirectories(const char* sep, int32_t bufLen, char* buf)
128 {
129 // function: string getDataDirectories(const string&)
130 try {
131 string out = getDataDirectories(sep);
132 copyString(out, buf, bufLen);
133 return int(out.size()) + 1;
134 } catch (...) {
135 return handleAllExceptions(-1, ERR);
136 }
137 }
138
139 int32_t ct_findInputFile(const char* name, int32_t bufLen, char* buf)
140 {
141 // function: string findInputFile(const string&)
142 try {
143 string out = findInputFile(name);
144 copyString(out, buf, bufLen);
145 return int(out.size()) + 1;
146 } catch (...) {
147 return handleAllExceptions(-1, ERR);
148 }
149 }
150
152 {
153 // function: void suppress_deprecation_warnings()
154 try {
156 return 0;
157 } catch (...) {
158 return handleAllExceptions(-1, ERR);
159 }
160 }
161
163 {
164 // function: void make_deprecation_warnings_fatal()
165 try {
167 return 0;
168 } catch (...) {
169 return handleAllExceptions(-1, ERR);
170 }
171 }
172
174 {
175 // function: void suppress_warnings()
176 try {
178 return 0;
179 } catch (...) {
180 return handleAllExceptions(-1, ERR);
181 }
182 }
183
185 {
186 // function: bool warnings_suppressed()
187 try {
188 bool out = warnings_suppressed();
189 return int(out);
190 } catch (...) {
191 return handleAllExceptions(-1, ERR);
192 }
193 }
194
196 {
197 // function: void make_warnings_fatal()
198 try {
200 return 0;
201 } catch (...) {
202 return handleAllExceptions(-1, ERR);
203 }
204 }
205
206 int32_t ct_suppress_thermo_warnings(int32_t suppress)
207 {
208 // function: void suppress_thermo_warnings(bool)
209 try {
210 bool suppress_ = (suppress != 0);
211 suppress_thermo_warnings(suppress_);
212 return 0;
213 } catch (...) {
214 return handleAllExceptions(-1, ERR);
215 }
216 }
217
218 int32_t ct_use_legacy_rate_constants(int32_t legacy)
219 {
220 // function: void use_legacy_rate_constants(bool)
221 try {
222 bool legacy_ = (legacy != 0);
224 return 0;
225 } catch (...) {
226 return handleAllExceptions(-1, ERR);
227 }
228 }
229
230 int32_t ct_appdelete()
231 {
232 // function: void appdelete()
233 try {
234 appdelete();
235 return 0;
236 } catch (...) {
237 return handleAllExceptions(-1, ERR);
238 }
239 }
240
241 const double ct_Avogadro()
242 {
243 // variable (getter): variable getter: Avogadro
244 try {
245 return Avogadro;
246 } catch (...) {
247 return handleAllExceptions(DERR, DERR);
248 }
249 }
250
251 const double ct_Boltzmann()
252 {
253 // variable (getter): variable getter: Boltzmann
254 try {
255 return Boltzmann;
256 } catch (...) {
257 return handleAllExceptions(DERR, DERR);
258 }
259 }
260
261 const double ct_Planck()
262 {
263 // variable (getter): variable getter: Planck
264 try {
265 return Planck;
266 } catch (...) {
267 return handleAllExceptions(DERR, DERR);
268 }
269 }
270
271 const double ct_ElectronCharge()
272 {
273 // variable (getter): variable getter: ElectronCharge
274 try {
275 return ElectronCharge;
276 } catch (...) {
277 return handleAllExceptions(DERR, DERR);
278 }
279 }
280
281 const double ct_lightSpeed()
282 {
283 // variable (getter): variable getter: lightSpeed
284 try {
285 return lightSpeed;
286 } catch (...) {
287 return handleAllExceptions(DERR, DERR);
288 }
289 }
290
291 const double ct_OneAtm()
292 {
293 // variable (getter): variable getter: OneAtm
294 try {
295 return OneAtm;
296 } catch (...) {
297 return handleAllExceptions(DERR, DERR);
298 }
299 }
300
301 const double ct_OneBar()
302 {
303 // variable (getter): variable getter: OneBar
304 try {
305 return OneBar;
306 } catch (...) {
307 return handleAllExceptions(DERR, DERR);
308 }
309 }
310
312 {
313 // variable (getter): variable getter: fineStructureConstant
314 try {
316 } catch (...) {
317 return handleAllExceptions(DERR, DERR);
318 }
319 }
320
321 const double ct_ElectronMass()
322 {
323 // variable (getter): variable getter: ElectronMass
324 try {
325 return ElectronMass;
326 } catch (...) {
327 return handleAllExceptions(DERR, DERR);
328 }
329 }
330
331 const double ct_GasConstant()
332 {
333 // variable (getter): variable getter: GasConstant
334 try {
335 return GasConstant;
336 } catch (...) {
337 return handleAllExceptions(DERR, DERR);
338 }
339 }
340
341 const double ct_StefanBoltz()
342 {
343 // variable (getter): variable getter: StefanBoltz
344 try {
345 return StefanBoltz;
346 } catch (...) {
347 return handleAllExceptions(DERR, DERR);
348 }
349 }
350
351 const double ct_Faraday()
352 {
353 // variable (getter): variable getter: Faraday
354 try {
355 return Faraday;
356 } catch (...) {
357 return handleAllExceptions(DERR, DERR);
358 }
359 }
360
361 const double ct_permeability_0()
362 {
363 // variable (getter): variable getter: permeability_0
364 try {
365 return permeability_0;
366 } catch (...) {
367 return handleAllExceptions(DERR, DERR);
368 }
369 }
370
371 const double ct_epsilon_0()
372 {
373 // variable (getter): variable getter: epsilon_0
374 try {
375 return epsilon_0;
376 } catch (...) {
377 return handleAllExceptions(DERR, DERR);
378 }
379 }
380
381 int32_t ct_getCanteraError(int32_t bufLen, char* buf)
382 {
383 // function: custom code
384 try {
385 // *************** begin custom code ***************
386 string err = Application::Instance()->lastErrorMessage();
387 copyString(err, buf, bufLen);
388 return static_cast<int32_t>(err.size());
389 // **************** end custom code ****************
390 } catch (...) {
391 return handleAllExceptions(-1, ERR);
392 }
393 }
394
396 {
397 // function: custom code
398 try {
399 // *************** begin custom code ***************
400 auto logwriter = make_unique<ExternalLogger>(writer);
401 setLogger(std::move(logwriter));
402 return 0;
403 // **************** end custom code ****************
404 } catch (...) {
405 return handleAllExceptions(-1, ERR);
406 }
407 }
408
409 int32_t ct_writeLog(const char* msg)
410 {
411 // function: void writelog_direct(const string&)
412 try {
413 writelog_direct(msg);
414 return 0;
415 } catch (...) {
416 return handleAllExceptions(-1, ERR);
417 }
418 }
419
421 {
422 // reserved CLib function: custom code
423 try {
424 // *************** begin custom code ***************
425 ConnectorNodeCabinet::clear();
426 Domain1DCabinet::clear();
427 Func1Cabinet::clear();
428 KineticsCabinet::clear();
429 MultiPhaseCabinet::clear();
430 Sim1DCabinet::clear();
431 ReactionPathDiagramCabinet::clear();
432 ReactorBaseCabinet::clear();
433 ReactorNetCabinet::clear();
434 ReactionCabinet::clear();
435 SolutionCabinet::clear();
436 ThermoPhaseCabinet::clear();
437 TransportCabinet::clear();
438 return 0;
439 // **************** end custom code ****************
440 } catch (...) {
441 return handleAllExceptions(-1, ERR);
442 }
443 }
444
446 {
447 // reserved CLib function: custom code
448 try {
449 // *************** begin custom code ***************
450 ConnectorNodeCabinet::reset();
451 Domain1DCabinet::reset();
452 Func1Cabinet::reset();
453 KineticsCabinet::reset();
454 MultiPhaseCabinet::reset();
455 Sim1DCabinet::reset();
456 ReactionPathDiagramCabinet::reset();
457 ReactorBaseCabinet::reset();
458 ReactorNetCabinet::reset();
459 ReactionCabinet::reset();
460 SolutionCabinet::reset();
461 ThermoPhaseCabinet::reset();
462 TransportCabinet::reset();
463 return 0;
464 // **************** end custom code ****************
465 } catch (...) {
466 return handleAllExceptions(-1, ERR);
467 }
468 }
469
470} // extern "C"
Headers for the MultiPhase object that is used to set up multiphase equilibrium problems (see Chemica...
Classes for reaction path analysis.
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Header file defining class TransportFactory (see TransportFactory)
Header file for base class WallBase.
static Application * Instance()
Return a pointer to the one and only instance of class Application.
string lastErrorMessage()
Retrieve the last error message in a string.
Some flow devices derived from class FlowDevice.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
int32_t ct_suppress_warnings()
Globally disable printing of (user) warnings.
Definition ct.cpp:173
int32_t ct_getCanteraError(int32_t bufLen, char *buf)
Get Cantera error.
Definition ct.cpp:381
const double ct_ElectronMass()
Electron Mass.
Definition ct.cpp:321
const double ct_Boltzmann()
Boltzmann constant.
Definition ct.cpp:251
int32_t ct_make_deprecation_warnings_fatal()
Turns deprecation warnings into exceptions.
Definition ct.cpp:162
int32_t ct_getDataDirectories(const char *sep, int32_t bufLen, char *buf)
Get the Cantera data directories.
Definition ct.cpp:127
int32_t ct_appdelete()
Delete and free all memory associated with the application.
Definition ct.cpp:230
const double ct_fineStructureConstant()
Fine structure constant.
Definition ct.cpp:311
int32_t ct_clearStorage()
Delete all objects with mapping preserved.
Definition ct.cpp:420
int32_t ct_findInputFile(const char *name, int32_t bufLen, char *buf)
Find an input file.
Definition ct.cpp:139
const double ct_StefanBoltz()
Stefan-Boltzmann constant.
Definition ct.cpp:341
int32_t ct_writeLog(const char *msg)
Write a message to the logger.
Definition ct.cpp:409
int32_t ct_make_warnings_fatal()
Turns Cantera warnings into exceptions.
Definition ct.cpp:195
int32_t ct_use_legacy_rate_constants(int32_t legacy)
Set definition used for rate constant calculation.
Definition ct.cpp:218
int32_t ct_suppress_thermo_warnings(int32_t suppress)
Globally disable printing of warnings about problematic thermo data, such as NASA polynomials with di...
Definition ct.cpp:206
const double ct_GasConstant()
Universal Gas Constant.
Definition ct.cpp:331
const double ct_Planck()
Planck constant.
Definition ct.cpp:261
int32_t ct_setLogCallback(LogCallback writer)
Set Logger callback.
Definition ct.cpp:395
int32_t ct_warnings_suppressed()
Returns.
Definition ct.cpp:184
int32_t ct_version(int32_t bufLen, char *buf)
Returns the Cantera version.
Definition ct.cpp:92
const double ct_epsilon_0()
Permittivity of free space.
Definition ct.cpp:371
int32_t ct_resetStorage()
Delete all objects and erase mapping.
Definition ct.cpp:445
const double ct_permeability_0()
Permeability of free space.
Definition ct.cpp:361
const double ct_ElectronCharge()
Elementary charge.
Definition ct.cpp:271
const double ct_OneAtm()
One atmosphere [Pa].
Definition ct.cpp:291
int32_t ct_suppress_deprecation_warnings()
Globally disable printing of deprecation warnings.
Definition ct.cpp:151
const double ct_lightSpeed()
Speed of Light in a vacuum.
Definition ct.cpp:281
const double ct_Faraday()
Faraday constant.
Definition ct.cpp:351
int32_t ct_gitCommit(int32_t bufLen, char *buf)
Returns the hash of the git commit from which Cantera was compiled, if known.
Definition ct.cpp:104
int32_t ct_addDataDirectory(const char *dir)
Add a directory to the data file search path.
Definition ct.cpp:116
const double ct_OneBar()
One bar [Pa].
Definition ct.cpp:301
const double ct_Avogadro()
Avogadro's Number.
Definition ct.cpp:241
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.
bool warnings_suppressed()
Returns true if warnings should be suppressed.
Definition global.cpp:91
void use_legacy_rate_constants(bool legacy)
Set definition used for rate constant calculation.
Definition global.cpp:111
void suppress_deprecation_warnings()
Globally disable printing of deprecation warnings.
Definition global.cpp:76
void make_warnings_fatal()
Turns Cantera warnings into exceptions.
Definition global.cpp:96
string version()
Returns the Cantera version.
Definition global.cpp:154
void make_deprecation_warnings_fatal()
Turns deprecation warnings into exceptions.
Definition global.cpp:81
void suppress_warnings()
Globally disable printing of (user) warnings.
Definition global.cpp:86
void suppress_thermo_warnings(bool suppress)
Globally disable printing of warnings about problematic thermo data, such as NASA polynomials with di...
Definition global.cpp:101
string gitCommit()
Returns the hash of the git commit from which Cantera was compiled, if known.
Definition global.cpp:159
string getDataDirectories(const string &sep)
Get the Cantera data directories.
Definition global.cpp:173
string findInputFile(const string &name)
Find an input file.
Definition global.cpp:178
void addDirectory(const string &dir)
Add a directory to the data file search path.
Definition global.cpp:168
void writelog_direct(const string &msg)
Write a message to the logger.
Definition global.cpp:45
void setLogger(Logger *logwriter)
Install a logger.
Definition global.cpp:27
const double Boltzmann
Boltzmann constant [J/K].
Definition ct_defs.h:84
const double Faraday
Faraday constant [C/kmol].
Definition ct_defs.h:131
const double Avogadro
Avogadro's Number [number/kmol].
Definition ct_defs.h:81
const double Planck
Planck constant [J-s].
Definition ct_defs.h:87
const double permeability_0
Permeability of free space [N/A2].
Definition ct_defs.h:134
const double OneAtm
One atmosphere [Pa].
Definition ct_defs.h:96
const double lightSpeed
Speed of Light in a vacuum [m/s].
Definition ct_defs.h:93
const double StefanBoltz
Stefan-Boltzmann constant [W/m2/K4].
Definition ct_defs.h:128
const double epsilon_0
Permittivity of free space [F/m].
Definition ct_defs.h:137
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:120
const double ElectronCharge
Elementary charge [C].
Definition ct_defs.h:90
const double fineStructureConstant
Fine structure constant [].
Definition ct_defs.h:108
const double OneBar
One bar [Pa].
Definition ct_defs.h:99
const double ElectronMass
Electron Mass [kg].
Definition ct_defs.h:111
void(* LogCallback)(enum LogLevel logLevel, const char *category, const char *message)
Represents a callback that is invoked to produce log output.
CT - 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
void appdelete()
Delete and free all memory associated with the application.
Definition global.cpp:143
Contains declarations for string manipulation functions within Cantera.