Skip to content

Commit

Permalink
Combined calllib and error handling into one callct command
Browse files Browse the repository at this point in the history
  • Loading branch information
ssun30 authored and speth committed May 11, 2023
1 parent 61b7602 commit 94f556c
Show file tree
Hide file tree
Showing 18 changed files with 281 additions and 265 deletions.
94 changes: 47 additions & 47 deletions interfaces/matlab_experimental/1D/Domain1D.m
Expand Up @@ -39,31 +39,31 @@

if nargin == 1
if strcmp(a, 'Inlet1D')
d.domainID = calllib(ct, 'inlet_new');
d.domainID = callct('inlet_new');
elseif strcmp(a, 'Surf1D')
d.domainID = calllib(ct, 'surf_new');
d.domainID = callct('surf_new');
elseif strcmp(a, 'Symm1D')
d.domainID = calllib(ct, 'symm_new');
d.domainID = callct('symm_new');
elseif strcmp(a, 'Outlet1D')
d.domainID = calllib(ct, 'outlet_new');
d.domainID = callct('outlet_new');
elseif strcmp(a, 'OutletRes')
d.domainID = calllib(ct, 'outletres_new');
d.domainID = callct('outletres_new');
else
error('Not enough arguments for that job number');
end
elseif nargin == 2
% a stagnation flow
if strcmp(a, 'StagnationFlow')
if isa(b, 'Solution')
d.domainID = calllib(ct, 'stflow_new', ...
d.domainID = callct('stflow_new', ...
b.tpID, b.kinID, b.trID, 1);
else
error('Wrong argument type. Expecting instance of class Solution.');
end
elseif strcmp(a, 'ReactingSurface')
if isa(b, 'Interface')
d.domainID = calllib(ct, 'reactingsurf_new');
calllib(ct, 'reactingsurf_setkineticsmgr', ...
d.domainID = callct('reactingsurf_new');
callct('reactingsurf_setkineticsmgr', ...
d.domainID, b.kinID);
else
error('Wrong argument type. Expecting instance of class Interface.');
Expand All @@ -78,7 +78,7 @@
flowtype = 1;
else flowtype = 2;
end
d.domainID = calllib(ct, 'stflow_new', ...
d.domainID = callct('stflow_new', ...
b.tpID, b.kinID, b.trID, flowtype);
else
error('Wrong argument type. Expecting instance of class Solution.');
Expand All @@ -104,7 +104,7 @@ function clear(d)
% Instance of class :mat:func:`Domain1D` (or another
% object that derives from Domain1D)
%
calllib(ct, 'domain_del', d.domainID);
callct('domain_del', d.domainID);
end

function d = disableEnergy(d)
Expand All @@ -117,7 +117,7 @@ function clear(d)
%
disp(' ');
disp('Disabling the energy equation...');
calllib(ct, 'stflow_solveEnergyEqn', d.domainID, 0);
callct('stflow_solveEnergyEqn', d.domainID, 0);
end

function d = enableEnergy(d)
Expand All @@ -130,7 +130,7 @@ function clear(d)
%
disp(' ');
disp('Enabling the energy equation...');
calllib(ct, 'stflow_solveEnergyEqn', d.domainID, 1);
callct('stflow_solveEnergyEqn', d.domainID, 1);
end

function d = disableSoret(d)
Expand All @@ -143,7 +143,7 @@ function clear(d)
%
disp(' ');
disp('Disabling the Soret effect...');
calllib(ct, 'stflow_enableSoret', d.domainID, 0);
callct('stflow_enableSoret', d.domainID, 0);
end

function d = enableSoret(d)
Expand All @@ -156,7 +156,7 @@ function clear(d)
%
disp(' ');
disp('Disabling the Soret effect...');
calllib(ct, 'stflow_enableSoret', d.domainID, 1);
callct('stflow_enableSoret', d.domainID, 1);
end

%% Domain Get Methods
Expand All @@ -173,8 +173,8 @@ function clear(d)
% 1x2 Vector of the lower and upper bounds.
%
n = d.componentIndex(component);
lower = calllib(ct, 'domain_lowerBound', d.domainID, n);
upper = calllib(ct, 'domain_upperBound', d.domainID, n);
lower = callct('domain_lowerBound', d.domainID, n);
upper = callct('domain_upperBound', d.domainID, n);
b = [lower, upper];
end

Expand All @@ -194,7 +194,7 @@ function clear(d)
if isa(name, 'double')
n = name;
else
n = calllib(ct, 'domain_componentIndex', ...
n = callct('domain_componentIndex', ...
d.domainID, name);
if n >= 0
n = n+1;
Expand Down Expand Up @@ -222,11 +222,11 @@ function clear(d)
s = cell(m);
for i = 1:n
id = index(i)-1;
buflen = calllib(ct, 'domain_componentName', ...
buflen = callct('domain_componentName', ...
d.domainID, id, 0, 0);
if buflen > 0
aa = char(zeros(1, buflen));
[out_buf, aa] = calllib(ct, 'domain_componentName', ...
[out_buf, aa] = callct('domain_componentName', ...
d.domainID, id, buflen, aa);
s{i} = aa;
end
Expand All @@ -244,7 +244,7 @@ function clear(d)
% This function returns an integer flag denoting the location
% of the domain, beginning with 1 at the left.
%
i = calllib(ct, 'domain_index', d.domainID);
i = callct('domain_index', d.domainID);
if i >= 0
i = i + 1;
end
Expand All @@ -264,7 +264,7 @@ function clear(d)
% This function returns an integer flag denoting the domain
% type.
%
i = calllib(ct, 'domain_type', d.domainID);
i = callct('domain_type', d.domainID);
end

function zz = gridPoints(d, n)
Expand All @@ -283,13 +283,13 @@ function clear(d)
np = d.nPoints;
zz = zeros(1, np);
for i = 1:np
zz(i) = calllib(ct, 'domain_grid', d.domainID, i-1);
zz(i) = callct('domain_grid', d.domainID, i-1);
end
else
m = length(n);
zz = zeros(1, m);
for i = 1:m
zz(i) = calllib(ct, 'domain_grid', d.domainID, n(i)-1);
zz(i) = callct('domain_grid', d.domainID, n(i)-1);
end
end
end
Expand Down Expand Up @@ -358,7 +358,7 @@ function clear(d)
% :return:
% The mass flux in the domain.
%
mdot = calllib(ct, 'bdry_mdot', d.domainID);
mdot = callct('bdry_mdot', d.domainID);
end

function y = massFraction(d, k)
Expand All @@ -382,7 +382,7 @@ function clear(d)
end

if d.isInlet
y = calllib(ct, 'bdry_massFraction', d.domainID, k-1);
y = callct('bdry_massFraction', d.domainID, k-1);
else error('Input domain must be an inlet');
end
end
Expand All @@ -397,7 +397,7 @@ function clear(d)
% :return:
% Number of variables at each grid point
%
n = calllib(ct, 'domain_nComponents', d.domainID);
n = callct('domain_nComponents', d.domainID);
end

function n = nPoints(d)
Expand All @@ -410,7 +410,7 @@ function clear(d)
% :return:
% Integer number of grid points.
%
n = calllib(ct, 'domain_nPoints', d.domainID);
n = callct('domain_nPoints', d.domainID);
end

function tol = tolerances(d, component)
Expand All @@ -426,8 +426,8 @@ function clear(d)
% 1x2 Vector of the relative and absolute error tolerances.

n = d.componentIndex(component);
rerr = calllib(ct, 'domain_rtol', d.domainID, n);
aerr = calllib(ct, 'domain_atol', d.domainID, n);
rerr = callct('domain_rtol', d.domainID, n);
aerr = callct('domain_atol', d.domainID, n);
tol = [rerr, aerr];
end

Expand All @@ -441,7 +441,7 @@ function clear(d)
% :return:
% Temperature. Units: K
%
temperature = calllib(ct, 'bdry_temperature', d.domainID);
temperature = callct('bdry_temperature', d.domainID);
end

function pressure = get.P(d)
Expand Down Expand Up @@ -472,7 +472,7 @@ function clear(d)
if t <= 0
error('The temperature must be positive');
end
calllib(ct, 'bdry_setTemperature', d.domainID, t);
callct('bdry_setTemperature', d.domainID, t);
end

function set.P(d, p)
Expand All @@ -488,7 +488,7 @@ function clear(d)
if p <= 0
error('The pressure must be positive');
end
calllib(ct, 'stflow_setPressure', d.domainID, p);
callct('stflow_setPressure', d.domainID, p);
end

function setBounds(d, component, lower, upper)
Expand All @@ -507,7 +507,7 @@ function setBounds(d, component, lower, upper)
%

n = d.componentIndex(component);
calllib(ct, 'domain_setBounds', d.domainID, n-1, lower, upper);
callct('domain_setBounds', d.domainID, n-1, lower, upper);
end

function setCoverageEqs(d, onoff)
Expand Down Expand Up @@ -540,7 +540,7 @@ function setCoverageEqs(d, onoff)
elseif isa(onoff, 'numeric')
ion = onoff;
end
calllib(ct, 'reactingsurf_enableCoverageEqs', d.domainID, ion);
callct('reactingsurf_enableCoverageEqs', d.domainID, ion);
end

function setFixedTempProfile(d, profile)
Expand All @@ -562,11 +562,11 @@ function setFixedTempProfile(d, profile)
sz = size(profile);
if sz(1) == 2
l = length(profile(1, :));
calllib(ct, 'stflow_setFixedTempProfile', d.domainID, ...
callct('stflow_setFixedTempProfile', d.domainID, ...
l, profile(1, :), l, profile(2, :));
elseif sz(2) == 2
l = length(profile(:, 1));
calllib(ct, 'stflow_setFixedTempProfile', d.domainID, ...
callct('stflow_setFixedTempProfile', d.domainID, ...
l, profile(:, 1), l, profile(:, 2));
else error('Wrong temperature profile array shape.');
end
Expand All @@ -582,7 +582,7 @@ function setID(d, id)
% :param id:
% String ID to assign
%
calllib(ct, 'domain_setID', d.domainID, id);
callct('domain_setID', d.domainID, id);
end

function setMdot(d, mdot)
Expand All @@ -595,7 +595,7 @@ function setMdot(d, mdot)
% :param mdot:
% Mass flow rate
%
calllib(ct, 'bdry_setMdot', d.domainID, mdot);
callct('bdry_setMdot', d.domainID, mdot);
end

function setMoleFractions(d, x)
Expand All @@ -609,7 +609,7 @@ function setMoleFractions(d, x)
% String specifying the species and mole fractions in
% the format ``'SPEC:X,SPEC2:X2'``.
%
calllib(ct, 'bdry_setMoleFractions', d.domainID, x);
callct('bdry_setMoleFractions', d.domainID, x);
end

function setProfileD(d, n, p)
Expand Down Expand Up @@ -655,19 +655,19 @@ function setSteadyTolerances(d, component, rtol, atol)
if strcmp(component, 'default')
nc = d.nComponents;
for ii = 1:nc
calllib(ct, 'domain_setSteadyTolerances', ...
callct('domain_setSteadyTolerances', ...
d.domainID, ii, rtol, atol);
end
elseif iscell(component)
nc = length(component);
for ii = 1:nc
n = d.componentIndex(component{ii});
calllib(ct, 'domain_setSteadyTolerances', ...
callct('domain_setSteadyTolerances', ...
d.domainID, n, rtol, atol);
end
else
n = d.componentIndex(component);
calllib(ct, 'domain_setSteadyTolerances', ...
callct('domain_setSteadyTolerances', ...
d.domainID, ii, rtol, atol);
end
end
Expand All @@ -691,19 +691,19 @@ function setTransientTolerances(d, component, rtol, atol)
if strcmp(component, 'default')
nc = d.nComponents;
for ii = 1:nc
calllib(ct, 'domain_setTransientTolerances', ...
callct('domain_setTransientTolerances', ...
d.domainID, ii, rtol, atol);
end
elseif iscell(component)
nc = length(component);
for ii = 1:nc
n = d.componentIndex(component{ii});
calllib(ct, 'domain_setTransientTolerances', ...
callct('domain_setTransientTolerances', ...
d.domainID, n, rtol, atol);
end
else
n = d.componentIndex(component);
calllib(ct, 'domain_setTransientTolerances', ...
callct('domain_setTransientTolerances', ...
d.domainID, ii, rtol, atol);
end
end
Expand All @@ -717,7 +717,7 @@ function setTransport(d, itr)
% ID of the solution object for which transport properties
% are calculated.
%
calllib(ct, 'stflow_setTransport', d.domainID, itr);
callct('stflow_setTransport', d.domainID, itr);
end

function setupGrid(d, grid)
Expand All @@ -729,7 +729,7 @@ function setupGrid(d, grid)
% Instance of class :mat:func:`Domain1D`
% :param grid:
%
calllib(ct, 'domain_setupGrid', d.domainID, numel(grid), grid);
callct('domain_setupGrid', d.domainID, numel(grid), grid);
end

end
Expand Down

0 comments on commit 94f556c

Please sign in to comment.