Cantera  3.2.0a2
Loading...
Searching...
No Matches
ctconnector.cpp
Go to the documentation of this file.
1/**
2 * CTCONNECTOR - Generated CLib %Cantera interface library.
3 *
4 * @file ctconnector.cpp
5 *
6 * Generated CLib API for Cantera's ConnectorNode 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
24#include "cantera/zeroD/Wall.h"
28
29using namespace Cantera;
30
31//! @cond
32//! Cabinet type definitions will be ignored by Doxygen
33
34// Define Cabinet<ConnectorNode> (single-instance object)
35typedef Cabinet<ConnectorNode> ConnectorNodeCabinet;
36template<> ConnectorNodeCabinet* ConnectorNodeCabinet::s_storage = 0; // initialized here
37
38typedef Cabinet<ReactorBase> ReactorBaseCabinet;
39template<> ReactorBaseCabinet* ReactorBaseCabinet::s_storage; // initialized elsewhere
40
41typedef Cabinet<Func1> Func1Cabinet;
42template<> Func1Cabinet* Func1Cabinet::s_storage; // initialized elsewhere
43
44//! @endcond
45
46extern "C" {
47
48 int32_t connector_new(const char* model, int32_t r0, int32_t r1, const char* name)
49 {
50 // constructor: shared_ptr<ConnectorNode> newConnectorNode(const string&, shared_ptr<ReactorBase>, shared_ptr<ReactorBase>, const string&)
51 try {
52 return ConnectorNodeCabinet::add(newConnectorNode(model, ReactorBaseCabinet::at(r0), ReactorBaseCabinet::at(r1), name));
53 } catch (...) {
54 return handleAllExceptions(-2, ERR);
55 }
56 }
57
58 int32_t connector_type(int32_t handle, int32_t bufLen, char* buf)
59 {
60 // getter: virtual string ConnectorNode::type()
61 try {
62 string out = ConnectorNodeCabinet::at(handle)->type();
63 copyString(out, buf, bufLen);
64 return int(out.size()) + 1;
65 } catch (...) {
66 return handleAllExceptions(-1, ERR);
67 }
68 }
69
70 int32_t connector_name(int32_t handle, int32_t bufLen, char* buf)
71 {
72 // getter: string ConnectorNode::name()
73 try {
74 string out = ConnectorNodeCabinet::at(handle)->name();
75 copyString(out, buf, bufLen);
76 return int(out.size()) + 1;
77 } catch (...) {
78 return handleAllExceptions(-1, ERR);
79 }
80 }
81
82 int32_t connector_setName(int32_t handle, const char* name)
83 {
84 // setter: void ConnectorNode::setName(const string&)
85 try {
86 ConnectorNodeCabinet::at(handle)->setName(name);
87 return 0;
88 } catch (...) {
89 return handleAllExceptions(-1, ERR);
90 }
91 }
92
93 int32_t flowdev_setPrimary(int32_t handle, int32_t primary)
94 {
95 // setter: virtual void FlowDevice::setPrimary(shared_ptr<ConnectorNode>)
96 try {
97 ConnectorNodeCabinet::as<FlowDevice>(handle)->setPrimary(ConnectorNodeCabinet::at(primary));
98 return 0;
99 } catch (...) {
100 return handleAllExceptions(-1, ERR);
101 }
102 }
103
104 double flowdev_massFlowRate(int32_t handle)
105 {
106 // getter: double FlowDevice::massFlowRate()
107 try {
108 return ConnectorNodeCabinet::as<FlowDevice>(handle)->massFlowRate();
109 } catch (...) {
110 return handleAllExceptions(DERR, DERR);
111 }
112 }
113
114 double flowdev_deviceCoefficient(int32_t handle)
115 {
116 // getter: double FlowDevice::deviceCoefficient()
117 try {
118 return ConnectorNodeCabinet::as<FlowDevice>(handle)->deviceCoefficient();
119 } catch (...) {
120 return handleAllExceptions(DERR, DERR);
121 }
122 }
123
124 int32_t flowdev_setDeviceCoefficient(int32_t handle, double c)
125 {
126 // setter: void FlowDevice::setDeviceCoefficient(double)
127 try {
128 ConnectorNodeCabinet::as<FlowDevice>(handle)->setDeviceCoefficient(c);
129 return 0;
130 } catch (...) {
131 return handleAllExceptions(-1, ERR);
132 }
133 }
134
135 int32_t flowdev_setPressureFunction(int32_t handle, int32_t f)
136 {
137 // setter: virtual void FlowDevice::setPressureFunction(shared_ptr<Func1>)
138 try {
139 ConnectorNodeCabinet::as<FlowDevice>(handle)->setPressureFunction(Func1Cabinet::at(f));
140 return 0;
141 } catch (...) {
142 return handleAllExceptions(-1, ERR);
143 }
144 }
145
146 int32_t flowdev_setTimeFunction(int32_t handle, int32_t g)
147 {
148 // setter: virtual void FlowDevice::setTimeFunction(shared_ptr<Func1>)
149 try {
150 ConnectorNodeCabinet::as<FlowDevice>(handle)->setTimeFunction(Func1Cabinet::at(g));
151 return 0;
152 } catch (...) {
153 return handleAllExceptions(-1, ERR);
154 }
155 }
156
157 double wall_expansionRate(int32_t handle)
158 {
159 // getter: virtual double WallBase::expansionRate()
160 try {
161 return ConnectorNodeCabinet::as<WallBase>(handle)->expansionRate();
162 } catch (...) {
163 return handleAllExceptions(DERR, DERR);
164 }
165 }
166
167 double wall_heatRate(int32_t handle)
168 {
169 // getter: virtual double WallBase::heatRate()
170 try {
171 return ConnectorNodeCabinet::as<WallBase>(handle)->heatRate();
172 } catch (...) {
173 return handleAllExceptions(DERR, DERR);
174 }
175 }
176
177 double wall_area(int32_t handle)
178 {
179 // getter: double WallBase::area()
180 try {
181 return ConnectorNodeCabinet::as<WallBase>(handle)->area();
182 } catch (...) {
183 return handleAllExceptions(DERR, DERR);
184 }
185 }
186
187 int32_t wall_setArea(int32_t handle, double a)
188 {
189 // setter: virtual void WallBase::setArea(double)
190 try {
191 ConnectorNodeCabinet::as<WallBase>(handle)->setArea(a);
192 return 0;
193 } catch (...) {
194 return handleAllExceptions(-1, ERR);
195 }
196 }
197
198 int32_t wall_setThermalResistance(int32_t handle, double Rth)
199 {
200 // setter: void Wall::setThermalResistance(double)
201 try {
202 ConnectorNodeCabinet::as<Wall>(handle)->setThermalResistance(Rth);
203 return 0;
204 } catch (...) {
205 return handleAllExceptions(-1, ERR);
206 }
207 }
208
209 int32_t wall_setHeatTransferCoeff(int32_t handle, double U)
210 {
211 // setter: void Wall::setHeatTransferCoeff(double)
212 try {
213 ConnectorNodeCabinet::as<Wall>(handle)->setHeatTransferCoeff(U);
214 return 0;
215 } catch (...) {
216 return handleAllExceptions(-1, ERR);
217 }
218 }
219
220 int32_t wall_setHeatFlux(int32_t handle, int32_t q)
221 {
222 // setter: void Wall::setHeatFlux(shared_ptr<Func1>)
223 try {
224 ConnectorNodeCabinet::as<Wall>(handle)->setHeatFlux(Func1Cabinet::at(q));
225 return 0;
226 } catch (...) {
227 return handleAllExceptions(-1, ERR);
228 }
229 }
230
231 int32_t wall_setExpansionRateCoeff(int32_t handle, double k)
232 {
233 // setter: void Wall::setExpansionRateCoeff(double)
234 try {
235 ConnectorNodeCabinet::as<Wall>(handle)->setExpansionRateCoeff(k);
236 return 0;
237 } catch (...) {
238 return handleAllExceptions(-1, ERR);
239 }
240 }
241
242 int32_t wall_setVelocity(int32_t handle, int32_t f)
243 {
244 // setter: void Wall::setVelocity(shared_ptr<Func1>)
245 try {
246 ConnectorNodeCabinet::as<Wall>(handle)->setVelocity(Func1Cabinet::at(f));
247 return 0;
248 } catch (...) {
249 return handleAllExceptions(-1, ERR);
250 }
251 }
252
253 int32_t wall_setEmissivity(int32_t handle, double epsilon)
254 {
255 // setter: void Wall::setEmissivity(double)
256 try {
257 ConnectorNodeCabinet::as<Wall>(handle)->setEmissivity(epsilon);
258 return 0;
259 } catch (...) {
260 return handleAllExceptions(-1, ERR);
261 }
262 }
263
264 int32_t connector_del(int32_t handle)
265 {
266 // destructor
267 try {
268 ConnectorNodeCabinet::del(handle);
269 return 0;
270 } catch (...) {
271 return handleAllExceptions(-1, ERR);
272 }
273 }
274
276 {
277 // reserved CLib function: custom code
278 try {
279 // *************** begin custom code ***************
280 return ConnectorNodeCabinet::size();
281 // **************** end custom code ****************
282 } catch (...) {
283 return handleAllExceptions(-1, ERR);
284 }
285 }
286
287 int32_t connector_parentHandle(int32_t handle)
288 {
289 // reserved CLib function: custom code
290 try {
291 // *************** begin custom code ***************
292 return ConnectorNodeCabinet::parent(handle);
293 // **************** end custom code ****************
294 } catch (...) {
295 return handleAllExceptions(-1, ERR);
296 }
297 }
298
299} // extern "C"
Header file for base class WallBase.
CTCONNECTOR - Generated CLib Cantera interface library.
Some flow devices derived from class FlowDevice.
int32_t flowdev_setTimeFunction(int32_t handle, int32_t g)
Set a function of time to modulate the mass flow rate.
double flowdev_massFlowRate(int32_t handle)
Mass flow rate (kg/s).
int32_t connector_del(int32_t handle)
Delete ConnectorNode object.
int32_t flowdev_setDeviceCoefficient(int32_t handle, double c)
Set the device coefficient (defined by derived class).
int32_t connector_setName(int32_t handle, const char *name)
Set connector name.
int32_t wall_setHeatTransferCoeff(int32_t handle, double U)
Set the overall heat transfer coefficient [W/m^2/K].
double wall_heatRate(int32_t handle)
Heat flow rate through the wall (W) at current reactor network time.
double flowdev_deviceCoefficient(int32_t handle)
Get the device coefficient (defined by derived class).
int32_t wall_setExpansionRateCoeff(int32_t handle, double k)
Set the expansion rate coefficient.
int32_t connector_new(const char *model, int32_t r0, int32_t r1, const char *name)
Create a ConnectorNode object of the specified type.
int32_t wall_setThermalResistance(int32_t handle, double Rth)
Set the thermal resistance of the wall [K*m^2/W].
int32_t wall_setVelocity(int32_t handle, int32_t f)
Set the wall velocity to a specified function of time,.
int32_t flowdev_setPrimary(int32_t handle, int32_t primary)
Set the primary mass flow controller.
int32_t connector_name(int32_t handle, int32_t bufLen, char *buf)
Retrieve connector name.
double wall_area(int32_t handle)
Area in (m^2).
int32_t flowdev_setPressureFunction(int32_t handle, int32_t f)
Set a function of pressure to modify the pressure response.
int32_t connector_cabinetSize()
Return size of ConnectorNode storage.
int32_t connector_parentHandle(int32_t handle)
Return handle to parent of ConnectorNode object.
int32_t wall_setArea(int32_t handle, double a)
Set the area [m^2].
int32_t connector_type(int32_t handle, int32_t bufLen, char *buf)
String indicating the connector implemented.
double wall_expansionRate(int32_t handle)
Rate of volume change (m^3/s) for the adjacent reactors at current reactor network time.
int32_t wall_setEmissivity(int32_t handle, double epsilon)
Set the emissivity.
int32_t wall_setHeatFlux(int32_t handle, int32_t q)
Specify the heat flux function.
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< ConnectorNode > newConnectorNode(const string &model, shared_ptr< ReactorBase > r0, shared_ptr< ReactorBase > r1, const string &name)
Create a ConnectorNode 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.