8 |
|
|
9 |
|
DumpWriter::DumpWriter( SimInfo* the_entry_plug ){ |
10 |
|
|
11 |
< |
entry_plug = the_entry_plug; |
12 |
< |
|
13 |
< |
strcpy( outName, entry_plug->sampleName ); |
14 |
< |
outFile.open(outName, ios::out | ios::trunc ); |
15 |
< |
|
16 |
< |
if( !outFile ){ |
11 |
> |
#ifdef IS_MPI |
12 |
> |
if(worldRank == TESTWRITE ){ |
13 |
> |
#endif // is_mpi |
14 |
|
|
15 |
< |
sprintf( painCave.errMsg, |
16 |
< |
"Could not open \"%s\" for dump output.\n", |
17 |
< |
outName); |
18 |
< |
painCave.isFatal = 1; |
19 |
< |
simError(); |
20 |
< |
} |
15 |
> |
entry_plug = the_entry_plug; |
16 |
> |
|
17 |
> |
strcpy( outName, entry_plug->sampleName ); |
18 |
> |
|
19 |
> |
std::cerr << "Opening " << outName << " for dumping.\n"; |
20 |
> |
|
21 |
> |
outFile.open(outName, ios::out | ios::trunc ); |
22 |
> |
|
23 |
> |
if( !outFile ){ |
24 |
> |
|
25 |
> |
sprintf( painCave.errMsg, |
26 |
> |
"Could not open \"%s\" for dump output.\n", |
27 |
> |
outName); |
28 |
> |
painCave.isFatal = 1; |
29 |
> |
simError(); |
30 |
> |
} |
31 |
|
|
32 |
< |
//outFile.setf( ios::scientific ); |
32 |
> |
//outFile.setf( ios::scientific ); |
33 |
> |
|
34 |
> |
#ifdef IS_MPI |
35 |
> |
} |
36 |
> |
#endif // is_mpi |
37 |
|
} |
38 |
|
|
39 |
|
DumpWriter::~DumpWriter( ){ |
40 |
|
|
41 |
< |
outFile.close(); |
41 |
> |
#ifdef IS_MPI |
42 |
> |
if(worldRank == TESTWRITE ){ |
43 |
> |
#endif // is_mpi |
44 |
> |
|
45 |
> |
outFile.close(); |
46 |
> |
|
47 |
> |
#ifdef IS_MPI |
48 |
> |
} |
49 |
> |
#endif // is_mpi |
50 |
|
} |
51 |
|
|
52 |
|
void DumpWriter::writeDump( double currentTime ){ |
53 |
|
|
54 |
< |
int i; |
55 |
< |
double q[4]; |
56 |
< |
DirectionalAtom* dAtom; |
38 |
< |
int nAtoms = entry_plug->n_atoms; |
39 |
< |
Atom** atoms = entry_plug->atoms; |
54 |
> |
#ifdef IS_MPI |
55 |
> |
if(worldRank == TESTWRITE ){ |
56 |
> |
#endif // is_mpi |
57 |
|
|
58 |
|
|
59 |
< |
outFile << nAtoms << "\n"; |
60 |
< |
|
61 |
< |
outFile << currentTime << "\t" |
62 |
< |
<< entry_plug->box_x << "\t" |
63 |
< |
<< entry_plug->box_y << "\t" |
64 |
< |
<< entry_plug->box_z << "\n"; |
65 |
< |
|
66 |
< |
for( i=0; i<nAtoms; i++ ){ |
67 |
< |
|
68 |
< |
outFile |
69 |
< |
<< atoms[i]->getType() << "\t" |
70 |
< |
<< atoms[i]->getX() << "\t" |
71 |
< |
<< atoms[i]->getY() << "\t" |
72 |
< |
<< atoms[i]->getZ() << "\t" |
73 |
< |
<< atoms[i]->get_vx() << "\t" |
57 |
< |
<< atoms[i]->get_vy() << "\t" |
58 |
< |
<< atoms[i]->get_vz() << "\t"; |
59 |
< |
|
60 |
< |
if( atoms[i]->isDirectional() ){ |
59 |
> |
int i; |
60 |
> |
double q[4]; |
61 |
> |
DirectionalAtom* dAtom; |
62 |
> |
int nAtoms = entry_plug->n_atoms; |
63 |
> |
Atom** atoms = entry_plug->atoms; |
64 |
> |
|
65 |
> |
|
66 |
> |
outFile << nAtoms << "\n"; |
67 |
> |
|
68 |
> |
outFile << currentTime << "\t" |
69 |
> |
<< entry_plug->box_x << "\t" |
70 |
> |
<< entry_plug->box_y << "\t" |
71 |
> |
<< entry_plug->box_z << "\n"; |
72 |
> |
|
73 |
> |
for( i=0; i<nAtoms; i++ ){ |
74 |
|
|
62 |
– |
dAtom = (DirectionalAtom *)atoms[i]; |
63 |
– |
dAtom->getQ( q ); |
64 |
– |
|
75 |
|
outFile |
76 |
< |
<< q[0] << "\t" |
77 |
< |
<< q[1] << "\t" |
78 |
< |
<< q[2] << "\t" |
79 |
< |
<< q[3] << "\t" |
80 |
< |
<< dAtom->getJx() << "\t" |
81 |
< |
<< dAtom->getJy() << "\t" |
82 |
< |
<< dAtom->getJz() << "\n"; |
76 |
> |
<< atoms[i]->getType() << "\t" |
77 |
> |
<< atoms[i]->getX() << "\t" |
78 |
> |
<< atoms[i]->getY() << "\t" |
79 |
> |
<< atoms[i]->getZ() << "\t" |
80 |
> |
<< atoms[i]->get_vx() << "\t" |
81 |
> |
<< atoms[i]->get_vy() << "\t" |
82 |
> |
<< atoms[i]->get_vz() << "\t"; |
83 |
> |
|
84 |
> |
if( atoms[i]->isDirectional() ){ |
85 |
> |
|
86 |
> |
dAtom = (DirectionalAtom *)atoms[i]; |
87 |
> |
dAtom->getQ( q ); |
88 |
> |
|
89 |
> |
outFile |
90 |
> |
<< q[0] << "\t" |
91 |
> |
<< q[1] << "\t" |
92 |
> |
<< q[2] << "\t" |
93 |
> |
<< q[3] << "\t" |
94 |
> |
<< dAtom->getJx() << "\t" |
95 |
> |
<< dAtom->getJy() << "\t" |
96 |
> |
<< dAtom->getJz() << "\n"; |
97 |
> |
} |
98 |
> |
else{ |
99 |
> |
outFile |
100 |
> |
<< 0.0 << "\t" |
101 |
> |
<< 0.0 << "\t" |
102 |
> |
<< 0.0 << "\t" |
103 |
> |
<< 0.0 << "\t" |
104 |
> |
<< 0.0 << "\t" |
105 |
> |
<< 0.0 << "\t" |
106 |
> |
<< 0.0 << "\n"; |
107 |
> |
} |
108 |
|
} |
109 |
< |
else{ |
110 |
< |
outFile |
111 |
< |
<< 0.0 << "\t" |
77 |
< |
<< 0.0 << "\t" |
78 |
< |
<< 0.0 << "\t" |
79 |
< |
<< 0.0 << "\t" |
80 |
< |
<< 0.0 << "\t" |
81 |
< |
<< 0.0 << "\t" |
82 |
< |
<< 0.0 << "\n"; |
83 |
< |
} |
109 |
> |
outFile.flush(); |
110 |
> |
|
111 |
> |
#ifdef IS_MPI |
112 |
|
} |
113 |
< |
outFile.flush(); |
113 |
> |
#endif // is_mpi |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
+ |
|
118 |
|
void DumpWriter::writeFinal(){ |
119 |
|
|
120 |
< |
char finalName[500]; |
121 |
< |
strcpy( finalName, entry_plug->finalName ); |
120 |
> |
#ifdef IS_MPI |
121 |
> |
if(worldRank == TESTWRITE ){ |
122 |
> |
#endif // is_mpi |
123 |
|
|
124 |
< |
ofstream finalOut( finalName ); |
125 |
< |
if( !finalOut ){ |
96 |
< |
sprintf( painCave.errMsg, |
97 |
< |
"Could not open \"%s\" for final dump output.\n", |
98 |
< |
finalName ); |
99 |
< |
painCave.isFatal = 1; |
100 |
< |
simError(); |
101 |
< |
} |
102 |
< |
|
103 |
< |
// finalOut.setf( ios::scientific ); |
104 |
< |
|
124 |
> |
char finalName[500]; |
125 |
> |
strcpy( finalName, entry_plug->finalName ); |
126 |
|
|
127 |
< |
int i; |
128 |
< |
double q[4]; |
129 |
< |
DirectionalAtom* dAtom; |
130 |
< |
int nAtoms = entry_plug->n_atoms; |
131 |
< |
Atom** atoms = entry_plug->atoms; |
132 |
< |
|
133 |
< |
|
134 |
< |
finalOut << nAtoms << "\n"; |
135 |
< |
|
136 |
< |
finalOut << 0.0 << "\t" |
137 |
< |
<< entry_plug->box_x << "\t" |
138 |
< |
<< entry_plug->box_y << "\t" |
139 |
< |
<< entry_plug->box_z << "\n"; |
140 |
< |
|
141 |
< |
for( i=0; i<nAtoms; i++ ){ |
142 |
< |
|
143 |
< |
finalOut |
144 |
< |
<< atoms[i]->getType() << "\t" |
145 |
< |
<< atoms[i]->getX() << "\t" |
146 |
< |
<< atoms[i]->getY() << "\t" |
147 |
< |
<< atoms[i]->getZ() << "\t" |
148 |
< |
<< atoms[i]->get_vx() << "\t" |
149 |
< |
<< atoms[i]->get_vy() << "\t" |
150 |
< |
<< atoms[i]->get_vz() << "\t"; |
151 |
< |
|
152 |
< |
if( atoms[i]->isDirectional() ){ |
127 |
> |
ofstream finalOut( finalName ); |
128 |
> |
if( !finalOut ){ |
129 |
> |
sprintf( painCave.errMsg, |
130 |
> |
"Could not open \"%s\" for final dump output.\n", |
131 |
> |
finalName ); |
132 |
> |
painCave.isFatal = 1; |
133 |
> |
simError(); |
134 |
> |
} |
135 |
> |
|
136 |
> |
// finalOut.setf( ios::scientific ); |
137 |
> |
|
138 |
> |
|
139 |
> |
int i; |
140 |
> |
double q[4]; |
141 |
> |
DirectionalAtom* dAtom; |
142 |
> |
int nAtoms = entry_plug->n_atoms; |
143 |
> |
Atom** atoms = entry_plug->atoms; |
144 |
> |
|
145 |
> |
|
146 |
> |
finalOut << nAtoms << "\n"; |
147 |
> |
|
148 |
> |
finalOut << 0.0 << "\t" |
149 |
> |
<< entry_plug->box_x << "\t" |
150 |
> |
<< entry_plug->box_y << "\t" |
151 |
> |
<< entry_plug->box_z << "\n"; |
152 |
> |
|
153 |
> |
for( i=0; i<nAtoms; i++ ){ |
154 |
|
|
133 |
– |
dAtom = (DirectionalAtom *)atoms[i]; |
134 |
– |
dAtom->getQ( q ); |
135 |
– |
|
155 |
|
finalOut |
156 |
< |
<< q[0] << "\t" |
157 |
< |
<< q[1] << "\t" |
158 |
< |
<< q[2] << "\t" |
159 |
< |
<< q[3] << "\t" |
160 |
< |
<< dAtom->getJx() << "\t" |
161 |
< |
<< dAtom->getJy() << "\t" |
162 |
< |
<< dAtom->getJz() << "\n"; |
156 |
> |
<< atoms[i]->getType() << "\t" |
157 |
> |
<< atoms[i]->getX() << "\t" |
158 |
> |
<< atoms[i]->getY() << "\t" |
159 |
> |
<< atoms[i]->getZ() << "\t" |
160 |
> |
<< atoms[i]->get_vx() << "\t" |
161 |
> |
<< atoms[i]->get_vy() << "\t" |
162 |
> |
<< atoms[i]->get_vz() << "\t"; |
163 |
> |
|
164 |
> |
if( atoms[i]->isDirectional() ){ |
165 |
> |
|
166 |
> |
dAtom = (DirectionalAtom *)atoms[i]; |
167 |
> |
dAtom->getQ( q ); |
168 |
> |
|
169 |
> |
finalOut |
170 |
> |
<< q[0] << "\t" |
171 |
> |
<< q[1] << "\t" |
172 |
> |
<< q[2] << "\t" |
173 |
> |
<< q[3] << "\t" |
174 |
> |
<< dAtom->getJx() << "\t" |
175 |
> |
<< dAtom->getJy() << "\t" |
176 |
> |
<< dAtom->getJz() << "\n"; |
177 |
> |
} |
178 |
> |
else{ |
179 |
> |
finalOut |
180 |
> |
<< 0.0 << "\t" |
181 |
> |
<< 0.0 << "\t" |
182 |
> |
<< 0.0 << "\t" |
183 |
> |
<< 0.0 << "\t" |
184 |
> |
<< 0.0 << "\t" |
185 |
> |
<< 0.0 << "\t" |
186 |
> |
<< 0.0 << "\n"; |
187 |
> |
} |
188 |
|
} |
189 |
< |
else{ |
190 |
< |
finalOut |
191 |
< |
<< 0.0 << "\t" |
148 |
< |
<< 0.0 << "\t" |
149 |
< |
<< 0.0 << "\t" |
150 |
< |
<< 0.0 << "\t" |
151 |
< |
<< 0.0 << "\t" |
152 |
< |
<< 0.0 << "\t" |
153 |
< |
<< 0.0 << "\n"; |
154 |
< |
} |
189 |
> |
finalOut.close(); |
190 |
> |
|
191 |
> |
#ifdef IS_MPI |
192 |
|
} |
193 |
< |
finalOut.close(); |
193 |
> |
#endif // is_mpi |
194 |
|
} |