Skip to content

Commit

Permalink
Changed names of functions handling loading and unloading Cantera.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssun30 authored and speth committed May 11, 2023
1 parent 7573742 commit 6279deb
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 48 deletions.
1 change: 1 addition & 0 deletions interfaces/matlab_experimental/Func/fplus.m
Expand Up @@ -10,6 +10,7 @@
% :return:
% Instance of class :mat:class:`fplus`
%

methods

function f = fplus(a, b)
Expand Down
26 changes: 0 additions & 26 deletions interfaces/matlab_experimental/Utility/LoadCantera.m

This file was deleted.

7 changes: 0 additions & 7 deletions interfaces/matlab_experimental/Utility/UnloadCantera.m

This file was deleted.

3 changes: 0 additions & 3 deletions interfaces/matlab_experimental/Utility/cantera_root.m

This file was deleted.

12 changes: 0 additions & 12 deletions interfaces/matlab_experimental/Utility/cleanup.m

This file was deleted.

21 changes: 21 additions & 0 deletions interfaces/matlab_experimental/Utility/ctCleanUp.m
@@ -0,0 +1,21 @@
function ctCleanUp()
% Delete all stored Cantera objects and reclaim memory.
%
ctIsLoaded;

classList = {'Domain1D', 'Sim1D', 'Func', 'Kinetics', ...
'Interface', 'Mixture', 'Solution', 'FlowDevice', 'Reactor', ...
'Wall', 'ReactorNet', 'ReactorSurface', 'ThermoPhase', 'Transport'};

varList = evalin('base', 'whos');

for i = 1:length(varList)
for j = 1:length(classList)
if isa(evalin('base', ['eval("', varList(i).name, '")']), ...
classList{j});
evalin('base', ['clear ', varList(i).name]);
break
end
end
end
end
27 changes: 27 additions & 0 deletions interfaces/matlab_experimental/Utility/ctLoad.m
@@ -0,0 +1,27 @@
function ctLoad()
% Load the Cantera C Library into Memory
%
if ispc
ctName = '/Lib/cantera_shared.dll';
elseif ismac
ctName = '/Lib/libcantera_shared.dylib';
elseif isunix
ctName = '/lib/libcantera_shared.so';
else
error('Operating System Not Supported!');
return;
end

if ~libisloaded(ctSharedLibrary)
[~, warnings] = loadlibrary([ctRoot, ctName], ...
[ctRoot, '/include/cantera/clib/ctmatlab.h'], ...
'includepath', [ctRoot '/include'], ...
'addheader', 'ct', 'addheader', 'ctfunc', ...
'addheader', 'ctmultiphase', 'addheader', ...
'ctonedim', 'addheader', 'ctreactor', ...
'addheader', 'ctrpath', 'addheader', 'ctsurf');
end

disp(sprintf('Cantera %s is ready for use.', ctVersion))

end
3 changes: 3 additions & 0 deletions interfaces/matlab_experimental/Utility/ctRoot.m
@@ -0,0 +1,3 @@
function output = ctRoot()
output = '/home/ssun30/anaconda3/envs/ct-matlab';
end
10 changes: 10 additions & 0 deletions interfaces/matlab_experimental/Utility/ctUnload.m
@@ -0,0 +1,10 @@
function ctUnload()
% Unload the Cantear C Library from the Memory
%
if libisloaded(ctSharedLibrary)
ctCleanUp;
unloadlibrary(ctSharedLibrary);
end

disp('Cantera has been unloaded');
end

0 comments on commit 6279deb

Please sign in to comment.