Skip to content

Commit

Permalink
[Solution] Implement Solution::setTransport by model name
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and bryanwweber committed Jun 7, 2022
1 parent 1ab81ac commit 7de9307
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
6 changes: 5 additions & 1 deletion include/cantera/base/Solution.h
Expand Up @@ -44,9 +44,13 @@ class Solution
//! Set the Kinetics object
virtual void setKinetics(shared_ptr<Kinetics> kinetics);

//! Set the Transport object
//! Set the Transport object directly
virtual void setTransport(shared_ptr<Transport> 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<ThermoPhase> thermo() {
return m_thermo;
Expand Down
24 changes: 14 additions & 10 deletions src/base/Solution.cpp
Expand Up @@ -51,6 +51,18 @@ void Solution::setTransport(shared_ptr<Transport> transport) {
m_transport = transport;
}

void Solution::setTransport(const std::string& model) {
if (model == "") {
setTransport(shared_ptr<Transport>(
newDefaultTransportMgr(m_thermo.get())));
} else if (model == "None") {
setTransport(shared_ptr<Transport>(newTransportMgr("None")));
} else {
setTransport(shared_ptr<Transport>(
newTransportMgr(model, m_thermo.get())));
}
}

void Solution::addAdjacent(shared_ptr<Solution> adjacent) {
if (m_adjacentByName.count(adjacent->name())) {
throw CanteraError("Solution::addAdjacent",
Expand Down Expand Up @@ -257,16 +269,8 @@ shared_ptr<Solution> newSolution(const AnyMap& phaseNode,
}
sol->setKinetics(newKinetics(phases, phaseNode, rootNode));

// transport
if (transport == "") {
sol->setTransport(shared_ptr<Transport>(
newDefaultTransportMgr(sol->thermo().get())));
} else if (transport == "None") {
sol->setTransport(shared_ptr<Transport>(newTransportMgr("None")));
} else {
sol->setTransport(shared_ptr<Transport>(
newTransportMgr(transport, sol->thermo().get())));
}
// set transport model by name
sol->setTransport(transport);

// save root-level information (YAML header)
AnyMap header;
Expand Down

0 comments on commit 7de9307

Please sign in to comment.