[Reactor] ReactorNet::addReactor takes a reference instead of a pointer
This reflects how the function is usually used. The old signature is now deprecated, as is the extra argument for transfering "ownership" to the ReactorNet object.
This commit is contained in:
parent
199cd4ceba
commit
a583949457
10 changed files with 28 additions and 8 deletions
|
|
@ -114,6 +114,13 @@ public:
|
|||
//@}
|
||||
|
||||
//! Add the reactor *r* to this reactor network.
|
||||
void addReactor(Reactor& r);
|
||||
|
||||
//! Add the reactor *r* to this reactor network.
|
||||
/**
|
||||
* @deprecated To be removed after Cantera 2.2. Use addReactor(Reactor&)
|
||||
* instead.
|
||||
*/
|
||||
void addReactor(Reactor* r, bool iown = false);
|
||||
|
||||
//! Return a reference to the *n*-th reactor in this network. The reactor
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ cdef extern from "cantera/zeroD/flowControllers.h":
|
|||
cdef extern from "cantera/zeroD/ReactorNet.h":
|
||||
cdef cppclass CxxReactorNet "Cantera::ReactorNet":
|
||||
CxxReactorNet()
|
||||
void addReactor(CxxReactor*)
|
||||
void addReactor(CxxReactor&)
|
||||
void advance(double) except +
|
||||
double step(double) except +
|
||||
double time()
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ cdef class ReactorNet:
|
|||
def add_reactor(self, Reactor r):
|
||||
"""Add a reactor to the network."""
|
||||
self._reactors.append(r)
|
||||
self.net.addReactor(r.reactor)
|
||||
self.net.addReactor(deref(r.reactor))
|
||||
|
||||
def advance(self, double t):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ void runexample()
|
|||
|
||||
// the simulation only contains one reactor
|
||||
ReactorNet sim;
|
||||
sim.addReactor(&combustor);
|
||||
sim.addReactor(combustor);
|
||||
|
||||
// take single steps to 6 s, writing the results to a CSV file
|
||||
// for later plotting.
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ int kinetics1(int np, void* p)
|
|||
// create a container object to run the simulation
|
||||
// and add the reactor to it
|
||||
ReactorNet sim;
|
||||
sim.addReactor(&r, false);
|
||||
sim.addReactor(&r);
|
||||
|
||||
// main loop
|
||||
clock_t t0 = clock(); // save start time
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ extern "C" {
|
|||
{
|
||||
try {
|
||||
NetworkCabinet::item(i).addReactor(
|
||||
&dynamic_cast<Reactor&>(ReactorCabinet::item(n)));
|
||||
dynamic_cast<Reactor&>(ReactorCabinet::item(n)));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
|
|
|
|||
|
|
@ -163,6 +163,12 @@ double ReactorNet::step(doublereal time)
|
|||
|
||||
void ReactorNet::addReactor(Reactor* r, bool iown)
|
||||
{
|
||||
warn_deprecated("ReactorNet::addReactor(Reactor*)",
|
||||
"To be removed after Cantera 2.2. Use 'addReactor(Reactor&) instead'.");
|
||||
if (iown) {
|
||||
warn_deprecated("ReactorNet::addReactor",
|
||||
"Ownership of Reactors by ReactorNet is deprecated.");
|
||||
}
|
||||
r->setNetwork(this);
|
||||
if (r->type() >= ReactorType) {
|
||||
m_reactors.push_back(r);
|
||||
|
|
@ -174,6 +180,13 @@ void ReactorNet::addReactor(Reactor* r, bool iown)
|
|||
}
|
||||
}
|
||||
|
||||
void ReactorNet::addReactor(Reactor& r)
|
||||
{
|
||||
r.setNetwork(this);
|
||||
m_reactors.push_back(&r);
|
||||
m_iown.push_back(false);
|
||||
}
|
||||
|
||||
void ReactorNet::eval(doublereal t, doublereal* y,
|
||||
doublereal* ydot, doublereal* p)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ int kinetics_example1(int job)
|
|||
// and add the reactor to it
|
||||
ReactorNet* sim_ptr = new ReactorNet();
|
||||
sim_ptr->setVerbose(false);
|
||||
sim_ptr->addReactor(&r);
|
||||
sim_ptr->addReactor(r);
|
||||
|
||||
double tm;
|
||||
double dt = 1.e-5; // interval at which output is written
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ int kinetics_example3(int job)
|
|||
// and add the reactor to it
|
||||
ReactorNet& sim = *(new ReactorNet());
|
||||
sim.setVerbose(false);
|
||||
sim.addReactor(&r);
|
||||
sim.addReactor(r);
|
||||
|
||||
double tm;
|
||||
double dt = 1.e-5; // interval at which output is written
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ int rxnpath_example1(int job)
|
|||
// create a container object to run the simulation
|
||||
// and add the reactor to it
|
||||
ReactorNet& sim = *(new ReactorNet());
|
||||
sim.addReactor(&r);
|
||||
sim.addReactor(r);
|
||||
|
||||
// create a reaction path diagram builder
|
||||
ReactionPathBuilder b;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue