Cantera  4.0.0a1
Loading...
Searching...
No Matches
cttrans.cpp
Go to the documentation of this file.
1/**
2 * CTTRANS - Generated CLib %Cantera interface library.
3 *
4 * @file cttrans.cpp
5 *
6 * Generated CLib API for Cantera's Transport 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
24using namespace Cantera;
25
26//! @cond
27//! Cabinet type definitions will be ignored by Doxygen
28
29// Define Cabinet<Transport> (single-instance object)
30typedef Cabinet<Transport> TransportCabinet;
31template<> TransportCabinet* TransportCabinet::s_storage = 0; // initialized here
32
33//! @endcond
34
35extern "C" {
36
37 int32_t trans_transportModel(int32_t handle, int32_t bufLen, char* buf)
38 {
39 // getter: virtual string Transport::transportModel()
40 try {
41 string out = TransportCabinet::at(handle)->transportModel();
42 copyString(out, buf, bufLen);
43 return int(out.size()) + 1;
44 } catch (...) {
45 return handleAllExceptions(-1, ERR);
46 }
47 }
48
49 double trans_viscosity(int32_t handle)
50 {
51 // getter: virtual double Transport::viscosity()
52 try {
53 return TransportCabinet::at(handle)->viscosity();
54 } catch (...) {
55 return handleAllExceptions(DERR, DERR);
56 }
57 }
58
59 double trans_thermalConductivity(int32_t handle)
60 {
61 // getter: virtual double Transport::thermalConductivity()
62 try {
63 return TransportCabinet::at(handle)->thermalConductivity();
64 } catch (...) {
65 return handleAllExceptions(DERR, DERR);
66 }
67 }
68
69 double trans_electricalConductivity(int32_t handle)
70 {
71 // getter: virtual double Transport::electricalConductivity()
72 try {
73 return TransportCabinet::at(handle)->electricalConductivity();
74 } catch (...) {
75 return handleAllExceptions(DERR, DERR);
76 }
77 }
78
79 int32_t trans_getThermalDiffCoeffs(int32_t handle, int32_t dtLen, double* dt)
80 {
81 // array getter: virtual void Transport::getThermalDiffCoeffs(span<double>)
82 try {
83 auto& obj = TransportCabinet::at(handle);
84 // no size checking specified
85 span<double> dt_(dt, dtLen);
86 obj->getThermalDiffCoeffs(dt_);
87 return 0;
88 } catch (...) {
89 return handleAllExceptions(-1, ERR);
90 }
91 }
92
93 int32_t trans_getMixDiffCoeffs(int32_t handle, int32_t dLen, double* d)
94 {
95 // array getter: virtual void Transport::getMixDiffCoeffs(span<double>)
96 try {
97 auto& obj = TransportCabinet::at(handle);
98 // no size checking specified
99 span<double> d_(d, dLen);
100 obj->getMixDiffCoeffs(d_);
101 return 0;
102 } catch (...) {
103 return handleAllExceptions(-1, ERR);
104 }
105 }
106
107 int32_t trans_getBinaryDiffCoeffs(int32_t handle, const int32_t ld, int32_t dLen, double* d)
108 {
109 // method: virtual void Transport::getBinaryDiffCoeffs(const size_t, span<double>)
110 try {
111 span<double> d_(d, dLen);
112 TransportCabinet::at(handle)->getBinaryDiffCoeffs(ld, d_);
113 return 0;
114 } catch (...) {
115 return handleAllExceptions(-1, ERR);
116 }
117 }
118
119 int32_t trans_getMultiDiffCoeffs(int32_t handle, const int32_t ld, int32_t dLen, double* d)
120 {
121 // method: virtual void Transport::getMultiDiffCoeffs(const size_t, span<double>)
122 try {
123 span<double> d_(d, dLen);
124 TransportCabinet::at(handle)->getMultiDiffCoeffs(ld, d_);
125 return 0;
126 } catch (...) {
127 return handleAllExceptions(-1, ERR);
128 }
129 }
130
131 int32_t trans_getMolarFluxes(int32_t handle, int32_t state1Len, const double* state1, int32_t state2Len, const double* state2, const double delta, int32_t cfluxesLen, double* cfluxes)
132 {
133 // method: virtual void Transport::getMolarFluxes(span<const double>, span<const double>, const double, span<double>)
134 try {
135 span<const double> state1_(state1, state1Len);
136 span<const double> state2_(state2, state2Len);
137 span<double> cfluxes_(cfluxes, cfluxesLen);
138 TransportCabinet::at(handle)->getMolarFluxes(state1_, state2_, delta, cfluxes_);
139 return 0;
140 } catch (...) {
141 return handleAllExceptions(-1, ERR);
142 }
143 }
144
145 int32_t trans_getMassFluxes(int32_t handle, int32_t state1Len, const double* state1, int32_t state2Len, const double* state2, double delta, int32_t mfluxesLen, double* mfluxes)
146 {
147 // method: virtual void Transport::getMassFluxes(span<const double>, span<const double>, double, span<double>)
148 try {
149 span<const double> state1_(state1, state1Len);
150 span<const double> state2_(state2, state2Len);
151 span<double> mfluxes_(mfluxes, mfluxesLen);
152 TransportCabinet::at(handle)->getMassFluxes(state1_, state2_, delta, mfluxes_);
153 return 0;
154 } catch (...) {
155 return handleAllExceptions(-1, ERR);
156 }
157 }
158
159 int32_t trans_del(int32_t handle)
160 {
161 // destructor
162 try {
163 TransportCabinet::del(handle);
164 return 0;
165 } catch (...) {
166 return handleAllExceptions(-1, ERR);
167 }
168 }
169
171 {
172 // reserved CLib function: custom code
173 try {
174 // *************** begin custom code ***************
175 return TransportCabinet::size();
176 // **************** end custom code ****************
177 } catch (...) {
178 return handleAllExceptions(-1, ERR);
179 }
180 }
181
182} // extern "C"
Header file defining class TransportFactory (see TransportFactory)
Template for classes to hold pointers to objects.
Definition Cabinet.h:51
CTTRANS - Generated CLib Cantera interface library.
int32_t trans_getMultiDiffCoeffs(int32_t handle, const int32_t ld, int32_t dLen, double *d)
Return the multicomponent diffusion coefficients [m²/s].
Definition cttrans.cpp:119
double trans_viscosity(int32_t handle)
Get the dynamic viscosity [Pa·s].
Definition cttrans.cpp:49
double trans_electricalConductivity(int32_t handle)
Get the electrical conductivity [siemens/m].
Definition cttrans.cpp:69
int32_t trans_transportModel(int32_t handle, int32_t bufLen, char *buf)
Identifies the model represented by this Transport object.
Definition cttrans.cpp:37
int32_t trans_getBinaryDiffCoeffs(int32_t handle, const int32_t ld, int32_t dLen, double *d)
Returns the matrix of binary diffusion coefficients [m²/s].
Definition cttrans.cpp:107
int32_t trans_getThermalDiffCoeffs(int32_t handle, int32_t dtLen, double *dt)
Return a vector of thermal diffusion coefficients [kg/m/s].
Definition cttrans.cpp:79
int32_t trans_getMassFluxes(int32_t handle, int32_t state1Len, const double *state1, int32_t state2Len, const double *state2, double delta, int32_t mfluxesLen, double *mfluxes)
Get the mass fluxes [kg/m²/s], given the thermodynamic state at two nearby points.
Definition cttrans.cpp:145
int32_t trans_getMixDiffCoeffs(int32_t handle, int32_t dLen, double *d)
Return a vector of mixture averaged diffusion coefficients [m²/s].
Definition cttrans.cpp:93
int32_t trans_del(int32_t handle)
Delete Transport object.
Definition cttrans.cpp:159
int32_t trans_getMolarFluxes(int32_t handle, int32_t state1Len, const double *state1, int32_t state2Len, const double *state2, const double delta, int32_t cfluxesLen, double *cfluxes)
Get the molar fluxes [kmol/m²/s], given the thermodynamic state at two nearby points.
Definition cttrans.cpp:131
double trans_thermalConductivity(int32_t handle)
Get the mixture thermal conductivity [W/m/K].
Definition cttrans.cpp:59
int32_t trans_cabinetSize()
Return size of Transport storage.
Definition cttrans.cpp:170
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.
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.