[MATLAB] Added extra checks in class destructors

to avoid calling the corresponding functions in
clib and throw a warning
This commit is contained in:
ssun30 2025-02-18 22:09:34 -05:00
parent 2f6c791692
commit 68f9bc8fda
11 changed files with 41 additions and 2 deletions

View File

@ -68,6 +68,10 @@ classdef Interface < handle & ThermoPhase & Kinetics
function delete(s)
% Delete :mat:class:`Interface` object.
if isempty(s.solnID)
return
end
ctFunc('soln_del', s.solnID);
end

View File

@ -190,6 +190,9 @@ classdef Mixture < handle
function delete(m)
% Delete the :mat:class:`Mixture` object.
if isempty(m.mixID)
return
end
calllib(ct, 'mix_del', m.mixID);
end

View File

@ -86,6 +86,10 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
function delete(s)
% Delete :mat:class:`Solution` object.
if isempty(s.solnID)
return
end
ctFunc('soln_del', s.solnID);
end

View File

@ -4,6 +4,10 @@ classdef Func1 < handle
id
end
properties (SetAccess = protected)
type
end
methods
%% Func1 Class Constructor
@ -36,7 +40,7 @@ classdef Func1 < handle
% * Advanced functors: ``'polynomial3'``, ``'Fourier'``, ``'Gaussian'``,
% ``'Arrhenius'``. Use vector parameter, for example
%
% >> x = Func('polynomial3', [1 2 3]) % x^2 + 2x + 3
% >> x = Func1('polynomial3', [1 2 3]) % x^2 + 2x + 3
%
% * Tabulation functors: ``'tabulated-linear'``,
% ``'tabulated-previous'``. Use pair of vector parameters, for example
@ -134,6 +138,9 @@ classdef Func1 < handle
function delete(f)
% Delete the :mat:class:`Func1` object.
if isempty(f.id)
return
end
ctFunc('func_del', f.id);
end
@ -179,7 +186,7 @@ classdef Func1 < handle
r = Func1(id);
end
function s = type(f)
function s = get.type(f)
% Return function type.
s = ctString('func_type', f.id);
end

View File

@ -101,6 +101,9 @@ classdef Domain1D < handle
function delete(d)
% Delete the :mat:class:`Domain1D` object.
if isempty(d.domainID)
return
end
ctFunc('domain_del', d.domainID);
end

View File

@ -50,6 +50,9 @@ classdef Sim1D < handle
function delete(s)
% Delete the :mat:class:`Sim1D` object.
if isempty(s.stID)
return
end
ctFunc('sim1D_del', s.stID);
end

View File

@ -83,6 +83,9 @@ classdef FlowDevice < handle
function delete(f)
% Delete the :mat:class:`FlowDevice` object.
if isempty(f.id)
return
end
ctFunc('flowdev_del', f.id);
end

View File

@ -140,6 +140,9 @@ classdef Reactor < handle
function delete(r)
% Delete the :mat:class:`Reactor` object.
if isempty(r.id)
return
end
ctFunc('reactor_del', r.id);
end

View File

@ -85,6 +85,9 @@ classdef ReactorNet < handle
function delete(r)
% Delete the :mat:class:`ReactorNet` object object.
if isempty(r.id)
return
end
ctFunc('reactornet_del', r.id);
end

View File

@ -56,6 +56,9 @@ classdef ReactorSurface < handle
function delete(s)
% Delete the :mat:class:`ReactorSurface` object.
if isempty(s.surfID)
return
end
ctFunc('reactorsurface_del', s.surfID);
end

View File

@ -127,6 +127,9 @@ classdef Wall < handle
function delete(w)
% Clear the :mat:class:`Wall` object.
if isempty(w.id)
return
end
ctFunc('wall_del', w.id);
end