Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransportBase.cpp
Go to the documentation of this file.
1 /**
2  * @file TransportBase.cpp
3  * Mixture-averaged transport properties for ideal gas mixtures.
4  */
6 
7 using namespace std;
8 
9 namespace Cantera
10 {
11 Transport::Transport(thermo_t* thermo, size_t ndim) :
12  m_thermo(thermo),
13  m_ready(false),
14  m_nsp(0),
15  m_nDim(ndim),
16  m_velocityBasis(VB_MASSAVG)
17 {
18 }
19 
20 Transport::Transport(const Transport& right)
21 {
22  m_thermo = right.m_thermo;
23  m_ready = right.m_ready;
24  m_nsp = right.m_nsp;
25  m_nDim = right.m_nDim;
27 }
28 
29 
30 Transport& Transport::operator=(const Transport& right)
31 {
32  if (&right != this) {
33  return *this;
34  }
35  m_thermo = right.m_thermo;
36  m_ready = right.m_ready;
37  m_nsp = right.m_nsp;
38  m_nDim = right.m_nDim;
39  m_velocityBasis = right.m_velocityBasis;
40  return *this;
41 }
42 
44 {
45  return new Transport(*this);
46 }
47 
49 {
50  return m_ready;
51 }
52 
53 void Transport::setNDim(const int ndim)
54 {
55  m_nDim = ndim;
56 }
57 
58 void Transport::checkSpeciesIndex(size_t k) const
59 {
60  if (k >= m_nsp) {
61  throw IndexError("checkSpeciesIndex", "species", k, m_nsp-1);
62  }
63 }
64 
65 void Transport::checkSpeciesArraySize(size_t kk) const
66 {
67  if (m_nsp > kk) {
68  throw ArraySizeError("checkSpeciesArraySize", kk, m_nsp);
69  }
70 }
71 
72 void Transport::setParameters(const int type, const int k,
73  const doublereal* const p)
74 {
75  throw NotImplementedError("Transport::setParameters");
76 }
77 
79 {
80  if (!ready()) {
81  m_thermo = &thermo;
82  m_nsp = m_thermo->nSpecies();
83  } else {
84  size_t newNum = thermo.nSpecies();
85  size_t oldNum = m_thermo->nSpecies();
86  if (newNum != oldNum) {
87  throw CanteraError("Transport::setThermo",
88  "base object cannot be changed after "
89  "the transport manager has been constructed because num species isn't the same.");
90  }
91  for (size_t i = 0; i < newNum; i++) {
92  std::string newS0 = thermo.speciesName(i);
93  std::string oldS0 = m_thermo->speciesName(i);
94  if (newNum != oldNum) {
95  throw CanteraError("Transport::setThermo",
96  "base object cannot be changed after "
97  "the transport manager has been constructed because species names are not the same");
98  }
99  }
100  m_thermo = &thermo;
101  }
102 }
103 
105 {
106  if (!ready()) {
107  m_ready = true;
108  } else
109  throw CanteraError("Transport::finalize",
110  "finalize has already been called.");
111 }
112 
113 void Transport::getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
114  size_t ldx, const doublereal* const grad_X,
115  size_t ldf, doublereal* const fluxes)
116 {
117  throw NotImplementedError("Transport::getSpeciesFluxes");
118 }
119 }
Array size error.
Definition: ctexceptions.h:154
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range Throws an exception if k is greater than nSpecies(...
Transport(thermo_t *thermo=0, size_t ndim=1)
Constructor.
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:213
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 finalize()
Enable the transport object for use.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
void checkSpeciesArraySize(size_t kk) const
Check that an array size is at least nSpecies() Throws an exception if kk is less than nSpecies()...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
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()
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:265
bool m_ready
true if finalize has been called
size_t m_nsp
Number of species.
const VelocityBasis VB_MASSAVG
Diffusion velocities are based on the mass averaged velocity.
Definition: TransportBase.h:86
virtual void setThermo(thermo_t &thermo)
Specifies the ThermoPhase object.
An array index is out of range.
Definition: ctexceptions.h:184
virtual Transport * duplMyselfAsTransport() const
Duplication routine for objects which inherit from Transport.
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.
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:272