ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/io/StatWriter.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-2.0/src/io/StatWriter.cpp (file contents):
Revision 1683, Thu Oct 28 22:34:02 2004 UTC vs.
Revision 1721 by tim, Tue Nov 9 01:08:31 2004 UTC

# Line 1 | Line 1
1   #define _LARGEFILE_SOURCE64
2   #define _FILE_OFFSET_BITS 64
3  
4 < #include <string.h>
5 < #include <iostream>
6 < #include <fstream>
7 <
8 < #include "io/ReadWrite.hpp"
4 > #include "io/StatWriter.hpp"
5   #include "utils/simError.h"
6  
7 + StatWriter::StatWriter( const std::string& filename, StatsBitSet mask) mask_(mask){
8  
12 StatWriter::StatWriter( SimInfo* the_entry_plug ){
13
14  entry_plug = the_entry_plug;
15
9   #ifdef IS_MPI
10    if(worldRank == 0 ){
11   #endif // is_mpi
12  
13 <    outName =  entry_plug->statusName;
21 <
22 <    //std::cerr << "Opening " << outName << " for stat\n";
23 <
24 <    outFile.open(outName.c_str(), ios::out | ios::trunc );
13 >    statfile_.open(filename.c_str(), ios::out | ios::trunc );
14      
15 <    if( !outFile ){
15 >    if( !statfile_ ){
16        
17        sprintf( painCave.errMsg,
18 <               "Could not open \"%s\" for stat output.\n",
19 <               outName.c_str());
18 >           "Could not open \"%s\" for stat output.\n",
19 >           filename.c_str());
20        painCave.isFatal = 1;
21        simError();
22      }
34
35    //outFile.setf( ios::scientific );
36    outFile << "#time(fs)\tE_tot\tV\tKE\tT(K)\tP(atm)\tVol(A^3)\tH_conserved";
37
38    if (entry_plug->useSolidThermInt || entry_plug->useLiquidThermInt)
39      outFile << "\tV_raw";
23      
41    if (entry_plug->useSolidThermInt)
42      outFile << "\tV_harm";
43
44    outFile << "\n";
45
46    
24   #ifdef IS_MPI
25    }
26  
27    sprintf( checkPointMsg,
28 <           "Sucessfully opened output file for stating.\n");
28 >               "Sucessfully opened output file for stating.\n");
29    MPIcheckPoint();
30   #endif // is_mpi
31  
55  tStats = new Thermo( entry_plug );
32   }
33  
34   StatWriter::~StatWriter( ){
# Line 61 | Line 37 | StatWriter::~StatWriter( ){
37    if(worldRank == 0 ){
38   #endif // is_mpi
39  
40 <    outFile.close();
65 <    delete tStats;
40 >    statfile_.close();
41  
42   #ifdef IS_MPI
43    }
44   #endif // is_mpi
45   }
46  
47 < void StatWriter::writeStat( double currentTime ){
47 > void StatWriter::writeTitle() {
48  
74  double totE, potE, kinE, temp, press, vol;
75  double conservedQuantity;
49  
77  totE = tStats->getTotalE();
78  potE = tStats->getPotential();
79  kinE = tStats->getKinetic();
80  temp = tStats->getTemperature();
81  press = tStats->getPressure();
82  vol = tStats->getVolume();
83  conservedQuantity = entry_plug->the_integrator->getConservedQuantity();
84
50   #ifdef IS_MPI
51 <  if(worldRank == 0 ){
51 >    if(worldRank == 0 ){
52   #endif // is_mpi
53  
54 <    outFile.precision(8);
55 <    outFile
56 <      << currentTime << "\t"
57 <      << totE << "\t"
58 <      << potE << "\t"
59 <      << kinE << "\t"
60 <      << temp << "\t"
61 <      << press << "\t"
97 <      << vol << "\t"
98 <      << conservedQuantity;
54 >        //write title
55 >        statfile_ << "#time (fs)"
56 >            for (int i =0; i < mask_.size(); ++i) {
57 >                if (mask_[i]) {
58 >                statfile_ << "\t" << Stats::getTitle(i);
59 >                }
60 >            }
61 >        statfile_ << std::endl;
62  
63 <    if (entry_plug->useSolidThermInt || entry_plug->useLiquidThermInt)
64 <      outFile << "\t" << entry_plug->vRaw;
65 <    
66 <    if (entry_plug->useSolidThermInt)
104 <      outFile << "\t" << entry_plug->vHarm;
63 > #ifdef IS_MPI
64 >  }
65 > #endif // is_mpi    
66 > }
67  
68 <    outFile << "\n";
68 > void StatWriter::writeStat(Snapshot* s){
69  
70 <    outFile.flush();
70 > #ifdef IS_MPI
71 >    if(worldRank == 0 ){
72 > #endif // is_mpi
73  
74 +        statfile_.precision(8);
75 +
76 +        statfile_ << s->getTimeStamp();
77 +        for (int i =0; i < mask_.size(); ++i) {
78 +            if (mask_[i]) {
79 +                statfile_ << "\t" << s->statData[i];
80 +            }
81 +        }
82 +        statfile_ << std::endl;
83 +
84 +        statfile_.flush();
85 +
86   #ifdef IS_MPI
87 <  }
87 >    }
88   #endif // is_mpi
89   }
90  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines