From 449e133e0252a863a84654047b91e5069a13d083 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Thu, 26 Jul 2007 21:55:32 +0000 Subject: [PATCH] Took out using namespace std from a couple of .h files. --- Cantera/src/base/XML_Writer.h | 36 +-- Cantera/src/transport/L_matrix.h | 3 +- Cantera/src/transport/MMCollisionInt.h | 110 +++++----- Cantera/src/transport/SolidTransport.h | 1 - Cantera/src/transport/TransportFactory.h | 266 +++++++++++------------ Cantera/src/transport/TransportParams.h | 20 +- 6 files changed, 212 insertions(+), 224 deletions(-) diff --git a/Cantera/src/base/XML_Writer.h b/Cantera/src/base/XML_Writer.h index e4dc9404d..26e1bf7d5 100644 --- a/Cantera/src/base/XML_Writer.h +++ b/Cantera/src/base/XML_Writer.h @@ -10,19 +10,19 @@ namespace Cantera { class XML_Writer { public: - XML_Writer(ostream& output) : + XML_Writer(std::ostream& output) : m_s(output), _indent(" "), _level(0) {} virtual ~XML_Writer() {} - ostream& m_s; + std::ostream& m_s; - string _indent; + std::string _indent; int _level; - ostream& output() { return m_s; } + std::ostream& output() { return m_s; } - inline string XML_filter(string name) { + inline std::string XML_filter(std::string name) { int ns = static_cast(name.size()); - string nm(name); + std::string nm(name); for (int m = 0; m < ns; m++) if (name[m] == ' ' || name[m] == '(' @@ -44,33 +44,33 @@ namespace Cantera { * s : Output stream containing the XML file * comment : Reference to a string containing the comment */ - inline void XML_comment(ostream& s, const string& comment) { + inline void XML_comment(std::ostream& s, const std::string& comment) { for (int n = 0; n < _level; n++) s << _indent; - s << "" << endl; + s << "" << std::endl; } - inline void XML_open(ostream& s, const string& tag, const string p = "") { + inline void XML_open(std::ostream& s, const std::string& tag, const std::string p = "") { for (int n = 0; n < _level; n++) s << _indent; _level++; - s << "<" << XML_filter(tag) << p << ">" << endl; + s << "<" << XML_filter(tag) << p << ">" << std::endl; } - inline void XML_close(ostream& s, const string& tag) { + inline void XML_close(std::ostream& s, const std::string& tag) { _level--; for (int n = 0; n < _level; n++) s << _indent; - s << "" << endl; + s << "" << std::endl; } template - void XML_item(ostream& s, const string& tag, T value) { + void XML_item(std::ostream& s, const std::string& tag, T value) { for (int n = 0; n < _level; n++) s << _indent; s << "<" << XML_filter(tag) << ">" - << value << "" << endl; + << value << "" << std::endl; } template - void XML_writeVector(ostream& s, const string& indent, - const string& name, int vsize, iter v) { + void XML_writeVector(std::ostream& s, const std::string& indent, + const std::string& name, int vsize, iter v) { int ni; for (ni = 0; ni < _level; ni++) s << _indent; s << "<" << XML_filter(name) << "> "; @@ -84,7 +84,7 @@ namespace Cantera { k++; } if (j < n5-1) { - s << endl; + s << std::endl; for (ni = 0; ni < _level; ni++) s << _indent; } } @@ -93,7 +93,7 @@ namespace Cantera { k++; } - s << "" << endl; + s << "" << std::endl; } }; diff --git a/Cantera/src/transport/L_matrix.h b/Cantera/src/transport/L_matrix.h index 9f2fec8b2..238d68370 100755 --- a/Cantera/src/transport/L_matrix.h +++ b/Cantera/src/transport/L_matrix.h @@ -18,8 +18,7 @@ #include "ct_defs.h" #include -using namespace std; -using namespace Cantera; + ///////////////////////////////////////////////////////////////////// diff --git a/Cantera/src/transport/MMCollisionInt.h b/Cantera/src/transport/MMCollisionInt.h index 530074c8a..797a30ea5 100755 --- a/Cantera/src/transport/MMCollisionInt.h +++ b/Cantera/src/transport/MMCollisionInt.h @@ -1,9 +1,7 @@ /** * @file MMCollisionInt.h - * * Monk and Monchick collision integrals */ - /* * $Author$ * $Revision$ @@ -17,7 +15,7 @@ #define CT_MMCOLLISIONINT_H #include -using namespace std; + #include "ct_defs.h" @@ -29,72 +27,72 @@ using namespace std; namespace Cantera { - class XML_Writer; + class XML_Writer; - class MMCollisionIntError { - public: - MMCollisionIntError(ostream& logfile, string msg) { - logfile << "#### ERROR ####" << endl; - logfile << "MMCollisionInt: " << msg << endl; - cerr << "Error in fitting collision integrals. " - << "Execution terminated." << endl - << "See transport log file for more information." << endl; - } - }; + class MMCollisionIntError { + public: + MMCollisionIntError(std::ostream& logfile, std::string msg) { + logfile << "#### ERROR ####" << std::endl; + logfile << "MMCollisionInt: " << msg << std::endl; + std::cerr << "Error in fitting collision integrals. " + << "Execution terminated." << std::endl + << "See transport log file for more information." << std::endl; + } + }; - /** - * Collision integrals. This class provides functions that - * interpolate the tabulated collision integrals in Monchick and - * Mason, "Transport Properties of Polar Gases," J. Chem. Phys. (1961) - * - * @ingroup transportgroup - */ - class MMCollisionInt { + /** + * Collision integrals. This class provides functions that + * interpolate the tabulated collision integrals in Monchick and + * Mason, "Transport Properties of Polar Gases," J. Chem. Phys. (1961) + * + * @ingroup transportgroup + */ + class MMCollisionInt { - public: + public: - MMCollisionInt(){} - virtual ~MMCollisionInt(); - void init(XML_Writer* xml, doublereal tsmin, - doublereal tsmax, int loglevel = 0); + MMCollisionInt(){} + virtual ~MMCollisionInt(); + void init(XML_Writer* xml, doublereal tsmin, + doublereal tsmax, int loglevel = 0); - doublereal omega22(double ts, double deltastar); - doublereal astar(double ts, double deltastar); - doublereal bstar(double ts, double deltastar); - doublereal cstar(double ts, double deltastar); + doublereal omega22(double ts, double deltastar); + doublereal astar(double ts, double deltastar); + doublereal bstar(double ts, double deltastar); + doublereal cstar(double ts, double deltastar); - void fit(ostream& logfile, int degree, doublereal deltastar, - doublereal* astar, doublereal* bstar, doublereal* cstar); + void fit(std::ostream& logfile, int degree, doublereal deltastar, + doublereal* astar, doublereal* bstar, doublereal* cstar); - void fit_omega22(ostream& logfile, int degree, doublereal deltastar, doublereal* om22); - doublereal omega11(double ts, double deltastar) { - return omega22(ts, deltastar)/astar(ts, deltastar); - } + void fit_omega22(std::ostream& logfile, int degree, doublereal deltastar, doublereal* om22); + doublereal omega11(double ts, double deltastar) { + return omega22(ts, deltastar)/astar(ts, deltastar); + } - private: + private: - doublereal fitDelta(int table, int ntstar, - int degree, doublereal* c); + doublereal fitDelta(int table, int ntstar, + int degree, doublereal* c); - vector m_o22poly; - vector m_apoly; - vector m_bpoly; - vector m_cpoly; + std::vector m_o22poly; + std::vector m_apoly; + std::vector m_bpoly; + std::vector m_cpoly; - static doublereal delta[8]; - static doublereal tstar22[37]; - static doublereal omega22_table[37*8]; - static doublereal tstar[39]; - static doublereal astar_table[39*8]; - static doublereal bstar_table[39*8]; - static doublereal cstar_table[39*8]; + static doublereal delta[8]; + static doublereal tstar22[37]; + static doublereal omega22_table[37*8]; + static doublereal tstar[39]; + static doublereal astar_table[39*8]; + static doublereal bstar_table[39*8]; + static doublereal cstar_table[39*8]; - vector_fp m_logTemp; - int m_nmin, m_nmax; - XML_Writer* m_xml; - int m_loglevel; - }; + vector_fp m_logTemp; + int m_nmin, m_nmax; + XML_Writer* m_xml; + int m_loglevel; + }; } #endif diff --git a/Cantera/src/transport/SolidTransport.h b/Cantera/src/transport/SolidTransport.h index 39f71a18c..c793c4e70 100644 --- a/Cantera/src/transport/SolidTransport.h +++ b/Cantera/src/transport/SolidTransport.h @@ -29,7 +29,6 @@ #include #include -using namespace std; // Cantera includes #include "TransportBase.h" diff --git a/Cantera/src/transport/TransportFactory.h b/Cantera/src/transport/TransportFactory.h index 74277e813..50abaddf9 100755 --- a/Cantera/src/transport/TransportFactory.h +++ b/Cantera/src/transport/TransportFactory.h @@ -1,8 +1,8 @@ /** * * @file TransportFactory.h - * * Header file defining class TransportFactory + * (see \link Cantera::TransportFactory TransportFactory\endlink) */ /* @@ -30,7 +30,6 @@ #include #include -using namespace std; // Cantera includes #include "ct_defs.h" @@ -43,181 +42,174 @@ using namespace std; namespace Cantera { - /** - * Struct to hold data read from a transport property database file. - */ - struct GasTransportData { - GasTransportData() : speciesName("-"), - geometry(-1), wellDepth(-1.0), - diameter(-1.0), - dipoleMoment(-1.0), - polarizability(-1.0), - rotRelaxNumber(-1.0) {} + /** + * Struct to hold data read from a transport property database file. + */ + struct GasTransportData { + GasTransportData() : speciesName("-"), + geometry(-1), wellDepth(-1.0), + diameter(-1.0), + dipoleMoment(-1.0), + polarizability(-1.0), + rotRelaxNumber(-1.0) {} - string speciesName; - int geometry; - doublereal wellDepth; - doublereal diameter; - doublereal dipoleMoment; - doublereal polarizability; - doublereal rotRelaxNumber; - }; + std::string speciesName; + int geometry; + doublereal wellDepth; + doublereal diameter; + doublereal dipoleMoment; + doublereal polarizability; + doublereal rotRelaxNumber; + }; - // forward references - class MMCollisionInt; - class TransportParams; - class XML_Node; + // forward references + class MMCollisionInt; + class TransportParams; + class XML_Node; + + /** + * The purpose of TransportFactory is to create new instances of + * 'transport managers', which are classes that provide transport + * properties and are derived from base class + * Transport. TransportFactory handles all initialization + * required, including evaluation of collision integrals and + * generating polynomial fits. Transport managers can also be + * created in other ways. @ingroup transportgroup + * @ingroup transportProps + */ + class TransportFactory : FactoryBase { + + public: /** - * The purpose of TransportFactory is to create new instances of - * 'transport managers', which are classes that provide transport - * properties and are derived from base class - * Transport. TransportFactory handles all initialization - * required, including evaluation of collision integrals and - * generating polynomial fits. Transport managers can also be - * created in other ways. @ingroup transportgroup - * @ingroup transportProps + * Return a pointer to a TransportFactory + * instance. TransportFactory is implemented as a 'singleton', + * which means that at most one instance may be created. The + * constructor is private. When a TransportFactory instance is + * required, call static method factory() to return a pointer + * to the TransportFactory instance. + * + * @code + * TransportFactory* f; + * f = TransportFactory::factory(); + * @endcode */ - class TransportFactory : FactoryBase { - - public: - - /** - * Return a pointer to a TransportFactory - * instance. TransportFactory is implemented as a 'singleton', - * which means that at most one instance may be created. The - * constructor is private. When a TransportFactory instance is - * required, call static method factory() to return a pointer - * to the TransportFactory instance. - * - * @code - * TransportFactory* f; - * f = TransportFactory::factory(); - * @endcode - */ - static TransportFactory* factory() { - #if defined(THREAD_SAFE_CANTERA) - boost::mutex::scoped_lock lock(transport_mutex) ; - #endif + static TransportFactory* factory() { +#if defined(THREAD_SAFE_CANTERA) + boost::mutex::scoped_lock lock(transport_mutex) ; +#endif if (!s_factory) { - s_factory = new TransportFactory(); - } - return s_factory; - } + s_factory = new TransportFactory(); + } + return s_factory; + } /** * Deletes the statically malloced instance. */ - virtual void deleteFactory(); + virtual void deleteFactory(); - /** - * Destructor + /** + * Destructor * * We do not delete statically * created single instance of this class here, because it would * create an infinite loop if destructor is called for that * single instance. - */ - virtual ~TransportFactory(); + */ + virtual ~TransportFactory(); - /// Build a new transport manager - virtual Transport* - newTransport(string model="", thermo_t* thermo=0, int log_level=0); + /// Build a new transport manager + virtual Transport* + newTransport(std::string model="", thermo_t* thermo=0, int log_level=0); - /// Initialize an existing transport manager - virtual void initTransport(Transport* tr, - thermo_t* thermo=0, int mode=0, int log_level=0); + /// Initialize an existing transport manager + virtual void initTransport(Transport* tr, + thermo_t* thermo=0, int mode=0, int log_level=0); - private: + private: - static TransportFactory* s_factory; - #if defined(THREAD_SAFE_CANTERA) - static boost::mutex transport_mutex ; - #endif + static TransportFactory* s_factory; +#if defined(THREAD_SAFE_CANTERA) + static boost::mutex transport_mutex ; +#endif - // The constructor is private; use static method factory() to - // get a pointer to a factory instance - TransportFactory(); + // The constructor is private; use static method factory() to + // get a pointer to a factory instance + TransportFactory(); - /// Read in transport parameters from a database - //void readTransportDatabase(ostream& logfile, - // XML_Node* db, - // const vector& names, - // TransportParams& tr); + /// Read in transport parameters from a database + //void readTransportDatabase(ostream& logfile, + // XML_Node* db, + // const vector& names, + // TransportParams& tr); - void getTransportData(const XML_Node* db, - XML_Node& log, const vector& names, - TransportParams& tr); + void getTransportData(const XML_Node* db, + XML_Node& log, const std::vector& names, + TransportParams& tr); - /** Generate polynomial fits to viscosity, conductivity, and - * binary diffusion coefficients */ - void fitProperties(TransportParams& tr, ostream& logfile=cout); + /** Generate polynomial fits to viscosity, conductivity, and + * binary diffusion coefficients */ + void fitProperties(TransportParams& tr, std::ostream& logfile=std::cout); - /// Generate polynomial fits to collision integrals - void fitCollisionIntegrals(ostream& logfile, - TransportParams& tr); + /// Generate polynomial fits to collision integrals + void fitCollisionIntegrals(std::ostream& logfile, + TransportParams& tr); - MMCollisionInt* m_integrals; + MMCollisionInt* m_integrals; - void setupMM(ostream& flog, const XML_Node* transport_database, - thermo_t* thermo, int mode, int log_level, - TransportParams& tr); + void setupMM(std::ostream& flog, const XML_Node* transport_database, + thermo_t* thermo, int mode, int log_level, + TransportParams& tr); - /// construct a new power-law transport manager - //Transport* newPowerTransport(const string& transport_database, - // phase_t* mix); + /// construct a new power-law transport manager + //Transport* newPowerTransport(const string& transport_database, + // phase_t* mix); - /// construct a new multicomponent transport manager - // Transport* newMultiTransport(const string& fname, - // thermo_t* thermo, int mode = 0, int log_level = 0); + /// construct a new multicomponent transport manager + // Transport* newMultiTransport(const string& fname, + // thermo_t* thermo, int mode = 0, int log_level = 0); - /// construct a new mixture-averaged transport server - //Transport* newMixTransport(const string& fname, - // thermo_t* thermo, int mode = 0, int log_level = 0); + /// construct a new mixture-averaged transport server + //Transport* newMixTransport(const string& fname, + // thermo_t* thermo, int mode = 0, int log_level = 0); - /// Second-order correction to the binary diffusion coefficients - void getBinDiffCorrection(doublereal t, - const TransportParams& tr, int k, int j, doublereal xk, doublereal xj, - doublereal& fkj, doublereal& fjk); + /// Second-order correction to the binary diffusion coefficients + void getBinDiffCorrection(doublereal t, + const TransportParams& tr, int k, int j, doublereal xk, doublereal xj, + doublereal& fkj, doublereal& fjk); - /// Corrections for polar-nonpolar binary diffusion coefficients - void makePolarCorrections(int i, int j, - const TransportParams& tr, doublereal& f_eps, doublereal& f_sigma); + /// Corrections for polar-nonpolar binary diffusion coefficients + void makePolarCorrections(int i, int j, + const TransportParams& tr, doublereal& f_eps, doublereal& f_sigma); - map m_models; - }; + std::map m_models; + }; - /** - * Create a new transport manager instance. - * @ingroup transportProps - */ - inline Transport* newTransportMgr(string transportModel="", - thermo_t* thermo=0, int loglevel=0, TransportFactory* f=0) { - if (f == 0) { - f = TransportFactory::factory(); - } - Transport* ptr = f->newTransport(transportModel, thermo, loglevel); - /* - * Note: We delete the static s_factory instance here, instead of in - * appdelete() in misc.cpp, to avoid linking problems involving - * the need for multiple cantera and transport library statements - * for applications that don't have transport in them. - */ - //TransportFactory::deleteFactory(); - return ptr; + /** + * Create a new transport manager instance. + * @ingroup transportProps + */ + inline Transport* newTransportMgr(std::string transportModel="", + thermo_t* thermo=0, int loglevel=0, TransportFactory* f=0) { + if (f == 0) { + f = TransportFactory::factory(); } + Transport* ptr = f->newTransport(transportModel, thermo, loglevel); + /* + * Note: We delete the static s_factory instance here, instead of in + * appdelete() in misc.cpp, to avoid linking problems involving + * the need for multiple cantera and transport library statements + * for applications that don't have transport in them. + */ + //TransportFactory::deleteFactory(); + return ptr; + } } #endif - - - - - - - diff --git a/Cantera/src/transport/TransportParams.h b/Cantera/src/transport/TransportParams.h index 91a667e98..eb46624a0 100755 --- a/Cantera/src/transport/TransportParams.h +++ b/Cantera/src/transport/TransportParams.h @@ -2,7 +2,7 @@ #define CT_TRANSPORTPARAMS_H #include -using namespace std; + #include "ct_defs.h" #include "TransportBase.h" @@ -29,21 +29,21 @@ namespace Cantera { vector_fp mw; // polynomial fits - vector visccoeffs; - vector condcoeffs; - vector diffcoeffs; + std::vector visccoeffs; + std::vector condcoeffs; + std::vector diffcoeffs; vector_fp polytempvec; - vector > poly; - vector omega22_poly; - vector astar_poly; - vector bstar_poly; - vector cstar_poly; + std::vector > poly; + std::vector omega22_poly; + std::vector astar_poly; + std::vector bstar_poly; + std::vector cstar_poly; vector_fp zrot; vector_fp crot; - vector polar; + std::vector polar; vector_fp alpha; vector_fp fitlist; vector_fp eps;