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