Cantera  2.3.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 http://www.cantera.org/license.txt for license and copyright information.
8 
10 
11 using namespace std;
12 
13 namespace Cantera
14 {
15 Transport::Transport(thermo_t* thermo, size_t ndim) :
16  m_thermo(thermo),
17  m_ready(false),
18  m_nsp(0),
19  m_nDim(ndim),
20  m_velocityBasis(VB_MASSAVG)
21 {
22 }
23 
25 {
26  warn_deprecated("Transport copy constructor", "To be removed after"
27  " Cantera 2.3 for all classes derived from Transport.");
28  m_thermo = right.m_thermo;
29  m_ready = right.m_ready;
30  m_nsp = right.m_nsp;
31  m_nDim = right.m_nDim;
33 }
34 
36 {
37  warn_deprecated("Transport assignment operator", "To be removed after"
38  " Cantera 2.3 for all classes derived from Transport.");
39  if (&right != this) {
40  return *this;
41  }
42  m_thermo = right.m_thermo;
43  m_ready = right.m_ready;
44  m_nsp = right.m_nsp;
45  m_nDim = right.m_nDim;
47  return *this;
48 }
49 
51 {
52  warn_deprecated("Transport::duplMyselfAsTransport",
53  "To be removed after Cantera 2.3.");
54  return new Transport(*this);
55 }
56 
58 {
59  return m_ready;
60 }
61 
62 void Transport::setNDim(const int ndim)
63 {
64  m_nDim = ndim;
65 }
66 
67 void Transport::checkSpeciesIndex(size_t k) const
68 {
69  if (k >= m_nsp) {
70  throw IndexError("checkSpeciesIndex", "species", k, m_nsp-1);
71  }
72 }
73 
74 void Transport::checkSpeciesArraySize(size_t kk) const
75 {
76  if (m_nsp > kk) {
77  throw ArraySizeError("checkSpeciesArraySize", kk, m_nsp);
78  }
79 }
80 
81 void Transport::setParameters(const int type, const int k,
82  const doublereal* const p)
83 {
84  throw NotImplementedError("Transport::setParameters");
85 }
86 
88 {
89  if (!ready()) {
90  m_thermo = &thermo;
91  m_nsp = m_thermo->nSpecies();
92  } else {
93  size_t newNum = thermo.nSpecies();
94  size_t oldNum = m_thermo->nSpecies();
95  if (newNum != oldNum) {
96  throw CanteraError("Transport::setThermo",
97  "base object cannot be changed after "
98  "the transport manager has been constructed because num species isn't the same.");
99  }
100  for (size_t i = 0; i < newNum; i++) {
101  std::string newS0 = thermo.speciesName(i);
102  std::string oldS0 = m_thermo->speciesName(i);
103  if (newNum != oldNum) {
104  throw CanteraError("Transport::setThermo",
105  "base object cannot be changed after "
106  "the transport manager has been constructed because species names are not the same");
107  }
108  }
109  m_thermo = &thermo;
110  }
111 }
112 
114 {
115  if (!ready()) {
116  m_ready = true;
117  } else {
118  throw CanteraError("Transport::finalize",
119  "finalize has already been called.");
120  }
121 }
122 
123 void Transport::getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
124  size_t ldx, const doublereal* const grad_X,
125  size_t ldf, doublereal* const fluxes)
126 {
127  throw NotImplementedError("Transport::getSpeciesFluxes");
128 }
129 }
Array size error.
Definition: ctexceptions.h:134
Transport(thermo_t *thermo=0, size_t ndim=1)
Constructor.
void checkSpeciesArraySize(size_t kk) const
Check that an array size is at least nSpecies().
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:193
size_t m_nDim
Number of dimensions used in flux expressions.
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
thermo_t * m_thermo
pointer to the object representing the phase
Base class for transport property managers.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:262
STL namespace.
void finalize()
Enable the transport object for use.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:267
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
virtual void setParameters(const int type, const int k, const doublereal *const p)
Set model parameters for derived classes.
void setNDim(const int ndim)
Set the number of dimensions to be expected in flux expressions.
thermo_t & thermo()
bool m_ready
true if finalize has been called
virtual Transport * duplMyselfAsTransport() const
Duplication routine for objects which inherit from Transport.
size_t m_nsp
Number of species.
const VelocityBasis VB_MASSAVG
Diffusion velocities are based on the mass averaged velocity.
Definition: TransportBase.h:83
virtual void setThermo(thermo_t &thermo)
Specifies the ThermoPhase object.
An array index is out of range.
Definition: ctexceptions.h:164
Namespace for the Cantera kernel.
Definition: application.cpp:29
virtual void getSpeciesFluxes(size_t ndim, const doublereal *const grad_T, size_t ldx, const doublereal *const grad_X, size_t ldf, doublereal *const fluxes)
Get the species diffusive mass fluxes wrt to the specified solution averaged velocity, given the gradients in mole fraction and temperature.
int m_velocityBasis
Velocity basis from which diffusion velocities are computed.
Transport & operator=(const Transport &right)