| 4 |
|
#include <iostream> |
| 5 |
|
#include <fstream> |
| 6 |
|
|
| 7 |
< |
#include <cstring> |
| 8 |
< |
#include <cstdio> |
| 9 |
< |
#include <cstdlib> |
| 7 |
> |
#include <string.h> |
| 8 |
> |
#include <stdio.h> |
| 9 |
> |
#include <stdlib.h> |
| 10 |
> |
#include <unistd.h> |
| 11 |
> |
#include <sys/types.h> |
| 12 |
> |
#include <sys/stat.h> |
| 13 |
|
|
| 14 |
|
|
| 15 |
|
#include "Atom.hpp" |
| 18 |
|
|
| 19 |
|
using namespace std; |
| 20 |
|
|
| 21 |
+ |
class FilePos{ |
| 22 |
|
|
| 23 |
+ |
public: |
| 24 |
+ |
FilePos(){ |
| 25 |
+ |
myPos = NULL; |
| 26 |
+ |
next = NULL; |
| 27 |
+ |
} |
| 28 |
+ |
FilePos( fpos_t* thePos ) { |
| 29 |
+ |
myPos = thePos; |
| 30 |
+ |
next = NULL; |
| 31 |
+ |
} |
| 32 |
+ |
~FilePos(){ |
| 33 |
+ |
if( next != NULL ) delete next; |
| 34 |
+ |
if( myPos != NULL ) delete myPos; |
| 35 |
+ |
} |
| 36 |
|
|
| 37 |
+ |
void add( fpos_t *thePos ){ |
| 38 |
+ |
if( next != NULL ) |
| 39 |
+ |
next->add( thePos ); |
| 40 |
+ |
else |
| 41 |
+ |
next = new FilePos( thePos ); |
| 42 |
+ |
} |
| 43 |
|
|
| 44 |
+ |
FilePos &operator=(fpos_t *thePos){ myPos = thePos; return *this; } |
| 45 |
+ |
|
| 46 |
+ |
void setPos( fpos_t *thePos ){ myPos = thePos; } |
| 47 |
+ |
fpos_t *getPos( void ){ return myPos; } |
| 48 |
+ |
|
| 49 |
+ |
FilePos* getNext( void ) { return next; } |
| 50 |
+ |
private: |
| 51 |
+ |
|
| 52 |
+ |
fpos_t *myPos; |
| 53 |
+ |
FilePos* next; |
| 54 |
+ |
|
| 55 |
+ |
}; |
| 56 |
+ |
|
| 57 |
|
class DumpWriter{ |
| 58 |
|
|
| 59 |
|
public: |
| 61 |
|
~DumpWriter(); |
| 62 |
|
|
| 63 |
|
void writeDump( double currentTime ); |
| 64 |
< |
void writeFinal( double finalTime ); |
| 64 |
> |
void writeFinal( double currentTime); |
| 65 |
> |
void writeFrame( vector<ofstream*>& outFile, double finalTime ); |
| 66 |
|
|
| 67 |
+ |
#ifdef IS_MPI |
| 68 |
+ |
void update(); |
| 69 |
+ |
#endif |
| 70 |
+ |
|
| 71 |
|
private: |
| 72 |
+ |
|
| 73 |
+ |
#ifdef IS_MPI |
| 74 |
+ |
void sortByGlobalIndex(); |
| 75 |
+ |
#endif |
| 76 |
+ |
|
| 77 |
|
SimInfo* entry_plug; |
| 78 |
< |
ofstream outFile; |
| 79 |
< |
char outName[500]; |
| 78 |
> |
ofstream dumpFile; |
| 79 |
> |
ofstream finalOut; |
| 80 |
> |
|
| 81 |
> |
#ifdef IS_MPI |
| 82 |
> |
vector<pair<int, int> > indexArray; |
| 83 |
> |
#endif |
| 84 |
|
}; |
| 85 |
|
|
| 86 |
|
class StatWriter{ |
| 90 |
|
~StatWriter(); |
| 91 |
|
|
| 92 |
|
void writeStat( double currentTime ); |
| 93 |
< |
|
| 93 |
> |
|
| 94 |
|
private: |
| 95 |
< |
|
| 95 |
> |
|
| 96 |
|
SimInfo* entry_plug; |
| 97 |
|
ofstream outFile; |
| 98 |
|
char outName[500]; |
| 107 |
|
~InitializeFromFile(); |
| 108 |
|
|
| 109 |
|
void readInit( SimInfo* the_entry_plug ); |
| 110 |
< |
|
| 110 |
> |
|
| 111 |
|
private: |
| 112 |
|
char* parseDumpLine(char* line, int atomIndex); |
| 113 |
< |
char* parseBoxLine(char* line, double boxMat[9], double &time ); |
| 113 |
> |
char* parseCommentLine(char* line, SimInfo* entry_plug); |
| 114 |
|
FILE *c_in_file; |
| 115 |
|
char c_in_name[500]; |
| 116 |
|
SimInfo* simnfo; |
| 130 |
|
|
| 131 |
|
private: |
| 132 |
|
|
| 133 |
< |
void readSet( int which Frame ); |
| 133 |
> |
void readSet( int whichFrame ); |
| 134 |
|
char* parseDumpLine(char* line, int atomIndex); |
| 135 |
|
char* parseCommentLine(char* line, double &time, double boxMat[9] ); |
| 136 |
|
FILE *inFile; |
| 138 |
|
bool isScanned; |
| 139 |
|
int nFrames; |
| 140 |
|
|
| 141 |
+ |
FilePos** frameStart; |
| 142 |
+ |
FilePos* headFP; |
| 143 |
+ |
|
| 144 |
|
SimInfo *simnfo; |
| 145 |
|
}; |
| 146 |
|
|