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

Comparing branches/new_design/OOPSE-4/src/io/StatWriter.cpp (file contents):
Revision 1683, Thu Oct 28 22:34:02 2004 UTC vs.
Revision 1819 by tim, Wed Dec 1 22:45:49 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 + namespace oopse {
8 + StatWriter::StatWriter( const std::string& filename, const StatsBitSet& mask) : mask_(mask){
9  
12 StatWriter::StatWriter( SimInfo* the_entry_plug ){
13
14  entry_plug = the_entry_plug;
15
10   #ifdef IS_MPI
11    if(worldRank == 0 ){
12   #endif // is_mpi
13  
14 <    outName =  entry_plug->statusName;
21 <
22 <    //std::cerr << "Opening " << outName << " for stat\n";
23 <
24 <    outFile.open(outName.c_str(), ios::out | ios::trunc );
14 >    statfile_.open(filename.c_str(), std::ios::out | std::ios::trunc );
15      
16 <    if( !outFile ){
16 >    if( !statfile_ ){
17        
18        sprintf( painCave.errMsg,
19 <               "Could not open \"%s\" for stat output.\n",
20 <               outName.c_str());
19 >           "Could not open \"%s\" for stat output.\n",
20 >           filename.c_str());
21        painCave.isFatal = 1;
22        simError();
23      }
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";
24      
41    if (entry_plug->useSolidThermInt)
42      outFile << "\tV_harm";
43
44    outFile << "\n";
45
46    
25   #ifdef IS_MPI
26    }
27  
28    sprintf( checkPointMsg,
29 <           "Sucessfully opened output file for stating.\n");
29 >               "Sucessfully opened output file for stating.\n");
30    MPIcheckPoint();
31   #endif // is_mpi
32  
55  tStats = new Thermo( entry_plug );
33   }
34  
35   StatWriter::~StatWriter( ){
# Line 61 | Line 38 | StatWriter::~StatWriter( ){
38    if(worldRank == 0 ){
39   #endif // is_mpi
40  
41 <    outFile.close();
65 <    delete tStats;
41 >    statfile_.close();
42  
43   #ifdef IS_MPI
44    }
45   #endif // is_mpi
46   }
47  
48 < void StatWriter::writeStat( double currentTime ){
48 > void StatWriter::writeTitle() {
49  
74  double totE, potE, kinE, temp, press, vol;
75  double conservedQuantity;
50  
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
51   #ifdef IS_MPI
52 <  if(worldRank == 0 ){
52 >    if(worldRank == 0 ){
53   #endif // is_mpi
54  
55 <    outFile.precision(8);
56 <    outFile
57 <      << currentTime << "\t"
58 <      << totE << "\t"
59 <      << potE << "\t"
60 <      << kinE << "\t"
61 <      << temp << "\t"
62 <      << press << "\t"
97 <      << vol << "\t"
98 <      << conservedQuantity;
55 >        //write title
56 >        statfile_ << "#";
57 >        for (int i =0; i < mask_.size(); ++i) {
58 >            if (mask_[i]) {
59 >            statfile_ << "\t" << Stats::getTitle(i) << "(" << Stats::getUnits(i) << ")";
60 >            }
61 >        }
62 >        statfile_ << std::endl;
63  
64 <    if (entry_plug->useSolidThermInt || entry_plug->useLiquidThermInt)
65 <      outFile << "\t" << entry_plug->vRaw;
66 <    
67 <    if (entry_plug->useSolidThermInt)
104 <      outFile << "\t" << entry_plug->vHarm;
64 > #ifdef IS_MPI
65 >  }
66 > #endif // is_mpi    
67 > }
68  
69 <    outFile << "\n";
69 > void StatWriter::writeStat(const Stats& s){
70  
71 <    outFile.flush();
71 > #ifdef IS_MPI
72 >    if(worldRank == 0 ){
73 > #endif // is_mpi
74  
75 +        statfile_.precision(8);
76 +
77 +        for (int i =0; i < mask_.size(); ++i) {
78 +            if (mask_[i]) {
79 +                statfile_ << "\t" << s[i];
80 +            }
81 +        }
82 +        statfile_ << std::endl;
83 +
84 +        statfile_.flush();
85 +
86   #ifdef IS_MPI
87 <  }
87 >    }
88   #endif // is_mpi
89   }
90  
91 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines