Cantera 2.6.0
TransportBase.cpp
Go to the documentation of this file.
1/**
2 * @file TransportBase.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
13using namespace std;
14
15namespace Cantera
16{
17Transport::Transport(ThermoPhase* thermo, size_t ndim) :
18 m_thermo(thermo),
19 m_ready(false),
20 m_nsp(0),
21 m_nDim(ndim),
22 m_velocityBasis(VB_MASSAVG)
23{
24}
25
27{
28 return m_ready;
29}
30
31void Transport::setNDim(const int ndim)
32{
33 m_nDim = ndim;
34}
35
36void Transport::checkSpeciesIndex(size_t k) const
37{
38 if (k >= m_nsp) {
39 throw IndexError("Transport::checkSpeciesIndex", "species", k, m_nsp-1);
40 }
41}
42
44{
45 if (m_nsp > kk) {
46 throw ArraySizeError("Transport::checkSpeciesArraySize", kk, m_nsp);
47 }
48}
49
51{
52 AnyMap out;
54 if (name != "") {
55 out["transport"] = name;
56 }
57 return out;
58}
59
61{
62 if (!ready()) {
65 } else {
66 size_t newNum = thermo.nSpecies();
67 size_t oldNum = m_thermo->nSpecies();
68 if (newNum != oldNum) {
69 throw CanteraError("Transport::setThermo",
70 "base object cannot be changed after "
71 "the transport manager has been constructed because num species isn't the same.");
72 }
73 for (size_t i = 0; i < newNum; i++) {
74 std::string newS0 = thermo.speciesName(i);
75 std::string oldS0 = m_thermo->speciesName(i);
76 if (newNum != oldNum) {
77 throw CanteraError("Transport::setThermo",
78 "base object cannot be changed after "
79 "the transport manager has been constructed because species names are not the same");
80 }
81 }
83 }
84}
85
86void Transport::setRoot(std::shared_ptr<Solution> root)
87{
88 m_root = root;
89}
90
92{
93 if (!ready()) {
94 m_ready = true;
95 } else {
96 throw CanteraError("Transport::finalize",
97 "finalize has already been called.");
98 }
99}
100}
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)
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
Array size error.
Definition: ctexceptions.h:128
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
std::string canonicalize(const std::string &name)
Get the canonical name registered for a type.
Definition: FactoryBase.h:95
An array index is out of range.
Definition: ctexceptions.h:158
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:273
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:200
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
static TransportFactory * factory()
Return a pointer to a TransportFactory instance.
virtual void setThermo(ThermoPhase &thermo)
Specifies the ThermoPhase object.
ThermoPhase * m_thermo
pointer to the object representing the phase
void setNDim(const int ndim)
Set the number of dimensions to be expected in flux expressions.
size_t m_nDim
Number of dimensions used in flux expressions.
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
bool m_ready
true if finalize has been called
void finalize()
Enable the transport object for use.
virtual void setRoot(std::shared_ptr< Solution > root)
Set root Solution holding all phase information.
AnyMap parameters() const
Return the parameters for a phase definition which are needed to reconstruct an identical object usin...
virtual std::string transportType() const
Identifies the Transport object type.
std::weak_ptr< Solution > m_root
reference to Solution
Transport(ThermoPhase *thermo=0, size_t ndim=1)
Constructor.
size_t m_nsp
Number of species.
ThermoPhase & thermo()
void checkSpeciesArraySize(size_t kk) const
Check that an array size is at least nSpecies().
const VelocityBasis VB_MASSAVG
Definition: TransportBase.h:69
Namespace for the Cantera kernel.
Definition: AnyMap.h:29