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:
trunk/OOPSE-2.0/src/io/StatWriter.cpp (file contents), Revision 1492 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
branches/new_design/OOPSE-2.0/src/io/StatWriter.cpp (file contents), Revision 1846 by tim, Sat Dec 4 00:01:32 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      }
24  
25 <    //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";
25 >    writeTitle();
26      
41    if (entry_plug->useSolidThermInt)
42      outFile << "\tV_harm";
43
44    outFile << "\n";
45
46    
27   #ifdef IS_MPI
28    }
29  
30    sprintf( checkPointMsg,
31 <           "Sucessfully opened output file for stating.\n");
31 >               "Sucessfully opened output file for stating.\n");
32    MPIcheckPoint();
33   #endif // is_mpi
34  
55  tStats = new Thermo( entry_plug );
35   }
36  
37   StatWriter::~StatWriter( ){
# Line 61 | Line 40 | StatWriter::~StatWriter( ){
40    if(worldRank == 0 ){
41   #endif // is_mpi
42  
43 <    outFile.close();
65 <    delete tStats;
43 >    statfile_.close();
44  
45   #ifdef IS_MPI
46    }
47   #endif // is_mpi
48   }
49  
50 < void StatWriter::writeStat( double currentTime ){
50 > void StatWriter::writeTitle() {
51  
74  double totE, potE, kinE, temp, press, vol;
75  double conservedQuantity;
52  
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
53   #ifdef IS_MPI
54 <  if(worldRank == 0 ){
54 >    if(worldRank == 0 ){
55   #endif // is_mpi
56  
57 <    outFile.precision(8);
58 <    outFile
59 <      << currentTime << "\t"
60 <      << totE << "\t"
61 <      << potE << "\t"
62 <      << kinE << "\t"
63 <      << temp << "\t"
64 <      << press << "\t"
97 <      << vol << "\t"
98 <      << conservedQuantity;
57 >        //write title
58 >        statfile_ << "#";
59 >        for (int i =0; i < mask_.size(); ++i) {
60 >            if (mask_[i]) {
61 >            statfile_ << "\t" << Stats::getTitle(i) << "(" << Stats::getUnits(i) << ")";
62 >            }
63 >        }
64 >        statfile_ << std::endl;
65  
66 <    if (entry_plug->useSolidThermInt || entry_plug->useLiquidThermInt)
67 <      outFile << "\t" << entry_plug->vRaw;
68 <    
69 <    if (entry_plug->useSolidThermInt)
104 <      outFile << "\t" << entry_plug->vHarm;
66 > #ifdef IS_MPI
67 >  }
68 > #endif // is_mpi    
69 > }
70  
71 <    outFile << "\n";
71 > void StatWriter::writeStat(const Stats& s){
72  
73 <    outFile.flush();
73 > #ifdef IS_MPI
74 >    if(worldRank == 0 ){
75 > #endif // is_mpi
76  
77 +        statfile_.precision(8);
78 +
79 +        for (int i =0; i < mask_.size(); ++i) {
80 +            if (mask_[i]) {
81 +                statfile_ << "\t" << s[i];
82 +            }
83 +        }
84 +        statfile_ << std::endl;
85 +
86 +        statfile_.flush();
87 +
88   #ifdef IS_MPI
89 <  }
89 >    }
90   #endif // is_mpi
91   }
92  
93 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines