Cantera  3.3.0a1
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_show(int32_t handle)
55 {
56 // method: void Sim1D::show()
57 try {
58 Sim1DCabinet::at(handle)->show();
59 return 0;
60 } catch (...) {
61 return handleAllExceptions(-1, ERR);
62 }
63 }
64
65 int32_t sim1D_setTimeStep(int32_t handle, double stepSize, int32_t tStepsLen, const int32_t* tSteps)
66 {
67 // method: void SteadyStateSystem::setTimeStep(double, const vector<int>&)
68 try {
69 const vector<int> tSteps_(tSteps, tSteps + tStepsLen);
70 Sim1DCabinet::as<SteadyStateSystem>(handle)->setTimeStep(stepSize, tSteps_);
71 return 0;
72 } catch (...) {
73 return handleAllExceptions(-1, ERR);
74 }
75 }
76
77 int32_t sim1D_getInitialSoln(int32_t handle)
78 {
79 // method: void Sim1D::getInitialSoln()
80 try {
81 Sim1DCabinet::at(handle)->getInitialSoln();
82 return 0;
83 } catch (...) {
84 return handleAllExceptions(-1, ERR);
85 }
86 }
87
88 int32_t sim1D_solve(int32_t handle, int32_t loglevel, int32_t refine_grid)
89 {
90 // method: void Sim1D::solve(int, bool)
91 try {
92 bool refine_grid_ = (refine_grid != 0);
93 Sim1DCabinet::at(handle)->solve(loglevel, refine_grid_);
94 return 0;
95 } catch (...) {
96 return handleAllExceptions(-1, ERR);
97 }
98 }
99
100 int32_t sim1D_refine(int32_t handle, int32_t loglevel)
101 {
102 // method: int Sim1D::refine(int)
103 try {
104 return Sim1DCabinet::at(handle)->refine(loglevel);
105 } catch (...) {
106 return handleAllExceptions(ERR, ERR);
107 }
108 }
109
110 int32_t sim1D_setRefineCriteria(int32_t handle, int32_t dom, double ratio, double slope, double curve, double prune)
111 {
112 // method: void Sim1D::setRefineCriteria(int, double, double, double, double)
113 try {
114 Sim1DCabinet::at(handle)->setRefineCriteria(dom, ratio, slope, curve, prune);
115 return 0;
116 } catch (...) {
117 return handleAllExceptions(-1, ERR);
118 }
119 }
120
121 int32_t sim1D_setGridMin(int32_t handle, int32_t dom, double gridmin)
122 {
123 // method: void Sim1D::setGridMin(int, double)
124 try {
125 Sim1DCabinet::at(handle)->setGridMin(dom, gridmin);
126 return 0;
127 } catch (...) {
128 return handleAllExceptions(-1, ERR);
129 }
130 }
131
132 int32_t sim1D_save(int32_t handle, const char* fname, const char* name, const char* desc, int32_t overwrite)
133 {
134 // method: void Sim1D::save(const string&, const string&, const string&, bool)
135 try {
136 bool overwrite_ = (overwrite != 0);
137 Sim1DCabinet::at(handle)->save(fname, name, desc, overwrite_);
138 return 0;
139 } catch (...) {
140 return handleAllExceptions(-1, ERR);
141 }
142 }
143
144 int32_t sim1D_restore(int32_t handle, const char* fname, const char* name)
145 {
146 // method: void Sim1D::_restore(const string&, const string&)
147 try {
148 Sim1DCabinet::at(handle)->_restore(fname, name);
149 return 0;
150 } catch (...) {
151 return handleAllExceptions(-1, ERR);
152 }
153 }
154
155 int32_t sim1D_writeStats(int32_t handle, int32_t printTime)
156 {
157 // setter: void OneDim::writeStats(int)
158 try {
159 Sim1DCabinet::as<OneDim>(handle)->writeStats(printTime);
160 return 0;
161 } catch (...) {
162 return handleAllExceptions(-1, ERR);
163 }
164 }
165
166 int32_t sim1D_domainIndex(int32_t handle, const char* name)
167 {
168 // size getter: size_t OneDim::domainIndex(const string&)
169 try {
170 return static_cast<int32_t>(Sim1DCabinet::as<OneDim>(handle)->domainIndex(name));
171 } catch (...) {
172 return handleAllExceptions(ERR, ERR);
173 }
174 }
175
176 int32_t sim1D_eval(int32_t handle, int32_t xLen, double* x, int32_t rLen, double* r, double rdt, int32_t count)
177 {
178 // method: void Sim1D::eval(double*, double*, double, int)
179 try {
180 Sim1DCabinet::at(handle)->eval(x, r, rdt, count);
181 return 0;
182 } catch (...) {
183 return handleAllExceptions(-1, ERR);
184 }
185 }
186
187 int32_t sim1D_setMaxJacAge(int32_t handle, int32_t ss_age, int32_t ts_age)
188 {
189 // method: void SteadyStateSystem::setJacAge(int, int)
190 try {
191 Sim1DCabinet::as<SteadyStateSystem>(handle)->setJacAge(ss_age, ts_age);
192 return 0;
193 } catch (...) {
194 return handleAllExceptions(-1, ERR);
195 }
196 }
197
198 int32_t sim1D_setFixedTemperature(int32_t handle, double t)
199 {
200 // method: int Sim1D::setFixedTemperature(double)
201 try {
202 return Sim1DCabinet::at(handle)->setFixedTemperature(t);
203 } catch (...) {
204 return handleAllExceptions(ERR, ERR);
205 }
206 }
207
208 int32_t sim1D_del(int32_t handle)
209 {
210 // destructor
211 try {
212 Sim1DCabinet::del(handle);
213 return 0;
214 } catch (...) {
215 return handleAllExceptions(-1, ERR);
216 }
217 }
218
220 {
221 // reserved CLib function: custom code
222 try {
223 // *************** begin custom code ***************
224 return Sim1DCabinet::size();
225 // **************** end custom code ****************
226 } catch (...) {
227 return handleAllExceptions(-1, ERR);
228 }
229 }
230
231} // extern "C"
Template for classes to hold pointers to objects.
Definition Cabinet.h:51
CTONEDIM - Generated CLib Cantera interface library.
int32_t sim1D_setTimeStep(int32_t handle, double stepSize, 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:65
int32_t sim1D_restore(int32_t handle, const char *fname, const char *name)
Retrieve data from a previously saved simulation.
Definition ctonedim.cpp:144
int32_t sim1D_getInitialSoln(int32_t handle)
Get the initial value of the system state from each domain in the simulation.
Definition ctonedim.cpp:77
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:155
int32_t sim1D_del(int32_t handle)
Delete Sim1D object.
Definition ctonedim.cpp:208
int32_t sim1D_cabinetSize()
Return size of Sim1D storage.
Definition ctonedim.cpp:219
int32_t sim1D_save(int32_t handle, const char *fname, const char *name, const char *desc, int32_t overwrite)
Save current simulation data to a container file or CSV format.
Definition ctonedim.cpp:132
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:176
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:110
int32_t sim1D_show(int32_t handle)
Show logging information on current solution for all domains.
Definition ctonedim.cpp:54
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:121
int32_t sim1D_refine(int32_t handle, int32_t loglevel)
Refine the grid in all domains.
Definition ctonedim.cpp:100
int32_t sim1D_setFixedTemperature(int32_t handle, double t)
Add node for fixed temperature point of freely propagating flame.
Definition ctonedim.cpp:198
int32_t sim1D_newSim1D(int32_t domainsLen, int32_t *domains)
Create a Sim1D object with a list of domains.
Definition ctonedim.cpp:40
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:88
int32_t sim1D_domainIndex(int32_t handle, const char *name)
Get the index of the domain named name.
Definition ctonedim.cpp:166
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:187
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:805
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Definition clib_utils.h:32