1 |
gezelter |
2 |
#ifndef __READWRITE_H__ |
2 |
|
|
#define __READWRITE_H__ |
3 |
|
|
#define _LARGEFILE_SOURCE64 |
4 |
|
|
#ifndef _FILE_OFFSET_BITS |
5 |
|
|
#define _FILE_OFFSET_BITS 64 |
6 |
|
|
#endif |
7 |
|
|
#include <iostream> |
8 |
|
|
#include <fstream> |
9 |
|
|
#include <string> |
10 |
|
|
#include <string.h> |
11 |
|
|
#include <stdio.h> |
12 |
|
|
#include <stdlib.h> |
13 |
|
|
#include <unistd.h> |
14 |
|
|
#include <sys/types.h> |
15 |
|
|
#include <sys/stat.h> |
16 |
|
|
|
17 |
|
|
|
18 |
tim |
3 |
#include "primitives/Atom.hpp" |
19 |
|
|
#include "brains/SimInfo.hpp" |
20 |
|
|
#include "brains/Thermo.hpp" |
21 |
|
|
#include "primitives/StuntDouble.hpp" |
22 |
gezelter |
2 |
|
23 |
|
|
using namespace std; |
24 |
|
|
|
25 |
|
|
class DumpWriter{ |
26 |
|
|
|
27 |
|
|
public: |
28 |
|
|
DumpWriter( SimInfo* the_entry_plug ); |
29 |
|
|
~DumpWriter(); |
30 |
|
|
|
31 |
|
|
void writeDump( double currentTime ); |
32 |
|
|
void writeFinal( double currentTime); |
33 |
|
|
void writeFrame( vector<ofstream*>& outFile, double finalTime ); |
34 |
|
|
|
35 |
|
|
#ifdef IS_MPI |
36 |
|
|
void update(); |
37 |
|
|
#endif |
38 |
|
|
|
39 |
|
|
private: |
40 |
|
|
|
41 |
|
|
#ifdef IS_MPI |
42 |
|
|
void sortByGlobalIndex(); |
43 |
|
|
#endif |
44 |
|
|
|
45 |
|
|
SimInfo* entry_plug; |
46 |
|
|
ofstream dumpFile; |
47 |
|
|
|
48 |
|
|
#ifdef IS_MPI |
49 |
|
|
vector<pair<int, int> > indexArray; |
50 |
|
|
#endif |
51 |
|
|
}; |
52 |
|
|
|
53 |
|
|
class StatWriter{ |
54 |
|
|
|
55 |
|
|
public: |
56 |
|
|
StatWriter( SimInfo* the_entry_plug ); |
57 |
|
|
~StatWriter(); |
58 |
|
|
|
59 |
|
|
void writeStat( double currentTime ); |
60 |
|
|
|
61 |
|
|
private: |
62 |
|
|
|
63 |
|
|
SimInfo* entry_plug; |
64 |
|
|
ofstream outFile; |
65 |
|
|
string outName; |
66 |
|
|
Thermo* tStats; |
67 |
|
|
|
68 |
|
|
}; |
69 |
|
|
|
70 |
|
|
class InitializeFromFile{ |
71 |
|
|
|
72 |
|
|
public: |
73 |
|
|
InitializeFromFile( char *in_name ); |
74 |
|
|
~InitializeFromFile(); |
75 |
|
|
|
76 |
|
|
void readInit( SimInfo* the_entry_plug ); |
77 |
|
|
|
78 |
|
|
private: |
79 |
|
|
char* parseDumpLine(char* line, StuntDouble* sd); |
80 |
|
|
char* parseCommentLine(char* line, SimInfo* entry_plug); |
81 |
|
|
FILE *c_in_file; |
82 |
|
|
char c_in_name[500]; |
83 |
|
|
SimInfo* simnfo; |
84 |
|
|
}; |
85 |
|
|
|
86 |
|
|
class DumpReader{ |
87 |
|
|
|
88 |
|
|
public: |
89 |
|
|
DumpReader(const char *in_name ); |
90 |
|
|
~DumpReader(); |
91 |
|
|
|
92 |
|
|
int getNframes(); |
93 |
|
|
void scanFile( void ); |
94 |
|
|
|
95 |
|
|
void getNextFrame() {} |
96 |
|
|
void readFrame(SimInfo* the_simnfo, int whichFrame); |
97 |
|
|
|
98 |
|
|
#ifdef IS_MPI |
99 |
|
|
void anonymousNodeDie( void ); |
100 |
|
|
void nodeZeroError( void ); |
101 |
|
|
#endif |
102 |
|
|
private: |
103 |
|
|
|
104 |
|
|
void readSet( int whichFrame ); |
105 |
|
|
char* parseDumpLine(char* readLine, StuntDouble* sd); |
106 |
|
|
char* parseCommentLine(char* readLine, SimInfo* entry_plug); |
107 |
|
|
FILE *inFile; |
108 |
|
|
string inFileName; |
109 |
|
|
bool isScanned; |
110 |
|
|
|
111 |
|
|
vector<fpos_t*> framePos; |
112 |
|
|
SimInfo *simnfo; |
113 |
|
|
}; |
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
#endif |