cantera/src/matlab/flowdevicemethods.cpp
Ingmar Schoegl d263566670 [Reactor] Deprecating magic numbers.
* add deprecation warning for int ReactorBase::type() (to be changed after Cantera 2.5)
 * introduce temporary std::string ReactorBase::typeStr() (to be renamed after Cantera 2.5)
 * deprecate all functions using the old call and introduce associated temporary functions
2019-08-01 15:37:48 -04:00

84 lines
2.2 KiB
C++

// This file is part of Cantera. See License.txt in the top-level directory or
// at https://cantera.org/license.txt for license and copyright information.
#include "ctmatutils.h"
#include "cantera/clib/ctreactor.h"
#include "cantera/clib/ct.h"
void flowdevicemethods(int nlhs, mxArray* plhs[],
int nrhs, const mxArray* prhs[])
{
int m, iok = 0, n;
int job = getInt(prhs[1]);
double r = Undef;
double v = Undef;
if (nrhs > 3) {
v = getDouble(prhs[3]);
}
// constructor
if (job == 0) {
char* type = getString(prhs[2]);
n = flowdev_new2(type);
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
double* h = mxGetPr(plhs[0]);
*h = double(n);
if (n < 0) {
reportError();
}
return;
}
// options that do not return a value
int i = getInt(prhs[2]);
if (job < 20) {
switch (job) {
case 1:
iok = flowdev_del(i);
break;
case 2:
m = getInt(prhs[4]);
iok = flowdev_install(i, int(v), m);
break;
case 3:
iok = flowdev_setMassFlowRate(i, v);
break;
case 4:
iok = flowdev_setParameters(i, 1, &v);
break;
case 5:
iok = flowdev_setFunction(i, int(v));
break;
case 7:
iok = flowdev_setMaster(i, int(v));
break;
default:
mexErrMsgTxt("unknown job parameter");
}
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
double* h = mxGetPr(plhs[0]);
*h = double(iok);
if (iok < 0) {
reportError();
}
return;
} else if (job < 40) {
// options that return a value of type 'double'
switch (job) {
case 21:
r = flowdev_massFlowRate(i, v);
break;
default:
mexErrMsgTxt("unknown job parameter");
}
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
double* h = mxGetPr(plhs[0]);
*h = r;
if (r == Undef) {
reportError();
}
return;
}
}