Cantera  3.0.0
Loading...
Searching...
No Matches
Transport.cpp
Go to the documentation of this file.
1/**
2 * @file Transport.cpp
3 * Mixture-averaged transport properties for ideal gas mixtures.
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
12
13namespace Cantera
14{
15Transport::Transport(ThermoPhase* thermo, size_t ndim) :
16 m_thermo(thermo),
17 m_nDim(ndim)
18{
19 if (thermo != nullptr) {
20 warn_deprecated("Transport::Transport", "Specifying the ThermoPhase object "
21 "in the Transport constructor is deprecated and will be removed after "
22 "Cantera 3.0");
23 }
24 if (ndim != npos) {
25 warn_deprecated("Transport::Transport", "The 'ndim' argument to the Transport "
26 "constructor is deprecated and will be removed after Cantera 3.0");
27 } else {
28 m_nDim = 1;
29 }
30}
31
33{
34 warn_deprecated("Transport::ready", "To be removed after Cantera 3.0");
35 return m_ready;
36}
37
38void Transport::setNDim(const int ndim)
39{
40 warn_deprecated("Transport::setNDim", "To be removed after Cantera 3.0");
41 m_nDim = ndim;
42}
43
44void Transport::checkSpeciesIndex(size_t k) const
45{
46 if (k >= m_nsp) {
47 throw IndexError("Transport::checkSpeciesIndex", "species", k, m_nsp-1);
48 }
49}
50
52{
53 if (m_nsp > kk) {
54 throw ArraySizeError("Transport::checkSpeciesArraySize", kk, m_nsp);
55 }
56}
57
59{
60 AnyMap out;
62 if (name != "") {
63 out["transport"] = name;
64 }
65 return out;
66}
67
69{
70 warn_deprecated("Transport::setThermo", "To be removed after Cantera 3.0");
71 if (!ready()) {
74 } else {
75 size_t newNum = thermo.nSpecies();
76 size_t oldNum = m_thermo->nSpecies();
77 if (newNum != oldNum) {
78 throw CanteraError("Transport::setThermo",
79 "base object cannot be changed after "
80 "the transport manager has been constructed because num species isn't the same.");
81 }
82 for (size_t i = 0; i < newNum; i++) {
83 string newS0 = thermo.speciesName(i);
84 string oldS0 = m_thermo->speciesName(i);
85 if (newNum != oldNum) {
86 throw CanteraError("Transport::setThermo",
87 "base object cannot be changed after "
88 "the transport manager has been constructed because species names are not the same");
89 }
90 }
92 }
93}
94
95void Transport::setRoot(shared_ptr<Solution> root)
96{
97 warn_deprecated("Transport::setRoot", "To be removed after Cantera 3.0");
98 m_root = root;
99}
100
102{
103 warn_deprecated("Transport::finalize", "To be removed after Cantera 3.0");
104 if (!ready()) {
105 m_ready = true;
106 } else {
107 throw CanteraError("Transport::finalize",
108 "finalize has already been called.");
109 }
110}
111}
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Header file defining class TransportFactory (see TransportFactory)
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Array size error.
Base class for exceptions thrown by Cantera classes.
string canonicalize(const string &name)
Get the canonical name registered for a type.
Definition FactoryBase.h:94
An array index is out of range.
size_t nSpecies() const
Returns the number of species in the phase.
Definition Phase.h:245
string speciesName(size_t k) const
Name of the species with index k.
Definition Phase.cpp:151
Base class for a phase with thermodynamic properties.
static TransportFactory * factory()
Return a pointer to a TransportFactory instance.
virtual void setThermo(ThermoPhase &thermo)
Specifies the ThermoPhase object.
Definition Transport.cpp:68
ThermoPhase * m_thermo
pointer to the object representing the phase
Definition Transport.h:821
void setNDim(const int ndim)
Set the number of dimensions to be expected in flux expressions.
Definition Transport.cpp:38
size_t m_nDim
Number of dimensions used in flux expressions.
Definition Transport.h:832
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
Definition Transport.cpp:44
bool m_ready
true if finalize has been called
Definition Transport.h:825
void finalize()
Enable the transport object for use.
virtual string transportModel() const
Identifies the model represented by this Transport object.
Definition Transport.h:173
AnyMap parameters() const
Return the parameters for a phase definition which are needed to reconstruct an identical object usin...
Definition Transport.cpp:58
std::weak_ptr< Solution > m_root
reference to Solution
Definition Transport.h:841
virtual void setRoot(shared_ptr< Solution > root)
Set root Solution holding all phase information.
Definition Transport.cpp:95
size_t m_nsp
Number of species.
Definition Transport.h:828
ThermoPhase & thermo()
Phase object.
Definition Transport.h:192
void checkSpeciesArraySize(size_t kk) const
Check that an array size is at least nSpecies().
Definition Transport.cpp:51
bool ready()
Returns true if the transport manager is ready for use.
Definition Transport.cpp:32
Transport(ThermoPhase *thermo=0, size_t ndim=npos)
Constructor.
Definition Transport.cpp:15
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:195
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1926