diff --git a/test_problems/cathermo/DH_graph_1/DH_graph_1.cpp b/test_problems/cathermo/DH_graph_1/DH_graph_1.cpp index 79b398f6e..a42e1ed47 100644 --- a/test_problems/cathermo/DH_graph_1/DH_graph_1.cpp +++ b/test_problems/cathermo/DH_graph_1/DH_graph_1.cpp @@ -2,7 +2,7 @@ * @file DH_graph_1 */ -#include "cantera/base/logger.h" +#include "fileLog.h" #include "cantera/thermo/DebyeHuckel.h" #include @@ -12,28 +12,6 @@ using namespace Cantera; typedef double doublereal; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs << endl; - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: DH_test " << endl; diff --git a/test_problems/cathermo/DH_graph_NM/DH_graph_1.cpp b/test_problems/cathermo/DH_graph_NM/DH_graph_1.cpp index 6caac3b1b..652bcdb36 100644 --- a/test_problems/cathermo/DH_graph_NM/DH_graph_1.cpp +++ b/test_problems/cathermo/DH_graph_NM/DH_graph_1.cpp @@ -2,7 +2,7 @@ * @file DH_graph_1 */ -#include "cantera/base/logger.h" +#include "fileLog.h" #include "cantera/thermo/DebyeHuckel.h" #include @@ -10,28 +10,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs << endl; - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: DH_test " << endl; diff --git a/test_problems/cathermo/DH_graph_Pitzer/DH_graph_1.cpp b/test_problems/cathermo/DH_graph_Pitzer/DH_graph_1.cpp index 6caac3b1b..652bcdb36 100644 --- a/test_problems/cathermo/DH_graph_Pitzer/DH_graph_1.cpp +++ b/test_problems/cathermo/DH_graph_Pitzer/DH_graph_1.cpp @@ -2,7 +2,7 @@ * @file DH_graph_1 */ -#include "cantera/base/logger.h" +#include "fileLog.h" #include "cantera/thermo/DebyeHuckel.h" #include @@ -10,28 +10,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs << endl; - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: DH_test " << endl; diff --git a/test_problems/cathermo/DH_graph_acommon/DH_graph_1.cpp b/test_problems/cathermo/DH_graph_acommon/DH_graph_1.cpp index 6caac3b1b..652bcdb36 100644 --- a/test_problems/cathermo/DH_graph_acommon/DH_graph_1.cpp +++ b/test_problems/cathermo/DH_graph_acommon/DH_graph_1.cpp @@ -2,7 +2,7 @@ * @file DH_graph_1 */ -#include "cantera/base/logger.h" +#include "fileLog.h" #include "cantera/thermo/DebyeHuckel.h" #include @@ -10,28 +10,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs << endl; - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: DH_test " << endl; diff --git a/test_problems/cathermo/DH_graph_bdotak/DH_graph_1.cpp b/test_problems/cathermo/DH_graph_bdotak/DH_graph_1.cpp index 6caac3b1b..652bcdb36 100644 --- a/test_problems/cathermo/DH_graph_bdotak/DH_graph_1.cpp +++ b/test_problems/cathermo/DH_graph_bdotak/DH_graph_1.cpp @@ -2,7 +2,7 @@ * @file DH_graph_1 */ -#include "cantera/base/logger.h" +#include "fileLog.h" #include "cantera/thermo/DebyeHuckel.h" #include @@ -10,28 +10,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs << endl; - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: DH_test " << endl; diff --git a/test_problems/cathermo/HMW_dupl_test/HMW_dupl_test.cpp b/test_problems/cathermo/HMW_dupl_test/HMW_dupl_test.cpp index 6853f6dd9..a7614b03c 100644 --- a/test_problems/cathermo/HMW_dupl_test/HMW_dupl_test.cpp +++ b/test_problems/cathermo/HMW_dupl_test/HMW_dupl_test.cpp @@ -3,7 +3,6 @@ * @file HMW_graph_1.cpp */ -#include "cantera/base/logger.h" #include "cantera/thermo.h" #include "TemperatureTable.h" #include "cantera/thermo/HMWSoln.h" @@ -13,28 +12,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs.flush(); - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: HMW_test " << endl; @@ -42,7 +19,6 @@ void printUsage() } - int main(int argc, char** argv) { @@ -58,12 +34,8 @@ int main(int argc, char** argv) } double Cp0_R[20], pmCp[20]; - //fileLog *fl = new fileLog("HMW_graph_1.log"); - //setLogger(fl); - HMWSoln* HMW = new HMWSoln(iFile, "NaCl_electrolyte"); - /* * Load in and initialize the */ diff --git a/test_problems/cathermo/HMW_graph_CpvT/HMW_graph_CpvT.cpp b/test_problems/cathermo/HMW_graph_CpvT/HMW_graph_CpvT.cpp index 5aa5d13a2..fd570442a 100644 --- a/test_problems/cathermo/HMW_graph_CpvT/HMW_graph_CpvT.cpp +++ b/test_problems/cathermo/HMW_graph_CpvT/HMW_graph_CpvT.cpp @@ -2,9 +2,9 @@ * @file HMW_graph_1.cpp */ -#include "cantera/base/logger.h" -#include "cantera/thermo.h" #include "TemperatureTable.h" + +#include "cantera/thermo.h" #include "cantera/thermo/HMWSoln.h" #include @@ -12,28 +12,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs.flush(); - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: HMW_test " << endl; @@ -78,9 +56,6 @@ int main(int argc, char** argv) } double Cp0_R[20], pmCp[20]; - //fileLog *fl = new fileLog("HMW_graph_1.log"); - //setLogger(fl); - HMWSoln* HMW = new HMWSoln(iFile, "NaCl_electrolyte"); diff --git a/test_problems/cathermo/HMW_graph_GvI/HMW_graph_GvI.cpp b/test_problems/cathermo/HMW_graph_GvI/HMW_graph_GvI.cpp index 05a8cbe7d..031a07679 100644 --- a/test_problems/cathermo/HMW_graph_GvI/HMW_graph_GvI.cpp +++ b/test_problems/cathermo/HMW_graph_GvI/HMW_graph_GvI.cpp @@ -10,23 +10,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - virtual void write(const string& msg) { - m_fs << msg; - } - virtual ~fileLog() { - m_fs.close(); - } - string m_fName; - fstream m_fs; -}; - void printUsage() { cout << "usage: HMW_test " << endl; @@ -85,9 +68,6 @@ int main(int argc, char** argv) aTemp[5] = 273.15 + 275.; aTemp[6] = 273.15 + 300.; - //fileLog *fl = new fileLog("HMW_graph_1.log"); - //setLogger(fl); - HMWSoln* HMW = new HMWSoln(iFile, "NaCl_electrolyte"); int nsp = HMW->nSpecies(); diff --git a/test_problems/cathermo/HMW_graph_GvT/HMW_graph_GvT.cpp b/test_problems/cathermo/HMW_graph_GvT/HMW_graph_GvT.cpp index 0bd8c71b2..66cad0228 100644 --- a/test_problems/cathermo/HMW_graph_GvT/HMW_graph_GvT.cpp +++ b/test_problems/cathermo/HMW_graph_GvT/HMW_graph_GvT.cpp @@ -4,7 +4,6 @@ */ #include "cantera/thermo/ThermoPhase.h" -#include "cantera/base/logger.h" #include "cantera/thermo.h" #include "cantera/thermo/HMWSoln.h" @@ -15,28 +14,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs.flush(); - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: HMW_test " << endl; @@ -87,9 +64,6 @@ int main(int argc, char** argv) strcpy(iFile, argv[1]); } - //fileLog *fl = new fileLog("HMW_graph_1.log"); - //setLogger(fl); - HMWSoln* HMW = new HMWSoln(iFile, "NaCl_electrolyte"); diff --git a/test_problems/cathermo/HMW_graph_HvT/HMW_graph_HvT.cpp b/test_problems/cathermo/HMW_graph_HvT/HMW_graph_HvT.cpp index 48a7c5c91..b05c96d6e 100644 --- a/test_problems/cathermo/HMW_graph_HvT/HMW_graph_HvT.cpp +++ b/test_problems/cathermo/HMW_graph_HvT/HMW_graph_HvT.cpp @@ -4,7 +4,6 @@ #include "cantera/thermo.h" #include "cantera/thermo/HMWSoln.h" -#include "cantera/base/logger.h" #include "TemperatureTable.h" @@ -13,28 +12,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs.flush(); - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: HMW_test " << endl; @@ -86,9 +63,6 @@ int main(int argc, char** argv) } double Enth0_RT[20], pmEnth[20], molarEnth; - //fileLog *fl = new fileLog("HMW_graph_1.log"); - //setLogger(fl); - HMWSoln* HMW = new HMWSoln(iFile, "NaCl_electrolyte"); diff --git a/test_problems/cathermo/HMW_graph_VvT/HMW_graph_VvT.cpp b/test_problems/cathermo/HMW_graph_VvT/HMW_graph_VvT.cpp index 3cd24cc8f..d78ba28a0 100644 --- a/test_problems/cathermo/HMW_graph_VvT/HMW_graph_VvT.cpp +++ b/test_problems/cathermo/HMW_graph_VvT/HMW_graph_VvT.cpp @@ -2,7 +2,6 @@ * @file HMW_graph_VvT */ -#include "cantera/base/logger.h" #include "cantera/thermo.h" #include "TemperatureTable.h" #include "cantera/thermo/HMWSoln.h" @@ -12,28 +11,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs.flush(); - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: HMW_test " << endl; @@ -77,9 +54,6 @@ int main(int argc, char** argv) } double V0[20], pmV[20]; - //fileLog *fl = new fileLog("HMW_graph_1.log"); - //setLogger(fl); - HMWSoln* HMW = new HMWSoln(iFile, "NaCl_electrolyte"); diff --git a/test_problems/cathermo/stoichSubSSTP/stoichSubSSTP.cpp b/test_problems/cathermo/stoichSubSSTP/stoichSubSSTP.cpp index 488894bf4..07e8c0de5 100644 --- a/test_problems/cathermo/stoichSubSSTP/stoichSubSSTP.cpp +++ b/test_problems/cathermo/stoichSubSSTP/stoichSubSSTP.cpp @@ -5,7 +5,6 @@ #include "cantera/thermo.h" #include "cantera/thermo/StoichSubstanceSSTP.h" -#include "cantera/base/logger.h" #include "TemperatureTable.h" @@ -14,28 +13,6 @@ using namespace std; using namespace Cantera; -class fileLog: public Logger -{ -public: - fileLog(string fName) { - m_fName = fName; - m_fs.open(fName.c_str()); - } - - virtual void write(const string& msg) { - m_fs << msg; - m_fs.flush(); - } - - virtual ~fileLog() { - m_fs.close(); - } - - string m_fName; - ofstream m_fs; - -}; - void printUsage() { cout << "usage: stoichSubSSTP " << endl; @@ -58,8 +35,6 @@ int main(int argc, char** argv) strcpy(iFile, argv[1]); } - //fileLog *fl = new fileLog("HMW_graph_1.log"); - //setLogger(fl); sprintf(file_ID,"%s#NaCl(S)", iFile); XML_Node* xm = get_XML_NameID("phase", file_ID, 0); StoichSubstanceSSTP* solid = new StoichSubstanceSSTP(*xm); diff --git a/test_problems/shared/fileLog.h b/test_problems/shared/fileLog.h new file mode 100644 index 000000000..2b9ccc740 --- /dev/null +++ b/test_problems/shared/fileLog.h @@ -0,0 +1,24 @@ +#include "cantera/base/logger.h" + +#include +#include + +class fileLog: public Cantera::Logger +{ +public: + fileLog(std::string fName) { + m_fName = fName; + m_fs.open(fName.c_str()); + } + + virtual void write(const std::string& msg) { + m_fs << msg << std::endl; + } + + virtual ~fileLog() { + m_fs.close(); + } + + std::string m_fName; + std::fstream m_fs; +};