mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[zeroD] Install Reactors when instantiating connectors
This commit is contained in:
parent
ad81e209e7
commit
7a6cc9a28f
@ -24,6 +24,8 @@ class ReactorBase;
|
|||||||
class FlowDevice : public ConnectorNode
|
class FlowDevice : public ConnectorNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
FlowDevice(shared_ptr<ReactorBase> r0, shared_ptr<ReactorBase> r1,
|
||||||
|
const string& name="(none)");
|
||||||
using ConnectorNode::ConnectorNode; // inherit constructors
|
using ConnectorNode::ConnectorNode; // inherit constructors
|
||||||
|
|
||||||
string type() const override {
|
string type() const override {
|
||||||
@ -55,6 +57,8 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* @param in Upstream reactor.
|
* @param in Upstream reactor.
|
||||||
* @param out Downstream 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);
|
bool install(ReactorBase& in, ReactorBase& out);
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ class Func1;
|
|||||||
class WallBase : public ConnectorNode
|
class WallBase : public ConnectorNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
WallBase(shared_ptr<ReactorBase> r0, shared_ptr<ReactorBase> r1,
|
||||||
|
const string& name="(none)");
|
||||||
using ConnectorNode::ConnectorNode; // inherit constructors
|
using ConnectorNode::ConnectorNode; // inherit constructors
|
||||||
|
|
||||||
string type() const override {
|
string type() const override {
|
||||||
@ -58,6 +60,8 @@ public:
|
|||||||
virtual void setArea(double a);
|
virtual void setArea(double a);
|
||||||
|
|
||||||
//! Install the wall between two reactors or reservoirs
|
//! 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);
|
bool install(ReactorBase& leftReactor, ReactorBase& rightReactor);
|
||||||
|
|
||||||
//! Called just before the start of integration
|
//! Called just before the start of integration
|
||||||
|
@ -48,10 +48,6 @@ shared_ptr<ConnectorNode> newConnectorNode(
|
|||||||
const string& model,
|
const string& model,
|
||||||
shared_ptr<ReactorBase> r0, shared_ptr<ReactorBase> r1, const string& name)
|
shared_ptr<ReactorBase> r0, shared_ptr<ReactorBase> 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<ConnectorNode>(
|
return shared_ptr<ConnectorNode>(
|
||||||
ConnectorFactory::factory()->create(model, r0, r1, name));
|
ConnectorFactory::factory()->create(model, r0, r1, name));
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,45 @@
|
|||||||
namespace Cantera
|
namespace Cantera
|
||||||
{
|
{
|
||||||
|
|
||||||
|
FlowDevice::FlowDevice(shared_ptr<ReactorBase> r0, shared_ptr<ReactorBase> 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)
|
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) {
|
if (m_in || m_out) {
|
||||||
throw CanteraError("FlowDevice::install", "Already installed");
|
throw CanteraError("FlowDevice::install", "Already installed");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,26 @@
|
|||||||
namespace Cantera
|
namespace Cantera
|
||||||
{
|
{
|
||||||
|
|
||||||
|
WallBase::WallBase(shared_ptr<ReactorBase> r0, shared_ptr<ReactorBase> 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)
|
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
|
// check if wall is already installed
|
||||||
if (m_left || m_right) {
|
if (m_left || m_right) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user