From ce73f8bacdd0e9e631e3ebf023b2dd6f54699939 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Mon, 27 Nov 2006 21:43:30 +0000 Subject: [PATCH] removed using namespace statements from Cantera header files, and fully qualified most members of std (string, vector< >, etc.) in header files. User programs may need to have "using namespace" statements added. --- Cantera/clib/src/Cabinet.h | 10 +- Cantera/clib/src/Storage.h | 24 ++-- Cantera/clib/src/clib_defs.h | 5 + Cantera/clib/src/ct.cpp | 3 + Cantera/cxx/demos/example_utils.h | 7 + Cantera/cxx/demos/rankine.cpp | 1 + Cantera/cxx/include/Cantera.h | 5 - Cantera/cxx/include/Edge.h | 2 +- Cantera/cxx/include/GRI30.h | 4 +- Cantera/cxx/include/IdealGasMix.h | 8 +- Cantera/cxx/include/IncompressibleSolid.h | 6 +- Cantera/cxx/include/Interface.h | 6 +- Cantera/cxx/include/Metal.h | 6 +- Cantera/cxx/include/PureFluid.h | 10 +- Cantera/cxx/include/importPhase.h | 2 +- Cantera/cxx/include/zerodim.h | 2 +- Cantera/cxx/src/cxxutils.cpp | 2 + Cantera/fortran/src/flib_defs.h | 5 + Cantera/src/Array.h | 7 +- Cantera/src/ArrayViewer.h | 4 +- Cantera/src/BandMatrix.cpp | 55 +------- Cantera/src/BandMatrix.h | 7 +- Cantera/src/CVodesIntegrator.h | 3 +- Cantera/src/Constituents.h | 32 ++--- Cantera/src/DAE_Solver.h | 2 +- Cantera/src/EdgeKinetics.h | 34 ++--- Cantera/src/Elements.cpp | 1 + Cantera/src/Elements.h | 16 +-- Cantera/src/Enhanced3BConc.h | 4 +- Cantera/src/FalloffMgr.h | 4 +- Cantera/src/GasKinetics.h | 52 +++----- Cantera/src/GeneralSpeciesThermo.h | 4 +- Cantera/src/Group.cpp | 3 +- Cantera/src/Group.h | 10 +- Cantera/src/ImplicitSurfChem.cpp | 3 +- Cantera/src/ImplicitSurfChem.h | 6 +- Cantera/src/Integrator.h | 4 +- Cantera/src/InterfaceKinetics.cpp | 2 + Cantera/src/InterfaceKinetics.h | 44 ++----- Cantera/src/Kinetics.h | 46 +++---- Cantera/src/KineticsFactory.cpp | 2 + Cantera/src/KineticsFactory.h | 10 +- Cantera/src/LatticePhase.h | 2 +- Cantera/src/LatticeSolidPhase.cpp | 3 + Cantera/src/LatticeSolidPhase.h | 4 +- Cantera/src/Mu0Poly.cpp | 3 +- Cantera/src/Mu0Poly.h | 2 +- Cantera/src/MultiPhase.cpp | 2 + Cantera/src/MultiPhase.h | 28 ++-- Cantera/src/MultiPhaseEquil.cpp | 10 -- Cantera/src/MultiPhaseEquil.h | 8 +- Cantera/src/Phase.cpp | 2 + Cantera/src/Phase.h | 20 +-- Cantera/src/RateCoeffMgr.h | 15 ++- Cantera/src/ReactionData.h | 13 +- Cantera/src/ReactionPath.cpp | 1 + Cantera/src/ReactionPath.h | 88 ++++++------- Cantera/src/ReactionStoichMgr.cpp | 2 + Cantera/src/ReactionStoichMgr.h | 12 +- Cantera/src/ResidEval.h | 4 +- Cantera/src/RxnRates.h | 41 +++--- Cantera/src/SpeciesThermo.h | 2 +- Cantera/src/SpeciesThermoFactory.cpp | 20 +-- Cantera/src/SpeciesThermoFactory.h | 10 +- Cantera/src/SpeciesThermoMgr.h | 16 +-- Cantera/src/StoichManager.h | 122 +++++++++--------- Cantera/src/SurfPhase.h | 2 +- Cantera/src/ThermoFactory.cpp | 2 + Cantera/src/ThermoFactory.h | 10 +- Cantera/src/ThermoPhase.cpp | 1 + Cantera/src/ThermoPhase.h | 10 +- Cantera/src/ThirdBodyMgr.h | 6 +- Cantera/src/ct2ctml.cpp | 2 + Cantera/src/ct_defs.h | 4 +- Cantera/src/ctexceptions.h | 12 +- Cantera/src/ctml.cpp | 3 + Cantera/src/ctml.h | 113 ++++++++-------- Cantera/src/ctvector.h | 2 + Cantera/src/global.h | 62 ++++----- Cantera/src/importCTML.cpp | 2 +- Cantera/src/importCTML.h | 24 ++-- Cantera/src/logger.h | 10 +- Cantera/src/misc.cpp | 7 +- Cantera/src/oneD/Domain1D.cpp | 4 +- Cantera/src/oneD/Domain1D.h | 26 ++-- Cantera/src/oneD/Inlet1D.h | 34 ++--- Cantera/src/oneD/MultiNewton.cpp | 21 ++- Cantera/src/oneD/MultiNewton.h | 2 +- Cantera/src/oneD/OneDim.cpp | 1 + Cantera/src/oneD/OneDim.h | 8 +- Cantera/src/oneD/Resid1D.h | 10 +- Cantera/src/oneD/Sim1D.cpp | 2 + Cantera/src/oneD/Sim1D.h | 12 +- Cantera/src/oneD/Solid1D.h | 12 +- Cantera/src/oneD/StFlow.cpp | 1 + Cantera/src/oneD/StFlow.h | 16 +-- Cantera/src/oneD/Surf1D.h | 8 +- Cantera/src/oneD/boundaries1D.cpp | 2 + Cantera/src/oneD/newton_utils.cpp | 2 + Cantera/src/oneD/refine.h | 8 +- Cantera/src/phasereport.cpp | 2 + Cantera/src/plots.cpp | 2 + Cantera/src/plots.h | 10 +- Cantera/src/polyfit.h | 2 +- Cantera/src/speciesThermoTypes.h | 9 +- Cantera/src/stringUtils.cpp | 74 +++++------ Cantera/src/stringUtils.h | 32 ++--- Cantera/src/transport/DustyGasTransport.cpp | 2 + Cantera/src/transport/MMCollisionInt.cpp | 1 + Cantera/src/transport/MixTransport.cpp | 1 + Cantera/src/transport/MultiTransport.cpp | 1 + Cantera/src/transport/MultiTransport.h | 16 +-- Cantera/src/transport/SolidTransport.cpp | 1 + Cantera/src/transport/TransportBase.h | 2 +- Cantera/src/transport/TransportFactory.cpp | 1 + Cantera/src/units.h | 16 +-- Cantera/src/vec_functions.h | 18 +-- Cantera/src/xml.h | 107 +++++++-------- Cantera/src/zeroD/ConstPressureReactor.cpp | 1 + Cantera/src/zeroD/ConstPressureReactor.h | 2 +- Cantera/src/zeroD/FlowDevice.cpp | 2 + Cantera/src/zeroD/FlowDevice.h | 8 +- Cantera/src/zeroD/FlowReactor.cpp | 1 + Cantera/src/zeroD/FlowReactor.h | 2 +- Cantera/src/zeroD/Reactor.cpp | 1 + Cantera/src/zeroD/Reactor.h | 8 +- Cantera/src/zeroD/ReactorBase.cpp | 1 + Cantera/src/zeroD/ReactorBase.h | 16 +-- Cantera/src/zeroD/ReactorFactory.cpp | 1 + Cantera/src/zeroD/ReactorFactory.h | 4 +- Cantera/src/zeroD/ReactorNet.cpp | 2 + Cantera/src/zeroD/ReactorNet.h | 8 +- Cantera/src/zeroD/Wall.cpp | 3 + Cantera/src/zeroD/Wall.h | 33 ++--- Cantera/user/user.cpp | 1 + ChangeLog | 8 ++ configure.in | 2 +- examples/cxx/example_utils.h | 5 + examples/cxx/examples.cpp | 3 + examples/cxx/kinetics_example1.cpp | 2 + ext/f2c_libs/arith.h | 7 +- preconfig | 2 +- .../ChemEquil_gri_matrix/gri_matrix.cpp | 3 + .../ChemEquil_gri_pairs/gri_pairs.cpp | 3 + test_problems/negATest/negATest.cpp | 9 +- test_problems/silane_equil/IdealGasMix.h | 8 +- test_problems/silane_equil/silane_equil.cpp | 3 + test_problems/surfkin/Interface.h | 6 +- test_problems/surfkin/surfdemo.cpp | 2 + tools/src/cti2ctml.cpp | 2 +- 150 files changed, 900 insertions(+), 890 deletions(-) diff --git a/Cantera/clib/src/Cabinet.h b/Cantera/clib/src/Cabinet.h index 460338de7..40049d8c0 100755 --- a/Cantera/clib/src/Cabinet.h +++ b/Cantera/clib/src/Cabinet.h @@ -19,7 +19,7 @@ * is retrieved from the list by the interface function, the desired * method is invoked, and the result returned to the non-C++ calling * procedure. By storing the pointers in a 'cabinet', there is no need - * to encode them in a string or integer and pass them out to the + * to encode them in a std::string or integer and pass them out to the * non-C++ calling routine, as some other interfacing schemes do. * * The Cabinet class can be used to store pointers to any class @@ -102,7 +102,7 @@ public: __table.push_back(new M(*old)); return static_cast(__table.size()) - 1; } - catch (CanteraError) {return -1;} + catch (Cantera::CanteraError) {return -1;} catch (...) {return -999;} } @@ -119,7 +119,7 @@ public: *dest = *src; return 0; } - catch (CanteraError) {return -1;} + catch (Cantera::CanteraError) {return -1;} catch (...) {return -999;} } @@ -150,7 +150,7 @@ public: __table[n] = __table[0]; } else { - throw CanteraError("Cabinet::del", + throw Cantera::CanteraError("Cabinet::del", "Attempt made to delete an already-deleted object."); } } @@ -163,7 +163,7 @@ public: if (n >= 0 && n < int(__table.size())) return __table[n]; else { - throw CanteraError("item","index out of range"+int2str(n)); + throw Cantera::CanteraError("item","index out of range"+Cantera::int2str(n)); return __table[0]; } } diff --git a/Cantera/clib/src/Storage.h b/Cantera/clib/src/Storage.h index 1fe554e5b..98a5a8cc0 100755 --- a/Cantera/clib/src/Storage.h +++ b/Cantera/clib/src/Storage.h @@ -19,11 +19,11 @@ public: virtual ~Storage(); // vectors to hold pointers to objects - vector __ktable; - vector __thtable; - vector __trtable; + std::vector __ktable; + std::vector __thtable; + std::vector __trtable; - map __thmap; + std::map __thmap; static Storage* storage() { if (__storage == 0) { @@ -33,9 +33,9 @@ public: } - int addThermo(ThermoPhase* th); - int addKinetics(Kinetics* kin); - int addTransport(Transport* tr); + int addThermo(Cantera::ThermoPhase* th); + int addKinetics(Cantera::Kinetics* kin); + int addTransport(Cantera::Transport* tr); // int addNewTransport(int model, char* dbase, int th, int loglevel); int clear(); void deleteKinetics(int n); @@ -45,23 +45,23 @@ public: static Storage* __storage; }; -inline ThermoPhase* ph(int n) { +inline Cantera::ThermoPhase* ph(int n) { return Storage::__storage->__thtable[n]; } -inline Kinetics* kin(int n) { +inline Cantera::Kinetics* kin(int n) { return Storage::__storage->__ktable[n]; } -inline ThermoPhase* th(int n) { +inline Cantera::ThermoPhase* th(int n) { return Storage::__storage->__thtable[n]; } -inline int thermo_index(string id) { +inline int thermo_index(std::string id) { return Storage::__storage->__thmap[id]; } -inline Transport* trans(int n) { +inline Cantera::Transport* trans(int n) { return Storage::__storage->__trtable[n]; } diff --git a/Cantera/clib/src/clib_defs.h b/Cantera/clib/src/clib_defs.h index a461c24ca..642762c0b 100755 --- a/Cantera/clib/src/clib_defs.h +++ b/Cantera/clib/src/clib_defs.h @@ -17,4 +17,9 @@ #define ERR -999 #define DERR -999.999 +namespace Cantera {} +using namespace Cantera; +namespace std {} +using namespace std; + #endif diff --git a/Cantera/clib/src/ct.cpp b/Cantera/clib/src/ct.cpp index 6f8d8ef00..d9bd16b8a 100755 --- a/Cantera/clib/src/ct.cpp +++ b/Cantera/clib/src/ct.cpp @@ -29,6 +29,9 @@ #include "clib_defs.h" +using namespace std; +using namespace Cantera; + inline XML_Node* _xml(int i) { return Cabinet::cabinet(false)->item(i); } diff --git a/Cantera/cxx/demos/example_utils.h b/Cantera/cxx/demos/example_utils.h index 5426c8871..59e62ef7d 100644 --- a/Cantera/cxx/demos/example_utils.h +++ b/Cantera/cxx/demos/example_utils.h @@ -4,6 +4,13 @@ #include #include +namespace Cantera{} +using namespace Cantera; +namespace std{} +using namespace std; +namespace CanteraZeroD{} +using namespace CanteraZeroD; + // Save the temperature, density, pressure, and mole fractions at one // time template diff --git a/Cantera/cxx/demos/rankine.cpp b/Cantera/cxx/demos/rankine.cpp index 50b7d2db7..91f2f059d 100644 --- a/Cantera/cxx/demos/rankine.cpp +++ b/Cantera/cxx/demos/rankine.cpp @@ -7,6 +7,7 @@ #include // defines class Water using namespace Cantera; +using namespace std; map h; map s; diff --git a/Cantera/cxx/include/Cantera.h b/Cantera/cxx/include/Cantera.h index f82261b4d..71a9b6941 100755 --- a/Cantera/cxx/include/Cantera.h +++ b/Cantera/cxx/include/Cantera.h @@ -2,9 +2,6 @@ #ifndef CANTERA_H_INCL #define CANTERA_H_INCL -namespace std{} -using namespace std; - // definitions #define CANTERA_APP #include "kernel/ct_defs.h" @@ -21,8 +18,6 @@ using namespace std; // The Cantera logger class #include "kernel/logger.h" -//using namespace Cantera; - #endif diff --git a/Cantera/cxx/include/Edge.h b/Cantera/cxx/include/Edge.h index ccbc71371..cb04e7e73 100644 --- a/Cantera/cxx/include/Edge.h +++ b/Cantera/cxx/include/Edge.h @@ -13,7 +13,7 @@ namespace Cantera { public EdgePhase, public EdgeKinetics { public: - Edge(string infile, string id, vector phases) + Edge(std::string infile, std::string id, std::vector phases) : m_ok(false), m_r(0) { m_r = get_XML_File(infile); diff --git a/Cantera/cxx/include/GRI30.h b/Cantera/cxx/include/GRI30.h index 1817cf9ca..b0d8f416b 100644 --- a/Cantera/cxx/include/GRI30.h +++ b/Cantera/cxx/include/GRI30.h @@ -28,8 +28,8 @@ namespace Cantera { bool operator!() { return !m_ok;} bool ready() const { return m_ok; } - friend ostream& operator<<(ostream& s, GRI30& mix) { - string r = report(mix, true); + friend std::ostream& operator<<(std::ostream& s, GRI30& mix) { + std::string r = report(mix, true); s << r; return s; } diff --git a/Cantera/cxx/include/IdealGasMix.h b/Cantera/cxx/include/IdealGasMix.h index ebb3f1ade..24f78e9a5 100644 --- a/Cantera/cxx/include/IdealGasMix.h +++ b/Cantera/cxx/include/IdealGasMix.h @@ -16,7 +16,7 @@ namespace Cantera { IdealGasMix() : m_ok(false), m_r(0) {} - IdealGasMix(string infile, string id="") : m_ok(false), m_r(0) { + IdealGasMix(std::string infile, std::string id="") : m_ok(false), m_r(0) { m_r = get_XML_File(infile); if (id == "-") id = ""; @@ -26,7 +26,7 @@ namespace Cantera { } - IdealGasMix(XML_Node& root, string id) : m_ok(false), m_r(0) { + IdealGasMix(XML_Node& root, std::string id) : m_ok(false), m_r(0) { m_ok = buildSolutionFromXML(root, id, "phase", this, this); } @@ -34,8 +34,8 @@ namespace Cantera { bool operator!() { return !m_ok;} bool ready() const { return m_ok; } - friend ostream& operator<<(ostream& s, IdealGasMix& mix) { - string r = report(mix, true); + friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) { + std::string r = report(mix, true); s << r; return s; } diff --git a/Cantera/cxx/include/IncompressibleSolid.h b/Cantera/cxx/include/IncompressibleSolid.h index 5dd14aa12..4cae7f94d 100644 --- a/Cantera/cxx/include/IncompressibleSolid.h +++ b/Cantera/cxx/include/IncompressibleSolid.h @@ -11,7 +11,7 @@ namespace Cantera { class IncompressibleSolid : public ConstDensityThermo { public: - IncompressibleSolid(string infile, string id="") : m_ok(false), m_r(0) { + IncompressibleSolid(std::string infile, std::string id="") : m_ok(false), m_r(0) { m_r = get_XML_File(infile); if (id == "-") id = ""; @@ -26,8 +26,8 @@ namespace Cantera { bool operator!() { return !m_ok;} bool ready() { return m_ok; } - //friend ostream& operator<<(ostream& s, IdealGasMix& mix) { - // string r = report(mix, true); + //friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) { + // std::string r = report(mix, true); // s << r; // return s; diff --git a/Cantera/cxx/include/Interface.h b/Cantera/cxx/include/Interface.h index 4afa88d65..4bfae2003 100644 --- a/Cantera/cxx/include/Interface.h +++ b/Cantera/cxx/include/Interface.h @@ -13,7 +13,7 @@ namespace Cantera { public SurfPhase, public InterfaceKinetics { public: - Interface(string infile, string id, vector phases) + Interface(std::string infile, std::string id, std::vector phases) : m_ok(false), m_r(0) { m_r = get_XML_File(infile); @@ -41,8 +41,8 @@ namespace Cantera { private: }; - inline Interface* importInterface(string infile, string id, - vector phases) { + inline Interface* importInterface(std::string infile, std::string id, + std::vector phases) { return new Interface(infile, id, phases); } diff --git a/Cantera/cxx/include/Metal.h b/Cantera/cxx/include/Metal.h index 9e9040dd2..331aa7a74 100644 --- a/Cantera/cxx/include/Metal.h +++ b/Cantera/cxx/include/Metal.h @@ -11,7 +11,7 @@ namespace Cantera { class Metal : public MetalPhase { public: - Metal(string infile, string id="") : m_ok(false), m_r(0) { + Metal(std::string infile, std::string id="") : m_ok(false), m_r(0) { m_r = get_XML_File(infile); if (id == "-") id = ""; @@ -26,8 +26,8 @@ namespace Cantera { bool operator!() { return !m_ok;} bool ready() { return m_ok; } - //friend ostream& operator<<(ostream& s, IdealGasMix& mix) { - // string r = report(mix, true); + //friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) { + // std::string r = report(mix, true); // s << r; // return s; diff --git a/Cantera/cxx/include/PureFluid.h b/Cantera/cxx/include/PureFluid.h index 454fb7410..c4f8d1f2a 100644 --- a/Cantera/cxx/include/PureFluid.h +++ b/Cantera/cxx/include/PureFluid.h @@ -17,7 +17,7 @@ namespace Cantera { PureFluid() : m_ok(false), m_r(0) {} - PureFluid(string infile, string id="") : m_ok(false), m_r(0) { + PureFluid(std::string infile, std::string id="") : m_ok(false), m_r(0) { m_r = get_XML_File(infile); if (id == "-") id = ""; @@ -27,7 +27,7 @@ namespace Cantera { } - PureFluid(XML_Node& root, string id) : m_ok(false), m_r(0) { + PureFluid(XML_Node& root, std::string id) : m_ok(false), m_r(0) { m_ok = buildSolutionFromXML(root, id, "phase", this, 0); } @@ -35,8 +35,8 @@ namespace Cantera { bool operator!() { return !m_ok;} bool ready() const { return m_ok; } - friend ostream& operator<<(ostream& s, PureFluid& mix) { - string r = report(mix, true); + friend std::ostream& operator<<(std::ostream& s, PureFluid& mix) { + std::string r = report(mix, true); s << r; return s; } @@ -50,7 +50,7 @@ namespace Cantera { class Water : public PureFluid { public: - Water() : PureFluid(string("liquidvapor.cti"),string("water")) {} + Water() : PureFluid(std::string("liquidvapor.cti"),std::string("water")) {} virtual ~Water() {} }; diff --git a/Cantera/cxx/include/importPhase.h b/Cantera/cxx/include/importPhase.h index 0269cf4a6..1cf0e74fa 100644 --- a/Cantera/cxx/include/importPhase.h +++ b/Cantera/cxx/include/importPhase.h @@ -8,7 +8,7 @@ namespace Cantera { - ThermoPhase* importPhase(string infile, string id="") { + ThermoPhase* importPhase(std::string infile, std::string id="") { ThermoPhase* p = newPhase(infile, id); return p; } diff --git a/Cantera/cxx/include/zerodim.h b/Cantera/cxx/include/zerodim.h index 7f36d37ba..6e689eac4 100644 --- a/Cantera/cxx/include/zerodim.h +++ b/Cantera/cxx/include/zerodim.h @@ -8,7 +8,7 @@ #include "kernel/zeroD/FlowReactor.h" #include "kernel/zeroD/ConstPressureReactor.h" -using namespace CanteraZeroD; +//using namespace CanteraZeroD; #endif diff --git a/Cantera/cxx/src/cxxutils.cpp b/Cantera/cxx/src/cxxutils.cpp index 5c1ba84e5..24fae7a45 100644 --- a/Cantera/cxx/src/cxxutils.cpp +++ b/Cantera/cxx/src/cxxutils.cpp @@ -7,6 +7,8 @@ #include "ThermoPhase.h" #include +using namespace std; + namespace Cantera { /** diff --git a/Cantera/fortran/src/flib_defs.h b/Cantera/fortran/src/flib_defs.h index ee5dbbaee..b7130b033 100644 --- a/Cantera/fortran/src/flib_defs.h +++ b/Cantera/fortran/src/flib_defs.h @@ -20,4 +20,9 @@ typedef integer status_t; +namespace Cantera {} +using namespace Cantera; +namespace std{} +using namespace std; + #endif diff --git a/Cantera/src/Array.h b/Cantera/src/Array.h index aa78e7120..df1e28358 100755 --- a/Cantera/src/Array.h +++ b/Cantera/src/Array.h @@ -131,9 +131,6 @@ namespace Cantera { * Evaluate a*x + y. */ void axpy(doublereal a, const Array2D& x, const Array2D& y) { - //const doublereal* xb = x.begin(); - //const doublereal* yb = y.begin(); - //doublereal* b = begin(); iterator b = begin(); const_iterator xb = x.begin(); const_iterator yb = y.begin(); @@ -189,7 +186,7 @@ namespace Cantera { }; /// output the array - inline ostream& operator<<(ostream& s, const Array2D& m) { + inline std::ostream& operator<<(std::ostream& s, const Array2D& m) { int nr = static_cast(m.nRows()); int nc = static_cast(m.nColumns()); int i,j; @@ -197,7 +194,7 @@ namespace Cantera { for (j = 0; j < nc; j++) { s << m(i,j) << ", "; } - s << endl; + s << std::endl; } return s; } diff --git a/Cantera/src/ArrayViewer.h b/Cantera/src/ArrayViewer.h index 1320d67f3..112648530 100755 --- a/Cantera/src/ArrayViewer.h +++ b/Cantera/src/ArrayViewer.h @@ -122,7 +122,7 @@ namespace Cantera { }; /// output the array - inline ostream& operator<<(ostream& s, const ArrayViewer& m) { + inline std::ostream& operator<<(std::ostream& s, const ArrayViewer& m) { int nr = static_cast(m.nRows()); int nc = static_cast(m.nColumns()); int i,j; @@ -130,7 +130,7 @@ namespace Cantera { for (j = 0; j < nc; j++) { s << m(i,j) << ", "; } - s << endl; + s << std::endl; } return s; } diff --git a/Cantera/src/BandMatrix.cpp b/Cantera/src/BandMatrix.cpp index 92f803448..b643fe1b2 100755 --- a/Cantera/src/BandMatrix.cpp +++ b/Cantera/src/BandMatrix.cpp @@ -11,11 +11,6 @@ #pragma warning(disable:4503) #endif - -//#include -//#include -//using namespace std; - #include "BandMatrix.h" #include "ctlapack.h" #include "utilities.h" @@ -23,6 +18,8 @@ #include "stringUtils.h" #include "global.h" +using namespace std; + namespace Cantera { @@ -140,42 +137,11 @@ namespace Cantera { ofstream fout("bandmatrix.csv"); fout << *this << endl; fout.close(); - //error("DGBTRF returned info = "+int2str(info)+".\n" - // +"Matrix written to file bandmatrix.csv\n"); - //throw CanteraError("BandMatrix::factor", - // "DGBTRF returned info = "+int2str(info)+".\n" - // +"Matrix written to file bandmatrix.csv\n"); } return info; } - /** - * Solve the linear system Ax = b, where A is this matrix. - * Calls LAPACK subroutine DGBTRS. - */ -// void BandMatrix::solve(const vector_fp& b, vector_fp& x) { -// int info = 0; -// copy(b.begin(), b.end(), x.begin()); // b -> x - -// // If the matrix has been modified since the last LU decomposition, -// // then do it now. -// if (!m_factored) factor(); - -// ct_dgbtrs(ctlapack::NoTranspose, columns(), nSubDiagonals(), -// nSuperDiagonals(), 1, ludata.begin(), ldim(), ipiv().begin(), -// x.begin(), columns(), info); - -// // error handling -// if (info != 0) { -// ofstream fout("bandmatrix.csv"); -// fout << *this << endl; -// fout.close(); -// throw CanteraError("BandMatrix::solve", -// "DGBTRS returned info = "+int2str(info)+".\n" -// +"Matrix written to file bandmatrix.csv\n"); -// } -// } int BandMatrix::solve(int n, const doublereal* b, doublereal* x) { copy(b, b+n, x); @@ -195,9 +161,6 @@ namespace Cantera { ofstream fout("bandmatrix.csv"); fout << *this << endl; fout.close(); - //throw CanteraError("BandMatrix::solve", - // "DGBTRS returned info = "+int2str(info)+".\n" - // +"Matrix written to file bandmatrix.csv\n"); } return info; } @@ -207,7 +170,6 @@ namespace Cantera { int nc = m.columns(); int i,j; for (i = 0; i < nr; i++) { - //s << "Row " << i+1 << ": "; for (j = 0; j < nc; j++) { s << m(i,j) << ", "; } @@ -215,18 +177,5 @@ namespace Cantera { } return s; } - - /** - * Solve Ax = b. Array b is overwritten on exit with x. - */ -// int bsolve(BandMatrix& A, double* b) { -// int info=0; -// A.ludata = A.data; -// ct_dgbsv(A.columns(), A.nSubDiagonals(), A.nSuperDiagonals(), -// 1, A.ludata.begin(), A.ldim(), A.ipiv().begin(), b, -// A.columns(), info); -// A.m_factored = true; -// return info; -// } } diff --git a/Cantera/src/BandMatrix.h b/Cantera/src/BandMatrix.h index 8f67cacfd..5652d6f4c 100755 --- a/Cantera/src/BandMatrix.h +++ b/Cantera/src/BandMatrix.h @@ -146,12 +146,7 @@ namespace Cantera { }; - ostream& operator<<(ostream& s, const BandMatrix& m); - - /** - * Solve Ax = b. Array b is overwritten on exit with x. - */ - // int bsolve(BandMatrix& A, double* b); + std::ostream& operator<<(std::ostream& s, const BandMatrix& m); } diff --git a/Cantera/src/CVodesIntegrator.h b/Cantera/src/CVodesIntegrator.h index d7a31bc8a..88dc18c1f 100644 --- a/Cantera/src/CVodesIntegrator.h +++ b/Cantera/src/CVodesIntegrator.h @@ -28,7 +28,6 @@ #ifdef SUNDIALS_VERSION_22 #include #else -//#include #include #endif @@ -41,7 +40,7 @@ namespace Cantera { */ class CVodesErr : public CanteraError { public: - CVodesErr(string msg) : CanteraError("CVodesIntegrator", msg){} + CVodesErr(std::string msg) : CanteraError("CVodesIntegrator", msg){} }; diff --git a/Cantera/src/Constituents.h b/Cantera/src/Constituents.h index 3832c647b..d7a14a908 100755 --- a/Cantera/src/Constituents.h +++ b/Cantera/src/Constituents.h @@ -17,7 +17,7 @@ #include "ct_defs.h" -using namespace std; +//using namespace std; #include "SpeciesThermo.h" #include "ctexceptions.h" @@ -33,7 +33,7 @@ namespace Cantera { class SpeciesRangeError : public CanteraError { public: - SpeciesRangeError(string func, int k, int kmax) : + SpeciesRangeError(std::string func, int k, int kmax) : CanteraError(func, "Species index " + int2str(k) + " outside valid range of 0 to " + int2str(kmax-1)) {} }; @@ -75,7 +75,7 @@ namespace Cantera { /// \param m Element index. /// \exception If m < 0 or m >= nElements(), the /// exception, ElementRangeError, is thrown. - string elementName(int m) const; + std::string elementName(int m) const; /// Index of element named 'name'. @@ -87,7 +87,7 @@ namespace Cantera { /// If 'name' is not /// the name of an element in the set, then the value -1 is /// returned. - int elementIndex(string name) const; + int elementIndex(std::string name) const; /// Atomic weight of element m. @@ -97,11 +97,11 @@ namespace Cantera { int atomicNumber(int m) const; /// Return a read-only reference to the vector of element names. - const vector& elementNames() const; + const std::vector& elementNames() const; /// Return a read-only reference to the vector of atomic weights. - const array_fp& atomicWeights() const; + const vector_fp& atomicWeights() const; /// Number of elements. @@ -122,14 +122,14 @@ namespace Cantera { //@{ /// Add an element. - /// @param symbol Atomic symbol string. + /// @param symbol Atomic symbol std::string. /// @param weight Atomic mass in amu. - void addElement(const string& symbol, doublereal weight); + void addElement(const std::string& symbol, doublereal weight); /// Add an element from an XML specification. void addElement(const XML_Node& e); - void addUniqueElement(const string& symbol, doublereal weight); + void addUniqueElement(const std::string& symbol, doublereal weight); void addUniqueElement(const XML_Node& e); @@ -159,7 +159,7 @@ namespace Cantera { * Return a const reference to the vector of molecular weights * of the species */ - const array_fp& molecularWeights() const; + const vector_fp& molecularWeights() const; /// Electrical charge of one species k molecule, divided by @@ -173,21 +173,21 @@ namespace Cantera { * They are not usually called by user programs. */ //@{ - void addSpecies(const string& name, const doublereal* comp, + void addSpecies(const std::string& name, const doublereal* comp, doublereal charge = 0.0, doublereal size = 1.0); - void addUniqueSpecies(const string& name, const doublereal* comp, + void addUniqueSpecies(const std::string& name, const doublereal* comp, doublereal charge = 0.0, doublereal size = 1.0); /** * Index of species named 'name'. The first species added * will have index 0, and the last one index nSpecies() - 1. */ - int speciesIndex(string name) const; + int speciesIndex(std::string name) const; /// Name of the species with index k - string speciesName(int k) const; + std::string speciesName(int k) const; /// Return a const referernce to the vector of species names - const vector& speciesNames() const; + const std::vector& speciesNames() const; /** * size(): * This routine returns the size of species k @@ -235,7 +235,7 @@ namespace Cantera { */ Elements * m_Elements; - vector m_speciesNames; + std::vector m_speciesNames; vector_fp m_speciesComp; /** * m_speciesCharge: Vector of species charges diff --git a/Cantera/src/DAE_Solver.h b/Cantera/src/DAE_Solver.h index bb40393a9..cb37eee20 100644 --- a/Cantera/src/DAE_Solver.h +++ b/Cantera/src/DAE_Solver.h @@ -206,7 +206,7 @@ namespace Cantera { private: - void warn(string msg) const { + void warn(std::string msg) const { writelog(">>>> Warning: method "+msg+" of base class " +"DAE_Solver called. Nothing done.\n"); } diff --git a/Cantera/src/EdgeKinetics.h b/Cantera/src/EdgeKinetics.h index b0f1a67cf..4f3ee0d2a 100644 --- a/Cantera/src/EdgeKinetics.h +++ b/Cantera/src/EdgeKinetics.h @@ -158,7 +158,7 @@ namespace Cantera { */ virtual void getCreationRates(doublereal* cdot) { updateROP(); - fill(cdot, cdot + m_kk, 0.0); + std::fill(cdot, cdot + m_kk, 0.0); m_revProductStoich.incrementSpecies( &m_kdata->m_ropf[0], cdot); m_irrevProductStoich.incrementSpecies( @@ -177,7 +177,7 @@ namespace Cantera { */ virtual void getDestructionRates(doublereal* ddot) { updateROP(); - fill(ddot, ddot + m_kk, 0.0); + std::fill(ddot, ddot + m_kk, 0.0); m_revProductStoich.incrementSpecies( &m_kdata->m_ropr[0], ddot); m_reactantStoich.incrementSpecies( @@ -193,7 +193,7 @@ namespace Cantera { */ virtual void getNetProductionRates(doublereal* net) { updateROP(); - fill(net, net + m_kk, 0.0); + std::fill(net, net + m_kk, 0.0); m_revProductStoich.incrementSpecies( &m_kdata->m_ropnet[0], net); m_irrevProductStoich.incrementSpecies( @@ -247,7 +247,7 @@ namespace Cantera { /** * Return a string representing the reaction. */ - virtual string reactionString(int i) const { + virtual std::string reactionString(int i) const { return m_rxneqn[i]; } @@ -284,9 +284,9 @@ namespace Cantera { void updateROP(); - const vector& reactantGroups(int i) + const std::vector& reactantGroups(int i) { return m_rgroups[i]; } - const vector& productGroups(int i) + const std::vector& productGroups(int i) { return m_pgroups[i]; } void _update_rates_T(); @@ -312,9 +312,9 @@ namespace Cantera { * The first pair is the reactionType of the reaction. * The second pair is ... */ - mutable map > m_index; + mutable std::map > m_index; - vector m_irrev; + std::vector m_irrev; StoichManagerN m_reactantStoich; StoichManagerN m_revProductStoich; @@ -329,16 +329,16 @@ namespace Cantera { */ int m_nrev; - map > m_rgroups; - map > m_pgroups; + std::map > m_rgroups; + std::map > m_pgroups; - vector m_rxntype; + std::vector m_rxntype; - mutable vector > m_rrxn; - mutable vector > m_prxn; + mutable std::vector > m_rrxn; + mutable std::vector > m_prxn; vector_int m_revindex; - vector m_rxneqn; + std::vector m_rxneqn; /** * Temporary data storage used in calculating the rates of @@ -376,12 +376,12 @@ namespace Cantera { void addGlobalReaction(const ReactionData& r); void installReagents(const ReactionData& r); - void installGroups(int irxn, const vector& r, - const vector& p); + void installGroups(int irxn, const std::vector& r, + const std::vector& p); void updateKc(); void registerReaction(int rxnNumber, int type, int loc) { - m_index[rxnNumber] = pair(type, loc); + m_index[rxnNumber] = std::pair(type, loc); } void applyButlerVolmerCorrection(doublereal* kf); bool m_finalized; diff --git a/Cantera/src/Elements.cpp b/Cantera/src/Elements.cpp index 2d938d789..768f06d6c 100644 --- a/Cantera/src/Elements.cpp +++ b/Cantera/src/Elements.cpp @@ -26,6 +26,7 @@ #include "ctexceptions.h" using namespace ctml; +using namespace std; #ifdef USE_DGG_CODE #include diff --git a/Cantera/src/Elements.h b/Cantera/src/Elements.h index 17f0c1a9c..f1376a56c 100644 --- a/Cantera/src/Elements.h +++ b/Cantera/src/Elements.h @@ -44,7 +44,7 @@ namespace Cantera { Elements(); ~Elements(); - static double LookupWtElements(const string &); + static double LookupWtElements(const std::string &); /// Atomic weight of element m. doublereal atomicWeight(int m) const { return m_atomicWeights[m]; } @@ -73,13 +73,13 @@ namespace Cantera { * * @param name String containing the index. */ - int elementIndex(string name) const; + int elementIndex(std::string name) const; /* * Name of the element with index \c m. @param m Element 11111 * index. If m < 0 or m >= nElements() an exception is thrown. */ - string elementName(int m) const; + std::string elementName(int m) const; /* elementNames() */ /** Returns a string vector containing the element names @@ -88,12 +88,12 @@ namespace Cantera { * @return const vector& : The vector contains * the element names in their indexed order. */ - const vector& elementNames() const { + const std::vector& elementNames() const { return m_elementNames; } /// Add an element. - void addElement(const string& symbol, + void addElement(const std::string& symbol, doublereal weight = -12345.0); void addElement(const XML_Node& e); @@ -101,7 +101,7 @@ namespace Cantera { * Add an element only if the element hasn't been added before. * This is accomplished via a string match on symbol. */ - void addUniqueElement(const string& symbol, + void addUniqueElement(const std::string& symbol, doublereal weight = -12345.0, int atomicNumber = 0); void addUniqueElement(const XML_Node& e); @@ -166,7 +166,7 @@ namespace Cantera { * * Note, a string search is the primary way to identify elements. */ - vector m_elementNames; + std::vector m_elementNames; /** * Number of Constituents Objects that use this object @@ -184,7 +184,7 @@ namespace Cantera { /** Vector of pointers to Elements Objects * */ - static vector Global_Elements_List; + static std::vector Global_Elements_List; }; diff --git a/Cantera/src/Enhanced3BConc.h b/Cantera/src/Enhanced3BConc.h index 82064cb54..0aa892a64 100755 --- a/Cantera/src/Enhanced3BConc.h +++ b/Cantera/src/Enhanced3BConc.h @@ -27,9 +27,9 @@ namespace Cantera { Enhanced3BConc() : m_n (0), m_deflt (1.0) {} - Enhanced3BConc(int n, const map& enhanced, + Enhanced3BConc(int n, const std::map& enhanced, doublereal deflt = 1.0) { - map::const_iterator iter; + std::map::const_iterator iter; for (iter = enhanced.begin(); iter != enhanced.end(); ++iter) { m_index.push_back( iter->first ); m_eff.push_back( iter->second - deflt); diff --git a/Cantera/src/FalloffMgr.h b/Cantera/src/FalloffMgr.h index fd62c9459..4b8c82026 100755 --- a/Cantera/src/FalloffMgr.h +++ b/Cantera/src/FalloffMgr.h @@ -111,11 +111,11 @@ namespace Cantera { protected: vector_int m_rxn, m_rxn0; - vector m_falloff; + std::vector m_falloff; FalloffFactory* m_factory; vector_int m_loc; int m_n, m_n0; - vector m_offset; + std::vector m_offset; size_t m_worksize; }; } diff --git a/Cantera/src/GasKinetics.h b/Cantera/src/GasKinetics.h index 3c60c9e20..07ff045e9 100755 --- a/Cantera/src/GasKinetics.h +++ b/Cantera/src/GasKinetics.h @@ -219,13 +219,6 @@ namespace Cantera { get_wdot(&m_kdata->m_ropnet[0], net); #else m_rxnstoich->getNetProductionRates(m_kk, &m_kdata->m_ropnet[0], net); - //fill(net, net + m_kk, 0.0); - //m_revProductStoich.incrementSpecies( - // m_kdata->m_ropnet.begin(), net); - //m_irrevProductStoich.incrementSpecies( - // m_kdata->m_ropnet.begin(), net); - //m_reactantStoich.decrementSpecies( - // m_kdata->m_ropnet.begin(), net); #endif } @@ -240,13 +233,6 @@ namespace Cantera { updateROP(); m_rxnstoich->getCreationRates(m_kk, &m_kdata->m_ropf[0], &m_kdata->m_ropr[0], cdot); - //fill(cdot, cdot + m_kk, 0.0); - //m_revProductStoich.incrementSpecies( - // m_kdata->m_ropf.begin(), cdot); - //m_irrevProductStoich.incrementSpecies( - // m_kdata->m_ropf.begin(), cdot); - //m_reactantStoich.incrementSpecies( - // m_kdata->m_ropr.begin(), cdot); } /** @@ -282,7 +268,7 @@ namespace Cantera { return m_index[i].first; } - virtual string reactionString(int i) const { + virtual std::string reactionString(int i) const { return m_rxneqn[i]; } @@ -345,9 +331,9 @@ namespace Cantera { void updateROP(); - const vector& reactantGroups(int i) + const std::vector& reactantGroups(int i) { return m_rgroups[i]; } - const vector& productGroups(int i) + const std::vector& productGroups(int i) { return m_pgroups[i]; } @@ -367,33 +353,29 @@ namespace Cantera { Rate1 m_falloff_high_rates; Rate1 m_rates; - mutable map > m_index; + mutable std::map > m_index; FalloffMgr m_falloffn; ThirdBodyMgr m_3b_concm; ThirdBodyMgr m_falloff_concm; - vector m_irrev; - - //StoichManagerN m_reactantStoich; - //StoichManagerN m_revProductStoich; - //StoichManagerN m_irrevProductStoich; + std::vector m_irrev; ReactionStoichMgr* m_rxnstoich; - vector m_fwdOrder; + std::vector m_fwdOrder; int m_nirrev; int m_nrev; - map > m_rgroups; - map > m_pgroups; + std::map > m_rgroups; + std::map > m_pgroups; - vector m_rxntype; + std::vector m_rxntype; - mutable vector > m_rrxn; - mutable vector > m_prxn; + mutable std::vector > m_rrxn; + mutable std::vector > m_prxn; /** * Difference between the input global reactants order @@ -404,7 +386,7 @@ namespace Cantera { vector_fp m_dn; vector_int m_revindex; - vector m_rxneqn; + std::vector m_rxneqn; GasKineticsData* m_kdata; @@ -416,22 +398,20 @@ namespace Cantera { private: int reactionNumber(){ return m_ii;} - vector > m_stoich; + std::vector > m_stoich; void addElementaryReaction(const ReactionData& r); void addThreeBodyReaction(const ReactionData& r); void addFalloffReaction(const ReactionData& r); void installReagents(const ReactionData& r); - //const vector_int& r, - // const vector_int& p, bool reversible); - void installGroups(int irxn, const vector& r, - const vector& p); + void installGroups(int irxn, const std::vector& r, + const std::vector& p); void updateKc(); void registerReaction(int rxnNumber, int type, int loc) { - m_index[rxnNumber] = pair(type, loc); + m_index[rxnNumber] = std::pair(type, loc); } bool m_finalized; }; diff --git a/Cantera/src/GeneralSpeciesThermo.h b/Cantera/src/GeneralSpeciesThermo.h index a26d43da5..1d9db84ac 100644 --- a/Cantera/src/GeneralSpeciesThermo.h +++ b/Cantera/src/GeneralSpeciesThermo.h @@ -47,7 +47,7 @@ namespace Cantera { * - c[1] - c[7] coefficients for low T range * - c[8] - c[14] coefficients for high T range */ - virtual void install(string name, int index, int type, + virtual void install(std::string name, int index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure); @@ -100,7 +100,7 @@ namespace Cantera { * Note, this object owns the objects, so they are deleted * in the destructor of this object. */ - vector m_sp; + std::vector m_sp; doublereal m_tlow_max; doublereal m_thigh_min; doublereal m_p0; diff --git a/Cantera/src/Group.cpp b/Cantera/src/Group.cpp index 2cd78526c..e6c2c36f7 100755 --- a/Cantera/src/Group.cpp +++ b/Cantera/src/Group.cpp @@ -53,7 +53,8 @@ namespace Cantera { if (!ok) { m_sign = -999; m_comp.resize(n,0); } } - ostream& Group::fmt(ostream& s, const vector& esymbols) const { + std::ostream& Group::fmt(std::ostream& s, + const std::vector& esymbols) const { s << "("; int nm; bool first = true; diff --git a/Cantera/src/Group.h b/Cantera/src/Group.h index 7fd5ae532..4bdb94ff2 100755 --- a/Cantera/src/Group.h +++ b/Cantera/src/Group.h @@ -14,7 +14,7 @@ #include "ct_defs.h" -using namespace std; +//using namespace std; namespace Cantera { /** @@ -86,9 +86,9 @@ namespace Cantera { friend void verifyInputs(const Group& g1, const Group& g2) { // if (Debug::on) { // if (g1.size() != g2.size()) { -// cerr << "Group: size mismatch!" << endl; -// cerr << " group 1 = " << g1 << endl; -// cerr << " group 2 = " << g2 << endl; +// cerr << "Group: size mismatch!" << std::endl; +// cerr << " group 1 = " << g1 << std::endl; +// cerr << " group 2 = " << g2 << std::endl; // } // } } @@ -116,7 +116,7 @@ namespace Cantera { return m_comp[m]; } - ostream& fmt(ostream& s, const vector& esymbols) const; + std::ostream& fmt(std::ostream& s, const std::vector& esymbols) const; friend std::ostream& operator<<(std::ostream& s, const Group& g); diff --git a/Cantera/src/ImplicitSurfChem.cpp b/Cantera/src/ImplicitSurfChem.cpp index 6400c5cf4..82991afc8 100755 --- a/Cantera/src/ImplicitSurfChem.cpp +++ b/Cantera/src/ImplicitSurfChem.cpp @@ -17,9 +17,10 @@ #endif #include "ImplicitSurfChem.h" - #include "Integrator.h" +using namespace std; + namespace Cantera { ImplicitSurfChem::ImplicitSurfChem(vector k) diff --git a/Cantera/src/ImplicitSurfChem.h b/Cantera/src/ImplicitSurfChem.h index 799f2cdf8..b8f4fa417 100755 --- a/Cantera/src/ImplicitSurfChem.h +++ b/Cantera/src/ImplicitSurfChem.h @@ -43,7 +43,7 @@ namespace Cantera { /** * Constructor for multiple surfaces. */ - ImplicitSurfChem(vector k); + ImplicitSurfChem(std::vector k); /** * Destructor. Deletes the integrator. @@ -96,8 +96,8 @@ namespace Cantera { */ void updateState(doublereal* y); - vector m_surf; - vector m_kin; + std::vector m_surf; + std::vector m_kin; vector_int m_nsp; vector_int m_surfindex; int m_nsurf; diff --git a/Cantera/src/Integrator.h b/Cantera/src/Integrator.h index d750a2ad2..c2c0f1800 100755 --- a/Cantera/src/Integrator.h +++ b/Cantera/src/Integrator.h @@ -173,7 +173,7 @@ namespace Cantera { private: doublereal m_dummy; - void warn(string msg) const { + void warn(std::string msg) const { writelog(">>>> Warning: method "+msg+" of base class " +"Integrator called. Nothing done.\n"); } @@ -181,7 +181,7 @@ namespace Cantera { }; // defined in ODE_integrators.cpp - Integrator* newIntegrator(string itype); + Integrator* newIntegrator(std::string itype); } // namespace diff --git a/Cantera/src/InterfaceKinetics.cpp b/Cantera/src/InterfaceKinetics.cpp index 73758cfa8..3e439c59e 100644 --- a/Cantera/src/InterfaceKinetics.cpp +++ b/Cantera/src/InterfaceKinetics.cpp @@ -20,6 +20,8 @@ #include "ImplicitSurfChem.h" +using namespace std; + namespace Cantera { ////////////////////////////////////////////////////////////////// diff --git a/Cantera/src/InterfaceKinetics.h b/Cantera/src/InterfaceKinetics.h index 19f1163ad..ac55ff3e9 100644 --- a/Cantera/src/InterfaceKinetics.h +++ b/Cantera/src/InterfaceKinetics.h @@ -85,19 +85,6 @@ namespace Cantera { virtual int ID() { return cInterfaceKinetics; } virtual int type() { return cInterfaceKinetics; } - /** - * Set the electric potential in the nth phase. - * @deprecated - * - * @param n phase Index in this kinetics object. - * @param V Electric potential (volts) - */ -// void setElectricPotential(int n, doublereal V) { -// thermo(n).setElectricPotential(V); -// m_redo_rates = true; -// } - - /// /// @name Reaction Rates Of Progress /// @@ -268,7 +255,7 @@ namespace Cantera { /** * Return a string representing the reaction. */ - virtual string reactionString(int i) const { + virtual std::string reactionString(int i) const { return m_rxneqn[i]; } @@ -311,9 +298,9 @@ namespace Cantera { void updateROP(); - //const vector& reactantGroups(int i) + //const std::vector& reactantGroups(int i) // { return m_rgroups[i]; } - //const vector& productGroups(int i) + //const std::vector& productGroups(int i) // { return m_pgroups[i]; } void _update_rates_T(); @@ -334,7 +321,6 @@ namespace Cantera { vector_int m_revindex; Rate1 m_rates; - //Rate1 m_rates; bool m_redo_rates; /** @@ -344,15 +330,10 @@ namespace Cantera { * The first pair is the reactionType of the reaction. * The second pair is ... */ - mutable map > m_index; + mutable std::map > m_index; - vector m_irrev; + std::vector m_irrev; - // StoichManagerN m_reactantStoich; - //StoichManagerN m_revProductStoich; - //StoichManagerN m_irrevProductStoich; - - //StoichManagerN m_globalReactantStoich; ReactionStoichMgr m_rxnstoich; int m_nirrev; @@ -362,10 +343,7 @@ namespace Cantera { */ int m_nrev; - // map > m_rgroups; - //map > m_pgroups; - - vector m_rxntype; + std::vector m_rxntype; /** * m_rrxn is a vector of maps. m_rrxn has a length @@ -376,7 +354,7 @@ namespace Cantera { * HKM -> mutable because search sometimes creates extra * entries. To be fixed in future... */ - mutable vector > m_rrxn; + mutable std::vector > m_rrxn; /** * m_rrxn is a vector of maps. m_rrxn has a length @@ -385,10 +363,10 @@ namespace Cantera { * reaction number being the key, and the * product stoichiometric coefficient being the value. */ - mutable vector > m_prxn; + mutable std::vector > m_prxn; - vector m_rxneqn; + std::vector m_rxneqn; /** * Temporary data storage used in calculating the rates of @@ -427,12 +405,10 @@ namespace Cantera { void addGlobalReaction(const ReactionData& r); void installReagents(const ReactionData& r); - //void installGroups(int irxn, const vector& r, - // const vector& p); void updateKc(); void registerReaction(int rxnNumber, int type, int loc) { - m_index[rxnNumber] = pair(type, loc); + m_index[rxnNumber] = std::pair(type, loc); } void applyButlerVolmerCorrection(doublereal* kf); bool m_finalized; diff --git a/Cantera/src/Kinetics.h b/Cantera/src/Kinetics.h index 0ffbc19bf..e2ae8216a 100755 --- a/Cantera/src/Kinetics.h +++ b/Cantera/src/Kinetics.h @@ -171,12 +171,12 @@ namespace Cantera { * Return the phase index of a phase in the list of phases * defined within the object. * - * @param ph string name of the phase + * @param ph std::string name of the phase * * If a -1 is returned, then the phase is not defined in * the Kinetics object. */ - int phaseIndex(string ph) { + int phaseIndex(std::string ph) { if (m_phaseindex.find(ph) == m_phaseindex.end()) { return -1; } @@ -285,20 +285,20 @@ namespace Cantera { } /** - * Return the string name of the kth species in the kinetics + * Return the std::string name of the kth species in the kinetics * manager. k is an integer from 0 to ktot - 1, where ktot is * the number of species in the kinetics manager, which is the * sum of the number of species in all phases participating in - * the kinetics manager. If k is out of bounds, the string + * the kinetics manager. If k is out of bounds, the std::string * "" is returned. */ - string kineticsSpeciesName(int k) const; + std::string kineticsSpeciesName(int k) const; /** * This routine will look up a species number based on - * the input string nm. The lookup of species will + * the input std::string nm. The lookup of species will * occur for all phases listed in the kinetics object, - * unless the string ph refers to a specific phase of + * unless the std::string ph refers to a specific phase of * the object. * * return @@ -308,15 +308,15 @@ namespace Cantera { * the value -1 is returned. * - If no match is found in any phase, the value -2 is returned. */ - int kineticsSpeciesIndex(string nm, string ph = "") const; + int kineticsSpeciesIndex(std::string nm, std::string ph = "") const; /** - * This function looks up the string name of a species and + * This function looks up the std::string name of a species and * returns a reference to the ThermoPhase object of the * phase where the species resides. - * Will throw an error if the species string doesn't match. + * Will throw an error if the species std::string doesn't match. */ - thermo_t& speciesPhase(string nm); + thermo_t& speciesPhase(std::string nm); /** * This function takes as an argument the kineticsSpecies index @@ -573,10 +573,10 @@ namespace Cantera { } /** - * Return a string representing the reaction. + * Return a std::string representing the reaction. */ - virtual string reactionString(int i) const { - err("reactionString"); return ""; + virtual std::string reactionString(int i) const { + err("reactionStd::String"); return ""; } /** @@ -633,7 +633,7 @@ namespace Cantera { * m_thermo -> vector of pointers to ThermoPhase phases * that participate in the kinetics * mechanism. - * m_phaseindex -> map containing the string id of each + * m_phaseindex -> map containing the std::string id of each * ThermoPhase phase as a key and the * index of the phase within the kinetics * manager object as the value. @@ -670,12 +670,12 @@ namespace Cantera { err("addReaction"); } - virtual const vector& reactantGroups(int i) { + virtual const std::vector& reactantGroups(int i) { //err("reactantGroups"); return m_dummygroups; } - virtual const vector& productGroups(int i) { + virtual const std::vector& productGroups(int i) { //err("productGroups"); return m_dummygroups; } @@ -752,7 +752,7 @@ namespace Cantera { * NOTE: These vectors will be wrong if there are real * stoichiometric coefficients in the expression. */ - vector m_reactants; + std::vector m_reactants; /** * This is a vector of vectors containing the products for @@ -765,7 +765,7 @@ namespace Cantera { * NOTE: These vectors will be wrong if there are real * stoichiometric coefficients in the expression. */ - vector m_products; + std::vector m_products; /** * m_thermo is a vector of pointers to ThermoPhase @@ -778,7 +778,7 @@ namespace Cantera { * the source term vector, originating from the reaction * mechanism. */ - vector m_thermo; + std::vector m_thermo; /** * m_start is a vector of integers specifying the beginning position @@ -795,7 +795,7 @@ namespace Cantera { * returning the index value, so that missing phases return * -1. */ - map m_phaseindex; + std::map m_phaseindex; int m_index; /** @@ -814,8 +814,8 @@ namespace Cantera { private: - vector m_dummygroups; - void err(string m) const; + std::vector m_dummygroups; + void err(std::string m) const; }; diff --git a/Cantera/src/KineticsFactory.cpp b/Cantera/src/KineticsFactory.cpp index 24ac8cf05..e09c931f0 100644 --- a/Cantera/src/KineticsFactory.cpp +++ b/Cantera/src/KineticsFactory.cpp @@ -23,6 +23,8 @@ #include "EdgeKinetics.h" #include "importCTML.h" +using namespace std; + namespace Cantera { KineticsFactory* KineticsFactory::s_factory = 0; diff --git a/Cantera/src/KineticsFactory.h b/Cantera/src/KineticsFactory.h index ac75f295f..9270dbc1a 100644 --- a/Cantera/src/KineticsFactory.h +++ b/Cantera/src/KineticsFactory.h @@ -22,7 +22,7 @@ namespace Cantera { class UnknownKineticsModel : public CanteraError { public: - UnknownKineticsModel(string proc, string kineticsModel) : + UnknownKineticsModel(std::string proc, std::string kineticsModel) : CanteraError(proc, "Specified Kinetics model " + kineticsModel + " does not match any known type.") {} @@ -51,9 +51,9 @@ namespace Cantera { * Create a new kinetics manager. */ virtual Kinetics* newKinetics(XML_Node& phase, - vector th); + std::vector th); - virtual Kinetics* newKinetics(string model); + virtual Kinetics* newKinetics(std::string model); private: @@ -66,7 +66,7 @@ namespace Cantera { * Create a new kinetics manager. */ inline Kinetics* newKineticsMgr(XML_Node& phase, - vector th, KineticsFactory* f=0) { + std::vector th, KineticsFactory* f=0) { if (f == 0) { f = KineticsFactory::factory(); } @@ -77,7 +77,7 @@ namespace Cantera { /** * Create a new kinetics manager. */ - inline Kinetics* newKineticsMgr(string model, KineticsFactory* f=0) { + inline Kinetics* newKineticsMgr(std::string model, KineticsFactory* f=0) { if (f == 0) { f = KineticsFactory::factory(); } diff --git a/Cantera/src/LatticePhase.h b/Cantera/src/LatticePhase.h index add856adf..b13e2550f 100644 --- a/Cantera/src/LatticePhase.h +++ b/Cantera/src/LatticePhase.h @@ -138,7 +138,7 @@ namespace Cantera { mutable array_fp m_g0_RT; mutable array_fp m_s0_R; doublereal m_press; - string m_vacancy; + std::string m_vacancy; doublereal m_molar_density; private: diff --git a/Cantera/src/LatticeSolidPhase.cpp b/Cantera/src/LatticeSolidPhase.cpp index 6c8fe3a39..301d51611 100644 --- a/Cantera/src/LatticeSolidPhase.cpp +++ b/Cantera/src/LatticeSolidPhase.cpp @@ -17,6 +17,9 @@ #include "SpeciesThermo.h" #include "importCTML.h" +#include +using namespace std; + namespace Cantera { doublereal LatticeSolidPhase:: diff --git a/Cantera/src/LatticeSolidPhase.h b/Cantera/src/LatticeSolidPhase.h index 9e1162b98..c06938f15 100644 --- a/Cantera/src/LatticeSolidPhase.h +++ b/Cantera/src/LatticeSolidPhase.h @@ -70,7 +70,7 @@ namespace Cantera { virtual void setParametersFromXML(const XML_Node& eosdata); - void setLatticeMoleFractions(int n, string x); + void setLatticeMoleFractions(int n, std::string x); protected: @@ -80,7 +80,7 @@ namespace Cantera { doublereal m_press; doublereal m_molar_density; int m_nlattice; - vector m_lattice; + std::vector m_lattice; mutable vector_fp m_x; private: diff --git a/Cantera/src/Mu0Poly.cpp b/Cantera/src/Mu0Poly.cpp index 1cc1f2857..ea33c0648 100644 --- a/Cantera/src/Mu0Poly.cpp +++ b/Cantera/src/Mu0Poly.cpp @@ -14,6 +14,7 @@ #include "xml.h" #include "ctml.h" +using namespace std; using namespace ctml; namespace Cantera { @@ -317,7 +318,7 @@ namespace Cantera { * parameterization for species k into a SpeciesThermo instance, * getting the information from an XML database. */ - void installMu0ThermoFromXML(string speciesName, + void installMu0ThermoFromXML(std::string speciesName, SpeciesThermo& sp, int k, const XML_Node* Mu0Node_ptr) { diff --git a/Cantera/src/Mu0Poly.h b/Cantera/src/Mu0Poly.h index 9da8ba1ae..756ce9171 100644 --- a/Cantera/src/Mu0Poly.h +++ b/Cantera/src/Mu0Poly.h @@ -123,7 +123,7 @@ namespace Cantera { }; - void installMu0ThermoFromXML(string speciesName, + void installMu0ThermoFromXML(std::string speciesName, SpeciesThermo& sp, int k, const XML_Node* Mu0Node_ptr); } diff --git a/Cantera/src/MultiPhase.cpp b/Cantera/src/MultiPhase.cpp index 7b0b8a98d..9790db104 100644 --- a/Cantera/src/MultiPhase.cpp +++ b/Cantera/src/MultiPhase.cpp @@ -5,6 +5,8 @@ #include "DenseMatrix.h" #include "stringUtils.h" +using namespace std; + namespace Cantera { /// Constructor. diff --git a/Cantera/src/MultiPhase.h b/Cantera/src/MultiPhase.h index 5dc035c66..bcf1f40ef 100644 --- a/Cantera/src/MultiPhase.h +++ b/Cantera/src/MultiPhase.h @@ -31,7 +31,7 @@ namespace Cantera { typedef size_t index_t; typedef ThermoPhase phase_t; typedef DenseMatrix array_t; - typedef vector phase_list; + typedef std::vector phase_list; /// Constructor. The constructor takes no arguments, since /// phases are added using method addPhase. @@ -57,16 +57,16 @@ namespace Cantera { int nElements() const { return int(m_nel); } /// Name of element \a m. - string elementName(int m) const { return m_enames[m]; } + std::string elementName(int m) const { return m_enames[m]; } /// Index of element with name \a name. - int elementIndex(string name) const { return m_enamemap[name] - 1;} + int elementIndex(std::string name) const { return m_enamemap[name] - 1;} /// Number of species, summed over all phases. int nSpecies() const { return int(m_nsp); } /// Name of species with index \a k. - string speciesName(int k) const { return m_snames[k]; } + std::string speciesName(int k) const { return m_snames[k]; } /// Number of atoms of element \a m in species \a k. doublereal nAtoms(int k, int m) { @@ -216,7 +216,7 @@ namespace Cantera { void setMolesByName(compositionMap& xMap); - void setMolesByName(const string& x); + void setMolesByName(const std::string& x); void setMoles(doublereal* n); @@ -248,7 +248,7 @@ namespace Cantera { /** * Vector of the ThermoPhase Pointers. */ - vector m_phase; + std::vector m_phase; array_t m_atoms; /** * Locally storred vector of mole fractions of all species @@ -257,10 +257,10 @@ namespace Cantera { vector_fp m_moleFractions; vector_int m_spphase; vector_int m_spstart; - vector m_enames; + std::vector m_enames; vector_int m_atomicNumber; - vector m_snames; - mutable map m_enamemap; + std::vector m_snames; + mutable std::map m_enamemap; /** * Number of phases in the MultiPhase object */ @@ -277,7 +277,7 @@ namespace Cantera { index_t m_nsp; bool m_init; int m_eloc; - mutable vector m_temp_OK; + mutable std::vector m_temp_OK; doublereal m_Tmin, m_Tmax; }; @@ -285,14 +285,14 @@ namespace Cantera { size_t ip; for (ip = 0; ip < x.nPhases(); ip++) { if (x.phase(ip).name() != "") { - s << "*************** " << x.phase(ip).name() << " *****************" << endl; + s << "*************** " << x.phase(ip).name() << " *****************" << std::endl; } else { - s << "*************** Phase " << ip << " *****************" << endl; + s << "*************** Phase " << ip << " *****************" << std::endl; } - s << "Moles: " << x.phaseMoles(ip) << endl; + s << "Moles: " << x.phaseMoles(ip) << std::endl; - s << report(x.phase(ip)) << endl; + s << report(x.phase(ip)) << std::endl; } return s; } diff --git a/Cantera/src/MultiPhaseEquil.cpp b/Cantera/src/MultiPhaseEquil.cpp index 4f038296b..b69c6a98d 100644 --- a/Cantera/src/MultiPhaseEquil.cpp +++ b/Cantera/src/MultiPhaseEquil.cpp @@ -7,16 +7,6 @@ #include using namespace std; -//#if DARWIN == 1 -//#define ISNAN __isnand -//#else -//#ifdef WIN32 -//#include -//#define ISNAN _isnan -//#else -//#define ISNAN isnan -//#endif -//#endif namespace Cantera { diff --git a/Cantera/src/MultiPhaseEquil.h b/Cantera/src/MultiPhaseEquil.h index 5023cfee9..07a979a0c 100644 --- a/Cantera/src/MultiPhaseEquil.h +++ b/Cantera/src/MultiPhaseEquil.h @@ -59,7 +59,7 @@ namespace Cantera { doublereal equilibrate(int XY, doublereal err = 1.0e-9, int maxsteps = 1000, int loglevel=-99); - string reactionString(index_t j); + std::string reactionString(index_t j); doublereal error(); void printInfo(); @@ -89,7 +89,7 @@ namespace Cantera { int solutionSpecies(int n) const { return m_dsoln[m_order[n]]; } bool isStoichPhase(int n) const { return (m_dsoln[m_order[n]] == 0); } doublereal mu(int n) const { return m_mu[m_species[m_order[n]]]; } - string speciesName(int n) const { return + std::string speciesName(int n) const { return m_mix->speciesName(m_species[m_order[n]]); } index_t m_nel_mix, m_nsp_mix, m_np; @@ -103,7 +103,7 @@ namespace Cantera { vector_fp m_work, m_work2, m_work3; vector_fp m_moles, m_lastmoles, m_dxi; vector_fp m_deltaG_RT, m_mu; - vector m_majorsp; + std::vector m_majorsp; vector_int m_sortindex; vector_int m_lastsort; vector_int m_dsoln; @@ -114,7 +114,7 @@ namespace Cantera { // with invalid thermo data vector_int m_species; vector_int m_element; - vector m_solnrxn; + std::vector m_solnrxn; bool m_force; }; diff --git a/Cantera/src/Phase.cpp b/Cantera/src/Phase.cpp index a4a76efbf..ca0209704 100755 --- a/Cantera/src/Phase.cpp +++ b/Cantera/src/Phase.cpp @@ -14,6 +14,8 @@ #include "vec_functions.h" #include "ctexceptions.h" +using namespace std; + namespace Cantera { diff --git a/Cantera/src/Phase.h b/Cantera/src/Phase.h index c584ab404..e71fb3e7d 100755 --- a/Cantera/src/Phase.h +++ b/Cantera/src/Phase.h @@ -63,11 +63,11 @@ namespace Cantera { const Phase &operator=(const Phase &c); XML_Node& xml() { return *m_xml; } - string id() const { return m_id; } - void setID(string id) {m_id = id;} + std::string id() const { return m_id; } + void setID(std::string id) {m_id = id;} - string name() const { return m_name; } - void setName(string nm) { m_name = nm; } + std::string name() const { return m_name; } + void setName(std::string nm) { m_name = nm; } int index() const { return m_index; } void setIndex(int m) { m_index = m; } @@ -101,7 +101,7 @@ namespace Cantera { */ void setMoleFractionsByName(compositionMap& xMap); - void setMoleFractionsByName(const string& x); + void setMoleFractionsByName(const std::string& x); /** * Set the species mass fractions by name. @@ -110,7 +110,7 @@ namespace Cantera { */ void setMassFractionsByName(compositionMap& yMap); - void setMassFractionsByName(const string& x); + void setMassFractionsByName(const std::string& x); /** Set the temperature (K), density (kg/m^3), and mole fractions. */ void setState_TRX(doublereal t, doublereal dens, const doublereal* x); @@ -170,11 +170,11 @@ namespace Cantera { doublereal moleFraction(int k) const; - doublereal moleFraction(string name) const; + doublereal moleFraction(std::string name) const; doublereal massFraction(int k) const; - doublereal massFraction(string name) const; + doublereal massFraction(std::string name) const; /** * Charge density [C/m^3]. @@ -220,8 +220,8 @@ namespace Cantera { vector_fp m_data; XML_Node* m_xml; - string m_id; - string m_name; + std::string m_id; + std::string m_name; }; typedef Phase phase_t; diff --git a/Cantera/src/RateCoeffMgr.h b/Cantera/src/RateCoeffMgr.h index 8fff31eb3..792c14617 100755 --- a/Cantera/src/RateCoeffMgr.h +++ b/Cantera/src/RateCoeffMgr.h @@ -20,6 +20,7 @@ #include "ct_defs.h" #include "ctexceptions.h" + namespace Cantera { /** @@ -84,8 +85,8 @@ namespace Cantera { * the call to update_C. */ void update_C(const doublereal* c) { - TYPENAME_KEYWORD vector::iterator b = m_rates.begin(); - TYPENAME_KEYWORD vector::iterator e = m_rates.end(); + TYPENAME_KEYWORD std::vector::iterator b = m_rates.begin(); + TYPENAME_KEYWORD std::vector::iterator e = m_rates.end(); int i = 0; for (; b != e; ++b, ++i) { b->update_C(c); @@ -101,8 +102,8 @@ namespace Cantera { * preloaded with the constant rate coefficients. */ void update(doublereal T, doublereal logT, doublereal* values) { - TYPENAME_KEYWORD vector::const_iterator b = m_rates.begin(); - TYPENAME_KEYWORD vector::const_iterator e = m_rates.end(); + TYPENAME_KEYWORD std::vector::const_iterator b = m_rates.begin(); + TYPENAME_KEYWORD std::vector::const_iterator e = m_rates.end(); doublereal recipT = 1.0/T; int i = 0; for (; b != e; ++b, ++i) { @@ -111,13 +112,13 @@ namespace Cantera { } } - void writeUpdate(ostream & output1, string key) { + void writeUpdate(std::ostream & output1, std::string key) { output1 << key; } protected: - vector m_rates; - vector m_rxn; + std::vector m_rates; + std::vector m_rxn; array_fp m_const; // not used }; diff --git a/Cantera/src/ReactionData.h b/Cantera/src/ReactionData.h index 113ab2c18..79c30cb65 100755 --- a/Cantera/src/ReactionData.h +++ b/Cantera/src/ReactionData.h @@ -12,11 +12,6 @@ #ifndef CT_REACTION_DATA_H #define CT_REACTION_DATA_H -//#include -//#include -//#include -//using namespace std; - #include "reaction_defs.h" namespace Cantera { @@ -45,9 +40,9 @@ namespace Cantera { vector_fp order; vector_fp rstoich; vector_fp pstoich; - vector rgroups; - vector pgroups; - map thirdBodyEfficiencies; + std::vector rgroups; + std::vector pgroups; + std::map thirdBodyEfficiencies; bool reversible; int rateCoeffType; vector_fp rateCoeffParameters; @@ -55,7 +50,7 @@ namespace Cantera { int falloffType; vector_fp falloffParameters; int error; - string equation; + std::string equation; doublereal default_3b_eff; vector_fp cov; bool global; diff --git a/Cantera/src/ReactionPath.cpp b/Cantera/src/ReactionPath.cpp index e417df64c..28fcc9eda 100755 --- a/Cantera/src/ReactionPath.cpp +++ b/Cantera/src/ReactionPath.cpp @@ -21,6 +21,7 @@ #include "reaction_defs.h" #include "Group.h" +using namespace std; namespace Cantera { diff --git a/Cantera/src/ReactionPath.h b/Cantera/src/ReactionPath.h index 80c42f8d7..f2ccf67d6 100755 --- a/Cantera/src/ReactionPath.h +++ b/Cantera/src/ReactionPath.h @@ -24,7 +24,7 @@ namespace Cantera { enum flow_t { NetFlow, OneWayFlow }; - Group parseGroupString(string str, vector& esyms); + Group parseGroupString(std::string str, std::vector& esyms); // forward references class Path; @@ -35,7 +35,7 @@ namespace Cantera { class SpeciesNode { public: - typedef vector path_list; + typedef std::vector path_list; /// Default constructor SpeciesNode() : number(-1), name(""), value(0.0), @@ -46,7 +46,7 @@ namespace Cantera { // public attributes int number; ///< Species number - string name; ///< Label on graph + std::string name; ///< Label on graph doublereal value; ///< May be used to set node appearance bool visible; ///< Visible on graph; @@ -88,7 +88,7 @@ namespace Cantera { public: - typedef map rxn_path_map; + typedef std::map rxn_path_map; /** * Constructor. Construct a one-way path from @@ -99,7 +99,7 @@ namespace Cantera { /// Destructor virtual ~Path() {} - void addReaction(int rxnNumber, doublereal value, string label = ""); + void addReaction(int rxnNumber, doublereal value, std::string label = ""); /// Upstream node. const SpeciesNode* begin() const { return m_a; } @@ -129,11 +129,11 @@ namespace Cantera { /// Map from reaction number to flow from that reaction in this path. const rxn_path_map& reactionMap() { return m_rxn; } - void writeLabel(ostream& s, doublereal threshold = 0.005); + void writeLabel(std::ostream& s, doublereal threshold = 0.005); protected: - map m_label; + std::map m_label; SpeciesNode *m_a, *m_b; rxn_path_map m_rxn; doublereal m_total; @@ -169,8 +169,8 @@ namespace Cantera { return (m_nodes[k] != 0); } - void writeData(ostream& s); - void exportToDot(ostream& s); + void writeData(std::ostream& s); + void exportToDot(std::ostream& s); void add(ReactionPathDiagram& d); SpeciesNode* node(int k) { return m_nodes[k]; } Path* path(int k1, int k2) { return m_paths[k1][k2]; } @@ -178,43 +178,43 @@ namespace Cantera { int nPaths() { return static_cast(m_pathlist.size()); } int nNodes() { return static_cast(m_nodes.size()); } - void addNode(int k, string nm, doublereal x = 0.0); + void addNode(int k, std::string nm, doublereal x = 0.0); void displayOnly(int k=-1) { m_local = k; } void linkNodes(int k1, int k2, int rxn, doublereal value, - string legend = ""); + std::string legend = ""); - void include(string aaname) { m_include.push_back(aaname); } - void exclude(string aaname) { m_exclude.push_back(aaname); } - void include(vector& names) { + void include(std::string aaname) { m_include.push_back(aaname); } + void exclude(std::string aaname) { m_exclude.push_back(aaname); } + void include(std::vector& names) { int n = static_cast(names.size()); for (int i = 0; i < n; i++) m_include.push_back(names[i]); } - void exclude(vector& names) { + void exclude(std::vector& names) { int n = static_cast(names.size()); for (int i = 0; i < n; i++) m_exclude.push_back(names[i]); } - vector& included() { return m_include; } - vector& excluded() { return m_exclude; } + std::vector& included() { return m_include; } + std::vector& excluded() { return m_exclude; } vector_int species(); vector_int reactions(); void findMajorPaths(doublereal threshold, int lda, doublereal* a); - void setFont(string font) { + void setFont(std::string font) { m_font = font; } // public attributes - string title; - string bold_color; - string normal_color; - string dashed_color; - string element; - string m_font; + std::string title; + std::string bold_color; + std::string normal_color; + std::string dashed_color; + std::string element; + std::string m_font; doublereal threshold, bold_min, dashed_max, label_min; doublereal x_size, y_size; - string name, dot_options; + std::string name, dot_options; flow_t flow_type; double scale; double arrow_width; @@ -224,13 +224,13 @@ namespace Cantera { protected: doublereal m_flxmax; - map > m_paths; - map m_nodes; - vector m_pathlist; - vector m_include; - vector m_exclude; + std::map > m_paths; + std::map m_nodes; + std::vector m_pathlist; + std::vector m_include; + std::vector m_exclude; vector_int m_speciesNumber; - map m_rxns; + std::map m_rxns; int m_local; }; @@ -242,14 +242,14 @@ namespace Cantera { ReactionPathBuilder() {} virtual ~ReactionPathBuilder() {} - int init(ostream& logfile, Kinetics& s); + int init(std::ostream& logfile, Kinetics& s); - int build(Kinetics& s, string element, ostream& output, + int build(Kinetics& s, std::string element, std::ostream& output, ReactionPathDiagram& r, bool quiet=false); - int findGroups(ostream& logfile, Kinetics& s); + int findGroups(std::ostream& logfile, Kinetics& s); - void writeGroup(ostream& out, const Group& g); + void writeGroup(std::ostream& out, const Group& g); protected: void findElements(Kinetics& kin); @@ -260,17 +260,17 @@ namespace Cantera { vector_fp m_ropf; vector_fp m_ropr; array_fp m_x; - vector m_reac; - vector m_prod; + std::vector m_reac; + std::vector m_prod; DenseMatrix m_elatoms; - vector > m_groups; - vector m_sgroup; - vector m_elementSymbols; - // map m_warn; - map > > m_transfer; - vector m_determinate; + std::vector > m_groups; + std::vector m_sgroup; + std::vector m_elementSymbols; + // std::map m_warn; + std::map > > m_transfer; + std::vector m_determinate; Array2D m_atoms; - map m_enamemap; + std::map m_enamemap; }; } diff --git a/Cantera/src/ReactionStoichMgr.cpp b/Cantera/src/ReactionStoichMgr.cpp index 1ffb45af5..83499d311 100644 --- a/Cantera/src/ReactionStoichMgr.cpp +++ b/Cantera/src/ReactionStoichMgr.cpp @@ -22,6 +22,8 @@ #include "diagnostics.h" #include "ReactionData.h" +using namespace std; + namespace Cantera { // create stoichiometry managers for the reactants of all reactions, diff --git a/Cantera/src/ReactionStoichMgr.h b/Cantera/src/ReactionStoichMgr.h index e30600ed0..c3bb2d7e9 100644 --- a/Cantera/src/ReactionStoichMgr.h +++ b/Cantera/src/ReactionStoichMgr.h @@ -218,15 +218,15 @@ namespace Cantera { */ virtual void multiplyRevProducts(const doublereal* c, doublereal* r); - virtual void write(string filename); + virtual void write(std::string filename); protected: - void writeCreationRates(ostream& f); - void writeDestructionRates(ostream& f); - void writeNetProductionRates(ostream& f); - void writeMultiplyReactants(ostream& f); - void writeMultiplyRevProducts(ostream& f); + void writeCreationRates(std::ostream& f); + void writeDestructionRates(std::ostream& f); + void writeNetProductionRates(std::ostream& f); + void writeMultiplyReactants(std::ostream& f); + void writeMultiplyRevProducts(std::ostream& f); StoichManagerN* m_reactants; StoichManagerN* m_revproducts; StoichManagerN* m_irrevproducts; diff --git a/Cantera/src/ResidEval.h b/Cantera/src/ResidEval.h index ff3069037..d2c3be01f 100755 --- a/Cantera/src/ResidEval.h +++ b/Cantera/src/ResidEval.h @@ -88,8 +88,8 @@ namespace Cantera { protected: - map m_alg; - map m_constrain; + std::map m_alg; + std::map m_constrain; private: diff --git a/Cantera/src/RxnRates.h b/Cantera/src/RxnRates.h index bcda6ee80..44f0c6a70 100755 --- a/Cantera/src/RxnRates.h +++ b/Cantera/src/RxnRates.h @@ -100,12 +100,12 @@ namespace Cantera { } - void writeUpdateRHS(ostream& s) const { - s << " exp(" << m_logA; - if (m_b != 0.0) s << " + " << m_b << " * tlog"; - if (m_E != 0.0) s << " - " << m_E << " * rt"; - s << ");" << endl; - } + void writeUpdateRHS(std::ostream& s) const { + s << " exp(" << m_logA; + if (m_b != 0.0) s << " + " << m_b << " * tlog"; + if (m_E != 0.0) s << " - " << m_E << " * rt"; + s << ");" << std::endl; + } doublereal activationEnergy_R() const { return m_E; @@ -123,13 +123,17 @@ namespace Cantera { public: static int type(){ return ARRHENIUS_SUM; } ArrheniusSum() : m_nterms(0) {} - ArrheniusSum( int csize, const doublereal* c ) { - m_nterms = 0; - addArrheniusTerm(c[0], c[1], c[2]); - } + void addArrheniusTerm(doublereal A, doublereal b, doublereal E) { - m_terms.push_back(Arrhenius(A, b, E)); - m_nterms++; + if (A > 0.0) { + m_terms.push_back(Arrhenius(A, b, E)); + m_sign.push_back(1); + } + else if (A < 0.0) { + m_terms.push_back(Arrhenius(-A, b, E)); + m_sign.push_back(-1); + } + m_nterms++; } void update_C(const doublereal* c) {} @@ -143,7 +147,7 @@ namespace Cantera { doublereal f, fsum = 0.0; for (n = 0; n < m_nterms; n++) { f = m_terms[n].updateRC(logT, recipT); - fsum += f; + fsum += m_sign[n]*f; } return log(fsum); } @@ -160,19 +164,20 @@ namespace Cantera { doublereal f, fsum = 0.0; for (n = 0; n < m_nterms; n++) { f = m_terms[n].updateRC(logT, recipT); - fsum += f; + fsum += m_sign[n]*f; } return fsum; } - void writeUpdateRHS(ostream& s) const { + void writeUpdateRHS(std::ostream& s) const { ; } - static bool alwaysComputeRate() { return true;} + static bool alwaysComputeRate() { return false;} protected: - vector m_terms; + std::vector m_terms; + vector_int m_sign; int m_nterms; }; @@ -320,7 +325,7 @@ namespace Cantera { return exp(lres); } - void writeUpdateRHS(ostream& s) const {} + void writeUpdateRHS(std::ostream& s) const {} protected: doublereal delta_s0, delta_e0; diff --git a/Cantera/src/SpeciesThermo.h b/Cantera/src/SpeciesThermo.h index b2efc6b8f..485575dda 100755 --- a/Cantera/src/SpeciesThermo.h +++ b/Cantera/src/SpeciesThermo.h @@ -84,7 +84,7 @@ namespace Cantera { * parameterization. * @see speciesThermoTypes.h */ - virtual void install(string name, int index, int type, + virtual void install(std::string name, int index, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, diff --git a/Cantera/src/SpeciesThermoFactory.cpp b/Cantera/src/SpeciesThermoFactory.cpp index 63ef63b8d..3b6bbd8cc 100755 --- a/Cantera/src/SpeciesThermoFactory.cpp +++ b/Cantera/src/SpeciesThermoFactory.cpp @@ -9,6 +9,8 @@ #pragma warning(disable:4786) #endif +using namespace std; + #include "SpeciesThermoFactory.h" #include "SpeciesThermo.h" @@ -41,7 +43,7 @@ namespace Cantera { int& has_nasa, int& has_shomate, int& has_simple, int &has_other) { const XML_Node& sparray = *node; - vector sp; + std::vector sp; // get all of the species nodes sparray.getChildren("species",sp); @@ -88,7 +90,7 @@ namespace Cantera { } SpeciesThermo* SpeciesThermoFactory:: - newSpeciesThermo(vector nodes) { + newSpeciesThermo(std::vector nodes) { int n = static_cast(nodes.size()); int inasa = 0, ishomate = 0, isimple = 0, iother = 0; for (int j = 0; j < n; j++) { @@ -111,7 +113,7 @@ namespace Cantera { * @todo is this used? */ SpeciesThermo* SpeciesThermoFactory:: - newSpeciesThermoOpt(vector nodes) { + newSpeciesThermoOpt(std::vector nodes) { int n = static_cast(nodes.size()); int inasa = 0, ishomate = 0, isimple = 0, iother = 0; for (int j = 0; j < n; j++) { @@ -156,7 +158,7 @@ namespace Cantera { /// Check the continuity of properties at the midpoint /// temperature. - void NasaThermo::checkContinuity(string name, double tmid, const doublereal* clow, + void NasaThermo::checkContinuity(std::string name, double tmid, const doublereal* clow, doublereal* chigh) { // heat capacity @@ -209,7 +211,7 @@ namespace Cantera { * This is called by method installThermoForSpecies if a NASA * block is found in the XML input. */ - static void installNasaThermoFromXML(string speciesName, + static void installNasaThermoFromXML(std::string speciesName, SpeciesThermo& sp, int k, const XML_Node* f0ptr, const XML_Node* f1ptr) { doublereal tmin0, tmax0, tmin1, tmax1, tmin, tmid, tmax; @@ -280,7 +282,7 @@ namespace Cantera { * Install a NASA96 polynomial thermodynamic property * parameterization for species k into a SpeciesThermo instance. */ - static void installNasa96ThermoFromXML(string speciesName, + static void installNasa96ThermoFromXML(std::string speciesName, SpeciesThermo& sp, int k, const XML_Node* f0ptr, const XML_Node* f1ptr) { doublereal tmin0, tmax0, tmin1, tmax1, tmin, tmid, tmax; @@ -340,7 +342,7 @@ namespace Cantera { * Install a Shomate polynomial thermodynamic property * parameterization for species k. */ - static void installShomateThermoFromXML(string speciesName, + static void installShomateThermoFromXML(std::string speciesName, SpeciesThermo& sp, int k, const XML_Node* f0ptr, const XML_Node* f1ptr) { doublereal tmin0, tmax0, tmin1, tmax1, tmin, tmid, tmax; @@ -395,7 +397,7 @@ namespace Cantera { * Install a constant-cp thermodynamic property * parameterization for species k. */ - static void installSimpleThermoFromXML(string speciesName, + static void installSimpleThermoFromXML(std::string speciesName, SpeciesThermo& sp, int k, const XML_Node& f) { doublereal tmin, tmax; @@ -431,7 +433,7 @@ namespace Cantera { s["name"], ""); } const XML_Node& thermo = s.child("thermo"); - const vector& tp = thermo.children(); + const std::vector& tp = thermo.children(); int nc = static_cast(tp.size()); if (nc == 1) { const XML_Node* f = tp[0]; diff --git a/Cantera/src/SpeciesThermoFactory.h b/Cantera/src/SpeciesThermoFactory.h index 546751fee..08bdb6a7b 100755 --- a/Cantera/src/SpeciesThermoFactory.h +++ b/Cantera/src/SpeciesThermoFactory.h @@ -27,8 +27,8 @@ namespace Cantera { */ class UnknownSpeciesThermoModel: public CanteraError { public: - UnknownSpeciesThermoModel(string proc, string spName, - string speciesThermoModel) : + UnknownSpeciesThermoModel(std::string proc, std::string spName, + std::string speciesThermoModel) : CanteraError(proc, "species " + spName + ": Specified speciesThermoPhase model " + speciesThermoModel + @@ -86,8 +86,8 @@ namespace Cantera { virtual SpeciesThermo* newSpeciesThermo(int type); virtual SpeciesThermo* newSpeciesThermo(XML_Node* node); - virtual SpeciesThermo* newSpeciesThermo(vector nodes); - virtual SpeciesThermo* newSpeciesThermoOpt(vector nodes); + virtual SpeciesThermo* newSpeciesThermo(std::vector nodes); + virtual SpeciesThermo* newSpeciesThermoOpt(std::vector nodes); virtual void installThermoForSpecies(int k, const XML_Node& s, @@ -138,7 +138,7 @@ namespace Cantera { return sptherm; } - inline SpeciesThermo* newSpeciesThermoMgr(vector nodes, + inline SpeciesThermo* newSpeciesThermoMgr(std::vector nodes, SpeciesThermoFactory* f=0, bool opt=false) { if (f == 0) { f = SpeciesThermoFactory::factory(); diff --git a/Cantera/src/SpeciesThermoMgr.h b/Cantera/src/SpeciesThermoMgr.h index 8db52e90d..845553f98 100755 --- a/Cantera/src/SpeciesThermoMgr.h +++ b/Cantera/src/SpeciesThermoMgr.h @@ -16,7 +16,7 @@ #include "stringUtils.h" #include "SpeciesThermo.h" #include -using namespace std; +//using namespace std; namespace Cantera { @@ -72,7 +72,7 @@ namespace Cantera { */ class RefPressureMismatch : public CanteraError { public: - RefPressureMismatch(string proc, doublereal prnew, + RefPressureMismatch(std::string proc, doublereal prnew, doublereal prold) : CanteraError(proc, "Species reference pressure (" + fp2str(prnew) + ") does not match previously-defined " @@ -83,7 +83,7 @@ namespace Cantera { class UnknownSpeciesThermo : public CanteraError { public: - UnknownSpeciesThermo(string proc, int type) : + UnknownSpeciesThermo(std::string proc, int type) : CanteraError(proc, "Specified species " "parameterization type (" + int2str(type) + ") does not match any known type.") {} @@ -104,7 +104,7 @@ namespace Cantera { SpeciesThermoDuo() {} virtual ~SpeciesThermoDuo(){} - virtual void install(string name, int sp, int type, + virtual void install(std::string name, int sp, int type, const doublereal* c, doublereal minTemp, doublereal maxTemp, @@ -146,7 +146,7 @@ namespace Cantera { } virtual int reportType(int k) const { - map::const_iterator p = speciesToType.find(k); + std::map::const_iterator p = speciesToType.find(k); if (p != speciesToType.end()) { const int type = p->second; return type; @@ -176,7 +176,7 @@ namespace Cantera { T1 m_thermo1; T2 m_thermo2; doublereal m_p0; - map speciesToType; + std::map speciesToType; }; //#define REMOVE_FOR_V155 @@ -194,7 +194,7 @@ namespace Cantera { SpeciesThermo1() : m_pref(0.0) {} virtual ~SpeciesThermo1(){} - virtual void install(string name, int sp, int type, const vector_fp& c) { + virtual void install(std::string name, int sp, int type, const vector_fp& c) { m_thermo.push_back(T(sp, c)); if (m_pref) { if (m_thermo.begin()->refPressure() != m_pref) { @@ -242,7 +242,7 @@ namespace Cantera { private: - vector m_thermo; + std::vector m_thermo; doublereal m_pref; }; //#endif diff --git a/Cantera/src/StoichManager.h b/Cantera/src/StoichManager.h index 951a443d3..f59c9d0e1 100755 --- a/Cantera/src/StoichManager.h +++ b/Cantera/src/StoichManager.h @@ -148,7 +148,7 @@ They are designed to explicitly unroll loops over species or reactions for return 0.0; } - inline static string fmt(string r, int n) { return r + "[" + int2str(n) + "]"; } + inline static std::string fmt(std::string r, int n) { return r + "[" + int2str(n) + "]"; } /** @@ -163,7 +163,7 @@ They are designed to explicitly unroll loops over species or reactions for C1( int rxn = 0, int ic0 = 0) : m_rxn (rxn), m_ic0 (ic0) {} - int data(vector& ic) { + int data(std::vector& ic) { ic.resize(1); ic[0] = m_ic0; return m_rxn; @@ -193,21 +193,21 @@ They are designed to explicitly unroll loops over species or reactions for int speciesIndex(int n) const { return m_ic0; } int nSpecies() { return 1;} - void writeMultiply(string r, map& out) { + void writeMultiply(std::string r, std::map& out) { out[m_rxn] = fmt(r, m_ic0); } - void writeIncrementReaction(string r, map& out) { + void writeIncrementReaction(std::string r, std::map& out) { out[m_rxn] += " + "+fmt(r, m_ic0); } - void writeDecrementReaction(string r, map& out) { + void writeDecrementReaction(std::string r, std::map& out) { out[m_rxn] += " - "+fmt(r, m_ic0); } - void writeIncrementSpecies(string r, map& out) { + void writeIncrementSpecies(std::string r, std::map& out) { out[m_ic0] += " + "+fmt(r, m_rxn); } - void writeDecrementSpecies(string r, map& out) { + void writeDecrementSpecies(std::string r, std::map& out) { out[m_ic0] += " - "+fmt(r, m_rxn); } @@ -226,7 +226,7 @@ They are designed to explicitly unroll loops over species or reactions for C2( int rxn = 0, int ic0 = 0, int ic1 = 0) : m_rxn (rxn), m_ic0 (ic0), m_ic1 (ic1) {} - int data(vector& ic) { + int data(std::vector& ic) { ic.resize(2); ic[0] = m_ic0; ic[1] = m_ic1; @@ -259,23 +259,23 @@ They are designed to explicitly unroll loops over species or reactions for int speciesIndex(int n) const { return (n == 0 ? m_ic0 : m_ic1); } int nSpecies() { return 2;} - void writeMultiply(string r, map& out) { + void writeMultiply(std::string r, std::map& out) { out[m_rxn] = fmt(r, m_ic0) + " * " + fmt(r, m_ic1); } - void writeIncrementReaction(string r, map& out) { + void writeIncrementReaction(std::string r, std::map& out) { out[m_rxn] += " + "+fmt(r, m_ic0)+" + "+fmt(r, m_ic1); } - void writeDecrementReaction(string r, map& out) { + void writeDecrementReaction(std::string r, std::map& out) { out[m_rxn] += " - "+fmt(r, m_ic0)+" - "+fmt(r, m_ic1); } - void writeIncrementSpecies(string r, map& out) { - string s = " + "+fmt(r, m_rxn); + void writeIncrementSpecies(std::string r, std::map& out) { + std::string s = " + "+fmt(r, m_rxn); out[m_ic0] += s; out[m_ic1] += s; } - void writeDecrementSpecies(string r, map& out) { - string s = " - "+fmt(r, m_rxn); + void writeDecrementSpecies(std::string r, std::map& out) { + std::string s = " - "+fmt(r, m_rxn); out[m_ic0] += s; out[m_ic1] += s; } @@ -304,7 +304,7 @@ They are designed to explicitly unroll loops over species or reactions for C3( int rxn = 0, int ic0 = 0, int ic1 = 0, int ic2 = 0) : m_rxn (rxn), m_ic0 (ic0), m_ic1 (ic1), m_ic2 (ic2) {} - int data(vector& ic) { + int data(std::vector& ic) { ic.resize(3); ic[0] = m_ic0; ic[1] = m_ic1; @@ -340,23 +340,23 @@ They are designed to explicitly unroll loops over species or reactions for int speciesIndex(int n) const { return (n == 0 ? m_ic0 : (n == 1 ? m_ic1 : m_ic2)); } int nSpecies() { return 3;} - void writeMultiply(string r, map& out) { + void writeMultiply(std::string r, std::map& out) { out[m_rxn] = fmt(r, m_ic0) + " * " + fmt(r, m_ic1) + " * " + fmt(r, m_ic2); } - void writeIncrementReaction(string r, map& out) { + void writeIncrementReaction(std::string r, std::map& out) { out[m_rxn] += " + "+fmt(r, m_ic0)+" + "+fmt(r, m_ic1)+" + "+fmt(r, m_ic2); } - void writeDecrementReaction(string r, map& out) { + void writeDecrementReaction(std::string r, std::map& out) { out[m_rxn] += " - "+fmt(r, m_ic0)+" - "+fmt(r, m_ic1)+" - "+fmt(r, m_ic2); } - void writeIncrementSpecies(string r, map& out) { - string s = " + "+fmt(r, m_rxn); + void writeIncrementSpecies(std::string r, std::map& out) { + std::string s = " + "+fmt(r, m_rxn); out[m_ic0] += s; out[m_ic1] += s; out[m_ic2] += s; } - void writeDecrementSpecies(string r, map& out) { - string s = " - "+fmt(r, m_rxn); + void writeDecrementSpecies(std::string r, std::map& out) { + std::string s = " - "+fmt(r, m_rxn); out[m_ic0] += s; out[m_ic1] += s; out[m_ic2] += s; @@ -389,7 +389,7 @@ They are designed to explicitly unroll loops over species or reactions for } } - int data(vector& ic) { + int data(std::vector& ic) { ic.resize(m_n); int n; for (n = 0; n < m_n; n++) ic[n] = m_ic[n]; @@ -431,7 +431,7 @@ They are designed to explicitly unroll loops over species or reactions for -= m_stoich[n]*input[m_ic[n]]; } - void writeMultiply(string r, map& out) { + void writeMultiply(std::string r, std::map& out) { int n; out[m_rxn] = ""; for (n = 0; n < m_n; n++) { @@ -443,28 +443,28 @@ They are designed to explicitly unroll loops over species or reactions for out[m_rxn] += " * "; } } - void writeIncrementReaction(string r, map& out) { + void writeIncrementReaction(std::string r, std::map& out) { int n; for (n = 0; n < m_n; n++) { out[m_rxn] += " + "+fp2str(m_stoich[n]) + "*" + fmt(r, m_ic[n]); } } - void writeDecrementReaction(string r, map& out) { + void writeDecrementReaction(std::string r, std::map& out) { int n; for (n = 0; n < m_n; n++) { out[m_rxn] += " - "+fp2str(m_stoich[n]) + "*" + fmt(r, m_ic[n]); } } - void writeIncrementSpecies(string r, map& out) { - string s = fmt(r, m_rxn); + void writeIncrementSpecies(std::string r, std::map& out) { + std::string s = fmt(r, m_rxn); int n; for (n = 0; n < m_n; n++) { out[m_ic[n]] += " + "+fp2str(m_stoich[n]) + "*" + s; } } - void writeDecrementSpecies(string r, map& out) { - string s = fmt(r, m_rxn); + void writeDecrementSpecies(std::string r, std::map& out) { + std::string s = fmt(r, m_rxn); int n; for (n = 0; n < m_n; n++) { out[m_ic[n]] += " - "+fp2str(m_stoich[n]) + "*" + s; @@ -516,32 +516,32 @@ They are designed to explicitly unroll loops over species or reactions for template - inline static void _writeIncrementSpecies(InputIter begin, InputIter end, string r, - map& out) { + inline static void _writeIncrementSpecies(InputIter begin, InputIter end, std::string r, + std::map& out) { for (; begin != end; ++begin) begin->writeIncrementSpecies(r, out); } template - inline static void _writeDecrementSpecies(InputIter begin, InputIter end, string r, - map& out) { + inline static void _writeDecrementSpecies(InputIter begin, InputIter end, std::string r, + std::map& out) { for (; begin != end; ++begin) begin->writeDecrementSpecies(r, out); } template - inline static void _writeIncrementReaction(InputIter begin, InputIter end, string r, - map& out) { + inline static void _writeIncrementReaction(InputIter begin, InputIter end, std::string r, + std::map& out) { for (; begin != end; ++begin) begin->writeIncrementReaction(r, out); } template - inline static void _writeDecrementReaction(InputIter begin, InputIter end, string r, - map& out) { + inline static void _writeDecrementReaction(InputIter begin, InputIter end, std::string r, + std::map& out) { for (; begin != end; ++begin) begin->writeDecrementReaction(r, out); } template - inline static void _writeMultiply(InputIter begin, InputIter end, string r, - map& out) { + inline static void _writeMultiply(InputIter begin, InputIter end, std::string r, + std::map& out) { for (; begin != end; ++begin) begin->writeMultiply(r, out); } @@ -708,35 +708,35 @@ They are designed to explicitly unroll loops over species or reactions for _decrementReactions(m_cn_list.begin(), m_cn_list.end(), input, output); } - void writeIncrementSpecies(string r, map& out) { + void writeIncrementSpecies(std::string r, std::map& out) { _writeIncrementSpecies(m_c1_list.begin(), m_c1_list.end(), r, out); _writeIncrementSpecies(m_c2_list.begin(), m_c2_list.end(), r, out); _writeIncrementSpecies(m_c3_list.begin(), m_c3_list.end(), r, out); _writeIncrementSpecies(m_cn_list.begin(), m_cn_list.end(), r, out); } - void writeDecrementSpecies(string r, map& out) { + void writeDecrementSpecies(std::string r, std::map& out) { _writeDecrementSpecies(m_c1_list.begin(), m_c1_list.end(), r, out); _writeDecrementSpecies(m_c2_list.begin(), m_c2_list.end(), r, out); _writeDecrementSpecies(m_c3_list.begin(), m_c3_list.end(), r, out); _writeDecrementSpecies(m_cn_list.begin(), m_cn_list.end(), r, out); } - void writeIncrementReaction(string r, map& out) { + void writeIncrementReaction(std::string r, std::map& out) { _writeIncrementReaction(m_c1_list.begin(), m_c1_list.end(), r, out); _writeIncrementReaction(m_c2_list.begin(), m_c2_list.end(), r, out); _writeIncrementReaction(m_c3_list.begin(), m_c3_list.end(), r, out); _writeIncrementReaction(m_cn_list.begin(), m_cn_list.end(), r, out); } - void writeDecrementReaction(string r, map& out) { + void writeDecrementReaction(std::string r, std::map& out) { _writeDecrementReaction(m_c1_list.begin(), m_c1_list.end(), r, out); _writeDecrementReaction(m_c2_list.begin(), m_c2_list.end(), r, out); _writeDecrementReaction(m_c3_list.begin(), m_c3_list.end(), r, out); _writeDecrementReaction(m_cn_list.begin(), m_cn_list.end(), r, out); } - void writeMultiply(string r, map& out) { + void writeMultiply(std::string r, std::map& out) { _writeMultiply(m_c1_list.begin(), m_c1_list.end(), r, out); _writeMultiply(m_c2_list.begin(), m_c2_list.end(), r, out); _writeMultiply(m_c3_list.begin(), m_c3_list.end(), r, out); @@ -746,20 +746,20 @@ They are designed to explicitly unroll loops over species or reactions for private: - vector m_c1_list; - vector m_c2_list; - vector m_c3_list; - vector m_cn_list; + std::vector m_c1_list; + std::vector m_c2_list; + std::vector m_c3_list; + std::vector m_cn_list; /** - * Mapping with the Reaction Number as key and the Number of species + * Std::Mapping with the Reaction Number as key and the Number of species * as the value. */ - map m_n; + std::map m_n; /** - * Mapping with the Reaction Number as key and the placement in the + * Std::Mapping with the Reaction Number as key and the placement in the * vector of reactions list( i.e., m_c1_list[]) as key */ - map m_loc; + std::map m_loc; }; #undef INCL_STOICH_WRITER @@ -785,7 +785,7 @@ They are designed to explicitly unroll loops over species or reactions for void add(int rxn, const vector_int& k, const vector_fp& order, const vector_fp& stoich) { int n, nn = k.size(); - string s; + std::string s; for (n = 0; n < nn; n++) { if (order[n] == 1.0) m_mult[rxn] += "*c[" + int2str(k[n]) + "]"; @@ -807,14 +807,14 @@ They are designed to explicitly unroll loops over species or reactions for } } - string mult(int rxn) { return m_mult[rxn]; } - string incrSpec(int k, string) { return m_is[k]; } - string decrSpec(int k) { return m_ds[k]; } - string incrRxn(int rxn) { return m_ir[rxn]; } - string decrRxn(int rxn) { return m_dr[rxn]; } + std::string mult(int rxn) { return m_mult[rxn]; } + std::string incrSpec(int k, std::string) { return m_is[k]; } + std::string decrSpec(int k) { return m_ds[k]; } + std::string incrRxn(int rxn) { return m_ir[rxn]; } + std::string decrRxn(int rxn) { return m_dr[rxn]; } private: - map m_mult, m_ir, m_dr, m_is, m_ds; + std::map m_mult, m_ir, m_dr, m_is, m_ds; }; #endif diff --git a/Cantera/src/SurfPhase.h b/Cantera/src/SurfPhase.h index f4f592cec..2969ea930 100644 --- a/Cantera/src/SurfPhase.h +++ b/Cantera/src/SurfPhase.h @@ -100,7 +100,7 @@ namespace Cantera { * Set the coverages from a string of colon-separated * name:value pairs. */ - void setCoveragesByName(string cov); + void setCoveragesByName(std::string cov); /** * Get the coverages. Array theta must be at least as long as diff --git a/Cantera/src/ThermoFactory.cpp b/Cantera/src/ThermoFactory.cpp index 1fd2bc558..4bb0bafdb 100644 --- a/Cantera/src/ThermoFactory.cpp +++ b/Cantera/src/ThermoFactory.cpp @@ -43,6 +43,8 @@ #include "LatticePhase.h" #endif +using namespace std; + namespace Cantera { ThermoFactory* ThermoFactory::s_factory = 0; diff --git a/Cantera/src/ThermoFactory.h b/Cantera/src/ThermoFactory.h index 9b9709457..11e23fed8 100644 --- a/Cantera/src/ThermoFactory.h +++ b/Cantera/src/ThermoFactory.h @@ -23,7 +23,7 @@ namespace Cantera { class UnknownThermoPhaseModel : public CanteraError { public: - UnknownThermoPhaseModel(string proc, string thermoModel) : + UnknownThermoPhaseModel(std::string proc, std::string thermoModel) : CanteraError(proc, "Specified ThermoPhase model " + thermoModel + " does not match any known type.") {} @@ -62,8 +62,8 @@ namespace Cantera { * Create a new thermodynamic property manager. * @param type the type to be created. */ - //virtual ThermoPhase* newThermo(XML_Node& node, string id); - virtual ThermoPhase* newThermoPhase(string model); + //virtual ThermoPhase* newThermo(XML_Node& node, std::string id); + virtual ThermoPhase* newThermoPhase(std::string model); private: @@ -75,7 +75,7 @@ namespace Cantera { /** * Create a new thermo manager instance. */ -// inline ThermoPhase* newThermoMgr(XML_Node& root, string id, +// inline ThermoPhase* newThermoMgr(XML_Node& root, std::string id, // ThermoFactory* f=0) { // if (f == 0) { // f = ThermoFactory::factory(); @@ -87,7 +87,7 @@ namespace Cantera { /** * Create a new thermo manager instance. */ - inline ThermoPhase* newThermoPhase(string model, + inline ThermoPhase* newThermoPhase(std::string model, ThermoFactory* f=0) { if (f == 0) { f = ThermoFactory::factory(); diff --git a/Cantera/src/ThermoPhase.cpp b/Cantera/src/ThermoPhase.cpp index c93358527..30509094a 100644 --- a/Cantera/src/ThermoPhase.cpp +++ b/Cantera/src/ThermoPhase.cpp @@ -20,6 +20,7 @@ #include "ThermoPhase.h" +using namespace std; namespace Cantera { /** diff --git a/Cantera/src/ThermoPhase.h b/Cantera/src/ThermoPhase.h index 87ca03566..2e432341a 100755 --- a/Cantera/src/ThermoPhase.h +++ b/Cantera/src/ThermoPhase.h @@ -693,7 +693,7 @@ namespace Cantera { void setState_TPX(doublereal t, doublereal p, compositionMap& x); /** Set the temperature (K), pressure (Pa), and mole fractions. */ - void setState_TPX(doublereal t, doublereal p, const string& x); + void setState_TPX(doublereal t, doublereal p, const std::string& x); /** Set the temperature (K), pressure (Pa), and mass fractions. */ void setState_TPY(doublereal t, doublereal p, const doublereal* y); @@ -702,7 +702,7 @@ namespace Cantera { void setState_TPY(doublereal t, doublereal p, compositionMap& y); /** Set the temperature (K), pressure (Pa), and mass fractions. */ - void setState_TPY(doublereal t, doublereal p, const string& y); + void setState_TPY(doublereal t, doublereal p, const std::string& y); /** Set the temperature (K) and pressure (Pa) */ void setState_TP(doublereal t, doublereal p); @@ -889,7 +889,7 @@ namespace Cantera { * phase. If none is given, the first XML * phase element encountered will be used. */ - virtual void initThermoFile(string inputFile, string id); + virtual void initThermoFile(std::string inputFile, std::string id); /** @@ -918,7 +918,7 @@ namespace Cantera { * to see if phaseNode is pointing to the phase * with the correct id. */ - virtual void initThermoXML(XML_Node& phaseNode, string id); + virtual void initThermoXML(XML_Node& phaseNode, std::string id); /** * @internal Initialize. This method is provided to allow @@ -1022,7 +1022,7 @@ namespace Cantera { private: - doublereal err(string msg) const; + doublereal err(std::string msg) const; }; diff --git a/Cantera/src/ThirdBodyMgr.h b/Cantera/src/ThirdBodyMgr.h index 41ac42cdf..33ab92c22 100755 --- a/Cantera/src/ThirdBodyMgr.h +++ b/Cantera/src/ThirdBodyMgr.h @@ -28,7 +28,7 @@ namespace Cantera { ThirdBodyMgr<_E>() : m_n(0) {} - void install( int rxnNumber, const map& enhanced, + void install( int rxnNumber, const std::map& enhanced, doublereal dflt=1.0) { m_n++; m_reaction_index.push_back( rxnNumber ); @@ -37,7 +37,7 @@ namespace Cantera { } void update(const vector_fp& conc, doublereal ctot, workPtr work) { - TYPENAME_KEYWORD vector<_E>::const_iterator b = m_concm.begin(); + TYPENAME_KEYWORD std::vector<_E>::const_iterator b = m_concm.begin(); //doublereal* v = m_values.begin(); for (; b != m_concm.end(); ++b, ++work) *work = b->update(conc, ctot); @@ -59,7 +59,7 @@ namespace Cantera { int m_n; vector_int m_reaction_index; - vector<_E> m_concm; + std::vector<_E> m_concm; }; } diff --git a/Cantera/src/ct2ctml.cpp b/Cantera/src/ct2ctml.cpp index 6bdfb658a..3aa3a569f 100644 --- a/Cantera/src/ct2ctml.cpp +++ b/Cantera/src/ct2ctml.cpp @@ -22,6 +22,8 @@ #include #include "ctml.h" +using namespace std; + //#define DEBUG_PATHS using namespace Cantera; diff --git a/Cantera/src/ct_defs.h b/Cantera/src/ct_defs.h index ab70c1046..cb38784cc 100755 --- a/Cantera/src/ct_defs.h +++ b/Cantera/src/ct_defs.h @@ -28,7 +28,7 @@ #include #include -using namespace std; +//using namespace std; //#include "ctvector.h" //using namespace ct; @@ -153,7 +153,7 @@ namespace Cantera { const int None = 0; // typedefs - typedef std::map compositionMap; + typedef std::map compositionMap; #define USE_STL_VECTOR #ifdef USE_STL_VECTOR typedef std::vector array_fp; diff --git a/Cantera/src/ctexceptions.h b/Cantera/src/ctexceptions.h index 3ebd385e2..0afd8b7df 100755 --- a/Cantera/src/ctexceptions.h +++ b/Cantera/src/ctexceptions.h @@ -16,7 +16,7 @@ #define CT_CTEXCEPTIONS_H #include -using namespace std; +//using namespace std; // See file misc.cpp for implementations of methods/functions declared // here. @@ -46,7 +46,7 @@ namespace Cantera { class CanteraError { public: CanteraError() {} - CanteraError(string proc, string msg); + CanteraError(std::string proc, std::string msg); virtual ~CanteraError(){} protected: }; @@ -55,17 +55,17 @@ namespace Cantera { /// class ArraySizeError : public CanteraError { public: - ArraySizeError(string proc, int sz, int reqd); + ArraySizeError(std::string proc, int sz, int reqd); }; /// Exception thrown if an element index is out of range. class ElementRangeError : public CanteraError { public: - ElementRangeError(string func, int m, int mmax); + ElementRangeError(std::string func, int m, int mmax); }; - void deprecatedMethod(string classnm, string oldnm, string newnm); - void removeAtVersion(string func, string version); + void deprecatedMethod(std::string classnm, std::string oldnm, std::string newnm); + void removeAtVersion(std::string func, std::string version); } #endif diff --git a/Cantera/src/ctml.cpp b/Cantera/src/ctml.cpp index f61171e8e..ede193d23 100755 --- a/Cantera/src/ctml.cpp +++ b/Cantera/src/ctml.cpp @@ -23,6 +23,9 @@ #define CTML_VERSION_1_4_1 +using namespace std; +using namespace Cantera; + namespace ctml { static doublereal fpValue(string val) { diff --git a/Cantera/src/ctml.h b/Cantera/src/ctml.h index 0bada33bd..2edc0dfcb 100755 --- a/Cantera/src/ctml.h +++ b/Cantera/src/ctml.h @@ -23,86 +23,89 @@ #include "ct_defs.h" #include "xml.h" #include "Array.h" -using namespace Cantera; +//using namespace Cantera; + namespace ctml { - const string CTML_Version = "1.4.1"; + const std::string CTML_Version = "1.4.1"; - bool isBuiltin(string nm); + bool isBuiltin(std::string nm); - void addBool(XML_Node& node, - string title, + void addBool(Cantera::XML_Node& node, + std::string title, bool val); - void addInteger(XML_Node& node, - string title, + void addInteger(Cantera::XML_Node& node, + std::string title, int val, - string units="", - string type=""); + std::string units="", + std::string type=""); - void addFloat(XML_Node& node, - string title, + void addFloat(Cantera::XML_Node& node, + std::string title, doublereal val, - string units="", - string type="", - doublereal minval = Undef, - doublereal maxval = Undef); + std::string units="", + std::string type="", + doublereal minval = Cantera::Undef, + doublereal maxval = Cantera::Undef); - void addIntegerArray(XML_Node& node, - string title, + void addIntegerArray(Cantera::XML_Node& node, + std::string title, int n, const int* vals, - string units="", - string type="", - doublereal minval=Undef, - doublereal maxval=Undef); + std::string units="", + std::string type="", + doublereal minval=Cantera::Undef, + doublereal maxval=Cantera::Undef); - void addFloatArray(XML_Node& node, - string title, + void addFloatArray(Cantera::XML_Node& node, + std::string title, int n, const double* vals, - string units="", - string type="", - doublereal minval = Undef, - doublereal maxval = Undef); + std::string units="", + std::string type="", + doublereal minval = Cantera::Undef, + doublereal maxval = Cantera::Undef); - void addString(XML_Node& node, - string title, - string val, - string type=""); + void addString(Cantera::XML_Node& node, + std::string title, + std::string val, + std::string type=""); - void getFloatArray(const XML_Node& node, vector_fp& v, - bool convert=true, string type="", - string nodeName = "floatArray"); + void getFloatArray(const Cantera::XML_Node& node, Cantera::vector_fp& v, + bool convert=true, std::string type="", + std::string nodeName = "floatArray"); - void getStringArray(const XML_Node& node, vector& v); - void getMap(const XML_Node& node, map& m); - void getPairs(const XML_Node& node, vector& key, - vector& val); - void getMatrixValues(const XML_Node& node, - const vector& keyString1, - const vector& keyString2, - Array2D &returnValues, bool convert = true, - bool matrixSymmetric = false); + void getStringArray(const Cantera::XML_Node& node, std::vector& v); + void getMap(const Cantera::XML_Node& node, std::map& m); + void getPairs(const Cantera::XML_Node& node, std::vector& key, + std::vector& val); + void getMatrixValues(const Cantera::XML_Node& node, + const std::vector& keyString1, + const std::vector& keyString2, + Cantera::Array2D &returnValues, bool convert = true, + bool matrixSymmetric = false); - void getIntegers(const XML_Node& node, map& v); - void getFloats(const XML_Node& node, map& v, + void getIntegers(const Cantera::XML_Node& node, std::map& v); + void getFloats(const Cantera::XML_Node& node, std::map& v, bool convert=true); - doublereal getFloat(const XML_Node& parent, string name, string type=""); - int getInteger(const XML_Node& parent, string name); + doublereal getFloat(const Cantera::XML_Node& parent, std::string name, + std::string type=""); + int getInteger(const Cantera::XML_Node& parent, std::string name); - void getStrings(const XML_Node& node, map& v); - void getFunction(const XML_Node& node, string& type, doublereal& xmin, - doublereal& xmax, vector_fp& coeffs); - XML_Node* getByTitle(XML_Node& node, string title); - void getString(XML_Node& node, string title, string& val, - string& type); + void getStrings(const Cantera::XML_Node& node, std::map& v); + void getFunction(const Cantera::XML_Node& node, std::string& type, + doublereal& xmin, doublereal& xmax, Cantera::vector_fp& coeffs); + Cantera::XML_Node* getByTitle(Cantera::XML_Node& node, std::string title); + void getString(Cantera::XML_Node& node, std::string title, + std::string& val, std::string& type); - string getString(const XML_Node& parent, string name); + std::string getString(const Cantera::XML_Node& parent, std::string name); // these are defined in ct2ctml.cpp - void get_CTML_Tree(XML_Node* node, string file); + void get_CTML_Tree(Cantera::XML_Node* node, std::string file); void ct2ctml(const char* file); } diff --git a/Cantera/src/ctvector.h b/Cantera/src/ctvector.h index 9e48565d8..9fece0a15 100755 --- a/Cantera/src/ctvector.h +++ b/Cantera/src/ctvector.h @@ -1,6 +1,8 @@ /** * @file ctvector.h * + * THESE CLASSES ARE NO LONGER USED. USE std::vector instead. + * * These classes are defined to represent floating-point and integer * arrays. They act as simplified replacements for std::vector * and std::vector, respectively. These classes are designed for diff --git a/Cantera/src/global.h b/Cantera/src/global.h index e8b2f6ec5..37007b8a1 100755 --- a/Cantera/src/global.h +++ b/Cantera/src/global.h @@ -29,14 +29,14 @@ namespace Cantera { int nErrors(); // The last error message - string lastErrorMessage(); + std::string lastErrorMessage(); // Set an error condition in the application class without // throwing an exception. - void setError(string r, string msg); + void setError(std::string r, std::string msg); // Prints all of the error messages to stream f - void showErrors(ostream& f); + void showErrors(std::ostream& f); // Print all of the error messages using function writelog. void showErrors(); @@ -45,69 +45,69 @@ namespace Cantera { void popError(); /// Find an input file. - string findInputFile(string name); + std::string findInputFile(std::string name); - void addDirectory(string dir); + void addDirectory(std::string dir); void appdelete(); /// The root directory where Cantera is installed - string canteraRoot(); + std::string canteraRoot(); /// Set the temporary file directory. The default is to use the /// directory specified by enviroment variable TMP or TEMP. If neither /// of these are defined, then the current working directory will be /// used for temporary files. Call this function to specify some other /// place to put temporary files. - void setTmpDir(string tmp); + void setTmpDir(std::string tmp); /// The directory where temporary files may be created - string tmpDir(); + std::string tmpDir(); /// Delay time in seconds. - string sleep(); + std::string sleep(); - void writelog(const string& msg); + void writelog(const std::string& msg); void writelog(const char* msg); - void error(const string& msg); + void error(const std::string& msg); // returns 1 for MATLAB, 2 for Python, and 0 for C++ or Fortran. int userInterface(); void setLogger(Logger* logwriter); - /// Return the conversion factor to convert unit string 'unit' to + /// Return the conversion factor to convert unit std::string 'unit' to /// SI units. - doublereal toSI(string unit); + doublereal toSI(std::string unit); /// Return the conversion factor to convert activation energy unit - /// string 'unit' to Kelvin. - doublereal actEnergyToSI(string unit); + /// std::string 'unit' to Kelvin. + doublereal actEnergyToSI(std::string unit); /// Return a pointer to the XML tree for a Cantera input file. - XML_Node* get_XML_File(string file); + XML_Node* get_XML_File(std::string file); /// Close a Cantera input file. - void close_XML_File(string file); + void close_XML_File(std::string file); #ifdef WITH_HTML_LOGS - void beginLogGroup(string title, int loglevel=-99); - void addLogEntry(string tag, string value); - void addLogEntry(string tag, doublereal value); - void addLogEntry(string tag, int value); - void addLogEntry(string msg); - void endLogGroup(string title=""); - void write_logfile(string file = "log.html"); + void beginLogGroup(std::string title, int loglevel=-99); + void addLogEntry(std::string tag, std::string value); + void addLogEntry(std::string tag, doublereal value); + void addLogEntry(std::string tag, int value); + void addLogEntry(std::string msg); + void endLogGroup(std::string title=""); + void write_logfile(std::string file = "log.html"); #else - inline void beginLogGroup(string title, int loglevel=-99) {} - inline void addLogEntry(string tag, string value) {} - inline void addLogEntry(string tag, doublereal value) {} - inline void addLogEntry(string tag, int value) {} - inline void addLogEntry(string msg) {} - inline void endLogGroup(string title="") {} - inline void write_logfile(string file = "log.html") {} + inline void beginLogGroup(std::string title, int loglevel=-99) {} + inline void addLogEntry(std::string tag, std::string value) {} + inline void addLogEntry(std::string tag, doublereal value) {} + inline void addLogEntry(std::string tag, int value) {} + inline void addLogEntry(std::string msg) {} + inline void endLogGroup(std::string title="") {} + inline void write_logfile(std::string file = "log.html") {} #endif } diff --git a/Cantera/src/importCTML.cpp b/Cantera/src/importCTML.cpp index 76c3ac6d5..ec169823e 100755 --- a/Cantera/src/importCTML.cpp +++ b/Cantera/src/importCTML.cpp @@ -41,7 +41,7 @@ #include "ctml.h" using namespace ctml; - +using namespace std; // these are all used to check for duplicate reactions class rxninfo { diff --git a/Cantera/src/importCTML.h b/Cantera/src/importCTML.h index d6b39de44..a3a1e2d1e 100755 --- a/Cantera/src/importCTML.h +++ b/Cantera/src/importCTML.h @@ -14,7 +14,7 @@ #define CT_IMPORTCTML_H #include -using namespace std; +//using namespace std; #include "ThermoPhase.h" #include "Kinetics.h" @@ -26,12 +26,12 @@ namespace Cantera { //class ThermoPhase; class XML_Node; - bool isCTMLFile(string infile); + bool isCTMLFile(std::string infile); - XML_Node* get_XML_Node(const string& src, XML_Node* root); + XML_Node* get_XML_Node(const std::string& src, XML_Node* root); - XML_Node* get_XML_NameID(const string& nameTarget, - const string& file_ID, XML_Node* root); + XML_Node* get_XML_NameID(const std::string& nameTarget, + const std::string& file_ID, XML_Node* root); bool installSpecies(int k, const XML_Node& s, thermo_t& p, SpeciesThermo& spthermo, int rule, @@ -40,13 +40,13 @@ namespace Cantera { bool importPhase(XML_Node& phase, ThermoPhase* th, SpeciesThermoFactory* spfactory = 0); - doublereal isDuplicateReaction(map& r1, - map& r2); + doublereal isDuplicateReaction(std::map& r1, + std::map& r2); - bool importKinetics(const XML_Node& phase, vector th, + bool importKinetics(const XML_Node& phase, std::vector th, Kinetics* kin); bool installReactionArrays(const XML_Node& parent, Kinetics& kin, - string default_phase, bool check_for_duplicates = false); + std::string default_phase, bool check_for_duplicates = false); /*** * This function will check a specific reaction to see if it the @@ -59,11 +59,11 @@ namespace Cantera { ReactionData& rdata, int negA); ThermoPhase* newPhase(XML_Node& phase); - ThermoPhase* newPhase(string file, string id); - bool buildSolutionFromXML(XML_Node& root, string id, string nm, + ThermoPhase* newPhase(std::string file, std::string id); + bool buildSolutionFromXML(XML_Node& root, std::string id, std::string nm, ThermoPhase* th, Kinetics* k); - const XML_Node *speciesXML_Node(string kname, + const XML_Node *speciesXML_Node(std::string kname, const XML_Node *phaseSpecies); } diff --git a/Cantera/src/logger.h b/Cantera/src/logger.h index 2bc614642..755a96278 100644 --- a/Cantera/src/logger.h +++ b/Cantera/src/logger.h @@ -6,7 +6,7 @@ #define CT_LOGGER_H #include -using namespace std; +//using namespace std; namespace Cantera { @@ -44,8 +44,8 @@ namespace Cantera { /// appended to the message, and so if one is desired it must /// be included in the string. - virtual void write(const string& msg) { - cout << msg; + virtual void write(const std::string& msg) { + std::cout << msg; } /// Write an error message and quit. The default behavior is @@ -56,8 +56,8 @@ namespace Cantera { /// terminate the application Cantera is invoked from (MATLAB, /// Excel, etc.) If this is not desired, then derive a class /// and reimplement this method. - virtual void error(const string& msg) { - cerr << msg << endl; + virtual void error(const std::string& msg) { + std::cerr << msg << std::endl; exit(-1); } diff --git a/Cantera/src/misc.cpp b/Cantera/src/misc.cpp index 010a7c06d..a65f5652d 100755 --- a/Cantera/src/misc.cpp +++ b/Cantera/src/misc.cpp @@ -1,3 +1,4 @@ + /** * @file misc.cpp * @@ -558,9 +559,9 @@ namespace Cantera { throw CanteraError("findInputFile", msg); return ""; } - else { - return name; - } + //else { + return name; + //} } doublereal toSI(string unit) { diff --git a/Cantera/src/oneD/Domain1D.cpp b/Cantera/src/oneD/Domain1D.cpp index 085c14c3c..0290342cf 100644 --- a/Cantera/src/oneD/Domain1D.cpp +++ b/Cantera/src/oneD/Domain1D.cpp @@ -88,8 +88,8 @@ namespace Cantera { jmax = m_points - 1; } else { // evaluate points for Jacobian - jmin = max(jpt-1, 0); - jmax = min(jpt+1,m_points-1); + jmin = std::max(jpt-1, 0); + jmax = std::min(jpt+1,m_points-1); } for (j = jmin; j <= jmax; j++) { diff --git a/Cantera/src/oneD/Domain1D.h b/Cantera/src/oneD/Domain1D.h index a5e3a0acd..a67d8e3c9 100644 --- a/Cantera/src/oneD/Domain1D.h +++ b/Cantera/src/oneD/Domain1D.h @@ -139,12 +139,12 @@ namespace Cantera { int nPoints() const { return m_points; } /// Name of the nth component. May be overloaded. - virtual string componentName(int n) const { + virtual std::string componentName(int n) const { if (m_name[n] != "") return m_name[n]; else return "component " + int2str(n); } - void setComponentName(int n, string name) { + void setComponentName(int n, std::string name) { m_name[n] = name; } @@ -153,7 +153,7 @@ namespace Cantera { } /// index of component with name \a name. - int componentIndex(string name) { + int componentIndex(std::string name) { int nc = nComponents(); for (int n = 0; n < nc; n++) { if (name == componentName(n)) return n; @@ -257,7 +257,7 @@ namespace Cantera { integer* mask, doublereal rdt=0.0); virtual doublereal residual(doublereal* x, int n, int j) { - throw CanteraError("Domain1D::residual","residual function must be overloaded in derived class"); + throw CanteraError("Domain1D::residual","residual function must be overloaded in derived class "+id()); } int timeDerivativeFlag(int n) { return m_td[n];} @@ -367,22 +367,22 @@ namespace Cantera { /** * Specify an identifying tag for this domain. */ - void setID(const string& s) {m_id = s;} + void setID(const std::string& s) {m_id = s;} - string id() { + std::string id() { if (m_id != "") return m_id; - else return string("domain ") + int2str(m_index); + else return std::string("domain ") + int2str(m_index); } /** * Specify descriptive text for this domain. */ - void setDesc(const string& s) {m_desc = s;} - const string& desc() { return m_desc; } + void setDesc(const std::string& s) {m_desc = s;} + const std::string& desc() { return m_desc; } virtual void getTransientMask(integer* mask){} - virtual void showSolution_s(ostream& s, const doublereal* x) {} + virtual void showSolution_s(std::ostream& s, const doublereal* x) {} virtual void showSolution(const doublereal* x); virtual void restore(const XML_Node& dom, doublereal* soln) {} @@ -394,7 +394,7 @@ namespace Cantera { doublereal zmax() const { return m_z[m_points - 1]; } - void setProfile(string name, doublereal* values, doublereal* soln) { + void setProfile(std::string name, doublereal* values, doublereal* soln) { int n, j; for (n = 0; n < m_nv; n++) { if (name == componentName(n)) { @@ -467,10 +467,10 @@ namespace Cantera { int m_iloc; int m_jstart; Domain1D *m_left, *m_right; - string m_id, m_desc; + std::string m_id, m_desc; Refiner* m_refiner; vector_int m_td; - vector m_name; + std::vector m_name; private: diff --git a/Cantera/src/oneD/Inlet1D.h b/Cantera/src/oneD/Inlet1D.h index cb04b70b4..7dbf6b96f 100644 --- a/Cantera/src/oneD/Inlet1D.h +++ b/Cantera/src/oneD/Inlet1D.h @@ -56,8 +56,8 @@ namespace Cantera { /// Temperature [K]. virtual doublereal temperature() {return m_temp;} - /// Set the mole fractions by specifying a string. - virtual void setMoleFractions(string xin){err("setMoleFractions");} + /// Set the mole fractions by specifying a std::string. + virtual void setMoleFractions(std::string xin){err("setMoleFractions");} /// Set the mole fractions by specifying an array. virtual void setMoleFractions(doublereal* xin){err("setMoleFractions");} @@ -92,7 +92,7 @@ namespace Cantera { doublereal m_temp, m_mdot; private: - void err(string method) { + void err(std::string method) { throw CanteraError("Bdry1D::"+method, "attempt to call base class method "+method); } @@ -155,10 +155,10 @@ namespace Cantera { virtual void _finalize(const doublereal* x) {} - virtual void setMoleFractions(string xin); + virtual void setMoleFractions(std::string xin); virtual void setMoleFractions(doublereal* xin); virtual doublereal massFraction(int k) {return m_yin[k];} - virtual string componentName(int n) const; + virtual std::string componentName(int n) const; virtual void init(); virtual void eval(int jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt); @@ -171,7 +171,7 @@ namespace Cantera { doublereal m_V0; int m_nsp; vector_fp m_yin; - string m_xstr; + std::string m_xstr; StFlow *m_flow; }; @@ -188,7 +188,7 @@ namespace Cantera { } virtual ~Empty1D(){} - virtual string componentName(int n) const; + virtual std::string componentName(int n) const; virtual void showSolution(const doublereal* x) {} virtual void init(); @@ -220,7 +220,7 @@ namespace Cantera { } virtual ~Symm1D(){} - virtual string componentName(int n) const; + virtual std::string componentName(int n) const; virtual void init(); @@ -252,7 +252,7 @@ namespace Cantera { } virtual ~Outlet1D(){} - virtual string componentName(int n) const; + virtual std::string componentName(int n) const; virtual void init(); @@ -299,10 +299,10 @@ namespace Cantera { ; } - virtual void setMoleFractions(string xin); + virtual void setMoleFractions(std::string xin); virtual void setMoleFractions(doublereal* xin); virtual doublereal massFraction(int k) {return m_yres[k];} - virtual string componentName(int n) const; + virtual std::string componentName(int n) const; virtual void init(); virtual void eval(int jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt); @@ -313,7 +313,7 @@ namespace Cantera { int m_nsp; vector_fp m_yres; - string m_xstr; + std::string m_xstr; StFlow *m_flow; }; @@ -333,7 +333,7 @@ namespace Cantera { } virtual ~Surf1D(){} - virtual string componentName(int n) const; + virtual std::string componentName(int n) const; virtual void init(); @@ -351,9 +351,9 @@ namespace Cantera { ; //m_temp = x[0]; } - virtual void showSolution_s(ostream& s, const doublereal* x) { - s << "------------------- Surface " << domainIndex() << " ------------------- " << endl; - s << " temperature: " << m_temp << " K" << " " << x[0] << endl; + virtual void showSolution_s(std::ostream& s, const doublereal* x) { + s << "------------------- Surface " << domainIndex() << " ------------------- " << std::endl; + s << " temperature: " << m_temp << " K" << " " << x[0] << std::endl; } virtual void showSolution(const doublereal* x) { @@ -393,7 +393,7 @@ namespace Cantera { virtual ~ReactingSurf1D(){} - virtual string componentName(int n) const; + virtual std::string componentName(int n) const; virtual void init(); diff --git a/Cantera/src/oneD/MultiNewton.cpp b/Cantera/src/oneD/MultiNewton.cpp index b3ad01e4b..88065f930 100644 --- a/Cantera/src/oneD/MultiNewton.cpp +++ b/Cantera/src/oneD/MultiNewton.cpp @@ -31,6 +31,8 @@ using namespace std; #include "../stringUtils.h" #include +using namespace std; + namespace Cantera { //---------------------------------------------------------- @@ -130,13 +132,14 @@ namespace Cantera { } #endif - //try { - iok = jac.solve(sz, step, step); - if (iok > 0) { + iok = jac.solve(sz, step, step); + + // if iok is non-zero, then solve failed + if (iok > 0) { iok--; int nd = r.nDomains(); for (n = nd-1; n >= 0; n--) - if (iok >= r.start(n)) { break; } + if (iok >= r.start(n)) { break; } Domain1D& dom = r.domain(n); int offset = iok - r.start(n); int pt = offset/dom.nComponents(); @@ -146,14 +149,10 @@ namespace Cantera { dom.id() + ", component " +dom.componentName(comp)+" at point " +int2str(pt)+"\n(Matrix row "+int2str(iok)+") \nsee file bandmatrix.csv\n"); - } - else if (iok < 0) + } + else if (iok < 0) throw CanteraError("MultiNewton::step", - "iok = "+int2str(iok)); - //} - //catch (CanteraError) { - //showErrors(cout); - //} + "iok = "+int2str(iok)); #ifdef DEBUG_STEP bool ok = false; diff --git a/Cantera/src/oneD/MultiNewton.h b/Cantera/src/oneD/MultiNewton.h index 203458097..8a4298981 100644 --- a/Cantera/src/oneD/MultiNewton.h +++ b/Cantera/src/oneD/MultiNewton.h @@ -61,7 +61,7 @@ namespace Cantera { doublereal* getWorkArray(); void releaseWorkArray(doublereal* work); - vector m_workarrays; + std::vector m_workarrays; int m_maxAge; int m_nv, m_np, m_n; doublereal m_elapsed; diff --git a/Cantera/src/oneD/OneDim.cpp b/Cantera/src/oneD/OneDim.cpp index 31deb1504..b01a4b03f 100644 --- a/Cantera/src/oneD/OneDim.cpp +++ b/Cantera/src/oneD/OneDim.cpp @@ -10,6 +10,7 @@ #include "../ctml.h" using namespace ctml; +using namespace std; namespace Cantera { diff --git a/Cantera/src/oneD/OneDim.h b/Cantera/src/oneD/OneDim.h index f252a5b0b..3dfac1b15 100644 --- a/Cantera/src/oneD/OneDim.h +++ b/Cantera/src/oneD/OneDim.h @@ -24,7 +24,7 @@ namespace Cantera { OneDim(); // Constructor. - OneDim(vector domains); + OneDim(std::vector domains); /// Destructor. virtual ~OneDim(); @@ -52,7 +52,7 @@ namespace Cantera { /// Return a reference to domain i. Domain1D& domain(int i) const { return *m_dom[i]; } - int domainIndex(string name); + int domainIndex(std::string name); /// The index of the start of domain i in the solution vector. int start(int i) const { return m_dom[i]->loc(); } @@ -139,7 +139,7 @@ namespace Cantera { void writeStats(); - void save(string fname, string id, string desc, doublereal* sol); + void save(std::string fname, std::string id, std::string desc, doublereal* sol); // options void setMinTimeStep(doublereal tmin) { m_tmin = tmin; } @@ -171,7 +171,7 @@ namespace Cantera { int m_bw; // Jacobian bandwidth int m_size; // solution vector size - vector m_dom, m_connect, m_bulk; + std::vector m_dom, m_connect, m_bulk; bool m_init; vector_int m_nvars; diff --git a/Cantera/src/oneD/Resid1D.h b/Cantera/src/oneD/Resid1D.h index 7046df4e4..d72b6a052 100644 --- a/Cantera/src/oneD/Resid1D.h +++ b/Cantera/src/oneD/Resid1D.h @@ -123,7 +123,7 @@ namespace Cantera { int nPoints() const { return m_points; } /// Name of the nth component. May be overloaded. - virtual string componentName(int n) const { + virtual std::string componentName(int n) const { return "component " + int2str(n); } /** @@ -312,12 +312,12 @@ namespace Cantera { /** * Specify an identifying tag for this domain. */ - void setID(const string& s) {m_id = s;} + void setID(const std::string& s) {m_id = s;} /** * Specify descriptive text for this domain. */ - void setDesc(const string& s) {m_desc = s;} + void setDesc(const std::string& s) {m_desc = s;} virtual void getTransientMask(integer* mask){} @@ -330,7 +330,7 @@ namespace Cantera { doublereal zmax() const { return m_z[m_points - 1]; } - void setProfile(string name, doublereal* values, doublereal* soln) { + void setProfile(std::string name, doublereal* values, doublereal* soln) { int n, j; for (n = 0; n < m_nv; n++) { if (name == componentName(n)) { @@ -383,7 +383,7 @@ namespace Cantera { int m_iloc; int m_jstart; Resid1D *m_left, *m_right; - string m_id, m_desc; + std::string m_id, m_desc; Refiner* m_refiner; private: diff --git a/Cantera/src/oneD/Sim1D.cpp b/Cantera/src/oneD/Sim1D.cpp index ed792fc01..56dd251d1 100644 --- a/Cantera/src/oneD/Sim1D.cpp +++ b/Cantera/src/oneD/Sim1D.cpp @@ -11,6 +11,8 @@ #include "Sim1D.h" #include "MultiJac.h" +using namespace std; + namespace Cantera { diff --git a/Cantera/src/oneD/Sim1D.h b/Cantera/src/oneD/Sim1D.h index 28c59e061..09e28e002 100644 --- a/Cantera/src/oneD/Sim1D.h +++ b/Cantera/src/oneD/Sim1D.h @@ -35,7 +35,7 @@ namespace Cantera { * the pointer to the leftmost domain is domain[0], the pointer to the * domain to its right is domain[1], etc. */ - Sim1D(vector& domains); + Sim1D(std::vector& domains); /// Destructor. Does nothing. virtual ~Sim1D() {} @@ -50,7 +50,7 @@ namespace Cantera { /// Set initial guess based on equilibrium //added by Karl Meredith - void setInitialGuess(string component, vector_fp& locs, vector_fp& vals); + void setInitialGuess(std::string component, vector_fp& locs, vector_fp& vals); /// Set one entry in the solution vector. void setValue(int dom, int comp, int localPoint, doublereal value); @@ -69,10 +69,10 @@ namespace Cantera { //@} - void save(string fname, string id, string desc); + void save(std::string fname, std::string id, std::string desc); /// Print to stream s the current solution for all domains. - void showSolution(ostream& s); + void showSolution(std::ostream& s); void showSolution(); const doublereal* solution() { return DATA_PTR(m_x); } @@ -100,11 +100,11 @@ namespace Cantera { doublereal slope = 0.8, doublereal curve = 0.8, doublereal prune = -0.1); void setMaxGridPoints(int dom = -1, int npoints = 300); - void restore(string fname, string id); + void restore(std::string fname, std::string id); void getInitialSoln(); void setSolution(const doublereal* soln) { - copy(soln, soln + m_x.size(), DATA_PTR(m_x)); + std::copy(soln, soln + m_x.size(), DATA_PTR(m_x)); } const doublereal* solution() const { return DATA_PTR(m_x); } diff --git a/Cantera/src/oneD/Solid1D.h b/Cantera/src/oneD/Solid1D.h index 25d1b28d2..3bb41f302 100644 --- a/Cantera/src/oneD/Solid1D.h +++ b/Cantera/src/oneD/Solid1D.h @@ -183,7 +183,7 @@ namespace Cantera { */ doublereal C_fixed(int k, int j) const {return m_fixedc(k,j);} - virtual string componentName(int n) const; + virtual std::string componentName(int n) const; void setDielectricConstant(doublereal e) { m_eps = e; } doublereal dielectricConstant() { return m_eps; } @@ -193,7 +193,7 @@ namespace Cantera { * May be called multiple times to generate animation. */ void outputTEC(ostream &s, const doublereal* x, - string title, int zone); + std::string title, int zone); virtual void showSolution(const doublereal* x); @@ -202,7 +202,7 @@ namespace Cantera { virtual void restore(XML_Node& dom, doublereal* soln); // overloaded in subclasses - virtual string solidType() { return ""; } + virtual std::string solidType() { return ""; } void solveEnergyEqn(int j=-1) { if (j < 0) @@ -382,9 +382,9 @@ namespace Cantera { bool m_ok; // flags - vector m_do_energy; - vector m_do_species; - vector m_do_gauss; + std::vector m_do_energy; + std::vector m_do_species; + std::vector m_do_gauss; // fixed T and Y values Array2D m_fixedy; diff --git a/Cantera/src/oneD/StFlow.cpp b/Cantera/src/oneD/StFlow.cpp index 5198d886c..c8f1a3e18 100644 --- a/Cantera/src/oneD/StFlow.cpp +++ b/Cantera/src/oneD/StFlow.cpp @@ -27,6 +27,7 @@ #include "MultiJac.h" using namespace ctml; +using namespace std; namespace Cantera { diff --git a/Cantera/src/oneD/StFlow.h b/Cantera/src/oneD/StFlow.h index ae310f6d4..1e3392d07 100644 --- a/Cantera/src/oneD/StFlow.h +++ b/Cantera/src/oneD/StFlow.h @@ -172,10 +172,10 @@ namespace Cantera { doublereal Y_fixed(int k, int j) const {return m_fixedy(k,j);} - virtual string componentName(int n) const; + virtual std::string componentName(int n) const; //added by Karl Meredith - int componentIndex(string name) const; + int componentIndex(std::string name) const; virtual void showSolution(const doublereal* x); @@ -185,7 +185,7 @@ namespace Cantera { virtual void restore(const XML_Node& dom, doublereal* soln); // overloaded in subclasses - virtual string flowType() { return ""; } + virtual std::string flowType() { return ""; } void solveEnergyEqn(int j=-1) { if (j < 0) @@ -442,9 +442,9 @@ namespace Cantera { bool m_ok; // flags - vector m_do_energy; + std::vector m_do_energy; bool m_do_soret; - vector m_do_species; + std::vector m_do_species; int m_transport_option; // solution estimate @@ -477,7 +477,7 @@ namespace Cantera { virtual ~AxiStagnFlow() {} virtual void eval(int j, doublereal* x, doublereal* r, integer* mask, doublereal rdt); - virtual string flowType() { return "Axisymmetric Stagnation"; } + virtual std::string flowType() { return "Axisymmetric Stagnation"; } }; /** @@ -490,7 +490,7 @@ namespace Cantera { virtual ~FreeFlame() {} virtual void eval(int j, doublereal* x, doublereal* r, integer* mask, doublereal rdt); - virtual string flowType() { return "Free Flame"; } + virtual std::string flowType() { return "Free Flame"; } virtual bool fixed_mdot() { return false; } }; @@ -504,7 +504,7 @@ namespace Cantera { virtual ~OneDFlow() {} virtual void eval(int j, doublereal* x, doublereal* r, integer* mask, doublereal rdt); - virtual string flowType() { return "OneDFlow"; } + virtual std::string flowType() { return "OneDFlow"; } doublereal mdot(doublereal* x, int j) { return x[index(c_offset_L,j)]; } diff --git a/Cantera/src/oneD/Surf1D.h b/Cantera/src/oneD/Surf1D.h index eb0456d20..44e8013e4 100644 --- a/Cantera/src/oneD/Surf1D.h +++ b/Cantera/src/oneD/Surf1D.h @@ -89,7 +89,7 @@ namespace Cantera { doublereal multiplier(int k) { return m_mult[k]; } - virtual string componentName(int n) const { + virtual std::string componentName(int n) const { return m_sphase->speciesName(n); } @@ -297,11 +297,11 @@ namespace Cantera { int m_sp_left, m_sp_right; int m_start_left, m_start_right, m_start_surf; ThermoPhase *m_phase_left, *m_phase_right; - vector m_bulk; - vector m_nbulk; + std::vector m_bulk; + std::vector m_nbulk; int m_nsurf; vector_fp m_mult; - vector m_do_surf_species; + std::vector m_do_surf_species; vector_fp m_fixed_cov; }; diff --git a/Cantera/src/oneD/boundaries1D.cpp b/Cantera/src/oneD/boundaries1D.cpp index 95a56d2bd..164047238 100644 --- a/Cantera/src/oneD/boundaries1D.cpp +++ b/Cantera/src/oneD/boundaries1D.cpp @@ -18,6 +18,8 @@ #include "Inlet1D.h" +using namespace std; + namespace Cantera { Bdry1D::Bdry1D() : Domain1D(1, 1, 0.0), diff --git a/Cantera/src/oneD/newton_utils.cpp b/Cantera/src/oneD/newton_utils.cpp index 93042c75d..7b914ffaa 100644 --- a/Cantera/src/oneD/newton_utils.cpp +++ b/Cantera/src/oneD/newton_utils.cpp @@ -10,6 +10,8 @@ #include "../ct_defs.h" #include "Domain1D.h" +using namespace std; + namespace Cantera { class Indx { diff --git a/Cantera/src/oneD/refine.h b/Cantera/src/oneD/refine.h index a01833efb..cfb15536e 100644 --- a/Cantera/src/oneD/refine.h +++ b/Cantera/src/oneD/refine.h @@ -40,10 +40,10 @@ namespace Cantera { protected: - map m_loc; - map m_keep; - map m_c; - vector m_active; + std::map m_loc; + std::map m_keep; + std::map m_c; + std::vector m_active; doublereal m_ratio, m_slope, m_curve, m_prune; doublereal m_min_range; Domain1D* m_domain; diff --git a/Cantera/src/phasereport.cpp b/Cantera/src/phasereport.cpp index 913a4bdfc..147aad76b 100644 --- a/Cantera/src/phasereport.cpp +++ b/Cantera/src/phasereport.cpp @@ -10,6 +10,8 @@ #include #include "mix_defs.h" +using namespace std; + namespace Cantera { /** diff --git a/Cantera/src/plots.cpp b/Cantera/src/plots.cpp index 6cca831a2..6022f8a35 100755 --- a/Cantera/src/plots.cpp +++ b/Cantera/src/plots.cpp @@ -18,6 +18,8 @@ #include "plots.h" +using namespace std; + namespace Cantera { void writePlotFile(string fname, string fmt, diff --git a/Cantera/src/plots.h b/Cantera/src/plots.h index abe01cdca..f013ddd40 100755 --- a/Cantera/src/plots.h +++ b/Cantera/src/plots.h @@ -5,20 +5,20 @@ #include #include #include -using namespace std; +//using namespace std; #include "Array.h" #include "ctexceptions.h" namespace Cantera { - void writePlotFile(string fname, string fmt, - string plotTitle, const vector names, const Array2D& data); + void writePlotFile(std::string fname, std::string fmt, + std::string plotTitle, const std::vector names, const Array2D& data); - void outputTEC(ostream &s, string title, const vector& names, + void outputTEC(std::ostream &s, std::string title, const std::vector& names, const Array2D& data); - void outputExcel(ostream &s, string title, const vector& names, + void outputExcel(std::ostream &s, std::string title, const std::vector& names, const Array2D& data); } diff --git a/Cantera/src/polyfit.h b/Cantera/src/polyfit.h index 225ec8a33..1bd070a4b 100755 --- a/Cantera/src/polyfit.h +++ b/Cantera/src/polyfit.h @@ -5,7 +5,7 @@ #define CT_POLYFIT_H #include -using namespace std; +//using namespace std; #include "ct_defs.h" diff --git a/Cantera/src/speciesThermoTypes.h b/Cantera/src/speciesThermoTypes.h index 95a04d498..244369260 100755 --- a/Cantera/src/speciesThermoTypes.h +++ b/Cantera/src/speciesThermoTypes.h @@ -39,13 +39,16 @@ #include "ct_defs.h" +#include "stringUtils.h" +#include "global.h" + namespace Cantera { struct UnknownThermoParam { UnknownThermoParam(int thermotype) { - cerr << endl << "### ERROR ###" << endl; - cerr << "Unknown species thermo parameterization (" - << thermotype << ")" << endl << endl; + writelog(std::string("\n ### ERROR ### \n") + + "Unknown species thermo parameterization (" + + int2str(thermotype) + ")\n\n"); } }; diff --git a/Cantera/src/stringUtils.cpp b/Cantera/src/stringUtils.cpp index d8e7e16e0..89b7f2fa0 100755 --- a/Cantera/src/stringUtils.cpp +++ b/Cantera/src/stringUtils.cpp @@ -14,38 +14,38 @@ #include "ct_defs.h" #include "ctexceptions.h" #include -#include +#include #include namespace Cantera { /** - * Convert a floating point number to a string using sprintf. + * Convert a floating point number to a std::string using sprintf. */ - string fp2str(double x, string fmt) { + std::string fp2str(double x, std::string fmt) { char buf[30]; sprintf(buf, fmt.c_str(), x); - return string(buf); + return std::string(buf); } /** - * Convert an integer number to a string using sprintf. + * Convert an integer number to a std::string using sprintf. */ - string int2str(int n, string fmt) { + std::string int2str(int n, std::string fmt) { char buf[30]; sprintf(buf, fmt.c_str(), n); - return string(buf); + return std::string(buf); } - string lowercase(string s) { + std::string lowercase(std::string s) { int n = static_cast(s.size()); - string lc(s); + std::string lc(s); for (int i = 0; i < n; i++) lc[i] = tolower(s[i]); return lc; } - static int firstChar(string s) { + static int firstChar(std::string s) { int i; int n = static_cast(s.size()); for (i = 0; i < n; i++) @@ -53,7 +53,7 @@ namespace Cantera { return i; } - static int lastChar(string s) { + static int lastChar(std::string s) { int i; int n = static_cast(s.size()); for (i = n-1; i >= 0; i--) @@ -64,7 +64,7 @@ namespace Cantera { /** * Strip leading and trailing white space. */ - string stripws(string s) { + std::string stripws(std::string s) { int ifirst = firstChar(s); int ilast = lastChar(s); return s.substr(ifirst, ilast - ifirst + 1); @@ -73,10 +73,10 @@ namespace Cantera { /** * Strip non-printing characters. */ - string stripnonprint(string s) { + std::string stripnonprint(std::string s) { int i; int n = static_cast(s.size()); - string ss = ""; + std::string ss = ""; for (i = 0; i < n; i++) { if (isprint(s[i])) { ss += s[i]; @@ -89,20 +89,20 @@ namespace Cantera { /** * Parse a composition string. */ - void parseCompString(const string ss, compositionMap& x) { - string s = ss; - string::size_type icolon, ibegin, iend; - string name, num, nm; + void parseCompString(const std::string ss, compositionMap& x) { + std::string s = ss; + std::string::size_type icolon, ibegin, iend; + std::string name, num, nm; do { ibegin = s.find_first_not_of(", ;\n\t"); - if (ibegin != string::npos) { + if (ibegin != std::string::npos) { s = s.substr(ibegin,s.size()); icolon = s.find(':'); iend = s.find_first_of(", ;\n\t"); //icomma = s.find(','); - if (icolon != string::npos) { + if (icolon != std::string::npos) { name = s.substr(0, icolon); - if (iend != string::npos) { + if (iend != std::string::npos) { num = s.substr(icolon+1, iend-icolon); s = s.substr(iend+1, s.size()); } @@ -129,16 +129,16 @@ namespace Cantera { /** * Parse a composition string. */ - void split(const string ss, vector& w) { - string s = ss; - string::size_type ibegin, iend; - string name, num, nm; + void split(const std::string ss, std::vector& w) { + std::string s = ss; + std::string::size_type ibegin, iend; + std::string name, num, nm; do { ibegin = s.find_first_not_of(", ;\n\t"); - if (ibegin != string::npos) { + if (ibegin != std::string::npos) { s = s.substr(ibegin,s.size()); iend = s.find_first_of(", ;\n\t"); - if (iend != string::npos) { + if (iend != std::string::npos) { w.push_back(s.substr(0, iend)); s = s.substr(iend+1, s.size()); } @@ -151,10 +151,10 @@ namespace Cantera { while (s != ""); } - int fillArrayFromString(const string& str, doublereal* a, char delim) { - string::size_type iloc; + int fillArrayFromString(const std::string& str, doublereal* a, char delim) { + std::string::size_type iloc; int count = 0; - string num, s; + std::string num, s; s = str; while (s.size() > 0) { iloc = s.find(delim); @@ -175,8 +175,8 @@ namespace Cantera { /** * Get the file name without the path or extension */ - string getFileName(const string& path) { - string file; + std::string getFileName(const std::string& path) { + std::string file; size_t idot = path.find_last_of('.'); size_t islash = path.find_last_of('/'); if (idot > 0 && idot < path.size()) { @@ -197,8 +197,8 @@ namespace Cantera { /** * Generate a logfile name based on an input file name */ - string logfileName(const string& infile) { - string logfile; + std::string logfileName(const std::string& infile) { + std::string logfile; size_t idot = infile.find_last_of('.'); size_t islash = infile.find_last_of('/'); if (idot > 0 && idot < infile.size()) { @@ -215,10 +215,10 @@ namespace Cantera { return logfile; } - string wrapString(const string& s, int len) { + std::string wrapString(const std::string& s, int len) { int nc = s.size(); int n, count=0; - string r; + std::string r; for (n = 0; n < nc; n++) { if (s[n] == '\n') count = 0; else count++; @@ -342,7 +342,7 @@ namespace Cantera { i++; } } else { - string hh(dptr); + std::string hh(dptr); free(eptr); throw CanteraError("aotofCheck", "Trouble processing string, " + hh); diff --git a/Cantera/src/stringUtils.h b/Cantera/src/stringUtils.h index b95407615..3aa6fab84 100755 --- a/Cantera/src/stringUtils.h +++ b/Cantera/src/stringUtils.h @@ -1,5 +1,5 @@ /** - * @file stringUtils.h + * @file std::stringUtils.h * */ @@ -17,27 +17,27 @@ namespace Cantera { class Phase; class ThermoPhase; - string fp2str(double x, string fmt = "%g"); - string int2str(int n, string fmt = "%d"); - string stripws(string s); - string stripnonprint(string s); - string lowercase(string s); - void parseCompString(const string ss, compositionMap& x); - void split(const string ss, vector& w); - int fillArrayFromString(const string& str, doublereal* a, char delim = ' '); - string report(const ThermoPhase& th, bool show_thermo = true); - string formatCompList(const Phase& mix, int xyc); - string logfileName(const string& infile); - string getFileName(const string& path); + std::string fp2str(double x, std::string fmt = "%g"); + std::string int2str(int n, std::string fmt = "%d"); + std::string stripws(std::string s); + std::string stripnonprint(std::string s); + std::string lowercase(std::string s); + void parseCompString(const std::string ss, compositionMap& x); + void split(const std::string ss, std::vector& w); + int fillArrayFromString(const std::string& str, doublereal* a, char delim = ' '); + std::string report(const ThermoPhase& th, bool show_thermo = true); + std::string formatCompList(const Phase& mix, int xyc); + std::string logfileName(const std::string& infile); + std::string getFileName(const std::string& path); - inline int intValue(string val) { + inline int intValue(std::string val) { return atoi(stripws(val).c_str()); } - inline doublereal fpValue(string val) { + inline doublereal fpValue(std::string val) { return atof(stripws(val).c_str()); } - string wrapString(const string& s, int len=70); + std::string wrapString(const std::string& s, int len=70); int stripLTWScstring(char str[]); double atofCheck(const char *dptr); diff --git a/Cantera/src/transport/DustyGasTransport.cpp b/Cantera/src/transport/DustyGasTransport.cpp index 6c9845186..3fd60a387 100644 --- a/Cantera/src/transport/DustyGasTransport.cpp +++ b/Cantera/src/transport/DustyGasTransport.cpp @@ -27,6 +27,8 @@ #include "../ThermoPhase.h" #include "DustyGasTransport.h" +using namespace std; + /** * Mole fractions below MIN_X will be set to MIN_X when computing * transport properties. diff --git a/Cantera/src/transport/MMCollisionInt.cpp b/Cantera/src/transport/MMCollisionInt.cpp index 8bb679e29..b29432cb5 100755 --- a/Cantera/src/transport/MMCollisionInt.cpp +++ b/Cantera/src/transport/MMCollisionInt.cpp @@ -20,6 +20,7 @@ #include "../xml.h" #include "../XML_Writer.h" #include +using namespace std; namespace Cantera { diff --git a/Cantera/src/transport/MixTransport.cpp b/Cantera/src/transport/MixTransport.cpp index 7bd332c39..6c4101adc 100755 --- a/Cantera/src/transport/MixTransport.cpp +++ b/Cantera/src/transport/MixTransport.cpp @@ -26,6 +26,7 @@ #include "TransportFactory.h" #include +using namespace std; /** * Mole fractions below MIN_X will be set to MIN_X when computing diff --git a/Cantera/src/transport/MultiTransport.cpp b/Cantera/src/transport/MultiTransport.cpp index cea09b2c1..ae429d306 100755 --- a/Cantera/src/transport/MultiTransport.cpp +++ b/Cantera/src/transport/MultiTransport.cpp @@ -37,6 +37,7 @@ #include "TransportFactory.h" #include +using namespace std; /** * Mole fractions below MIN_X will be set to MIN_X when computing diff --git a/Cantera/src/transport/MultiTransport.h b/Cantera/src/transport/MultiTransport.h index 212ed66d0..8aeb594fa 100755 --- a/Cantera/src/transport/MultiTransport.h +++ b/Cantera/src/transport/MultiTransport.h @@ -125,7 +125,7 @@ namespace Cantera { if (eps > 0.0) m_eps_gmres = eps; } - void save(string outfile); + void save(std::string outfile); /** * @internal @@ -194,8 +194,8 @@ namespace Cantera { vector_fp m_mw; // polynomial fits - vector m_visccoeffs; - vector m_diffcoeffs; + std::vector m_visccoeffs; + std::vector m_diffcoeffs; vector_fp m_polytempvec; // property values @@ -206,11 +206,11 @@ namespace Cantera { array_fp m_molefracs; - vector > m_poly; - vector m_astar_poly; - vector m_bstar_poly; - vector m_cstar_poly; - vector m_om22_poly; + std::vector > m_poly; + std::vector m_astar_poly; + std::vector m_bstar_poly; + std::vector m_cstar_poly; + std::vector m_om22_poly; DenseMatrix m_astar; DenseMatrix m_bstar; DenseMatrix m_cstar; diff --git a/Cantera/src/transport/SolidTransport.cpp b/Cantera/src/transport/SolidTransport.cpp index da9ba8b12..849d4f537 100644 --- a/Cantera/src/transport/SolidTransport.cpp +++ b/Cantera/src/transport/SolidTransport.cpp @@ -23,6 +23,7 @@ #include "../utilities.h" #include +using namespace std; namespace Cantera { diff --git a/Cantera/src/transport/TransportBase.h b/Cantera/src/transport/TransportBase.h index 3d188bd94..c2c1efbd4 100755 --- a/Cantera/src/transport/TransportBase.h +++ b/Cantera/src/transport/TransportBase.h @@ -284,7 +284,7 @@ namespace Cantera { * method, the base class method will be called, resulting in * an exception being thrown. */ - doublereal err(string msg) const; + doublereal err(std::string msg) const; }; diff --git a/Cantera/src/transport/TransportFactory.cpp b/Cantera/src/transport/TransportFactory.cpp index aedae266a..272ef7564 100755 --- a/Cantera/src/transport/TransportFactory.cpp +++ b/Cantera/src/transport/TransportFactory.cpp @@ -34,6 +34,7 @@ #include "../IdealGasPhase.h" #include "../ctml.h" +using namespace std; /** * polynomial degree used for fitting collision integrals diff --git a/Cantera/src/units.h b/Cantera/src/units.h index c28ed28a7..593e15845 100644 --- a/Cantera/src/units.h +++ b/Cantera/src/units.h @@ -34,7 +34,7 @@ namespace Cantera { * energy to SI units. * @param units activation energy units */ - doublereal actEnergyToSI(string units) { + doublereal actEnergyToSI(std::string units) { if (m_act_u.find(units) != m_act_u.end()) { return m_act_u[units]; } @@ -50,15 +50,15 @@ namespace Cantera { * called m_u[] and m_act_u for activity * coefficients. These maps are initialized with likely values. */ - doublereal toSI(string units) { + doublereal toSI(std::string units) { // if dimensionless, return 1.0 if (units == "") return 1.0; doublereal f = 1.0, fctr; int tsize; - string u = units, tok, tsub; - string::size_type k; + std::string u = units, tok, tsub; + std::string::size_type k; char action = '-'; while (1 > 0) { @@ -66,7 +66,7 @@ namespace Cantera { // get token consisting of all characters up to the next // dash, slash, or the end of the string k = u.find_first_of("/-"); - if (k != string::npos) + if (k != std::string::npos) tok = u.substr(0,k); else tok = u; @@ -109,7 +109,7 @@ namespace Cantera { throw CanteraError("toSI","unknown unit: "+tsub); if (action == '-') f *= fctr; else if (action == '/') f /= fctr; - if (k == string::npos) break; + if (k == std::string::npos) break; action = u[k]; u = u.substr(k+1,u.size()); } @@ -121,8 +121,8 @@ namespace Cantera { /// pointer to the single instance of Unit static Unit* s_u; - map m_u; - map m_act_u; + std::map m_u; + std::map m_act_u; Unit(){ diff --git a/Cantera/src/vec_functions.h b/Cantera/src/vec_functions.h index 5817d189d..02a0484e6 100755 --- a/Cantera/src/vec_functions.h +++ b/Cantera/src/vec_functions.h @@ -29,7 +29,7 @@ namespace Cantera { */ template inline void copyn(size_t n, const T& x, T& y) { - copy(x.begin(), x.begin() + n, y.begin()); + std::copy(x.begin(), x.begin() + n, y.begin()); } /** @@ -38,8 +38,8 @@ namespace Cantera { */ template inline void divide_each(T& x, const T& y) { - transform(x.begin(), x.end(), y.begin(), - x.begin(), divides()); + std::transform(x.begin(), x.end(), y.begin(), + x.begin(), std::divides()); } /** @@ -48,8 +48,8 @@ namespace Cantera { */ template inline void multiply_each(T& x, const T& y) { - transform(x.begin(), x.end(), y.begin(), - x.begin(), multiplies()); + std::transform(x.begin(), x.end(), y.begin(), + x.begin(), std::multiplies()); } /** @@ -65,7 +65,7 @@ namespace Cantera { */ template inline doublereal dot_product(const T& x, const T& y) { - return inner_product(x.begin(), x.end(), y.begin(), 0.0); + return std::inner_product(x.begin(), x.end(), y.begin(), 0.0); } /** @@ -81,8 +81,8 @@ namespace Cantera { */ template inline void add_each(T& x, const T& y) { - transform(x.begin(), x.end(), y.begin(), - x.begin(), plus()); + std::transform(x.begin(), x.end(), y.begin(), + x.begin(), std::plus()); } template @@ -98,7 +98,7 @@ namespace Cantera { * value, and return this value. */ template - inline T absmax(const vector& v) { + inline T absmax(const std::vector& v) { int n = v.size(); T val; T maxval = 0.0; diff --git a/Cantera/src/xml.h b/Cantera/src/xml.h index 952e083d7..25e796c54 100755 --- a/Cantera/src/xml.h +++ b/Cantera/src/xml.h @@ -19,7 +19,7 @@ #include #include #include -using namespace std; +//using namespace std; #include "ctexceptions.h" #include "ct_defs.h" @@ -38,20 +38,21 @@ namespace Cantera { */ class XML_Reader { public: - XML_Reader(istream& input) : m_s(input), m_line(0) {} + XML_Reader(std::istream& input) : m_s(input), m_line(0) {} - istream& m_s; + std::istream& m_s; int m_line; void getchr(char& ch); - string strip(const string& aline); - string inquotes(const string& aline); + std::string strip(const std::string& aline); + std::string inquotes(const std::string& aline); - int findQuotedString(const string& aline, string &rstring); + int findQuotedString(const std::string& aline, std::string &rstring); - void parseTag(string line, string& name, map& attribs); - string readTag(map& attribs); - string readValue(); + void parseTag(std::string line, std::string& name, + std::map& attribs); + std::string readTag(std::map& attribs); + std::string readValue(); }; @@ -60,21 +61,21 @@ namespace Cantera { class XML_Node { public: - XML_Node(string nm = "--", XML_Node* p = 0, int n = 0); + XML_Node(std::string nm = "--", XML_Node* p = 0, int n = 0); virtual ~XML_Node(); - void addComment(string comment); + void addComment(std::string comment); XML_Node& addChild(XML_Node& node); - XML_Node& addChild(string name); - XML_Node& addChild(string name, string value); - XML_Node& addChild(string name, double value, string fmt="%g"); + XML_Node& addChild(std::string name); + XML_Node& addChild(std::string name, std::string value); + XML_Node& addChild(std::string name, double value, std::string fmt="%g"); void removeChild(XML_Node* node); - void addValue(string val); - void addValue(doublereal val, string fmt="%g"); - void addAttribute(string attrib, string value); - void addAttribute(string attrib, double value, string fmt="%g"); - void writeHeader(ostream& s); - string value() const { return m_value; } - string value(string loc) const { return child(loc).value(); } + void addValue(std::string val); + void addValue(doublereal val, std::string fmt="%g"); + void addAttribute(std::string attrib, std::string value); + void addAttribute(std::string attrib, double value, std::string fmt="%g"); + void writeHeader(std::ostream& s); + std::string value() const { return m_value; } + std::string value(std::string loc) const { return child(loc).value(); } void setLineNumber(int n) {m_linenum = n;} int lineNumber() const {return m_linenum;} doublereal fp_value() const { @@ -83,8 +84,8 @@ namespace Cantera { integer int_value() const { return atoi(m_value.c_str()); } - string operator()() const { return m_value; } - string operator()(string loc) const { return value(loc); } + std::string operator()() const { return m_value; } + std::string operator()(std::string loc) const { return value(loc); } /** * The operator[] is overloaded to provide a lookup capability @@ -93,54 +94,54 @@ namespace Cantera { * For example * xmlNode["id"] * will return the value of the attribute "id" for the current - * XML element. It will return the blank string if there isn't + * XML element. It will return the blank std::string if there isn't * an attribute with that name. */ - string operator[](string attr) const { + std::string operator[](std::string attr) const { return attrib(attr); } /** * This function searches the attibutes vector for the parameter - * string attribute. If a match is found, the attribute value + * std::string attribute. If a match is found, the attribute value * is returned as a string. If no match is found, the empty string * is returned. * - * @param(attr) String containing the attribute to be searched for. + * @param(attr) Std::String containing the attribute to be searched for. */ - string attrib(string attr) const { - map::const_iterator i = m_attribs.find(attr); + std::string attrib(std::string attr) const { + std::map::const_iterator i = m_attribs.find(attr); if (i != m_attribs.end()) return i->second; return ""; } - map& attribs() { return m_attribs; } + std::map& attribs() { return m_attribs; } XML_Node* parent() const { return m_parent; } XML_Node* setParent(XML_Node* p) { m_parent = p; return p; } - bool hasChild(string ch) const { + bool hasChild(std::string ch) const { return (m_childindex.find(ch) != m_childindex.end()); } - bool hasAttrib(string a) const { + bool hasAttrib(std::string a) const { return (m_attribs.find(a) != m_attribs.end()); } - string name() const { return m_name; } - string id() const { + std::string name() const { return m_name; } + std::string id() const { if (hasAttrib("id")) return attrib("id"); else return ""; } int number() const { return m_n; } XML_Node& child(int n) const { return *m_children[n]; } - vector& children() { return m_children; } - const vector& children() const { return m_children; } + std::vector& children() { return m_children; } + const std::vector& children() const { return m_children; } int nChildren() const { return m_nchildren; } - void build(istream& f); + void build(std::istream& f); - void _require(string a, string v) const; + void _require(std::string a, std::string v) const; /** * This routine carries out a search for an XML node based @@ -155,15 +156,15 @@ namespace Cantera { * This algorithm does a lateral search of first generation children * first before diving deeper into each tree branch. */ - XML_Node* findNameID(const string &nameTarget, - const string &idTarget) const; + XML_Node* findNameID(const std::string &nameTarget, + const std::string &idTarget) const; - XML_Node* findID(const string& id, int depth=100) const; - XML_Node* findByAttr(const string& attr, const string& val); - XML_Node* findByName(const string& nm); - void getChildren(string name, vector& children) const; - XML_Node& child(string loc) const; - void write(ostream& s, int level = 0) const; + XML_Node* findID(const std::string& id, int depth=100) const; + XML_Node* findByAttr(const std::string& attr, const std::string& val); + XML_Node* findByName(const std::string& nm); + void getChildren(std::string name, std::vector& children) const; + XML_Node& child(std::string loc) const; + void write(std::ostream& s, int level = 0) const; XML_Node& root() const { return *m_root; } void setRoot(XML_Node& root) { m_root = &root; } void copyUnion(XML_Node *node_dest); @@ -172,18 +173,18 @@ namespace Cantera { void unlock() {m_locked = false; } private: - void write_int(ostream& s, int level = 0) const; + void write_int(std::ostream& s, int level = 0) const; protected: - string m_name; - string m_value; - map m_childindex; - map m_attribs; + std::string m_name; + std::string m_value; + std::map m_childindex; + std::map m_attribs; XML_Node* m_parent; XML_Node* m_root; bool m_locked; - vector m_children; + std::vector m_children; int m_nchildren; int m_n; bool m_iscomment; @@ -191,7 +192,7 @@ namespace Cantera { }; - XML_Node * findXMLPhase(XML_Node* root, const string &id); + XML_Node * findXMLPhase(XML_Node* root, const std::string &id); } diff --git a/Cantera/src/zeroD/ConstPressureReactor.cpp b/Cantera/src/zeroD/ConstPressureReactor.cpp index 439369269..a15b810d2 100644 --- a/Cantera/src/zeroD/ConstPressureReactor.cpp +++ b/Cantera/src/zeroD/ConstPressureReactor.cpp @@ -19,6 +19,7 @@ #include "../SurfPhase.h" using namespace Cantera; +using namespace std; namespace CanteraZeroD { diff --git a/Cantera/src/zeroD/ConstPressureReactor.h b/Cantera/src/zeroD/ConstPressureReactor.h index ed46e54a9..0e82d1306 100644 --- a/Cantera/src/zeroD/ConstPressureReactor.h +++ b/Cantera/src/zeroD/ConstPressureReactor.h @@ -60,7 +60,7 @@ namespace CanteraZeroD { virtual void updateState(doublereal* y); - virtual int componentIndex(string nm) const; + virtual int componentIndex(std::string nm) const; protected: diff --git a/Cantera/src/zeroD/FlowDevice.cpp b/Cantera/src/zeroD/FlowDevice.cpp index bdf9e3ead..14a180c2c 100644 --- a/Cantera/src/zeroD/FlowDevice.cpp +++ b/Cantera/src/zeroD/FlowDevice.cpp @@ -3,6 +3,8 @@ #include "ReactorBase.h" #include "../Func1.h" +using namespace std; + namespace CanteraZeroD { bool FlowDevice::install(ReactorBase& in, ReactorBase& out) { diff --git a/Cantera/src/zeroD/FlowDevice.h b/Cantera/src/zeroD/FlowDevice.h index 7936cba1d..d20083a0a 100644 --- a/Cantera/src/zeroD/FlowDevice.h +++ b/Cantera/src/zeroD/FlowDevice.h @@ -17,6 +17,8 @@ #endif #include "../ct_defs.h" +#include "../global.h" +#include "../stringUtils.h" namespace Cantera { class Func1; @@ -174,9 +176,9 @@ namespace CanteraZeroD { ReactorBase* m_out; vector_int m_in2out, m_out2in; - void warn(string meth) { - cerr << "Warning: method " << meth << " of base class " - << " FlowDevice called. Nothing done."; + void warn(std::string meth) { + writelog(std::string("Warning: method ") + meth + " of base class " + + " FlowDevice called. Nothing done.\n"); } }; diff --git a/Cantera/src/zeroD/FlowReactor.cpp b/Cantera/src/zeroD/FlowReactor.cpp index 26c3ea778..2234da45b 100644 --- a/Cantera/src/zeroD/FlowReactor.cpp +++ b/Cantera/src/zeroD/FlowReactor.cpp @@ -15,6 +15,7 @@ #include "FlowReactor.h" using namespace Cantera; +using namespace std; namespace CanteraZeroD { diff --git a/Cantera/src/zeroD/FlowReactor.h b/Cantera/src/zeroD/FlowReactor.h index f928aa84b..e6b750d79 100644 --- a/Cantera/src/zeroD/FlowReactor.h +++ b/Cantera/src/zeroD/FlowReactor.h @@ -68,7 +68,7 @@ namespace CanteraZeroD { double speed() const { return m_speed; } double distance() const { return m_dist; } - virtual int componentIndex(string nm) const; + virtual int componentIndex(std::string nm) const; protected: diff --git a/Cantera/src/zeroD/Reactor.cpp b/Cantera/src/zeroD/Reactor.cpp index 26da3f3e2..9385f348f 100644 --- a/Cantera/src/zeroD/Reactor.cpp +++ b/Cantera/src/zeroD/Reactor.cpp @@ -20,6 +20,7 @@ #include "../SurfPhase.h" using namespace Cantera; +using namespace std; namespace CanteraZeroD { diff --git a/Cantera/src/zeroD/Reactor.h b/Cantera/src/zeroD/Reactor.h index 368681fc6..87dd51bf4 100644 --- a/Cantera/src/zeroD/Reactor.h +++ b/Cantera/src/zeroD/Reactor.h @@ -115,10 +115,10 @@ namespace CanteraZeroD { virtual int nSensParams(); virtual void addSensitivityReaction(int rxn); - virtual string sensParamID(int p) { return m_pname[p]; } + virtual std::string sensParamID(int p) { return m_pname[p]; } - // virtual string component(int k) const; - virtual int componentIndex(string nm) const; + // virtual std::string component(int k) const; + virtual int componentIndex(std::string nm) const; protected: @@ -137,7 +137,7 @@ namespace CanteraZeroD { int m_nsens; vector_int m_pnum; - vector m_pname; + std::vector m_pname; vector_int m_nsens_wall; vector_fp m_mult_save; diff --git a/Cantera/src/zeroD/ReactorBase.cpp b/Cantera/src/zeroD/ReactorBase.cpp index 880755176..9348e6d66 100644 --- a/Cantera/src/zeroD/ReactorBase.cpp +++ b/Cantera/src/zeroD/ReactorBase.cpp @@ -18,6 +18,7 @@ #include "FlowDevice.h" #include "Wall.h" +using namespace std; namespace CanteraZeroD { ReactorBase::ReactorBase(string name) : m_nsp(0), diff --git a/Cantera/src/zeroD/ReactorBase.h b/Cantera/src/zeroD/ReactorBase.h index 433612be2..d67aa1b2a 100644 --- a/Cantera/src/zeroD/ReactorBase.h +++ b/Cantera/src/zeroD/ReactorBase.h @@ -45,14 +45,14 @@ namespace CanteraZeroD { public: - ReactorBase(string name = "(none)"); + ReactorBase(std::string name = "(none)"); virtual ~ReactorBase(){} //----------------------------------------------------- virtual int type() const { return 0; } - string name() const { return m_name; } - void setName(string name) { m_name = name; } + std::string name() const { return m_name; } + void setName(std::string name) { m_name = name; } /** @name Methods to set up a simulation. */ //@{ @@ -143,7 +143,7 @@ namespace CanteraZeroD { //@} - int error(string msg) const { + int error(std::string msg) const { writelog("Error: "+msg); return 1; } @@ -161,16 +161,16 @@ namespace CanteraZeroD { doublereal m_intEnergy; doublereal m_pressure; vector_fp m_state; - vector m_inlet, m_outlet; - vector m_wall; + std::vector m_inlet, m_outlet; + std::vector m_wall; vector_int m_lr; int m_nwalls; - string m_name; + std::string m_name; double m_rho0; private: - void tilt(string method="") const { + void tilt(std::string method="") const { throw CanteraError("ReactorBase::"+method, "ReactorBase method called!"); } }; diff --git a/Cantera/src/zeroD/ReactorFactory.cpp b/Cantera/src/zeroD/ReactorFactory.cpp index ed0e640e9..0bd165a70 100644 --- a/Cantera/src/zeroD/ReactorFactory.cpp +++ b/Cantera/src/zeroD/ReactorFactory.cpp @@ -22,6 +22,7 @@ #include "FlowReactor.h" #include "ConstPressureReactor.h" +using namespace std; namespace CanteraZeroD { ReactorFactory* ReactorFactory::s_factory = 0; diff --git a/Cantera/src/zeroD/ReactorFactory.h b/Cantera/src/zeroD/ReactorFactory.h index 8a28cb7a0..6dae2ad20 100644 --- a/Cantera/src/zeroD/ReactorFactory.h +++ b/Cantera/src/zeroD/ReactorFactory.h @@ -45,7 +45,7 @@ namespace CanteraZeroD { * @param n the type to be created. */ virtual ReactorBase* newReactor(int n); - virtual ReactorBase* newReactor(string reactorType); + virtual ReactorBase* newReactor(std::string reactorType); private: @@ -53,7 +53,7 @@ namespace CanteraZeroD { ReactorFactory(){} }; - inline ReactorBase* newReactor(string model, + inline ReactorBase* newReactor(std::string model, ReactorFactory* f=0) { if (f == 0) { f = ReactorFactory::factory(); diff --git a/Cantera/src/zeroD/ReactorNet.cpp b/Cantera/src/zeroD/ReactorNet.cpp index b988043e9..910ab4b7e 100644 --- a/Cantera/src/zeroD/ReactorNet.cpp +++ b/Cantera/src/zeroD/ReactorNet.cpp @@ -1,6 +1,8 @@ #include "ReactorNet.h" #include "../Integrator.h" +using namespace std; + namespace CanteraZeroD { ReactorNet::ReactorNet() : FuncEval(), m_nr(0), m_nreactors(0), diff --git a/Cantera/src/zeroD/ReactorNet.h b/Cantera/src/zeroD/ReactorNet.h index d0ab06204..33983ec18 100644 --- a/Cantera/src/zeroD/ReactorNet.h +++ b/Cantera/src/zeroD/ReactorNet.h @@ -119,7 +119,7 @@ namespace CanteraZeroD { return m_integ->sensitivity(k, p)/m_integ->solution(k); } - double sensitivity(string species, int p, int reactor=0) { + double sensitivity(std::string species, int p, int reactor=0) { int k = globalComponentIndex(species, reactor); return sensitivity(k, p); } @@ -134,12 +134,12 @@ namespace CanteraZeroD { doublereal* y); virtual int nparams() { return m_ntotpar; } - int globalComponentIndex(string species, int reactor=0); + int globalComponentIndex(std::string species, int reactor=0); protected: - vector m_r; - vector m_reactors; + std::vector m_r; + std::vector m_reactors; int m_nr; int m_nreactors; Integrator* m_integ; diff --git a/Cantera/src/zeroD/Wall.cpp b/Cantera/src/zeroD/Wall.cpp index eede0e8e8..61a19c9ec 100644 --- a/Cantera/src/zeroD/Wall.cpp +++ b/Cantera/src/zeroD/Wall.cpp @@ -5,6 +5,9 @@ #include "../InterfaceKinetics.h" #include "../SurfPhase.h" +using Cantera::Func1; +using Cantera::Kinetics; + namespace CanteraZeroD { diff --git a/Cantera/src/zeroD/Wall.h b/Cantera/src/zeroD/Wall.h index af25b44d7..263ee5d6a 100644 --- a/Cantera/src/zeroD/Wall.h +++ b/Cantera/src/zeroD/Wall.h @@ -28,7 +28,7 @@ namespace Cantera { class Func1; class SurfPhase; } -using namespace Cantera; +//using namespace Cantera; namespace CanteraZeroD { @@ -69,12 +69,12 @@ namespace CanteraZeroD { /// Set the emissivity. void setEmissivity(doublereal epsilon) { if (epsilon > 1.0 || epsilon < 0.0) - throw CanteraError("Wall::setEmissivity", + throw Cantera::CanteraError("Wall::setEmissivity", "emissivity must be between 0.0 and 1.0"); m_emiss = epsilon; } /** Set the piston velocity to a specified function. */ - void setVelocity(Func1* f=0) {if (f) m_vf = f;} + void setVelocity(Cantera::Func1* f=0) {if (f) m_vf = f;} /** * Set the expansion rate coefficient. @@ -83,7 +83,7 @@ namespace CanteraZeroD { /// Specify the heat flux function \f$ q_0(t) \f$. - void setHeatFlux(Func1* q) { m_qf = q;} + void setHeatFlux(Cantera::Func1* q) { m_qf = q;} /// Install the wall between two reactors or reservoirs bool install(ReactorBase& leftReactor, ReactorBase& rightReactor); @@ -110,15 +110,16 @@ namespace CanteraZeroD { // Specify the heterogeneous reaction mechanisms for each side // of the wall. - void setKinetics(Kinetics* leftMechanism, Kinetics* rightMechanism); + void setKinetics(Cantera::Kinetics* leftMechanism, + Cantera::Kinetics* rightMechanism); /// Return a pointer to the surface phase object for the left /// or right wall surface. - SurfPhase* surface(int leftright) { + Cantera::SurfPhase* surface(int leftright) { return m_surf[leftright]; } - Kinetics* kinetics(int leftright) { + Cantera::Kinetics* kinetics(int leftright) { return m_chem[leftright]; } @@ -142,7 +143,7 @@ namespace CanteraZeroD { return m_pright.size(); } void addSensitivityReaction(int leftright, int rxn); - string sensitivityParamID(int leftright, int p) { + std::string sensitivityParamID(int leftright, int p) { if (leftright == 0) return m_pname_left[p]; else @@ -159,18 +160,18 @@ namespace CanteraZeroD { ReactorBase* m_left; ReactorBase* m_right; - Kinetics * m_chem[2]; - SurfPhase* m_surf[2]; + Cantera::Kinetics * m_chem[2]; + Cantera::SurfPhase* m_surf[2]; int m_nsp[2]; doublereal m_area, m_k, m_rrth; doublereal m_emiss; - Func1 *m_vf; - Func1 *m_qf; - vector_fp m_leftcov, m_rightcov; + Cantera::Func1 *m_vf; + Cantera::Func1 *m_qf; + Cantera::vector_fp m_leftcov, m_rightcov; - vector_int m_pleft, m_pright; - vector_fp m_leftmult_save, m_rightmult_save; - vector m_pname_left, m_pname_right; + Cantera::vector_int m_pleft, m_pright; + Cantera::vector_fp m_leftmult_save, m_rightmult_save; + std::vector m_pname_left, m_pname_right; private: diff --git a/Cantera/user/user.cpp b/Cantera/user/user.cpp index 9e8c793b4..b4a757340 100644 --- a/Cantera/user/user.cpp +++ b/Cantera/user/user.cpp @@ -8,6 +8,7 @@ using namespace Cantera; namespace User { + using namespace std; void hello() { cout << "Hello!" << endl; diff --git a/ChangeLog b/ChangeLog index 0216ea8e9..a349d3fff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-11-14 01:20 dggoodwin + + * Cantera/python/examples/reactors/surf_pfr.py: added pfr example + +2006-11-14 01:18 dggoodwin + + * Cantera.README: Cantera.README no longer used + 2006-11-14 00:40 dggoodwin * configure, configure.in, Cantera/src/MultiPhaseEquil.cpp: minor diff --git a/configure.in b/configure.in index a27b04d36..019860917 100755 --- a/configure.in +++ b/configure.in @@ -95,7 +95,7 @@ case $ac_sys_system in EXTRA_LINK="-framework Accelerate $EXTRA_LINK"; # CXX_INCLUDES="$CXX_INCLUDES -I/System/Library/Frameworks/Accelerate.framework/Headers" mex_ext=mexmac;; - CYGWIN*) OS_IS_CYGWIN=1; mex_ext=dll;; + CYGWIN*) OS_IS_CYGWIN=1; mex_ext=mexw32;; Linux* ) case $BITHARDWARE in 64 ) if test "$BITCHANGE" = "y" ; then ldemulationarg='-melf_i386' diff --git a/examples/cxx/example_utils.h b/examples/cxx/example_utils.h index faa6c5963..2439816e1 100755 --- a/examples/cxx/example_utils.h +++ b/examples/cxx/example_utils.h @@ -4,6 +4,11 @@ #include #include +using namespace Cantera; +using namespace std; +namespace CanteraZeroD{} +using namespace CanteraZeroD; + // Save the temperature, density, pressure, and mole fractions at one // time template diff --git a/examples/cxx/examples.cpp b/examples/cxx/examples.cpp index a33734ba8..d33460d72 100755 --- a/examples/cxx/examples.cpp +++ b/examples/cxx/examples.cpp @@ -1,5 +1,8 @@ #include +using namespace Cantera; +using namespace std; + //#include "ctexceptions.h" // turn off warnings under Windows diff --git a/examples/cxx/kinetics_example1.cpp b/examples/cxx/kinetics_example1.cpp index 481f890f9..e3ccb5453 100755 --- a/examples/cxx/kinetics_example1.cpp +++ b/examples/cxx/kinetics_example1.cpp @@ -21,6 +21,8 @@ #include #include #include "example_utils.h" +using namespace Cantera; +using namespace std; // Kinetics example. This is written as a function so that one // driver program can run multiple examples. diff --git a/ext/f2c_libs/arith.h b/ext/f2c_libs/arith.h index 9746f9c1c..508eb414f 100644 --- a/ext/f2c_libs/arith.h +++ b/ext/f2c_libs/arith.h @@ -1,3 +1,4 @@ -#define IEEE_8087 -#define Arith_Kind_ASL 1 -#define Double_Align +#define IEEE_MC68k +#define Arith_Kind_ASL 2 +#define Double_Align +#define NANCHECK diff --git a/preconfig b/preconfig index 987cd6e7c..b45bd16f8 100755 --- a/preconfig +++ b/preconfig @@ -254,7 +254,7 @@ USE_SUNDIALS=${USE_SUNDIALS:='default'} # This is where you installed sundials if you used the --prefix option # when you configured sundials. If you didn't use the prefix option, # then comment this line out. -SUNDIALS_HOME=${SUNDIALS_HOME:=$HOME/sundials} +#SUNDIALS_HOME=${SUNDIALS_HOME:=$HOME/sundials} # It is recommended that you install the newest release of sundials diff --git a/test_problems/ChemEquil_gri_matrix/gri_matrix.cpp b/test_problems/ChemEquil_gri_matrix/gri_matrix.cpp index a6f8d65d6..6e81554b3 100644 --- a/test_problems/ChemEquil_gri_matrix/gri_matrix.cpp +++ b/test_problems/ChemEquil_gri_matrix/gri_matrix.cpp @@ -18,6 +18,9 @@ #include "equilibrium.h" #endif +using namespace std; +using namespace Cantera; + int main(int argc, char **argv) { int numSucc = 0; int numFail = 0; diff --git a/test_problems/ChemEquil_gri_pairs/gri_pairs.cpp b/test_problems/ChemEquil_gri_pairs/gri_pairs.cpp index 35115a1fa..ea3978a5e 100644 --- a/test_problems/ChemEquil_gri_pairs/gri_pairs.cpp +++ b/test_problems/ChemEquil_gri_pairs/gri_pairs.cpp @@ -18,6 +18,9 @@ #include "equilibrium.h" #endif +using namespace std; +using namespace Cantera; + int main(int argc, char **argv) { try { IdealGasMix g("gri30.xml", "gri30_mix"); diff --git a/test_problems/negATest/negATest.cpp b/test_problems/negATest/negATest.cpp index 97b88aade..59cfbacf0 100644 --- a/test_problems/negATest/negATest.cpp +++ b/test_problems/negATest/negATest.cpp @@ -6,6 +6,7 @@ * */ + #ifdef SRCDIRTREE #include "ct_defs.h" #include "ctml.h" @@ -23,13 +24,15 @@ #include "kernel/InterfaceKinetics.h" #endif -using namespace Cantera; +#include + +using namespace Cantera; +using namespace std; -# int main(int argc, char **argv) { try { int i; - string infile = "noxNeg.xml"; + std::string infile = "noxNeg.xml"; double x[20]; double cdot[20], ddot[20]; diff --git a/test_problems/silane_equil/IdealGasMix.h b/test_problems/silane_equil/IdealGasMix.h index 81948e031..98ff16675 100644 --- a/test_problems/silane_equil/IdealGasMix.h +++ b/test_problems/silane_equil/IdealGasMix.h @@ -16,7 +16,7 @@ namespace Cantera { IdealGasMix() : m_ok(false), m_r(0) {} - IdealGasMix(string infile, string id="") : m_ok(false), m_r(0) { + IdealGasMix(std::string infile, std::string id="") : m_ok(false), m_r(0) { m_r = get_XML_File(infile); if (id == "-") id = ""; @@ -26,7 +26,7 @@ namespace Cantera { } - IdealGasMix(XML_Node& root, string id) : m_ok(false), m_r(0) { + IdealGasMix(XML_Node& root, std::string id) : m_ok(false), m_r(0) { m_ok = buildSolutionFromXML(root, id, "phase", this, this); } @@ -34,8 +34,8 @@ namespace Cantera { bool operator!() { return !m_ok;} bool ready() const { return m_ok; } - friend ostream& operator<<(ostream& s, IdealGasMix& mix) { - string r = report(mix, true); + friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) { + std::string r = report(mix, true); s << r; return s; } diff --git a/test_problems/silane_equil/silane_equil.cpp b/test_problems/silane_equil/silane_equil.cpp index e0560b8b3..dd1e37ae0 100644 --- a/test_problems/silane_equil/silane_equil.cpp +++ b/test_problems/silane_equil/silane_equil.cpp @@ -19,6 +19,9 @@ #include "equilibrium.h" #endif +using namespace std; +using namespace Cantera; + int main(int argc, char **argv) { try { IdealGasMix g("silane.xml", "silane"); diff --git a/test_problems/surfkin/Interface.h b/test_problems/surfkin/Interface.h index 9e2e92268..c17153690 100644 --- a/test_problems/surfkin/Interface.h +++ b/test_problems/surfkin/Interface.h @@ -36,10 +36,10 @@ namespace Cantera { * in the interface * */ - Interface(string infile, string id, vector phases) + Interface(std::string infile, std::string id, std::vector phases) : m_ok(false), m_r(0) { - string path = findInputFile(infile); - ifstream fin(path.c_str()); + std::string path = findInputFile(infile); + std::ifstream fin(path.c_str()); if (!fin) { throw CanteraError("Interface","could not open " +path+" for reading."); diff --git a/test_problems/surfkin/surfdemo.cpp b/test_problems/surfkin/surfdemo.cpp index 0aad0cf7f..9859ab2a0 100644 --- a/test_problems/surfkin/surfdemo.cpp +++ b/test_problems/surfkin/surfdemo.cpp @@ -13,7 +13,9 @@ #include "IdealGasMix.h" #include "Interface.h" #endif + using namespace Cantera; +using namespace std; int main() { diff --git a/tools/src/cti2ctml.cpp b/tools/src/cti2ctml.cpp index 8b53015d9..45016caa3 100644 --- a/tools/src/cti2ctml.cpp +++ b/tools/src/cti2ctml.cpp @@ -18,7 +18,7 @@ #include "xml.h" #include "ctml.h" - +using namespace Cantera; using namespace std; #ifdef DEBUG_HKM