Cantera  2.4.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  return m_ready;
27 }
28 
29 void Transport::setNDim(const int ndim)
30 {
31  m_nDim = ndim;
32 }
33 
34 void Transport::checkSpeciesIndex(size_t k) const
35 {
36  if (k >= m_nsp) {
37  throw IndexError("checkSpeciesIndex", "species", k, m_nsp-1);
38  }
39 }
40 
41 void Transport::checkSpeciesArraySize(size_t kk) const
42 {
43  if (m_nsp > kk) {
44  throw ArraySizeError("checkSpeciesArraySize", kk, m_nsp);
45  }
46 }
47 
48 void Transport::setParameters(const int type, const int k,
49  const doublereal* const p)
50 {
51  throw NotImplementedError("Transport::setParameters");
52 }
53 
55 {
56  if (!ready()) {
57  m_thermo = &thermo;
58  m_nsp = m_thermo->nSpecies();
59  } else {
60  size_t newNum = thermo.nSpecies();
61  size_t oldNum = m_thermo->nSpecies();
62  if (newNum != oldNum) {
63  throw CanteraError("Transport::setThermo",
64  "base object cannot be changed after "
65  "the transport manager has been constructed because num species isn't the same.");
66  }
67  for (size_t i = 0; i < newNum; i++) {
68  std::string newS0 = thermo.speciesName(i);
69  std::string oldS0 = m_thermo->speciesName(i);
70  if (newNum != oldNum) {
71  throw CanteraError("Transport::setThermo",
72  "base object cannot be changed after "
73  "the transport manager has been constructed because species names are not the same");
74  }
75  }
76  m_thermo = &thermo;
77  }
78 }
79 
81 {
82  if (!ready()) {
83  m_ready = true;
84  } else {
85  throw CanteraError("Transport::finalize",
86  "finalize has already been called.");
87  }
88 }
89 
90 void Transport::getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
91  size_t ldx, const doublereal* const grad_X,
92  size_t ldf, doublereal* const fluxes)
93 {
94  throw NotImplementedError("Transport::getSpeciesFluxes");
95 }
96 }
Array size error.
Definition: ctexceptions.h:128
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:187
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
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:266
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:191
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
size_t m_nsp
Number of species.
const VelocityBasis VB_MASSAVG
Diffusion velocities are based on the mass averaged velocity.
Definition: TransportBase.h:67
virtual void setThermo(thermo_t &thermo)
Specifies the ThermoPhase object.
An array index is out of range.
Definition: ctexceptions.h:158
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
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.