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
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
Header file defining class TransportFactory (see TransportFactory)
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
shared_ptr< ThermoPhase > thermo()
Accessor for the ThermoPhase pointer.
Definition: Solution.h:50
std::string name() const
Return the name of this Solution object.
Definition: Solution.cpp:22
shared_ptr< Kinetics > kinetics()
Accessor for the Kinetics pointer.
Definition: Solution.h:55
shared_ptr< Transport > transport()
Accessor for the Transport pointer.
Definition: Solution.h:60
shared_ptr< Kinetics > m_kinetics
Kinetics manager.
Definition: Solution.h:66
void setThermo(shared_ptr< ThermoPhase > thermo)
Set the ThermoPhase object.
Definition: Solution.cpp:40
shared_ptr< ThermoPhase > m_thermo
ThermoPhase manager.
Definition: Solution.h:65
void setName(const std::string &name)
Set the name of this Solution object.
Definition: Solution.cpp:31
void setTransport(shared_ptr< Transport > transport)
Set the Transport object.
Definition: Solution.cpp:54
static shared_ptr< Solution > create()
Create an empty Solution object.
Definition: Solution.h:30
shared_ptr< Transport > m_transport
Transport manager.
Definition: Solution.h:67
void setKinetics(shared_ptr< Kinetics > kinetics)
Set the Kinetics object.
Definition: Solution.cpp:47
ThermoPhase * newPhase(XML_Node &xmlphase)
Create a new ThermoPhase object and initializes it according to the XML tree.
Transport * newDefaultTransportMgr(thermo_t *thermo, int loglevel)
Create a new transport manager instance.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
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...
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
unique_ptr< Kinetics > newKinetics(vector< ThermoPhase * > &phases, const AnyMap &phaseNode, const AnyMap &rootNode)