Cantera  3.2.0a4
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_usesHDF5()
117 {
118 // function: bool usesHDF5()
119 try {
120 bool out = usesHDF5();
121 return int(out);
122 } catch (...) {
123 return handleAllExceptions(-1, ERR);
124 }
125 }
126
127 int32_t ct_addDataDirectory(const char* dir)
128 {
129 // function: void addDataDirectory(const string&)
130 try {
131 addDataDirectory(dir);
132 return 0;
133 } catch (...) {
134 return handleAllExceptions(-1, ERR);
135 }
136 }
137
138 int32_t ct_getDataDirectories(const char* sep, int32_t bufLen, char* buf)
139 {
140 // function: string getDataDirectories(const string&)
141 try {
142 string out = getDataDirectories(sep);
143 copyString(out, buf, bufLen);
144 return int(out.size()) + 1;
145 } catch (...) {
146 return handleAllExceptions(-1, ERR);
147 }
148 }
149
150 int32_t ct_findInputFile(const char* name, int32_t bufLen, char* buf)
151 {
152 // function: string findInputFile(const string&)
153 try {
154 string out = findInputFile(name);
155 copyString(out, buf, bufLen);
156 return int(out.size()) + 1;
157 } catch (...) {
158 return handleAllExceptions(-1, ERR);
159 }
160 }
161
163 {
164 // function: void suppress_deprecation_warnings()
165 try {
167 return 0;
168 } catch (...) {
169 return handleAllExceptions(-1, ERR);
170 }
171 }
172
174 {
175 // function: void make_deprecation_warnings_fatal()
176 try {
178 return 0;
179 } catch (...) {
180 return handleAllExceptions(-1, ERR);
181 }
182 }
183
185 {
186 // function: void suppress_warnings()
187 try {
189 return 0;
190 } catch (...) {
191 return handleAllExceptions(-1, ERR);
192 }
193 }
194
196 {
197 // function: bool warnings_suppressed()
198 try {
199 bool out = warnings_suppressed();
200 return int(out);
201 } catch (...) {
202 return handleAllExceptions(-1, ERR);
203 }
204 }
205
207 {
208 // function: void make_warnings_fatal()
209 try {
211 return 0;
212 } catch (...) {
213 return handleAllExceptions(-1, ERR);
214 }
215 }
216
217 int32_t ct_suppress_thermo_warnings(int32_t suppress)
218 {
219 // function: void suppress_thermo_warnings(bool)
220 try {
221 bool suppress_ = (suppress != 0);
222 suppress_thermo_warnings(suppress_);
223 return 0;
224 } catch (...) {
225 return handleAllExceptions(-1, ERR);
226 }
227 }
228
229 int32_t ct_use_legacy_rate_constants(int32_t legacy)
230 {
231 // function: void use_legacy_rate_constants(bool)
232 try {
233 bool legacy_ = (legacy != 0);
235 return 0;
236 } catch (...) {
237 return handleAllExceptions(-1, ERR);
238 }
239 }
240
241 int32_t ct_appdelete()
242 {
243 // function: void appdelete()
244 try {
245 appdelete();
246 return 0;
247 } catch (...) {
248 return handleAllExceptions(-1, ERR);
249 }
250 }
251
252 const double ct_Avogadro()
253 {
254 // variable (getter): variable getter: Avogadro
255 try {
256 return Avogadro;
257 } catch (...) {
258 return handleAllExceptions(DERR, DERR);
259 }
260 }
261
262 const double ct_Boltzmann()
263 {
264 // variable (getter): variable getter: Boltzmann
265 try {
266 return Boltzmann;
267 } catch (...) {
268 return handleAllExceptions(DERR, DERR);
269 }
270 }
271
272 const double ct_Planck()
273 {
274 // variable (getter): variable getter: Planck
275 try {
276 return Planck;
277 } catch (...) {
278 return handleAllExceptions(DERR, DERR);
279 }
280 }
281
282 const double ct_ElectronCharge()
283 {
284 // variable (getter): variable getter: ElectronCharge
285 try {
286 return ElectronCharge;
287 } catch (...) {
288 return handleAllExceptions(DERR, DERR);
289 }
290 }
291
292 const double ct_lightSpeed()
293 {
294 // variable (getter): variable getter: lightSpeed
295 try {
296 return lightSpeed;
297 } catch (...) {
298 return handleAllExceptions(DERR, DERR);
299 }
300 }
301
302 const double ct_OneAtm()
303 {
304 // variable (getter): variable getter: OneAtm
305 try {
306 return OneAtm;
307 } catch (...) {
308 return handleAllExceptions(DERR, DERR);
309 }
310 }
311
312 const double ct_OneBar()
313 {
314 // variable (getter): variable getter: OneBar
315 try {
316 return OneBar;
317 } catch (...) {
318 return handleAllExceptions(DERR, DERR);
319 }
320 }
321
323 {
324 // variable (getter): variable getter: fineStructureConstant
325 try {
327 } catch (...) {
328 return handleAllExceptions(DERR, DERR);
329 }
330 }
331
332 const double ct_ElectronMass()
333 {
334 // variable (getter): variable getter: ElectronMass
335 try {
336 return ElectronMass;
337 } catch (...) {
338 return handleAllExceptions(DERR, DERR);
339 }
340 }
341
342 const double ct_GasConstant()
343 {
344 // variable (getter): variable getter: GasConstant
345 try {
346 return GasConstant;
347 } catch (...) {
348 return handleAllExceptions(DERR, DERR);
349 }
350 }
351
352 const double ct_StefanBoltz()
353 {
354 // variable (getter): variable getter: StefanBoltz
355 try {
356 return StefanBoltz;
357 } catch (...) {
358 return handleAllExceptions(DERR, DERR);
359 }
360 }
361
362 const double ct_Faraday()
363 {
364 // variable (getter): variable getter: Faraday
365 try {
366 return Faraday;
367 } catch (...) {
368 return handleAllExceptions(DERR, DERR);
369 }
370 }
371
372 const double ct_permeability_0()
373 {
374 // variable (getter): variable getter: permeability_0
375 try {
376 return permeability_0;
377 } catch (...) {
378 return handleAllExceptions(DERR, DERR);
379 }
380 }
381
382 const double ct_epsilon_0()
383 {
384 // variable (getter): variable getter: epsilon_0
385 try {
386 return epsilon_0;
387 } catch (...) {
388 return handleAllExceptions(DERR, DERR);
389 }
390 }
391
392 int32_t ct_getCanteraError(int32_t bufLen, char* buf)
393 {
394 // function: custom code
395 try {
396 // *************** begin custom code ***************
397 string err = Application::Instance()->lastErrorMessage();
398 copyString(err, buf, bufLen);
399 return static_cast<int32_t>(err.size());
400 // **************** end custom code ****************
401 } catch (...) {
402 return handleAllExceptions(-1, ERR);
403 }
404 }
405
407 {
408 // function: custom code
409 try {
410 // *************** begin custom code ***************
411 auto logwriter = make_unique<ExternalLogger>(writer);
412 setLogger(std::move(logwriter));
413 return 0;
414 // **************** end custom code ****************
415 } catch (...) {
416 return handleAllExceptions(-1, ERR);
417 }
418 }
419
420 int32_t ct_writeLog(const char* msg)
421 {
422 // function: void writelog_direct(const string&)
423 try {
424 writelog_direct(msg);
425 return 0;
426 } catch (...) {
427 return handleAllExceptions(-1, ERR);
428 }
429 }
430
432 {
433 // reserved CLib function: custom code
434 try {
435 // *************** begin custom code ***************
436 ConnectorNodeCabinet::reset();
437 Domain1DCabinet::reset();
438 Func1Cabinet::reset();
439 KineticsCabinet::reset();
440 MultiPhaseCabinet::reset();
441 Sim1DCabinet::reset();
442 ReactionPathDiagramCabinet::reset();
443 ReactorBaseCabinet::reset();
444 ReactorNetCabinet::reset();
445 ReactionCabinet::reset();
446 SolutionCabinet::reset();
447 ThermoPhaseCabinet::reset();
448 TransportCabinet::reset();
449 return 0;
450 // **************** end custom code ****************
451 } catch (...) {
452 return handleAllExceptions(-1, ERR);
453 }
454 }
455
456} // 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.
Template for classes to hold pointers to objects.
Definition Cabinet.h:51
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:184
int32_t ct_getCanteraError(int32_t bufLen, char *buf)
Get Cantera error.
Definition ct.cpp:392
const double ct_ElectronMass()
Electron Mass.
Definition ct.cpp:332
const double ct_Boltzmann()
Boltzmann constant.
Definition ct.cpp:262
int32_t ct_make_deprecation_warnings_fatal()
Turns deprecation warnings into exceptions.
Definition ct.cpp:173
int32_t ct_getDataDirectories(const char *sep, int32_t bufLen, char *buf)
Get the Cantera data directories.
Definition ct.cpp:138
int32_t ct_appdelete()
Delete and free all memory associated with the application.
Definition ct.cpp:241
const double ct_fineStructureConstant()
Fine structure constant.
Definition ct.cpp:322
int32_t ct_findInputFile(const char *name, int32_t bufLen, char *buf)
Find an input file.
Definition ct.cpp:150
const double ct_StefanBoltz()
Stefan-Boltzmann constant.
Definition ct.cpp:352
int32_t ct_writeLog(const char *msg)
Write a message to the logger.
Definition ct.cpp:420
int32_t ct_make_warnings_fatal()
Turns Cantera warnings into exceptions.
Definition ct.cpp:206
int32_t ct_use_legacy_rate_constants(int32_t legacy)
Set definition used for rate constant calculation.
Definition ct.cpp:229
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:217
const double ct_GasConstant()
Universal Gas Constant.
Definition ct.cpp:342
const double ct_Planck()
Planck constant.
Definition ct.cpp:272
int32_t ct_usesHDF5()
Returns true if Cantera was compiled with C++ HDF5 support.
Definition ct.cpp:116
int32_t ct_setLogCallback(LogCallback writer)
Set Logger callback.
Definition ct.cpp:406
int32_t ct_warnings_suppressed()
Returns true if warnings should be suppressed.
Definition ct.cpp:195
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:382
int32_t ct_resetStorage()
Delete all objects and erase mapping.
Definition ct.cpp:431
const double ct_permeability_0()
Permeability of free space.
Definition ct.cpp:372
const double ct_ElectronCharge()
Elementary charge.
Definition ct.cpp:282
const double ct_OneAtm()
One atmosphere [Pa].
Definition ct.cpp:302
int32_t ct_suppress_deprecation_warnings()
Globally disable printing of deprecation warnings.
Definition ct.cpp:162
const double ct_lightSpeed()
Speed of Light in a vacuum.
Definition ct.cpp:292
const double ct_Faraday()
Faraday constant.
Definition ct.cpp:362
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:127
const double ct_OneBar()
One bar [Pa].
Definition ct.cpp:312
const double ct_Avogadro()
Avogadro's Number.
Definition ct.cpp:252
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
bool usesHDF5()
Returns true if Cantera was compiled with C++ HDF5 support.
Definition global.cpp:218
string getDataDirectories(const string &sep)
Get the Cantera data directories.
Definition global.cpp:180
string findInputFile(const string &name)
Find an input file.
Definition global.cpp:185
void addDataDirectory(const string &dir)
Add a directory to the data file search path.
Definition global.cpp:175
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.