| 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
9#include "cantera/transport/Transport.h"
10#include "cantera/thermo/ThermoPhase.h"
11#include "cantera/transport/TransportFactory.h"
12
13 namespace Cantera
14{
15 Transport::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
32 bool Transport::ready()
33{
34 warn_deprecated("Transport::ready", "To be removed after Cantera 3.0");
35 return m_ready;
36}
37
38 void Transport::setNDim(const int ndim)
39{
40 warn_deprecated("Transport::setNDim", "To be removed after Cantera 3.0");
41 m_nDim = ndim;
42}
43
44 void 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
51 void Transport::checkSpeciesArraySize(size_t kk) const
52{
53 if (m_nsp > kk) {
54 throw ArraySizeError("Transport::checkSpeciesArraySize", kk, m_nsp);
55 }
56}
57
58 AnyMap Transport::parameters() const
59{
60 AnyMap out;
61 string name = TransportFactory::factory()->canonicalize(transportModel());
62 if (name != "") {
63 out["transport"] = name;
64 }
65 return out;
66}
67
68 void Transport::setThermo(ThermoPhase& thermo)
69{
70 warn_deprecated("Transport::setThermo", "To be removed after Cantera 3.0");
71 if (!ready()) {
72 m_thermo = &thermo;
73 m_nsp = m_thermo->nSpecies();
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 }
91 m_thermo = &thermo;
92 }
93}
94
95 void 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
101 void Transport::finalize()
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}
ThermoPhase.h
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
TransportFactory.h
Header file defining class TransportFactory (see TransportFactory)
Transport.h
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::ArraySizeError
Array size error.
Definition ctexceptions.h:135
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition ctexceptions.h:66
Cantera::Factory::canonicalize
string canonicalize(const string &name)
Get the canonical name registered for a type.
Definition FactoryBase.h:94
Cantera::IndexError
An array index is out of range.
Definition ctexceptions.h:165
Cantera::Phase::nSpecies
size_t nSpecies() const
Returns the number of species in the phase.
Definition Phase.h:245
Cantera::Phase::speciesName
string speciesName(size_t k) const
Name of the species with index k.
Definition Phase.cpp:151
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition ThermoPhase.h:390
Cantera::TransportFactory::factory
static TransportFactory * factory()
Return a pointer to a TransportFactory instance.
Definition TransportFactory.cpp:53
Cantera::Transport::setThermo
virtual void setThermo(ThermoPhase &thermo)
Specifies the ThermoPhase object.
Definition Transport.cpp:68
Cantera::Transport::m_thermo
ThermoPhase * m_thermo
pointer to the object representing the phase
Definition Transport.h:821
Cantera::Transport::setNDim
void setNDim(const int ndim)
Set the number of dimensions to be expected in flux expressions.
Definition Transport.cpp:38
Cantera::Transport::m_nDim
size_t m_nDim
Number of dimensions used in flux expressions.
Definition Transport.h:832
Cantera::Transport::checkSpeciesIndex
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
Definition Transport.cpp:44
Cantera::Transport::m_ready
bool m_ready
true if finalize has been called
Definition Transport.h:825
Cantera::Transport::finalize
void finalize()
Enable the transport object for use.
Definition Transport.cpp:101
Cantera::Transport::transportModel
virtual string transportModel() const
Identifies the model represented by this Transport object.
Definition Transport.h:173
Cantera::Transport::parameters
AnyMap parameters() const
Return the parameters for a phase definition which are needed to reconstruct an identical object usin...
Definition Transport.cpp:58
Cantera::Transport::m_root
std::weak_ptr< Solution > m_root
reference to Solution
Definition Transport.h:841
Cantera::Transport::setRoot
virtual void setRoot(shared_ptr< Solution > root)
Set root Solution holding all phase information.
Definition Transport.cpp:95
Cantera::Transport::m_nsp
size_t m_nsp
Number of species.
Definition Transport.h:828
Cantera::Transport::thermo
ThermoPhase & thermo()
Phase object.
Definition Transport.h:192
Cantera::Transport::checkSpeciesArraySize
void checkSpeciesArraySize(size_t kk) const
Check that an array size is at least nSpecies().
Definition Transport.cpp:51
Cantera::Transport::ready
bool ready()
Returns true if the transport manager is ready for use.
Definition Transport.cpp:32
Cantera::Transport::Transport
Transport(ThermoPhase *thermo=0, size_t ndim=npos)
Constructor.
Definition Transport.cpp:15
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:195
Cantera::warn_deprecated
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