mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Changed all callct2 to ctString
This commit is contained in:
parent
6279debf1e
commit
7647893d73
@ -125,7 +125,7 @@ classdef Domain1D < handle
|
||||
function d = Domain1D(varargin)
|
||||
% Create a :mat:class:`Domain1D` object.
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
if nargin == 1
|
||||
a = varargin{1};
|
||||
@ -317,7 +317,7 @@ classdef Domain1D < handle
|
||||
|
||||
for i = 1:n
|
||||
id = index(i) - 1;
|
||||
output = callct2('domain_componentName', d.domainID, id);
|
||||
output = ctString('domain_componentName', d.domainID, id);
|
||||
s{i} = output;
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ classdef Sim1D < handle
|
||||
function s = Sim1D(domains)
|
||||
% Create a :mat:class:`Sim1D` object.
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
s.stID = -1;
|
||||
s.domains = domains;
|
||||
|
@ -40,7 +40,7 @@ classdef Interface < handle & ThermoPhase & Kinetics
|
||||
function s = Interface(src, id, p1, p2, p3, p4)
|
||||
% Create an :mat:class:`Interface` object.
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
t = ThermoPhase(src, id);
|
||||
s@ThermoPhase(src, id);
|
||||
|
@ -108,7 +108,7 @@ classdef Kinetics < handle
|
||||
% Instance of class :mat:class:`Kinetics`
|
||||
%
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
% indices for bulk phases in a heterogeneous mechanism
|
||||
inb1 = -1;
|
||||
@ -395,7 +395,7 @@ classdef Kinetics < handle
|
||||
% :return:
|
||||
% String reaction equation.
|
||||
|
||||
rxn = callct2('kin_getReactionString', kin.kinID, irxn - 1);
|
||||
rxn = ctString('kin_getReactionString', kin.kinID, irxn - 1);
|
||||
end
|
||||
|
||||
function rxn = get.reactionEqns(kin)
|
||||
|
@ -56,7 +56,7 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
|
||||
function s = Solution(src, id, trans)
|
||||
% Create a :mat:class:`Solution` object.
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
if nargin < 2 || nargin > 3
|
||||
error('Solution class constructor expects 2 or 3 input arguments.');
|
||||
|
@ -252,7 +252,7 @@ classdef ThermoPhase < handle
|
||||
|
||||
function tp = ThermoPhase(src, id)
|
||||
% Create a :mat:class:`ThermoPhase` object.
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
if nargin ~= 2
|
||||
error('ThermoPhase expects 2 input arguments.');
|
||||
@ -275,13 +275,14 @@ classdef ThermoPhase < handle
|
||||
function display(tp)
|
||||
% Display thermo properties
|
||||
|
||||
buflen = 0 - calllib(ct, 'thermo_report', tp.tpID, 0, '', 1);
|
||||
buflen = 0 - calllib(ctLib, 'thermo_report', tp.tpID, 0, '', 1);
|
||||
aa = char(ones(1, buflen));
|
||||
ptr = libpointer('cstring', aa);
|
||||
[iok, bb] = calllib(ct, 'thermo_report', tp.tpID, buflen, ptr, 1);
|
||||
[iok, bb] = calllib(ctLib, 'thermo_report', tp.tpID, buflen, ...
|
||||
ptr, 1);
|
||||
|
||||
if iok < 0
|
||||
error(geterr);
|
||||
error(ctGetErr);
|
||||
else
|
||||
disp(bb);
|
||||
end
|
||||
@ -528,7 +529,7 @@ classdef ThermoPhase < handle
|
||||
return
|
||||
end
|
||||
|
||||
n = callct('thermo_nAtoms', tp.tpID, k - 1, m - 1)
|
||||
n = callct('thermo_nAtoms', tp.tpID, k - 1, m - 1);
|
||||
|
||||
end
|
||||
|
||||
@ -612,7 +613,7 @@ classdef ThermoPhase < handle
|
||||
|
||||
for j = 1:n
|
||||
ksp = k(i, j) - 1;
|
||||
output = callct2('thermo_getSpeciesName', tp.tpID, ksp);
|
||||
output = ctString('thermo_getSpeciesName', tp.tpID, ksp);
|
||||
nm{i, j} = output;
|
||||
end
|
||||
|
||||
@ -799,7 +800,7 @@ classdef ThermoPhase < handle
|
||||
end
|
||||
|
||||
function e = get.eosType(tp)
|
||||
e = callct2('thermo_getEosType', tp.tpID);
|
||||
e = ctString('thermo_getEosType', tp.tpID);
|
||||
end
|
||||
|
||||
function v = get.isIdealGas(tp)
|
||||
|
@ -53,7 +53,7 @@ classdef Transport < handle
|
||||
% Instance of class :mat:class:`Transport`.
|
||||
%
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
tr.trID = 0;
|
||||
|
||||
if nargin == 2
|
||||
|
@ -65,7 +65,7 @@ classdef Func < handle
|
||||
% Instance of class :mat:class:`Func`
|
||||
%
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
if ~isa(typ, 'char')
|
||||
error('Function type must be a string');
|
||||
|
@ -152,7 +152,7 @@ classdef Mixture < handle
|
||||
function m = Mixture(phases)
|
||||
% Create a :mat:class:`Mixture` object.
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
if nargin > 1
|
||||
error('Mixture: wrong number of arguments');
|
||||
|
@ -61,7 +61,7 @@ classdef FlowDevice < handle
|
||||
function x = FlowDevice(typ)
|
||||
% Create a :mat:class:`FlowDevice` object.
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
if nargin == 0
|
||||
error('please specify the type of flow device to be created');
|
||||
|
@ -113,7 +113,7 @@ classdef Reactor < handle
|
||||
function r = Reactor(content, typ)
|
||||
% Create a :mat:class:`Reactor` object.
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
if nargin == 0
|
||||
content = 0;
|
||||
|
@ -61,7 +61,7 @@ classdef ReactorNet < handle
|
||||
function r = ReactorNet(reactors)
|
||||
% Create a :mat:class:`ReactorNet` object.
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
if nargin ~= 1
|
||||
error('Wrong number of arguments to ReactorNet constructor.');
|
||||
|
@ -46,7 +46,7 @@ classdef ReactorSurface < handle
|
||||
function s = ReactorSurface(surf, reactor, area)
|
||||
% Create a :mat:class:`ReactorSurface` object.
|
||||
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
s.surfID = callct('reactorsurface_new', 0);
|
||||
s.reactor = -1;
|
||||
|
@ -88,7 +88,7 @@ classdef Wall < handle
|
||||
|
||||
function w = Wall(l, r)
|
||||
% Create a :mat:class:`Wall` object.
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
|
||||
% At the moment, only one wall type is implemented
|
||||
typ = 'Wall';
|
||||
|
@ -5,10 +5,10 @@ function output = callct(varargin)
|
||||
errorcode = [-1, -999.999, double(intmax('uint64'))];
|
||||
|
||||
funcName = varargin{1};
|
||||
output = calllib(ct, funcName, varargin{2:end});
|
||||
output = calllib(ctLib, funcName, varargin{2:end});
|
||||
|
||||
if ismember(output, errorcode)
|
||||
error(geterr);
|
||||
error(ctGetErr);
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,3 +0,0 @@
|
||||
if ~libisloaded(ct)
|
||||
error('Cantera is not loaded');
|
||||
end
|
@ -8,7 +8,7 @@ function d = getDataDirectories()
|
||||
% :return:
|
||||
% Cell array with strings representing the data file search directories
|
||||
%
|
||||
checklib;
|
||||
ctIsLoaded;
|
||||
buflen = calllib(ct, 'ct_getDataDirectories', 0, '', ';');
|
||||
aa = char(ones(1, buflen));
|
||||
ptr = libpointer('cstring', aa);
|
11
interfaces/matlab_experimental/Utility/ctGetErr.m
Normal file
11
interfaces/matlab_experimental/Utility/ctGetErr.m
Normal file
@ -0,0 +1,11 @@
|
||||
function e = ctGetErr()
|
||||
% Get the error message from a Cantera error.
|
||||
%
|
||||
|
||||
try
|
||||
e = ctString('ct_getCanteraError');
|
||||
catch ME
|
||||
e = getReport(ME);
|
||||
end
|
||||
|
||||
end
|
@ -6,6 +6,6 @@ function v = canteraGitCommit()
|
||||
% :return:
|
||||
% A string containing the Git commit hash for the current version of Cantera.
|
||||
%
|
||||
checklib;
|
||||
v = callct2('ct_getGitCommit');
|
||||
ctIsLoaded;
|
||||
v = ctString('ct_getGitCommit');
|
||||
end
|
8
interfaces/matlab_experimental/Utility/ctIsLoaded.m
Normal file
8
interfaces/matlab_experimental/Utility/ctIsLoaded.m
Normal file
@ -0,0 +1,8 @@
|
||||
function i = ctIsLoaded()
|
||||
if ~libisloaded(ctLib)
|
||||
error('Cantera is not loaded');
|
||||
end
|
||||
|
||||
i = true;
|
||||
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
function str = ct()
|
||||
% Return name of 'cantera_shared' library.
|
||||
function str = ctLib()
|
||||
% Return name of Cantera Shared Library depending on OS.
|
||||
if ispc
|
||||
str = 'cantera_shared';
|
||||
else
|
@ -12,7 +12,7 @@ function ctLoad()
|
||||
return;
|
||||
end
|
||||
|
||||
if ~libisloaded(ctSharedLibrary)
|
||||
if ~libisloaded(ctLib)
|
||||
[~, warnings] = loadlibrary([ctRoot, ctName], ...
|
||||
[ctRoot, '/include/cantera/clib/ctmatlab.h'], ...
|
||||
'includepath', [ctRoot '/include'], ...
|
||||
|
@ -1,24 +1,24 @@
|
||||
function output = callct2(varargin)
|
||||
function output = ctString(varargin)
|
||||
% Calls Cantera library functions with string outputs and returns
|
||||
% errors if necessary.
|
||||
|
||||
err1 = -1;
|
||||
|
||||
funcName = varargin{1};
|
||||
buflen = calllib(ct, funcName, varargin{2:end}, 0, '');
|
||||
buflen = calllib(ctLib, funcName, varargin{2:end}, 0, '');
|
||||
|
||||
if buflen > 0
|
||||
aa = char(ones(1, buflen));
|
||||
ptr = libpointer('cstring', aa);
|
||||
[iok, bb] = calllib(ct, funcName, varargin{2:end}, buflen, ptr);
|
||||
[iok, bb] = calllib(ctLib, funcName, varargin{2:end}, buflen, ptr);
|
||||
output = bb;
|
||||
clear aa bb ptr;
|
||||
else
|
||||
error(geterr);
|
||||
error(ctGetErr);
|
||||
end
|
||||
|
||||
if iok == -err1
|
||||
error(geterr);
|
||||
error(ctGetErr);
|
||||
end
|
||||
|
||||
end
|
@ -1,9 +1,9 @@
|
||||
function ctUnload()
|
||||
% Unload the Cantear C Library from the Memory
|
||||
%
|
||||
if libisloaded(ctSharedLibrary)
|
||||
if libisloaded(ctLib)
|
||||
ctCleanUp;
|
||||
unloadlibrary(ctSharedLibrary);
|
||||
unloadlibrary(ctLib);
|
||||
end
|
||||
|
||||
disp('Cantera has been unloaded');
|
||||
|
@ -1,11 +1,11 @@
|
||||
function v = canteraVersion()
|
||||
function v = ctVersion()
|
||||
% Get Cantera version information. ::
|
||||
%
|
||||
% >> canteraVersion()
|
||||
% >> ctVersion()
|
||||
%
|
||||
% :return:
|
||||
% A string containing the Cantera version.
|
||||
%
|
||||
checklib;
|
||||
v = callct2('ct_getCanteraVersion');
|
||||
ctIsLoaded;
|
||||
v = ctString('ct_getCanteraVersion');
|
||||
end
|
@ -1,17 +0,0 @@
|
||||
function e = geterr()
|
||||
% Get the error message from a Cantera error.
|
||||
%
|
||||
checklib;
|
||||
|
||||
try
|
||||
buflen = calllib(ct, 'ct_getCanteraError', 0, '');
|
||||
aa = char(ones(1, buflen));
|
||||
ptr = libpointer('cstring', aa);
|
||||
[iok, bb] = calllib(ct, 'ct_getCanteraError', buflen, ptr);
|
||||
e = bb;
|
||||
clear aa bb ptr
|
||||
catch ME
|
||||
e = getReport(ME);
|
||||
end
|
||||
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
% runs selected examples without pausing
|
||||
|
||||
LoadCantera
|
||||
ctLoad
|
||||
clear all
|
||||
close all
|
||||
|
||||
@ -26,6 +26,6 @@ diamond_cvd;
|
||||
|
||||
clear all
|
||||
close all
|
||||
UnloadCantera
|
||||
ctUnload
|
||||
|
||||
disp('Test example run successful.')
|
||||
|
Loading…
Reference in New Issue
Block a user