Cantera 2.6.0
Solution.h
Go to the documentation of this file.
1//! @file Solution.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef CT_SOLUTION_H
7#define CT_SOLUTION_H
8
10#include "cantera/base/AnyMap.h"
11
12namespace Cantera
13{
14
15class ThermoPhase;
16class Kinetics;
17class Transport;
18
19//! A container class holding managers for all pieces defining a phase
21{
22protected:
23 Solution();
24
25public:
26 virtual ~Solution() {}
27 Solution(const Solution&) = delete;
28 Solution& operator=(const Solution&) = delete;
29
30 //! Create an empty Solution object
31 static shared_ptr<Solution> create() {
32 return shared_ptr<Solution>( new Solution );
33 }
34
35 //! Return the name of this Solution object
36 std::string name() const;
37
38 //! Set the name of this Solution object
39 void setName(const std::string& name);
40
41 //! Set the ThermoPhase object
42 virtual void setThermo(shared_ptr<ThermoPhase> thermo);
43
44 //! Set the Kinetics object
45 virtual void setKinetics(shared_ptr<Kinetics> kinetics);
46
47 //! Set the Transport object
48 virtual void setTransport(shared_ptr<Transport> transport);
49
50 //! Accessor for the ThermoPhase pointer
51 shared_ptr<ThermoPhase> thermo() {
52 return m_thermo;
53 }
54
55 //! Accessor for the Kinetics pointer
56 shared_ptr<Kinetics> kinetics() {
57 return m_kinetics;
58 }
59
60 //! Accessor for the Transport pointer
61 shared_ptr<Transport> transport() {
62 return m_transport;
63 }
64
65 //! Add a phase adjacent to this phase. Usually this means a higher-dimensional
66 //! phase that participates in reactions in this phase.
67 void addAdjacent(shared_ptr<Solution> adjacent);
68
69 //! Get the Solution object for an adjacent phase by index
70 shared_ptr<Solution> adjacent(size_t i) {
71 return m_adjacent.at(i);
72 }
73
74 //! Get the Solution object for an adjacent phase by name
75 shared_ptr<Solution> adjacent(const std::string& name) {
76 return m_adjacentByName.at(name);
77 }
78
79 //! Get the number of adjacent phases
80 size_t nAdjacent() const {
81 return m_adjacent.size();
82 }
83
84 AnyMap parameters(bool withInput=false) const;
85
86 //! Access input data associated with header definition
87 const AnyMap& header() const;
88 AnyMap& header();
89
90 //! Retrieve source used for object creation; usually an input file name
91 const std::string source() const;
92
93 //! Overwrite source (only required if object is not created using newSolution)
94 void setSource(const std::string& source);
95
96protected:
97 shared_ptr<ThermoPhase> m_thermo; //!< ThermoPhase manager
98 shared_ptr<Kinetics> m_kinetics; //!< Kinetics manager
99 shared_ptr<Transport> m_transport; //!< Transport manager
100
101 //! Adjacent phases, for access by index
102 std::vector<shared_ptr<Solution>> m_adjacent;
103
104 //! Adjacent phases, for access by name
105 std::map<std::string, shared_ptr<Solution>> m_adjacentByName;
106
107 AnyMap m_header; //!< Additional input fields; usually from a YAML input file
108};
109
110//! Create and initialize a new Solution from an input file
111/*!
112 * This constructor wraps newPhase(), newKinetics() and newTransportMgr() routines
113 * for initialization.
114 *
115 * @param infile name of the input file
116 * @param name name of the phase in the file. If this is blank, the first phase
117 * in the file is used.
118 * @param transport name of the transport model. If blank, the transport model specified
119 * in the phase definition is used.
120 * @param adjacent vector containing names of adjacent phases that participate in this
121 * phases kinetics. If empty, adjacent phases will be instantiated based
122 * on the phase definition.
123 * @returns an initialized Solution object.
124 */
125shared_ptr<Solution> newSolution(const std::string& infile, const std::string& name,
126 const std::string& transport, const std::vector<std::string>& adjacent);
127
128//! Create and initialize a new Solution manager from an input file
129/*!
130 * This constructor wraps newPhase(), newKinetics() and
131 * newTransportMgr() routines for initialization.
132 *
133 * @param infile name of the input file
134 * @param name name of the phase in the file.
135 * If this is blank, the first phase in the file is used.
136 * @param transport name of the transport model.
137 * @param adjacent vector containing adjacent Solution objects. If empty, adjacent
138 * phases will be instantiated based on the phase definition.
139 * @returns an initialized Solution object.
140 */
141shared_ptr<Solution> newSolution(const std::string& infile,
142 const std::string& name="",
143 const std::string& transport="",
144 const std::vector<shared_ptr<Solution>>& adjacent={});
145
146//! Create and initialize a new Solution manager from AnyMap objects
147/*!
148 * This constructor wraps newPhase(), newKinetics() and
149 * newTransportMgr() routines for initialization.
150 *
151 * @param phaseNode the node containing the phase definition (that is, thermo model,
152 * list of species, and initial state)
153 * @param rootNode the root node of the tree containing the phase definition, which
154 * will be used as the default location from which to read species definitions.
155 * @param transport name of the transport model.
156 * @param adjacent vector containing adjacent Solution objects. If empty, adjacent
157 * phases will be instantiated based on the phase definition.
158 * @param related vector of phases related to the same root Solution object. Used
159 * internally by newSolution() when creating complex interfaces where
160 * a phase may be adjacent to multiple other phases but should be
161 * instantiated only once.
162 * @returns an initialized Solution object.
163 */
164shared_ptr<Solution> newSolution(
165 const AnyMap& phaseNode, const AnyMap& rootNode=AnyMap(),
166 const std::string& transport="",
167 const std::vector<shared_ptr<Solution>>& adjacent={},
168 const std::map<std::string, shared_ptr<Solution>>& related={});
169
170}
171
172#endif
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
A container class holding managers for all pieces defining a phase.
Definition: Solution.h:21
static shared_ptr< Solution > create()
Create an empty Solution object.
Definition: Solution.h:31
std::string name() const
Return the name of this Solution object.
Definition: Solution.cpp:24
shared_ptr< Kinetics > kinetics()
Accessor for the Kinetics pointer.
Definition: Solution.h:56
void addAdjacent(shared_ptr< Solution > adjacent)
Add a phase adjacent to this phase.
Definition: Solution.cpp:54
void setSource(const std::string &source)
Overwrite source (only required if object is not created using newSolution)
Definition: Solution.cpp:117
shared_ptr< Kinetics > m_kinetics
Kinetics manager.
Definition: Solution.h:98
virtual void setThermo(shared_ptr< ThermoPhase > thermo)
Set the ThermoPhase object.
Definition: Solution.cpp:42
shared_ptr< ThermoPhase > m_thermo
ThermoPhase manager.
Definition: Solution.h:97
std::map< std::string, shared_ptr< Solution > > m_adjacentByName
Adjacent phases, for access by name.
Definition: Solution.h:105
void setName(const std::string &name)
Set the name of this Solution object.
Definition: Solution.cpp:33
AnyMap m_header
Additional input fields; usually from a YAML input file.
Definition: Solution.h:107
shared_ptr< Solution > adjacent(const std::string &name)
Get the Solution object for an adjacent phase by name.
Definition: Solution.h:75
size_t nAdjacent() const
Get the number of adjacent phases.
Definition: Solution.h:80
std::vector< shared_ptr< Solution > > m_adjacent
Adjacent phases, for access by index.
Definition: Solution.h:102
virtual void setTransport(shared_ptr< Transport > transport)
Set the Transport object.
Definition: Solution.cpp:50
const std::string source() const
Retrieve source used for object creation; usually an input file name.
Definition: Solution.cpp:112
shared_ptr< ThermoPhase > thermo()
Accessor for the ThermoPhase pointer.
Definition: Solution.h:51
shared_ptr< Transport > transport()
Accessor for the Transport pointer.
Definition: Solution.h:61
const AnyMap & header() const
Access input data associated with header definition.
Definition: Solution.cpp:102
shared_ptr< Solution > adjacent(size_t i)
Get the Solution object for an adjacent phase by index.
Definition: Solution.h:70
shared_ptr< Transport > m_transport
Transport manager.
Definition: Solution.h:99
virtual void setKinetics(shared_ptr< Kinetics > kinetics)
Set the Kinetics object.
Definition: Solution.cpp:46
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
shared_ptr< Solution > newSolution(const std::string &infile, const std::string &name, const std::string &transport, const std::vector< std::string > &adjacent)
Create and initialize a new Solution from an input file.
Definition: Solution.cpp:172