Cantera  3.2.0a2
Loading...
Searching...
No Matches
ctreactornet.cpp
Go to the documentation of this file.
1/**
2 * CTREACTORNET - Generated CLib %Cantera interface library.
3 *
4 * @file ctreactornet.cpp
5 *
6 * Generated CLib API for Cantera's ReactorNet 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
25using namespace Cantera;
26
27//! @cond
28//! Cabinet type definitions will be ignored by Doxygen
29
30// Define Cabinet<ReactorNet> (single-instance object)
31typedef Cabinet<ReactorNet> ReactorNetCabinet;
32template<> ReactorNetCabinet* ReactorNetCabinet::s_storage = 0; // initialized here
33
34typedef Cabinet<ReactorBase> ReactorBaseCabinet;
35template<> ReactorBaseCabinet* ReactorBaseCabinet::s_storage; // initialized elsewhere
36
37//! @endcond
38
39extern "C" {
40
41 int32_t reactornet_new(int32_t reactorsLen, int32_t* reactors)
42 {
43 // constructor: shared_ptr<ReactorNet> newReactorNet(vector<shared_ptr<ReactorBase>>&)
44 try {
45 vector<shared_ptr<ReactorBase>> reactors_;
46 for (int i = 0; i < reactorsLen; i++) {
47 reactors_.push_back(ReactorBaseCabinet::at(reactors[i]));
48 }
49 return ReactorNetCabinet::add(newReactorNet(reactors_));
50 } catch (...) {
51 return handleAllExceptions(-2, ERR);
52 }
53 }
54
55 int32_t reactornet_setInitialTime(int32_t handle, double time)
56 {
57 // setter: void ReactorNet::setInitialTime(double)
58 try {
59 ReactorNetCabinet::at(handle)->setInitialTime(time);
60 return 0;
61 } catch (...) {
62 return handleAllExceptions(-1, ERR);
63 }
64 }
65
66 int32_t reactornet_setMaxTimeStep(int32_t handle, double maxstep)
67 {
68 // setter: void ReactorNet::setMaxTimeStep(double)
69 try {
70 ReactorNetCabinet::at(handle)->setMaxTimeStep(maxstep);
71 return 0;
72 } catch (...) {
73 return handleAllExceptions(-1, ERR);
74 }
75 }
76
77 int32_t reactornet_setTolerances(int32_t handle, double rtol, double atol)
78 {
79 // method: void ReactorNet::setTolerances(double, double)
80 try {
81 ReactorNetCabinet::at(handle)->setTolerances(rtol, atol);
82 return 0;
83 } catch (...) {
84 return handleAllExceptions(-1, ERR);
85 }
86 }
87
88 int32_t reactornet_setSensitivityTolerances(int32_t handle, double rtol, double atol)
89 {
90 // method: void ReactorNet::setSensitivityTolerances(double, double)
91 try {
92 ReactorNetCabinet::at(handle)->setSensitivityTolerances(rtol, atol);
93 return 0;
94 } catch (...) {
95 return handleAllExceptions(-1, ERR);
96 }
97 }
98
99 int32_t reactornet_advance(int32_t handle, double t)
100 {
101 // setter: void ReactorNet::advance(double)
102 try {
103 ReactorNetCabinet::at(handle)->advance(t);
104 return 0;
105 } catch (...) {
106 return handleAllExceptions(-1, ERR);
107 }
108 }
109
110 double reactornet_step(int32_t handle)
111 {
112 // getter: double ReactorNet::step()
113 try {
114 return ReactorNetCabinet::at(handle)->step();
115 } catch (...) {
116 return handleAllExceptions(DERR, DERR);
117 }
118 }
119
120 double reactornet_time(int32_t handle)
121 {
122 // getter: double ReactorNet::time()
123 try {
124 return ReactorNetCabinet::at(handle)->time();
125 } catch (...) {
126 return handleAllExceptions(DERR, DERR);
127 }
128 }
129
130 double reactornet_rtol(int32_t handle)
131 {
132 // getter: double ReactorNet::rtol()
133 try {
134 return ReactorNetCabinet::at(handle)->rtol();
135 } catch (...) {
136 return handleAllExceptions(DERR, DERR);
137 }
138 }
139
140 double reactornet_atol(int32_t handle)
141 {
142 // getter: double ReactorNet::atol()
143 try {
144 return ReactorNetCabinet::at(handle)->atol();
145 } catch (...) {
146 return handleAllExceptions(DERR, DERR);
147 }
148 }
149
150 double reactornet_sensitivity(int32_t handle, const char* component, int32_t p, int32_t reactor)
151 {
152 // method: double ReactorNet::sensitivity(const string&, size_t, int)
153 try {
154 return ReactorNetCabinet::at(handle)->sensitivity(component, p, reactor);
155 } catch (...) {
156 return handleAllExceptions(DERR, DERR);
157 }
158 }
159
160 int32_t reactornet_del(int32_t handle)
161 {
162 // destructor
163 try {
164 ReactorNetCabinet::del(handle);
165 return 0;
166 } catch (...) {
167 return handleAllExceptions(-1, ERR);
168 }
169 }
170
172 {
173 // reserved CLib function: custom code
174 try {
175 // *************** begin custom code ***************
176 return ReactorNetCabinet::size();
177 // **************** end custom code ****************
178 } catch (...) {
179 return handleAllExceptions(-1, ERR);
180 }
181 }
182
183 int32_t reactornet_parentHandle(int32_t handle)
184 {
185 // reserved CLib function: custom code
186 try {
187 // *************** begin custom code ***************
188 return ReactorNetCabinet::parent(handle);
189 // **************** end custom code ****************
190 } catch (...) {
191 return handleAllExceptions(-1, ERR);
192 }
193 }
194
195} // extern "C"
CTREACTORNET - Generated CLib Cantera interface library.
int32_t reactornet_advance(int32_t handle, double t)
Advance the state of all reactors in the independent variable (time or space).
int32_t reactornet_setSensitivityTolerances(int32_t handle, double rtol, double atol)
Set the relative and absolute tolerances for integrating the sensitivity equations.
double reactornet_time(int32_t handle)
Current value of the simulation time [s], for reactor networks that are solved in the time domain.
int32_t reactornet_cabinetSize()
Return size of ReactorNet storage.
int32_t reactornet_del(int32_t handle)
Delete ReactorNet object.
int32_t reactornet_parentHandle(int32_t handle)
Return handle to parent of ReactorNet object.
double reactornet_rtol(int32_t handle)
Relative tolerance.
double reactornet_step(int32_t handle)
Advance the state of all reactors with respect to the independent variable (time or space).
int32_t reactornet_setTolerances(int32_t handle, double rtol, double atol)
Set the relative and absolute tolerances for the integrator.
int32_t reactornet_setInitialTime(int32_t handle, double time)
Set the initial value of the independent variable (typically time).
double reactornet_atol(int32_t handle)
Absolute integration tolerance.
double reactornet_sensitivity(int32_t handle, const char *component, int32_t p, int32_t reactor)
Return the sensitivity of the component named.
int32_t reactornet_setMaxTimeStep(int32_t handle, double maxstep)
Set the maximum integrator step.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
shared_ptr< ReactorNet > newReactorNet(vector< shared_ptr< ReactorBase > > &reactors)
Create a reactor network containing one or more coupled reactors.
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Definition clib_utils.h:32