ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/io/ReadWrite.hpp
Revision: 1772
Committed: Tue Nov 23 22:48:31 2004 UTC (19 years, 7 months ago) by chrisfen
File size: 3072 byte(s)
Log Message:
Improvements to restraints

File Contents

# Content
1 #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 #include "primitives/Atom.hpp"
19 #include "brains/SimInfo.hpp"
20 #include "brains/Thermo.hpp"
21 #include "primitives/StuntDouble.hpp"
22
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 RestraintWriter{
71
72 public:
73 RestraintWriter( SimInfo* the_entry_plug );
74 ~RestraintWriter();
75
76 void writeZangle( double currentTime );
77 void writeZangle(double currentTime, const char *in_name);
78 void writeFrame( vector<ofstream*>& outFile, double finalTime );
79
80 #ifdef IS_MPI
81 void update();
82 #endif
83
84 private:
85
86 #ifdef IS_MPI
87 void sortByGlobalIndex();
88 vector<pair<int, int> > indexArray;
89 #endif
90
91 SimInfo* entry_plug;
92 ofstream zAngFile;
93
94 };
95
96 class InitializeFromFile{
97
98 public:
99 InitializeFromFile( char *in_name );
100 ~InitializeFromFile();
101
102 void readInit( SimInfo* the_entry_plug );
103
104 private:
105 char* parseDumpLine(char* line, StuntDouble* sd);
106 char* parseCommentLine(char* line, SimInfo* entry_plug);
107 FILE *c_in_file;
108 char c_in_name[500];
109 SimInfo* simnfo;
110 };
111
112 class DumpReader{
113
114 public:
115 DumpReader(const char *in_name );
116 ~DumpReader();
117
118 int getNframes();
119 void scanFile( void );
120
121 void getNextFrame() {}
122 void readFrame(SimInfo* the_simnfo, int whichFrame);
123
124 #ifdef IS_MPI
125 void anonymousNodeDie( void );
126 void nodeZeroError( void );
127 #endif
128 private:
129
130 void readSet( int whichFrame );
131 char* parseDumpLine(char* readLine, StuntDouble* sd);
132 char* parseCommentLine(char* readLine, SimInfo* entry_plug);
133 FILE *inFile;
134 string inFileName;
135 bool isScanned;
136
137 vector<fpos_t*> framePos;
138 SimInfo *simnfo;
139 };
140
141 class RestraintReader{
142
143 public:
144 RestraintReader( SimInfo* the_simnfo );
145 ~RestraintReader();
146
147 void readIdealCrystal();
148 void readZangle( const char *in_name );
149 void zeroZangle();
150
151 #ifdef IS_MPI
152 void anonymousNodeDie( void );
153 void nodeZeroError( void );
154 #endif
155
156 private:
157 char* parseIdealLine(char* readLine, StuntDouble* sd);
158 char *idealName;
159 FILE *inFile;
160 FILE *inAngFile;
161 FILE *inIdealFile;
162 string inFileName;
163 string inAngFileName;
164 string inIdealFileName;
165 bool isScanned;
166
167 double angleTransfer;
168 vector<fpos_t*> framePos;
169 SimInfo *simnfo;
170 };
171
172 #endif