Cantera  3.2.0a2
Loading...
Searching...
No Matches
ctonedim.cpp
Go to the documentation of this file.
1/**
2 * CTONEDIM - Generated CLib %Cantera interface library.
3 *
4 * @file ctonedim.cpp
5 *
6 * Generated CLib API for Cantera's Sim1D 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
21#include "cantera/oneD/Sim1D.h"
23
24using namespace Cantera;
25
26//! @cond
27//! Cabinet type definitions will be ignored by Doxygen
28
29// Define Cabinet<Sim1D> (single-instance object)
30typedef Cabinet<Sim1D> Sim1DCabinet;
31template<> Sim1DCabinet* Sim1DCabinet::s_storage = 0; // initialized here
32
33typedef Cabinet<Domain1D> Domain1DCabinet;
34template<> Domain1DCabinet* Domain1DCabinet::s_storage; // initialized elsewhere
35
36//! @endcond
37
38extern "C" {
39
40 int32_t sim1D_newSim1D(int32_t domainsLen, int32_t* domains)
41 {
42 // constructor: shared_ptr<Sim1D> newSim1D(vector<shared_ptr<Domain1D>>&)
43 try {
44 vector<shared_ptr<Domain1D>> domains_;
45 for (int i = 0; i < domainsLen; i++) {
46 domains_.push_back(Domain1DCabinet::at(domains[i]));
47 }
48 return Sim1DCabinet::add(newSim1D(domains_));
49 } catch (...) {
50 return handleAllExceptions(-2, ERR);
51 }
52 }
53
54 int32_t sim1D_setValue(int32_t handle, int32_t dom, int32_t comp, int32_t localPoint, double value)
55 {
56 // method: void Sim1D::setValue(size_t, size_t, size_t, double)
57 try {
58 Sim1DCabinet::at(handle)->setValue(dom, comp, localPoint, value);
59 return 0;
60 } catch (...) {
61 return handleAllExceptions(-1, ERR);
62 }
63 }
64
65 int32_t sim1D_setProfile(int32_t handle, int32_t dom, int32_t comp, int32_t posLen, const double* pos, int32_t valuesLen, const double* values)
66 {
67 // method: void Sim1D::setProfile(size_t, size_t, const vector<double>&, const vector<double>&)
68 try {
69 const vector<double> pos_(pos, pos + posLen);
70 const vector<double> values_(values, values + valuesLen);
71 Sim1DCabinet::at(handle)->setProfile(dom, comp, pos_, values_);
72 return 0;
73 } catch (...) {
74 return handleAllExceptions(-1, ERR);
75 }
76 }
77
78 int32_t sim1D_setFlatProfile(int32_t handle, int32_t dom, int32_t comp, double v)
79 {
80 // method: void Sim1D::setFlatProfile(size_t, size_t, double)
81 try {
82 Sim1DCabinet::at(handle)->setFlatProfile(dom, comp, v);
83 return 0;
84 } catch (...) {
85 return handleAllExceptions(-1, ERR);
86 }
87 }
88
89 int32_t sim1D_setInitialGuess(int32_t handle, const char* component, int32_t locsLen, double* locs, int32_t valsLen, double* vals)
90 {
91 // method: void Sim1D::setInitialGuess(const string&, vector<double>&, vector<double>&)
92 try {
93 vector<double> locs_(locs, locs + locsLen);
94 vector<double> vals_(vals, vals + valsLen);
95 Sim1DCabinet::at(handle)->setInitialGuess(component, locs_, vals_);
96 return 0;
97 } catch (...) {
98 return handleAllExceptions(-1, ERR);
99 }
100 }
101
102 int32_t sim1D_show(int32_t handle)
103 {
104 // method: void Sim1D::show()
105 try {
106 Sim1DCabinet::at(handle)->show();
107 return 0;
108 } catch (...) {
109 return handleAllExceptions(-1, ERR);
110 }
111 }
112
113 int32_t sim1D_setTimeStep(int32_t handle, double stepsize, int32_t n, int32_t tstepsLen, const int32_t* tsteps)
114 {
115 // method: void SteadyStateSystem::setTimeStep(double, size_t, const int*)
116 try {
117 Sim1DCabinet::as<SteadyStateSystem>(handle)->setTimeStep(stepsize, n, tsteps);
118 return 0;
119 } catch (...) {
120 return handleAllExceptions(-1, ERR);
121 }
122 }
123
124 int32_t sim1D_getInitialSoln(int32_t handle)
125 {
126 // method: void Sim1D::getInitialSoln()
127 try {
128 Sim1DCabinet::at(handle)->getInitialSoln();
129 return 0;
130 } catch (...) {
131 return handleAllExceptions(-1, ERR);
132 }
133 }
134
135 int32_t sim1D_solve(int32_t handle, int32_t loglevel, int32_t refine_grid)
136 {
137 // method: void Sim1D::solve(int, bool)
138 try {
139 bool refine_grid_ = (refine_grid != 0);
140 Sim1DCabinet::at(handle)->solve(loglevel, refine_grid_);
141 return 0;
142 } catch (...) {
143 return handleAllExceptions(-1, ERR);
144 }
145 }
146
147 int32_t sim1D_refine(int32_t handle, int32_t loglevel)
148 {
149 // method: int Sim1D::refine(int)
150 try {
151 return Sim1DCabinet::at(handle)->refine(loglevel);
152 } catch (...) {
153 return handleAllExceptions(ERR, ERR);
154 }
155 }
156
157 int32_t sim1D_setRefineCriteria(int32_t handle, int32_t dom, double ratio, double slope, double curve, double prune)
158 {
159 // method: void Sim1D::setRefineCriteria(int, double, double, double, double)
160 try {
161 Sim1DCabinet::at(handle)->setRefineCriteria(dom, ratio, slope, curve, prune);
162 return 0;
163 } catch (...) {
164 return handleAllExceptions(-1, ERR);
165 }
166 }
167
168 int32_t sim1D_setGridMin(int32_t handle, int32_t dom, double gridmin)
169 {
170 // method: void Sim1D::setGridMin(int, double)
171 try {
172 Sim1DCabinet::at(handle)->setGridMin(dom, gridmin);
173 return 0;
174 } catch (...) {
175 return handleAllExceptions(-1, ERR);
176 }
177 }
178
179 int32_t sim1D_save(int32_t handle, const char* fname, const char* name, const char* desc)
180 {
181 // method: void Sim1D::save(const string&, const string&, const string&)
182 try {
183 Sim1DCabinet::at(handle)->save(fname, name, desc);
184 return 0;
185 } catch (...) {
186 return handleAllExceptions(-1, ERR);
187 }
188 }
189
190 int32_t sim1D_writeStats(int32_t handle, int32_t printTime)
191 {
192 // setter: void OneDim::writeStats(int)
193 try {
194 Sim1DCabinet::as<OneDim>(handle)->writeStats(printTime);
195 return 0;
196 } catch (...) {
197 return handleAllExceptions(-1, ERR);
198 }
199 }
200
201 int32_t sim1D_domainIndex(int32_t handle, const char* name)
202 {
203 // method: size_t OneDim::domainIndex(const string&)
204 try {
205 return Sim1DCabinet::as<OneDim>(handle)->domainIndex(name);
206 } catch (...) {
207 return handleAllExceptions(ERR, ERR);
208 }
209 }
210
211 double sim1D_value(int32_t handle, int32_t dom, int32_t comp, int32_t localPoint)
212 {
213 // method: double Sim1D::value(size_t, size_t, size_t)
214 try {
215 return Sim1DCabinet::at(handle)->value(dom, comp, localPoint);
216 } catch (...) {
217 return handleAllExceptions(DERR, DERR);
218 }
219 }
220
221 double sim1D_workValue(int32_t handle, int32_t dom, int32_t comp, int32_t localPoint)
222 {
223 // method: double Sim1D::workValue(size_t, size_t, size_t)
224 try {
225 return Sim1DCabinet::at(handle)->workValue(dom, comp, localPoint);
226 } catch (...) {
227 return handleAllExceptions(DERR, DERR);
228 }
229 }
230
231 int32_t sim1D_eval(int32_t handle, int32_t xLen, double* x, int32_t rLen, double* r, double rdt, int32_t count)
232 {
233 // method: void Sim1D::eval(double*, double*, double, int)
234 try {
235 Sim1DCabinet::at(handle)->eval(x, r, rdt, count);
236 return 0;
237 } catch (...) {
238 return handleAllExceptions(-1, ERR);
239 }
240 }
241
242 int32_t sim1D_setMaxJacAge(int32_t handle, int32_t ss_age, int32_t ts_age)
243 {
244 // method: void SteadyStateSystem::setJacAge(int, int)
245 try {
246 Sim1DCabinet::as<SteadyStateSystem>(handle)->setJacAge(ss_age, ts_age);
247 return 0;
248 } catch (...) {
249 return handleAllExceptions(-1, ERR);
250 }
251 }
252
253 int32_t sim1D_setFixedTemperature(int32_t handle, double t)
254 {
255 // method: int Sim1D::setFixedTemperature(double)
256 try {
257 return Sim1DCabinet::at(handle)->setFixedTemperature(t);
258 } catch (...) {
259 return handleAllExceptions(ERR, ERR);
260 }
261 }
262
263 int32_t sim1D_del(int32_t handle)
264 {
265 // destructor
266 try {
267 Sim1DCabinet::del(handle);
268 return 0;
269 } catch (...) {
270 return handleAllExceptions(-1, ERR);
271 }
272 }
273
275 {
276 // reserved CLib function: custom code
277 try {
278 // *************** begin custom code ***************
279 return Sim1DCabinet::size();
280 // **************** end custom code ****************
281 } catch (...) {
282 return handleAllExceptions(-1, ERR);
283 }
284 }
285
286 int32_t sim1D_parentHandle(int32_t handle)
287 {
288 // reserved CLib function: custom code
289 try {
290 // *************** begin custom code ***************
291 return Sim1DCabinet::parent(handle);
292 // **************** end custom code ****************
293 } catch (...) {
294 return handleAllExceptions(-1, ERR);
295 }
296 }
297
298} // extern "C"
int32_t sim1D_setValue(int32_t handle, int32_t dom, int32_t comp, int32_t localPoint, double value)
Set a single value in the solution vector.
Definition ctonedim.cpp:54
int32_t sim1D_getInitialSoln(int32_t handle)
Get the initial value of the system state from each domain in the simulation.
Definition ctonedim.cpp:124
int32_t sim1D_writeStats(int32_t handle, int32_t printTime)
Write statistics about the number of iterations and Jacobians at each grid level.
Definition ctonedim.cpp:190
int32_t sim1D_del(int32_t handle)
Delete Sim1D object.
Definition ctonedim.cpp:263
double sim1D_workValue(int32_t handle, int32_t dom, int32_t comp, int32_t localPoint)
Get an entry in the work vector, which may contain either a new system state or the current residual ...
Definition ctonedim.cpp:221
int32_t sim1D_cabinetSize()
Return size of Sim1D storage.
Definition ctonedim.cpp:274
int32_t sim1D_setInitialGuess(int32_t handle, const char *component, int32_t locsLen, double *locs, int32_t valsLen, double *vals)
Set initial guess for one component for all domains.
Definition ctonedim.cpp:89
int32_t sim1D_save(int32_t handle, const char *fname, const char *name, const char *desc)
Save current simulation data to a container file or CSV format.
Definition ctonedim.cpp:179
int32_t sim1D_parentHandle(int32_t handle)
Return handle to parent of Sim1D object.
Definition ctonedim.cpp:286
int32_t sim1D_eval(int32_t handle, int32_t xLen, double *x, int32_t rLen, double *r, double rdt, int32_t count)
Evaluate the residual function.
Definition ctonedim.cpp:231
int32_t sim1D_setProfile(int32_t handle, int32_t dom, int32_t comp, int32_t posLen, const double *pos, int32_t valuesLen, const double *values)
Specify a profile for one component of one domain.
Definition ctonedim.cpp:65
int32_t sim1D_setRefineCriteria(int32_t handle, int32_t dom, double ratio, double slope, double curve, double prune)
Set grid refinement criteria.
Definition ctonedim.cpp:157
int32_t sim1D_show(int32_t handle)
Show logging information on current solution for all domains.
Definition ctonedim.cpp:102
int32_t sim1D_setGridMin(int32_t handle, int32_t dom, double gridmin)
Set the minimum grid spacing in the specified domain(s).
Definition ctonedim.cpp:168
int32_t sim1D_refine(int32_t handle, int32_t loglevel)
Refine the grid in all domains.
Definition ctonedim.cpp:147
int32_t sim1D_setFixedTemperature(int32_t handle, double t)
Add node for fixed temperature point of freely propagating flame.
Definition ctonedim.cpp:253
int32_t sim1D_newSim1D(int32_t domainsLen, int32_t *domains)
Create a Sim1D object with a list of domains.
Definition ctonedim.cpp:40
double sim1D_value(int32_t handle, int32_t dom, int32_t comp, int32_t localPoint)
Get one entry in the solution vector.
Definition ctonedim.cpp:211
int32_t sim1D_setFlatProfile(int32_t handle, int32_t dom, int32_t comp, double v)
Set component 'comp' of domain 'dom' to value 'v' at all points.
Definition ctonedim.cpp:78
int32_t sim1D_solve(int32_t handle, int32_t loglevel, int32_t refine_grid)
Performs the hybrid Newton steady/time-stepping solution.
Definition ctonedim.cpp:135
int32_t sim1D_setTimeStep(int32_t handle, double stepsize, int32_t n, int32_t tstepsLen, const int32_t *tsteps)
Set the number of time steps to try when the steady Newton solver is unsuccessful.
Definition ctonedim.cpp:113
int32_t sim1D_domainIndex(int32_t handle, const char *name)
Get the index of the domain named.
Definition ctonedim.cpp:201
int32_t sim1D_setMaxJacAge(int32_t handle, int32_t ss_age, int32_t ts_age)
Set the maximum number of steps that can be taken using the same Jacobian before it must be re-evalua...
Definition ctonedim.cpp:242
CTONEDIM - Generated CLib Cantera interface library.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
shared_ptr< Sim1D > newSim1D(vector< shared_ptr< Domain1D > > &domains)
Create a Sim1D object with a list of domains.
Definition Sim1D.cpp:849
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Definition clib_utils.h:32