Took out using namespace std from a couple of .h files.

This commit is contained in:
Harry Moffat 2007-07-26 21:55:32 +00:00
parent a82de03550
commit 449e133e02
6 changed files with 212 additions and 224 deletions

View file

@ -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<int>(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 << "<!--" << comment << "-->" << endl;
s << "<!--" << comment << "-->" << 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 << "</" << XML_filter(tag) << ">" << endl;
s << "</" << XML_filter(tag) << ">" << std::endl;
}
template<class T>
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 << "</" << tag << ">" << endl;
<< value << "</" << tag << ">" << std::endl;
}
template<class iter>
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 << "</" << XML_filter(name) << ">" << endl;
s << "</" << XML_filter(name) << ">" << std::endl;
}
};

View file

@ -18,8 +18,7 @@
#include "ct_defs.h"
#include <vector>
using namespace std;
using namespace Cantera;
/////////////////////////////////////////////////////////////////////

View file

@ -1,9 +1,7 @@
/**
* @file MMCollisionInt.h
*
* Monk and Monchick collision integrals
*/
/*
* $Author$
* $Revision$
@ -17,7 +15,7 @@
#define CT_MMCOLLISIONINT_H
#include <vector>
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<vector_fp> m_o22poly;
vector<vector_fp> m_apoly;
vector<vector_fp> m_bpoly;
vector<vector_fp> m_cpoly;
std::vector<vector_fp> m_o22poly;
std::vector<vector_fp> m_apoly;
std::vector<vector_fp> m_bpoly;
std::vector<vector_fp> 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

View file

@ -29,7 +29,6 @@
#include <numeric>
#include <algorithm>
using namespace std;
// Cantera includes
#include "TransportBase.h"

View file

@ -1,8 +1,8 @@
/**
*
* @file TransportFactory.h
*
* Header file defining class TransportFactory
* (see \link Cantera::TransportFactory TransportFactory\endlink)
*/
/*
@ -30,7 +30,6 @@
#include <iostream>
#include <new>
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<string>& names,
// TransportParams& tr);
/// Read in transport parameters from a database
//void readTransportDatabase(ostream& logfile,
// XML_Node* db,
// const vector<string>& names,
// TransportParams& tr);
void getTransportData(const XML_Node* db,
XML_Node& log, const vector<string>& names,
TransportParams& tr);
void getTransportData(const XML_Node* db,
XML_Node& log, const std::vector<std::string>& 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<string, int> m_models;
};
std::map<std::string, int> 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

View file

@ -2,7 +2,7 @@
#define CT_TRANSPORTPARAMS_H
#include <vector>
using namespace std;
#include "ct_defs.h"
#include "TransportBase.h"
@ -29,21 +29,21 @@ namespace Cantera {
vector_fp mw;
// polynomial fits
vector<vector_fp> visccoeffs;
vector<vector_fp> condcoeffs;
vector<vector_fp> diffcoeffs;
std::vector<vector_fp> visccoeffs;
std::vector<vector_fp> condcoeffs;
std::vector<vector_fp> diffcoeffs;
vector_fp polytempvec;
vector<vector<int> > poly;
vector<vector_fp > omega22_poly;
vector<vector_fp > astar_poly;
vector<vector_fp > bstar_poly;
vector<vector_fp > cstar_poly;
std::vector<std::vector<int> > poly;
std::vector<vector_fp > omega22_poly;
std::vector<vector_fp > astar_poly;
std::vector<vector_fp > bstar_poly;
std::vector<vector_fp > cstar_poly;
vector_fp zrot;
vector_fp crot;
vector<bool> polar;
std::vector<bool> polar;
vector_fp alpha;
vector_fp fitlist;
vector_fp eps;