1 |
#include <cstring> |
2 |
#include <iostream> |
3 |
#include <fstream> |
4 |
|
5 |
#include "ReadWrite.hpp" |
6 |
#include "simError.h" |
7 |
|
8 |
|
9 |
StatWriter::StatWriter( SimInfo* the_entry_plug ){ |
10 |
|
11 |
entry_plug = the_entry_plug; |
12 |
|
13 |
strcpy( outName, entry_plug->statusName ); |
14 |
outFile.open(outName, ios::out | ios::trunc ); |
15 |
|
16 |
if( !outFile ){ |
17 |
|
18 |
sprintf( painCave.errMsg, |
19 |
"Could not open \"%s\" for stat output.\n", |
20 |
outName); |
21 |
painCave.isFatal = 1; |
22 |
simError(); |
23 |
} |
24 |
|
25 |
//outFile.setf( ios::scientific ); |
26 |
outFile << "#time(fs)\ttot_E\tpotential\tkinetic\ttemperature\n"; |
27 |
|
28 |
tStats = new Thermo( entry_plug ); |
29 |
} |
30 |
|
31 |
StatWriter::~StatWriter( ){ |
32 |
|
33 |
outFile.close(); |
34 |
delete tStats; |
35 |
} |
36 |
|
37 |
void StatWriter::writeStat( double currentTime ){ |
38 |
|
39 |
outFile.precision(8); |
40 |
outFile |
41 |
<< currentTime << "\t" |
42 |
<< tStats->getTotalE() << "\t" |
43 |
<< tStats->getPotential() << "\t" |
44 |
<< tStats->getKinetic() << "\t" |
45 |
<< tStats->getTemperature() << "\n"; |
46 |
outFile.flush(); |
47 |
} |