# | Line 1 | Line 1 | |
---|---|---|
1 | + | #define _FILE_OFFSET_BITS 64 |
2 | + | |
3 | #include <cstring> | |
4 | #include <iostream> | |
5 | #include <fstream> | |
# | Line 70 | Line 72 | void DumpWriter::writeDump( double currentTime ){ | |
72 | char tempBuffer[BUFFERSIZE]; | |
73 | char writeLine[BUFFERSIZE]; | |
74 | ||
75 | < | int i, j, which_node, done, which_atom, local_index; |
75 | > | int i; |
76 | > | #ifdef IS_MPI |
77 | > | int j, which_node, done, which_atom, local_index; |
78 | > | #else //is_mpi |
79 | > | int nAtoms = entry_plug->n_atoms; |
80 | > | #endif //is_mpi |
81 | > | |
82 | double q[4]; | |
83 | DirectionalAtom* dAtom; | |
76 | – | int nAtoms = entry_plug->n_atoms; |
84 | Atom** atoms = entry_plug->atoms; | |
85 | + | double pos[3], vel[3]; |
86 | ||
87 | ||
88 | #ifndef IS_MPI | |
89 | ||
90 | outFile << nAtoms << "\n"; | |
91 | ||
92 | < | outFile << currentTime << "\t" |
93 | < | << entry_plug->box_x << "\t" |
94 | < | << entry_plug->box_y << "\t" |
95 | < | << entry_plug->box_z << "\n"; |
92 | > | outFile << currentTime << ";\t" |
93 | > | << entry_plug->Hmat[0][0] << "\t" |
94 | > | << entry_plug->Hmat[1][0] << "\t" |
95 | > | << entry_plug->Hmat[2][0] << ";\t" |
96 | > | |
97 | > | << entry_plug->Hmat[0][1] << "\t" |
98 | > | << entry_plug->Hmat[1][1] << "\t" |
99 | > | << entry_plug->Hmat[2][1] << ";\t" |
100 | > | |
101 | > | << entry_plug->Hmat[0][2] << "\t" |
102 | > | << entry_plug->Hmat[1][2] << "\t" |
103 | > | << entry_plug->Hmat[2][2] << ";\n"; |
104 | ||
105 | for( i=0; i<nAtoms; i++ ){ | |
106 | ||
107 | + | atoms[i]->getPos(pos); |
108 | + | atoms[i]->getVel(vel); |
109 | ||
110 | sprintf( tempBuffer, | |
111 | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | |
112 | atoms[i]->getType(), | |
113 | < | atoms[i]->getX(), |
114 | < | atoms[i]->getY(), |
115 | < | atoms[i]->getZ(), |
116 | < | atoms[i]->get_vx(), |
117 | < | atoms[i]->get_vy(), |
118 | < | atoms[i]->get_vz()); |
113 | > | pos[0], |
114 | > | pos[1], |
115 | > | pos[2], |
116 | > | vel[0], |
117 | > | vel[1], |
118 | > | vel[2]); |
119 | strcpy( writeLine, tempBuffer ); | |
120 | ||
121 | if( atoms[i]->isDirectional() ){ | |
# | Line 138 | Line 156 | void DumpWriter::writeDump( double currentTime ){ | |
156 | ||
157 | if( worldRank == 0 ){ | |
158 | outFile << mpiSim->getTotAtoms() << "\n"; | |
159 | + | |
160 | + | outFile << currentTime << ";\t" |
161 | + | << entry_plug->Hmat[0][0] << "\t" |
162 | + | << entry_plug->Hmat[1][0] << "\t" |
163 | + | << entry_plug->Hmat[2][0] << ";\t" |
164 | + | |
165 | + | << entry_plug->Hmat[0][1] << "\t" |
166 | + | << entry_plug->Hmat[1][1] << "\t" |
167 | + | << entry_plug->Hmat[2][1] << ";\t" |
168 | + | |
169 | + | << entry_plug->Hmat[0][2] << "\t" |
170 | + | << entry_plug->Hmat[1][2] << "\t" |
171 | + | << entry_plug->Hmat[2][2] << ";\n"; |
172 | ||
142 | – | outFile << currentTime << "\t" |
143 | – | << entry_plug->box_x << "\t" |
144 | – | << entry_plug->box_y << "\t" |
145 | – | << entry_plug->box_z << "\n"; |
173 | outFile.flush(); | |
174 | for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { | |
175 | // Get the Node number which has this atom; | |
# | Line 159 | Line 186 | void DumpWriter::writeDump( double currentTime ){ | |
186 | } | |
187 | if (local_index != -1) { | |
188 | //format the line | |
189 | + | |
190 | + | atoms[local_index]->getPos(pos); |
191 | + | atoms[local_index]->getVel(vel); |
192 | + | |
193 | sprintf( tempBuffer, | |
194 | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | |
195 | atoms[local_index]->getType(), | |
196 | < | atoms[local_index]->getX(), |
197 | < | atoms[local_index]->getY(), |
198 | < | atoms[local_index]->getZ(), |
199 | < | atoms[local_index]->get_vx(), |
200 | < | atoms[local_index]->get_vy(), |
201 | < | atoms[local_index]->get_vz()); // check here. |
196 | > | pos[0], |
197 | > | pos[1], |
198 | > | pos[2], |
199 | > | vel[0], |
200 | > | vel[1], |
201 | > | vel[2]); // check here. |
202 | strcpy( writeLine, tempBuffer ); | |
203 | ||
204 | if( atoms[local_index]->isDirectional() ){ | |
# | Line 249 | Line 280 | void DumpWriter::writeDump( double currentTime ){ | |
280 | } | |
281 | if (local_index != -1) { | |
282 | //format the line | |
283 | + | |
284 | + | atoms[local_index]->getPos(pos); |
285 | + | atoms[local_index]->getVel(vel); |
286 | + | |
287 | sprintf( tempBuffer, | |
288 | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | |
289 | atoms[local_index]->getType(), | |
290 | < | atoms[local_index]->getX(), |
291 | < | atoms[local_index]->getY(), |
292 | < | atoms[local_index]->getZ(), |
293 | < | atoms[local_index]->get_vx(), |
294 | < | atoms[local_index]->get_vy(), |
295 | < | atoms[local_index]->get_vz()); // check here. |
290 | > | pos[0], |
291 | > | pos[1], |
292 | > | pos[2], |
293 | > | vel[0], |
294 | > | vel[1], |
295 | > | vel[2]); // check here. |
296 | strcpy( writeLine, tempBuffer ); | |
297 | ||
298 | if( atoms[local_index]->isDirectional() ){ | |
# | Line 307 | Line 342 | void DumpWriter::writeDump( double currentTime ){ | |
342 | #endif // is_mpi | |
343 | } | |
344 | ||
345 | < | void DumpWriter::writeFinal(){ |
345 | > | void DumpWriter::writeFinal(double finalTime){ |
346 | ||
347 | char finalName[500]; | |
348 | ofstream finalOut; | |
# | Line 318 | Line 353 | void DumpWriter::writeFinal(){ | |
353 | ||
354 | double q[4]; | |
355 | DirectionalAtom* dAtom; | |
321 | – | int nAtoms = entry_plug->n_atoms; |
356 | Atom** atoms = entry_plug->atoms; | |
357 | < | int i, j, which_node, done, game_over, which_atom, local_index; |
357 | > | int i; |
358 | > | #ifdef IS_MPI |
359 | > | int j, which_node, done, which_atom, local_index; |
360 | > | #else //is_mpi |
361 | > | int nAtoms = entry_plug->n_atoms; |
362 | > | #endif //is_mpi |
363 | ||
364 | + | double pos[3], vel[3]; |
365 | ||
366 | #ifdef IS_MPI | |
367 | if(worldRank == 0 ){ | |
# | Line 353 | Line 393 | void DumpWriter::writeFinal(){ | |
393 | ||
394 | finalOut << nAtoms << "\n"; | |
395 | ||
396 | < | finalOut << entry_plug->box_x << "\t" |
397 | < | << entry_plug->box_y << "\t" |
398 | < | << entry_plug->box_z << "\n"; |
396 | > | finalOut << finalTime << ";\t" |
397 | > | << entry_plug->Hmat[0][0] << "\t" |
398 | > | << entry_plug->Hmat[1][0] << "\t" |
399 | > | << entry_plug->Hmat[2][0] << ";\t" |
400 | > | |
401 | > | << entry_plug->Hmat[0][1] << "\t" |
402 | > | << entry_plug->Hmat[1][1] << "\t" |
403 | > | << entry_plug->Hmat[2][1] << ";\t" |
404 | > | |
405 | > | << entry_plug->Hmat[0][2] << "\t" |
406 | > | << entry_plug->Hmat[1][2] << "\t" |
407 | > | << entry_plug->Hmat[2][2] << ";\n"; |
408 | ||
409 | for( i=0; i<nAtoms; i++ ){ | |
410 | ||
411 | + | atoms[i]->getPos(pos); |
412 | + | atoms[i]->getVel(vel); |
413 | + | |
414 | sprintf( tempBuffer, | |
415 | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | |
416 | atoms[i]->getType(), | |
417 | < | atoms[i]->getX(), |
418 | < | atoms[i]->getY(), |
419 | < | atoms[i]->getZ(), |
420 | < | atoms[i]->get_vx(), |
421 | < | atoms[i]->get_vy(), |
422 | < | atoms[i]->get_vz()); |
417 | > | pos[0], |
418 | > | pos[1], |
419 | > | pos[2], |
420 | > | vel[0], |
421 | > | vel[1], |
422 | > | vel[2]); |
423 | strcpy( writeLine, tempBuffer ); | |
424 | ||
425 | if( atoms[i]->isDirectional() ){ | |
# | Line 411 | Line 463 | void DumpWriter::writeFinal(){ | |
463 | if( worldRank == 0 ){ | |
464 | finalOut << mpiSim->getTotAtoms() << "\n"; | |
465 | ||
466 | < | finalOut << entry_plug->box_x << "\t" |
467 | < | << entry_plug->box_y << "\t" |
468 | < | << entry_plug->box_z << "\n"; |
466 | > | finalOut << finalTime << ";\t" |
467 | > | << entry_plug->Hmat[0][0] << "\t" |
468 | > | << entry_plug->Hmat[1][0] << "\t" |
469 | > | << entry_plug->Hmat[2][0] << ";\t" |
470 | > | |
471 | > | << entry_plug->Hmat[0][1] << "\t" |
472 | > | << entry_plug->Hmat[1][1] << "\t" |
473 | > | << entry_plug->Hmat[2][1] << ";\t" |
474 | > | |
475 | > | << entry_plug->Hmat[0][2] << "\t" |
476 | > | << entry_plug->Hmat[1][2] << "\t" |
477 | > | << entry_plug->Hmat[2][2] << ";\n"; |
478 | ||
479 | for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { | |
480 | // Get the Node number which has this molecule: | |
# | Line 427 | Line 488 | void DumpWriter::writeFinal(){ | |
488 | for (j=0; (j<mpiSim->getMyNlocal()) && (local_index < 0); j++) { | |
489 | if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; | |
490 | } | |
491 | < | if (local_index != -1) { |
491 | > | if (local_index != -1) { |
492 | > | |
493 | > | atoms[local_index]->getPos(pos); |
494 | > | atoms[local_index]->getVel(vel); |
495 | > | |
496 | sprintf( tempBuffer, | |
497 | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | |
498 | atoms[local_index]->getType(), | |
499 | < | atoms[local_index]->getX(), |
500 | < | atoms[local_index]->getY(), |
501 | < | atoms[local_index]->getZ(), |
502 | < | atoms[local_index]->get_vx(), |
503 | < | atoms[local_index]->get_vy(), |
504 | < | atoms[local_index]->get_vz()); |
499 | > | pos[0], |
500 | > | pos[1], |
501 | > | pos[2], |
502 | > | vel[0], |
503 | > | vel[1], |
504 | > | vel[2]); |
505 | strcpy( writeLine, tempBuffer ); | |
506 | ||
507 | if( atoms[local_index]->isDirectional() ){ | |
# | Line 516 | Line 581 | void DumpWriter::writeFinal(){ | |
581 | } | |
582 | if (local_index != -1) { | |
583 | ||
584 | + | atoms[local_index]->getPos(pos); |
585 | + | atoms[local_index]->getVel(vel); |
586 | + | |
587 | //format the line | |
588 | sprintf( tempBuffer, | |
589 | "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | |
590 | atoms[local_index]->getType(), | |
591 | < | atoms[local_index]->getX(), |
592 | < | atoms[local_index]->getY(), |
593 | < | atoms[local_index]->getZ(), |
594 | < | atoms[local_index]->get_vx(), |
595 | < | atoms[local_index]->get_vy(), |
596 | < | atoms[local_index]->get_vz()); // check here. |
591 | > | pos[0], |
592 | > | pos[1], |
593 | > | pos[2], |
594 | > | vel[0], |
595 | > | vel[1], |
596 | > | vel[2]); // check here. |
597 | strcpy( writeLine, tempBuffer ); | |
598 | ||
599 | if( atoms[local_index]->isDirectional() ){ |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |