[Matlab] 'cleanup' now deletes all Cantera objects

'cleanup' previously only deleted ThermoPhase, Kinetics, Transport, Domain1D,
Sim1D, and XML_Node objects, while missing all objects associated with reactor
networks (Reactor, ReactorNet, FlowDevice, Wall), MultiPhase, Func1, and
reaction paths (ReactionPathBuilder, ReactionPathDiagram).

Fixes #251.
This commit is contained in:
Ray Speth 2015-04-08 23:08:42 -04:00
parent f59bcdf057
commit b495262aff
10 changed files with 60 additions and 0 deletions

View file

@ -103,6 +103,16 @@ extern "C" {
}
}
int func_clear()
{
try {
FuncCabinet::clear();
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int func_copy(int i)
{
try {

View file

@ -9,6 +9,7 @@
extern "C" {
CANTERA_CAPI int func_new(int type, size_t n, size_t lenp, double* p);
CANTERA_CAPI int func_del(int i);
CANTERA_CAPI int func_clear();
CANTERA_CAPI int func_copy(int i);
CANTERA_CAPI int func_assign(int i, int j);
CANTERA_CAPI double func_value(int i, double t);

View file

@ -36,6 +36,16 @@ extern "C" {
}
}
int mix_clear()
{
try {
mixCabinet::clear();
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int mix_copy(int i)
{
try {

View file

@ -9,6 +9,7 @@
extern "C" {
CANTERA_CAPI int mix_new();
CANTERA_CAPI int mix_del(int i);
CANTERA_CAPI int mix_clear();
CANTERA_CAPI int mix_copy(int i);
CANTERA_CAPI int mix_assign(int i, int j);
CANTERA_CAPI int mix_addPhase(int i, int j, double moles);

View file

@ -656,4 +656,17 @@ extern "C" {
return handleAllExceptions(-1, ERR);
}
}
int clear_reactors()
{
try {
ReactorCabinet::clear();
NetworkCabinet::clear();
FlowDeviceCabinet::clear();
WallCabinet::clear();
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
}

View file

@ -71,6 +71,8 @@ extern "C" {
CANTERA_CAPI int wall_setEmissivity(int i, double epsilon);
CANTERA_CAPI int wall_ready(int i);
CANTERA_CAPI int wall_addSensitivityReaction(int i, int lr, int rxn);
CANTERA_CAPI int clear_reactors();
}
#endif

View file

@ -308,4 +308,15 @@ extern "C" {
return handleAllExceptions(-1, ERR);
}
}
int clear_rxnpath()
{
try {
DiagramCabinet::clear();
BuilderCabinet::clear();
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
}

View file

@ -34,6 +34,8 @@ extern "C" {
CANTERA_CAPI int rbuild_init(int i, char* logfile, int k);
CANTERA_CAPI int rbuild_build(int i, int k, char* el, char* dotfile,
int idiag, int iquiet);
CANTERA_CAPI int clear_rxnpath();
}
#endif

View file

@ -5,8 +5,12 @@
#include <iostream>
#include "clib/ct.h"
#include "clib/ctreactor.h"
#include "clib/ctonedim.h"
#include "clib/ctmultiphase.h"
#include "clib/ctxml.h"
#include "clib/ctfunc.h"
#include "clib/ctrpath.h"
#include "ctmatutils.h"
using namespace std;
@ -66,8 +70,12 @@ void ctfunctions(int nlhs, mxArray* plhs[],
case 4:
iok = domain_clear();
iok = sim1D_clear();
iok = mix_clear();
iok = xml_clear();
iok = func_clear();
iok = clearStorage();
iok = clear_reactors();
iok = clear_rxnpath();
break;
default:

View file

@ -9,3 +9,5 @@ assertEqual(length(dkm), nSpecies(gas))
function testImportCTI
gas = importPhase('h2o2.cti');
assertEqual(temperature(gas), 300)
cleanup()