diff --git a/include/cantera/zeroD/FlowDevice.h b/include/cantera/zeroD/FlowDevice.h index f4a62e20d..aac16f58f 100644 --- a/include/cantera/zeroD/FlowDevice.h +++ b/include/cantera/zeroD/FlowDevice.h @@ -24,6 +24,8 @@ class ReactorBase; class FlowDevice : public ConnectorNode { public: + FlowDevice(shared_ptr r0, shared_ptr r1, + const string& name="(none)"); using ConnectorNode::ConnectorNode; // inherit constructors string type() const override { @@ -55,6 +57,8 @@ public: /*! * @param in Upstream reactor. * @param out Downstream reactor. + * @deprecated To be removed after Cantera 3.2. Reactors should be provided to + * constructor instead. */ bool install(ReactorBase& in, ReactorBase& out); diff --git a/include/cantera/zeroD/Wall.h b/include/cantera/zeroD/Wall.h index f5a941ef2..3e5269077 100644 --- a/include/cantera/zeroD/Wall.h +++ b/include/cantera/zeroD/Wall.h @@ -22,6 +22,8 @@ class Func1; class WallBase : public ConnectorNode { public: + WallBase(shared_ptr r0, shared_ptr r1, + const string& name="(none)"); using ConnectorNode::ConnectorNode; // inherit constructors string type() const override { @@ -58,6 +60,8 @@ public: virtual void setArea(double a); //! Install the wall between two reactors or reservoirs + //! @deprecated To be removed after Cantera 3.2. Reactors should be provided to + //! constructor instead. bool install(ReactorBase& leftReactor, ReactorBase& rightReactor); //! Called just before the start of integration diff --git a/src/zeroD/ConnectorFactory.cpp b/src/zeroD/ConnectorFactory.cpp index e48012810..b947fbf6a 100644 --- a/src/zeroD/ConnectorFactory.cpp +++ b/src/zeroD/ConnectorFactory.cpp @@ -48,10 +48,6 @@ shared_ptr newConnectorNode( const string& model, shared_ptr r0, shared_ptr r1, const string& name) { - if (!r0 || !r1) { - warn_deprecated("newConnectorNode", - "Instantiation of empty connector nodes to be removed after Cantera 3.2."); - } return shared_ptr( ConnectorFactory::factory()->create(model, r0, r1, name)); } diff --git a/src/zeroD/FlowDevice.cpp b/src/zeroD/FlowDevice.cpp index d298a933c..34903390e 100644 --- a/src/zeroD/FlowDevice.cpp +++ b/src/zeroD/FlowDevice.cpp @@ -11,8 +11,45 @@ namespace Cantera { +FlowDevice::FlowDevice(shared_ptr r0, shared_ptr r1, + const string& name) : ConnectorNode(r0, r1, name) +{ + if (!m_nodes.first || !m_nodes.second) { + warn_deprecated("FlowDevice::FlowDevice", + "After Cantera 3.1, Reactors must be provided to a FlowDevice " + "constructor."); + return; + } + m_in = r0.get(); + m_out = r1.get(); + m_in->addOutlet(*this); + m_out->addInlet(*this); + + // construct adapters between inlet and outlet species + const ThermoPhase& mixin = m_in->contents(); + const ThermoPhase& mixout = m_out->contents(); + + m_nspin = mixin.nSpecies(); + m_nspout = mixout.nSpecies(); + string nm; + size_t ki, ko; + for (ki = 0; ki < m_nspin; ki++) { + nm = mixin.speciesName(ki); + ko = mixout.speciesIndex(nm); + m_in2out.push_back(ko); + } + for (ko = 0; ko < m_nspout; ko++) { + nm = mixout.speciesName(ko); + ki = mixin.speciesIndex(nm); + m_out2in.push_back(ki); + } +} + bool FlowDevice::install(ReactorBase& in, ReactorBase& out) { + warn_deprecated("FlowDevice::install", + "To be removed after Cantera 3.1. Reactors should be provided to constructor " + "instead."); if (m_in || m_out) { throw CanteraError("FlowDevice::install", "Already installed"); } diff --git a/src/zeroD/Wall.cpp b/src/zeroD/Wall.cpp index 519e80f85..9d638c328 100644 --- a/src/zeroD/Wall.cpp +++ b/src/zeroD/Wall.cpp @@ -10,8 +10,26 @@ namespace Cantera { +WallBase::WallBase(shared_ptr r0, shared_ptr r1, + const string& name) : ConnectorNode(r0, r1, name) +{ + if (!m_nodes.first || !m_nodes.second) { + warn_deprecated("FlowDevice::FlowDevice", + "After Cantera 3.2, Reactors must be provided to a FlowDevice " + "constructor."); + return; + } + m_left = r0.get(); + m_right = r1.get(); + m_left->addWall(*this, 0); + m_right->addWall(*this, 1); +} + bool WallBase::install(ReactorBase& rleft, ReactorBase& rright) { + warn_deprecated("WallBase::install", + "To be removed after Cantera 3.2. Reactors should be provided to constructor " + "instead."); // check if wall is already installed if (m_left || m_right) { return false;