mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Avoid class destructors from deleting already-deleted objects.
This commit is contained in:
parent
7e6f9c999e
commit
6e8ab95ac6
@ -11,13 +11,18 @@ classdef Interface < handle & ThermoPhase & Kinetics
|
||||
% - src: YAML file containing the interface or edge phase.
|
||||
% - id: Name of the interface or edge phase in the YAML file.
|
||||
% Optional:
|
||||
% - p1: 1st Adjoining phase to the interface.
|
||||
% - p2: 2nd Adjoining phase to the interface.
|
||||
% - p3: 3rd Adjoining phase to the interface.
|
||||
% - p4: 4th Adjoining phase to the interface.
|
||||
% - p1: 1st adjacent phase to the interface.
|
||||
% - p2: 2nd adjacent phase to the interface.
|
||||
% - p3: 3rd adjacent phase to the interface.
|
||||
% - p4: 4th adjacent phase to the interface.
|
||||
% :return:
|
||||
% Instance of class :mat:class:`Interface`.
|
||||
|
||||
properties (SetAccess = immutable)
|
||||
phaseID
|
||||
interfaceName
|
||||
end
|
||||
|
||||
properties (SetAccess = public)
|
||||
|
||||
% Surface coverages of the species on an interface.
|
||||
@ -28,6 +33,7 @@ classdef Interface < handle & ThermoPhase & Kinetics
|
||||
|
||||
properties (SetAccess = protected)
|
||||
concentrations % Concentrations of the species on an interface.
|
||||
nAdjacent % Number of adjacent phases.
|
||||
end
|
||||
|
||||
methods
|
||||
@ -39,15 +45,20 @@ classdef Interface < handle & ThermoPhase & Kinetics
|
||||
ctIsLoaded;
|
||||
|
||||
src = varargin{1};
|
||||
id = varargin{2};
|
||||
name = varargin{2};
|
||||
na = nargin - 2;
|
||||
|
||||
t = ThermoPhase(src, id);
|
||||
s@ThermoPhase(src, id);
|
||||
adj = [];
|
||||
for i = 3:nargin
|
||||
adj(i-2) = varargin{i}.phaseID;
|
||||
end
|
||||
|
||||
args = varargin(3:end);
|
||||
|
||||
s@Kinetics(t, src, id, args{:});
|
||||
s.tpID = t.tpID;
|
||||
ID = ctFunc('soln_newInterface', src, name, na, adj);
|
||||
s@ThermoPhase('CreateFromSolution', ID);
|
||||
s@Kinetics('CreateFromSolution', ID);
|
||||
s.phaseID = ID;
|
||||
s.interfaceName = name;
|
||||
s.nAdjacent = ctFunc('soln_nAdjacent', ID);
|
||||
end
|
||||
|
||||
%% Interface Class Destructor
|
||||
@ -59,6 +70,11 @@ classdef Interface < handle & ThermoPhase & Kinetics
|
||||
|
||||
%% Interface Get Methods
|
||||
|
||||
function phase = adjacent(s, n)
|
||||
% Get the nth adjacent phase of an interface.
|
||||
phase = ctFunc('soln_adjacent', s, n);
|
||||
end
|
||||
|
||||
function c = coverages(s)
|
||||
% Surface coverages of the species on an interface.
|
||||
|
||||
|
@ -144,6 +144,16 @@ classdef Kinetics < handle
|
||||
kin.kinID = ctFunc('kin_newFromFile', src, id, ph, neighbours{:});
|
||||
end
|
||||
|
||||
%% Kinetics Class Destructor
|
||||
|
||||
function delete(kin)
|
||||
% Delete the :mat:class:`Sim1D` object.
|
||||
|
||||
if ~isa(kin, 'Solution') && ~isa(kin, 'Interface')
|
||||
ctFunc('kin_del', kin.kinID);
|
||||
end
|
||||
end
|
||||
|
||||
%% Get scalar attributes
|
||||
|
||||
function n = kineticsSpeciesIndex(kin, name, phase)
|
||||
|
@ -49,7 +49,7 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
|
||||
% Instance of class :mat:class:`Solution`.
|
||||
|
||||
properties (SetAccess = immutable)
|
||||
solnID
|
||||
phaseID
|
||||
solnName
|
||||
end
|
||||
|
||||
@ -79,8 +79,8 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
|
||||
s@ThermoPhase('CreateFromSolution', ID);
|
||||
s@Kinetics('CreateFromSolution', ID);
|
||||
s@Transport('CreateFromSolution', ID);
|
||||
s.solnID = ID;
|
||||
s.solnName = ctString('soln_name', s.solnID);
|
||||
s.phaseID = ID;
|
||||
s.solnName = ctString('soln_name', s.phaseID);
|
||||
s.th = s.tpID;
|
||||
end
|
||||
|
||||
@ -88,7 +88,7 @@ classdef Solution < handle & ThermoPhase & Kinetics & Transport
|
||||
|
||||
function delete(s)
|
||||
% Delete :mat:class:`Solution` object.
|
||||
ctFunc('soln_del', s.solnID);
|
||||
ctFunc('soln_del', s.phaseID);
|
||||
disp('Solution class object has been deleted');
|
||||
end
|
||||
|
||||
|
@ -434,6 +434,16 @@ classdef ThermoPhase < handle
|
||||
tp.basis = 'molar';
|
||||
end
|
||||
|
||||
%% ThermoPhase class Destructor
|
||||
|
||||
function delete(tp)
|
||||
% Delete the :mat:class:`ThermoPhase` object.
|
||||
|
||||
if ~isa(tp, 'Solution') && ~isa(tp, 'Interface')
|
||||
ctFunc('thermo_del', tp.tpID);
|
||||
end
|
||||
end
|
||||
|
||||
%% ThermoPhase Utility Methods
|
||||
|
||||
function display(tp)
|
||||
@ -911,7 +921,7 @@ classdef ThermoPhase < handle
|
||||
end
|
||||
|
||||
function v = get.isIdealGas(tp)
|
||||
v = strcmp(tp.eosType, 'IdealGas');
|
||||
v = strcmp(tp.eosType, 'ideal-gas');
|
||||
end
|
||||
|
||||
function b = get.isothermalCompressibility(tp)
|
||||
|
@ -90,6 +90,16 @@ classdef Transport < handle
|
||||
|
||||
end
|
||||
|
||||
%% Transport Destructor Methods
|
||||
|
||||
function delete(tr)
|
||||
% Delete the :mat:class:`Transport` object.
|
||||
|
||||
if ~isa(tr, 'Solution')
|
||||
ctFunc('trans_del', tr.trID);
|
||||
end
|
||||
end
|
||||
|
||||
%% Transport Get Methods
|
||||
|
||||
function v = get.viscosity(tr)
|
||||
|
Loading…
Reference in New Issue
Block a user