From 7de930701a819a660535d2a23c84b41a4fc7be9d Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 4 May 2022 21:34:19 -0500 Subject: [PATCH] [Solution] Implement Solution::setTransport by model name --- include/cantera/base/Solution.h | 6 +++++- src/base/Solution.cpp | 24 ++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/cantera/base/Solution.h b/include/cantera/base/Solution.h index 3e39777de6..d392a0ea01 100644 --- a/include/cantera/base/Solution.h +++ b/include/cantera/base/Solution.h @@ -44,9 +44,13 @@ class Solution //! Set the Kinetics object virtual void setKinetics(shared_ptr kinetics); - //! Set the Transport object + //! Set the Transport object directly virtual void setTransport(shared_ptr transport); + //! Set the Transport object by name + //! @param model name of transport model + virtual void setTransport(const std::string& model); + //! Accessor for the ThermoPhase pointer shared_ptr thermo() { return m_thermo; diff --git a/src/base/Solution.cpp b/src/base/Solution.cpp index f5fef21ee9..6352ce257b 100644 --- a/src/base/Solution.cpp +++ b/src/base/Solution.cpp @@ -51,6 +51,18 @@ void Solution::setTransport(shared_ptr transport) { m_transport = transport; } +void Solution::setTransport(const std::string& model) { + if (model == "") { + setTransport(shared_ptr( + newDefaultTransportMgr(m_thermo.get()))); + } else if (model == "None") { + setTransport(shared_ptr(newTransportMgr("None"))); + } else { + setTransport(shared_ptr( + newTransportMgr(model, m_thermo.get()))); + } +} + void Solution::addAdjacent(shared_ptr adjacent) { if (m_adjacentByName.count(adjacent->name())) { throw CanteraError("Solution::addAdjacent", @@ -257,16 +269,8 @@ shared_ptr newSolution(const AnyMap& phaseNode, } sol->setKinetics(newKinetics(phases, phaseNode, rootNode)); - // transport - if (transport == "") { - sol->setTransport(shared_ptr( - newDefaultTransportMgr(sol->thermo().get()))); - } else if (transport == "None") { - sol->setTransport(shared_ptr(newTransportMgr("None"))); - } else { - sol->setTransport(shared_ptr( - newTransportMgr(transport, sol->thermo().get()))); - } + // set transport model by name + sol->setTransport(transport); // save root-level information (YAML header) AnyMap header;