4 |
|
#include "io/StatWriter.hpp" |
5 |
|
#include "utils/simError.h" |
6 |
|
|
7 |
< |
StatWriter::StatWriter( const std::string& filename, const StatsBitSet& mask) mask_(mask){ |
7 |
> |
namespace oopse { |
8 |
> |
StatWriter::StatWriter( const std::string& filename, const StatsBitSet& mask) : mask_(mask){ |
9 |
|
|
10 |
|
#ifdef IS_MPI |
11 |
|
if(worldRank == 0 ){ |
12 |
|
#endif // is_mpi |
13 |
|
|
14 |
< |
statfile_.open(filename.c_str(), ios::out | ios::trunc ); |
14 |
> |
statfile_.open(filename.c_str(), std::ios::out | std::ios::trunc ); |
15 |
|
|
16 |
|
if( !statfile_ ){ |
17 |
|
|
53 |
|
#endif // is_mpi |
54 |
|
|
55 |
|
//write title |
56 |
< |
statfile_ << "#time (fs)" |
57 |
< |
for (int i =0; i < mask_.size(); ++i) { |
58 |
< |
if (mask_[i]) { |
59 |
< |
statfile_ << "\t" << Stats::getTitle(i); |
59 |
< |
} |
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 |
|
#ifdef IS_MPI |
66 |
|
#endif // is_mpi |
67 |
|
} |
68 |
|
|
69 |
< |
void StatWriter::writeStat(Snapshot* s){ |
69 |
> |
void StatWriter::writeStat(const Stats& s){ |
70 |
|
|
71 |
|
#ifdef IS_MPI |
72 |
|
if(worldRank == 0 ){ |
74 |
|
|
75 |
|
statfile_.precision(8); |
76 |
|
|
76 |
– |
statfile_ << s->getTimeStamp(); |
77 |
|
for (int i =0; i < mask_.size(); ++i) { |
78 |
|
if (mask_[i]) { |
79 |
< |
statfile_ << "\t" << s->statData[i]; |
79 |
> |
statfile_ << "\t" << s[i]; |
80 |
|
} |
81 |
|
} |
82 |
|
statfile_ << std::endl; |
88 |
|
#endif // is_mpi |
89 |
|
} |
90 |
|
|
91 |
+ |
} |