Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
file.h
Go to the documentation of this file.
1 #ifndef _FILE_H_
2 #define _FILE_H_
3 
4 #include <cstdio>
5 #include <cstdlib>
6 #include <iostream>
7 #include <ostream>
8 #include <fstream>
9 #include <string>
10 #include <time.h>
11 #include <sstream>
12 #include <iomanip>
13 #include <math.h>
14 
15 #include "util.h"
16 #include "datatypedef.h"
17 #include "points.h"
18 
19 //Helper classes
20 #include "partition.h"
21 
22 using std::string;
23 using std::ofstream;
24 using std::ifstream;
25 using std::cout;
26 using std::cerr;
27 
28 
32 class datafile {
33 
34  public:
35 
49  datafile(ifstream &infile, ofstream &outfile, bool loud, string filename, int dim,
50  std::vector< std::vector<int> > rFieldMappings, std::vector<index_order> rIndexOrder,
51  std::vector<adj_map> conv_factor, std::vector<adj_map> norm_val);
52 
57  virtual string get_mod_name();
58 
62  virtual ~datafile();
63 
68  datafile(const datafile& d);
69 
73  virtual void parse();
74 
81  int partition_layout(int partition, int n);
82 
88  points *get_points(int partition);
89 
95  pnt get_point(int n);
96 
103  pnt get_point(int n, int partition);
104 
109  int get_num_points();
110 
116  int get_num_points(int partition);
117 
122  int get_num_vars();
123 
128  string get_title();
129 
134  int get_num_partitions();
135 
136  protected:
137 
138  string filename;
139 
140  //File streams for reading and loggin
141  ifstream &infile;
142  ofstream &outfile;
143  bool loud;
144 
149  void error_out(string err_ps);
150 
155  void status_out(string st_ps);
156 
161  void LogFieldMappings();
162 
163  //PARTITIONS
164  partition **data_part;
165 
166  //File info
168  std::vector<string> var_names;
169  string title;
170 
175  int get_num_dep_vars();
176 
177  //Number of dimensions
178  //aka independent variables
180 
181  //Conversion information
182  std::vector<adj_map> conv_factor;
183  std::vector<adj_map> norm_val;
184 
185  //Field mappings
186  std::vector< std::vector<int> > mFieldMappings;
187 
188  private:
189 
190  //Dependent Variables
191  int dep_vars;
192 
193  protected:
194 
195  index_order get_index_order(int partition);
196 
197  std::vector<index_order> mIndexOrder;
198 };
199 
200 
201 
206 class tecplot_data : public datafile {
207 
208  public:
209 
214  virtual string get_mod_name();
215 
219  tecplot_data(ifstream &infile, ofstream &outfile, bool loud, string filename, int dim,
220  std::vector< std::vector<int> > rFieldMappings, std::vector<index_order> rIndexOrder,
221  std::vector<adj_map> conv_factor, std::vector<adj_map> norm_val);
222 
226  virtual ~tecplot_data();
227 
233  virtual void parse();
234 
235  protected:
236 
241  void read_header();
242 
248  int count_zones();
249 
254  void seek_to_zone();
255 
260  string *get_zone_header(int zone);
261 
266  string *get_zone_nodes(int zone);
267 
268  //Logging
274  void zone_error_out(int zone, string zs_err);
275 
281  void zone_status_out(int zone, string zs_out);
282 
289  tpzone *zone_detect(int zone);
290 
291  private:
292 
293  static const int BUFFER_SIZE = 512;
294 
295 };
296 
297 #endif
virtual string get_mod_name()
Get the name of the class (tecplot_data)
Definition: file.cpp:194
datafile(ifstream &infile, ofstream &outfile, bool loud, string filename, int dim, std::vector< std::vector< int > > rFieldMappings, std::vector< index_order > rIndexOrder, std::vector< adj_map > conv_factor, std::vector< adj_map > norm_val)
Construct data file object using specified information.
Definition: file.cpp:5
std::vector< string > var_names
Definition: file.h:168
pnt get_point(int n)
Get the nth point of the file.
Definition: file.cpp:111
string * get_zone_header(int zone)
Read the zone header.
Definition: file.cpp:373
const NT & d
int get_num_points()
Get the number of points in the file.
Definition: file.cpp:130
string * get_zone_nodes(int zone)
Retrieve zone point data from the zone body.
Definition: file.cpp:414
Base class for file parsing.
Definition: file.h:32
virtual void parse()
Parse the data file.
Definition: file.cpp:57
void zone_error_out(int zone, string zs_err)
Log an error message with appended zone information so the error can be located.
Definition: file.cpp:252
static const int BUFFER_SIZE
Definition: file.h:293
Definition: points.h:30
int get_num_dep_vars()
Get number of dependent variables.
Definition: file.cpp:163
int dimensions
Definition: file.h:179
Used to store index order information.
Definition: datatypedef.h:22
void status_out(string st_ps)
Log the string specified as a status event.
Definition: file.cpp:70
string get_title()
Get file title if specified in file header.
Definition: file.cpp:155
partition ** data_part
Definition: file.h:164
ofstream & outfile
Definition: file.h:142
int get_num_vars()
Get the number of variables in the file.
Definition: file.cpp:159
Point object that represents a single point.
Definition: datatypedef.h:68
bool loud
Definition: file.h:143
virtual void parse()
Parse the tecplot file.
Definition: file.cpp:281
int count_zones()
Count the number of zones in the tecplot file, starting from the current location of the file stream...
Definition: file.cpp:262
void read_header()
Read the tecplot header from the file and retrieve the title, variable names, and number of variables...
Definition: file.cpp:207
std::vector< std::vector< int > > mFieldMappings
Definition: file.h:186
points * get_points(int partition)
Get a partitions&#39; points.
Definition: file.cpp:100
int num_partitions
Definition: file.h:167
int get_num_partitions()
Get number of partition in the file.
Definition: file.cpp:151
ifstream & infile
Definition: file.h:141
std::vector< adj_map > norm_val
Definition: file.h:183
const NT & n
tpzone * zone_detect(int zone)
Read the header information for the specified zone, then create a new zone object based on the type o...
Definition: file.cpp:340
std::vector< index_order > mIndexOrder
Definition: file.h:197
virtual ~datafile()
Free used data, delete the object.
Definition: file.cpp:30
tecplot_data(ifstream &infile, ofstream &outfile, bool loud, string filename, int dim, std::vector< std::vector< int > > rFieldMappings, std::vector< index_order > rIndexOrder, std::vector< adj_map > conv_factor, std::vector< adj_map > norm_val)
Constructor that initializes values.
Definition: file.cpp:186
virtual string get_mod_name()
Get class name.
Definition: file.cpp:53
int dep_vars
Definition: file.h:191
void zone_status_out(int zone, string zs_out)
Log a status message with appended zone information.
Definition: file.cpp:245
void seek_to_zone()
Seek to the next zone in the file.
Definition: file.cpp:198
string title
Definition: file.h:169
void LogFieldMappings()
Log the field mapping data from the command line and stored in mFieldMappings.
Definition: file.cpp:79
index_order get_index_order(int partition)
Definition: file.cpp:167
int partition_layout(int partition, int n)
Get the size of n dimension of the specified partition.
Definition: file.cpp:90
virtual ~tecplot_data()
Destructor.
Definition: file.cpp:182
string filename
Definition: file.h:138
std::vector< adj_map > conv_factor
Definition: file.h:182
Base class for tecplot files Implements useful functions for tecplot file parsing.
Definition: file.h:206
void error_out(string err_ps)
Log the string specified as an error event.
Definition: file.cpp:65