1 |
< |
#include "io/DumpWrite.hpp" |
1 |
> |
#include "io/DumpWriter.hpp" |
2 |
> |
#include "primitives/Molecule.hpp" |
3 |
|
#include "utils/simError.h" |
4 |
|
|
5 |
|
#ifdef IS_MPI |
6 |
|
#include <mpi.h> |
7 |
|
#endif //is_mpi |
8 |
+ |
|
9 |
|
namespace oopse { |
10 |
+ |
|
11 |
|
DumpWriter::DumpWriter(SimInfo* info, const std::string& filename) |
12 |
|
: info_(info), filename_(filename){ |
13 |
|
#ifdef IS_MPI |
15 |
|
if (worldRank == 0) { |
16 |
|
#endif // is_mpi |
17 |
|
|
18 |
< |
dumpFile.open(filename_.c_str(), ios::out | ios::trunc); |
18 |
> |
dumpFile_.open(filename_.c_str(), ios::out | ios::trunc); |
19 |
|
|
20 |
< |
if (!dumpFile) { |
20 |
> |
if (!dumpFile_) { |
21 |
|
sprintf(painCave.errMsg, "Could not open \"%s\" for dump output.\n", |
22 |
< |
info_->filename_.c_str()); |
22 |
> |
filename_.c_str()); |
23 |
|
painCave.isFatal = 1; |
24 |
|
simError(); |
25 |
|
} |
42 |
|
if (worldRank == 0) { |
43 |
|
#endif // is_mpi |
44 |
|
|
45 |
< |
dumpFile.close(); |
45 |
> |
dumpFile_.close(); |
46 |
|
|
47 |
|
#ifdef IS_MPI |
48 |
|
|
52 |
|
|
53 |
|
} |
54 |
|
|
55 |
< |
void writeCommentLine(Snapshot* s) { |
55 |
> |
void DumpWriter::writeCommentLine(std::ostream& os, Snapshot* s) { |
56 |
|
|
57 |
|
double currentTime; |
58 |
|
Mat3x3d hmat; |
67 |
|
eta = s->getEta(); |
68 |
|
|
69 |
|
os << currentTime << ";\t" |
70 |
< |
<< hmat[0][0] << "\t" << hmat[1][0] << "\t" << hmat[2][0] << ";\t" |
71 |
< |
<< hmat[0][1] << "\t" << hmat[1][1] << "\t" << hmat[2][1] << ";\t" |
72 |
< |
<< hmat[0][2] << "\t" << hmat[1][2] << "\t" << hmat[2][2] << ";"; |
70 |
> |
<< hmat(0, 0) << "\t" << hmat(1, 0) << "\t" << hmat(2, 0) << ";\t" |
71 |
> |
<< hmat(0, 1) << "\t" << hmat(1, 1) << "\t" << hmat(2, 1) << ";\t" |
72 |
> |
<< hmat(0, 2) << "\t" << hmat(1, 2) << "\t" << hmat(2, 2) << ";"; |
73 |
|
|
74 |
|
//write out additional parameters, such as chi and eta |
75 |
|
|
76 |
< |
os << chi << "\t" << integralOfChiDt << "\t;" |
76 |
> |
os << chi << "\t" << integralOfChiDt << "\t;"; |
77 |
|
|
78 |
< |
os << eta[0][0] << "\t" << eta[1][0] << "\t" << eta[2][0] << ";\t" |
79 |
< |
<< eta[0][1] << "\t" << eta[1][1] << "\t" << eta[2][1] << ";\t" |
80 |
< |
<< eta[0][2] << "\t" << eta[1][2] << "\t" << eta[2][2] << ";"; |
78 |
> |
os << eta(0, 0) << "\t" << eta(1, 0) << "\t" << eta(2, 0) << ";\t" |
79 |
> |
<< eta(0, 1) << "\t" << eta(1, 1) << "\t" << eta(2, 1) << ";\t" |
80 |
> |
<< eta(0, 2) << "\t" << eta(1, 2) << "\t" << eta(2, 2) << ";"; |
81 |
|
|
82 |
|
os << endl; |
83 |
|
} |
96 |
|
|
97 |
|
Molecule* mol; |
98 |
|
StuntDouble* integrableObject; |
99 |
< |
typename SimInfo::MoleculeIterator mi; |
100 |
< |
typename Molecule::IntegrableObjectIterator ii; |
99 |
> |
SimInfo::MoleculeIterator mi; |
100 |
> |
Molecule::IntegrableObjectIterator ii; |
101 |
|
|
102 |
|
int nTotObjects; |
103 |
|
nTotObjects = info_->getNGlobalIntegrableObjects(); |
107 |
|
|
108 |
|
os << nTotObjects << "\n"; |
109 |
|
|
110 |
< |
writeCommentLine(info_->getSnapshotManager()->getCurrentSnapshot()); |
110 |
> |
writeCommentLine(os, info_->getSnapshotManager()->getCurrentSnapshot()); |
111 |
|
|
112 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
113 |
|
|
119 |
|
vel = integrableObject->getVel(); |
120 |
|
|
121 |
|
sprintf(tempBuffer, "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", |
122 |
< |
integrableObject->getType(), |
122 |
> |
integrableObject->getType().c_str(), |
123 |
|
pos[0], pos[1], pos[2], |
124 |
|
vel[0], vel[1], vel[2]); |
125 |
|
|