Cantera  2.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  */
8 
13 
15 
16 #include <iostream>
17 using namespace std;
18 
19 /**
20  * Mole fractions below MIN_X will be set to MIN_X when computing
21  * transport properties.
22  */
23 #define MIN_X 1.e-20
24 
25 
26 namespace Cantera
27 {
28 
29 //////////////////// class LiquidTransport methods //////////////
30 
31 
32 Transport::Transport(thermo_t* thermo, size_t ndim) :
33  m_thermo(thermo),
34  m_ready(false),
35  m_nsp(0),
36  m_nDim(ndim),
37  m_velocityBasis(VB_MASSAVG)
38 {
39 }
40 
42 {
43  m_thermo = right.m_thermo;
44  m_ready = right.m_ready;
45  m_nsp = right.m_nsp;
46  m_nDim = right.m_nDim;
48 }
49 
50 
52 {
53  if (&right != this) {
54  return *this;
55  }
56  m_thermo = right.m_thermo;
57  m_ready = right.m_ready;
58  m_nsp = right.m_nsp;
59  m_nDim = right.m_nDim;
61  return *this;
62 }
63 
65 {
66  Transport* tr = new Transport(*this);
67  return tr;
68 }
69 
70 
72 {
73 }
74 
76 {
77  return m_ready;
78 }
79 
80 // Set the number of dimensions to be expected in flux expressions
81 /* Internal memory will be set with this value
82  */
83 void Transport::setNDim(const int ndim)
84 {
85  m_nDim = ndim;
86 }
87 
88 void Transport::checkSpeciesIndex(size_t k) const
89 {
90  if (k >= m_nsp) {
91  throw IndexError("checkSpeciesIndex", "species", k, m_nsp-1);
92  }
93 }
94 
95 void Transport::checkSpeciesArraySize(size_t kk) const
96 {
97  if (m_nsp > kk) {
98  throw ArraySizeError("checkSpeciesArraySize", kk, m_nsp);
99  }
100 }
101 
102 /* Set transport model parameters. This method may be
103  * overloaded in subclasses to set model-specific parameters.
104  */
105 void Transport::setParameters(const int type, const int k,
106  const doublereal* const p)
107 {
108  err("setParameters");
109 }
110 
111 
113 {
114  if (!ready()) {
115  m_thermo = &thermo;
116  m_nsp = m_thermo->nSpecies();
117  } else
118  throw CanteraError("Transport::setThermo",
119  "the phase object cannot be changed after "
120  "the transport manager has been constructed.");
121 }
122 
123 
124 doublereal Transport::err(std::string msg) const
125 {
126 
127  throw CanteraError("Transport Base Class",
128  "\n\n\n**** Method "+ msg +" not implemented in model "
129  + int2str(model()) + " ****\n"
130  "(Did you forget to specify a transport model?)\n\n\n");
131 
132  return 0.0;
133 }
134 
135 
137 {
138  if (!ready()) {
139  m_ready = true;
140  } else
141  throw CanteraError("Transport::finalize",
142  "finalize has already been called.");
143 }
144 
145 //====================================================================================================================
146 void Transport::getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
147  size_t ldx, const doublereal* const grad_X,
148  size_t ldf, doublereal* const fluxes)
149 {
150  err("getSpeciesFluxes");
151 }
152 //====================================================================================================================
153 }