Cantera  2.5.1
Solution.cpp
Go to the documentation of this file.
1 /**
2  * @file Solution.cpp
3  * Definition file for class Solution.
4  */
5 
6 // This file is part of Cantera. See License.txt in the top-level directory or
7 // at https://cantera.org/license.txt for license and copyright information.
8 
16 
17 namespace Cantera
18 {
19 
20 Solution::Solution() {}
21 
22 std::string Solution::name() const {
23  if (m_thermo) {
24  return m_thermo->name();
25  } else {
26  throw CanteraError("Solution::name",
27  "Requires associated 'ThermoPhase'");
28  }
29 }
30 
31 void Solution::setName(const std::string& name) {
32  if (m_thermo) {
33  m_thermo->setName(name);
34  } else {
35  throw CanteraError("Solution::setName",
36  "Requires associated 'ThermoPhase'");
37  }
38 }
39 
40 void Solution::setThermo(shared_ptr<ThermoPhase> thermo) {
41  m_thermo = thermo;
42  if (m_thermo) {
43  m_thermo->setRoot(shared_from_this());
44  }
45 }
46 
47 void Solution::setKinetics(shared_ptr<Kinetics> kinetics) {
49  if (m_kinetics) {
50  m_kinetics->setRoot(shared_from_this());
51  }
52 }
53 
54 void Solution::setTransport(shared_ptr<Transport> transport) {
56  if (m_transport) {
57  m_transport->setRoot(shared_from_this());
58  }
59 }
60 
61 shared_ptr<Solution> newSolution(const std::string& infile,
62  const std::string& name,
63  const std::string& transport,
64  const std::vector<shared_ptr<Solution>>& adjacent) {
65 
66  // instantiate Solution object
67  auto sol = Solution::create();
68 
69  // thermo phase
70  sol->setThermo(shared_ptr<ThermoPhase>(newPhase(infile, name)));
71 
72  // kinetics
73  std::vector<ThermoPhase*> phases;
74  phases.push_back(sol->thermo().get());
75  for (auto& adj : adjacent) {
76  phases.push_back(adj->thermo().get());
77  }
78  sol->setKinetics(newKinetics(phases, infile, name));
79 
80  // transport
81  if (transport == "") {
82  sol->setTransport(shared_ptr<Transport>(newDefaultTransportMgr(sol->thermo().get())));
83  } else if (transport != "None") {
84  sol->setTransport(shared_ptr<Transport>(newTransportMgr(transport, sol->thermo().get())));
85  }
86 
87  return sol;
88 }
89 
90 } // namespace Cantera
KineticsFactory.h
Cantera::Solution::setName
void setName(const std::string &name)
Set the name of this Solution object.
Definition: Solution.cpp:31
TransportFactory.h
Cantera::Solution::setTransport
void setTransport(shared_ptr< Transport > transport)
Set the Transport object.
Definition: Solution.cpp:54
Cantera::newKinetics
unique_ptr< Kinetics > newKinetics(vector< ThermoPhase * > &phases, const AnyMap &phaseNode, const AnyMap &rootNode)
Definition: KineticsFactory.cpp:55
Kinetics.h
Cantera::Solution::name
std::string name() const
Return the name of this Solution object.
Definition: Solution.cpp:22
Cantera::Solution::m_transport
shared_ptr< Transport > m_transport
Transport manager.
Definition: Solution.h:67
Cantera::newSolution
shared_ptr< Solution > newSolution(const std::string &infile, const std::string &name, const std::string &transport, const std::vector< shared_ptr< Solution >> &adjacent)
Create and initialize a new Solution manager from an input file.
Definition: Solution.cpp:61
ThermoFactory.h
Cantera::Solution::create
static shared_ptr< Solution > create()
Create an empty Solution object.
Definition: Solution.h:30
Cantera::newTransportMgr
Transport * newTransportMgr(const std::string &transportModel, thermo_t *thermo, int loglevel, int ndim)
Build a new transport manager using a transport manager that may not be the same as in the phase desc...
Definition: TransportFactory.cpp:117
Cantera::Solution::kinetics
shared_ptr< Kinetics > kinetics()
Accessor for the Kinetics pointer.
Definition: Solution.h:55
Cantera::Solution::thermo
shared_ptr< ThermoPhase > thermo()
Accessor for the ThermoPhase pointer.
Definition: Solution.h:50
Cantera::Solution::setThermo
void setThermo(shared_ptr< ThermoPhase > thermo)
Set the ThermoPhase object.
Definition: Solution.cpp:40
Cantera::newPhase
ThermoPhase * newPhase(XML_Node &xmlphase)
Create a new ThermoPhase object and initializes it according to the XML tree.
Definition: ThermoFactory.cpp:104
Cantera::Solution::m_thermo
shared_ptr< ThermoPhase > m_thermo
ThermoPhase manager.
Definition: Solution.h:65
Cantera::Solution::setKinetics
void setKinetics(shared_ptr< Kinetics > kinetics)
Set the Kinetics object.
Definition: Solution.cpp:47
Cantera::Solution::m_kinetics
shared_ptr< Kinetics > m_kinetics
Kinetics manager.
Definition: Solution.h:66
Cantera::Solution::transport
shared_ptr< Transport > transport()
Accessor for the Transport pointer.
Definition: Solution.h:60
Solution.h
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:60
Cantera::newDefaultTransportMgr
Transport * newDefaultTransportMgr(thermo_t *thermo, int loglevel)
Create a new transport manager instance.
Definition: TransportFactory.cpp:123
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:263
TransportBase.h
ThermoPhase.h