Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
datafile Class Reference

Base class for file parsing. More...

#include <file.h>

Inheritance diagram for datafile:
Collaboration diagram for datafile:

Public Member Functions

 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. More...
 
virtual string get_mod_name ()
 Get class name. More...
 
virtual ~datafile ()
 Free used data, delete the object. More...
 
 datafile (const datafile &d)
 Deep copy constructor. More...
 
virtual void parse ()
 Parse the data file. More...
 
int partition_layout (int partition, int n)
 Get the size of n dimension of the specified partition. More...
 
pointsget_points (int partition)
 Get a partitions' points. More...
 
pnt get_point (int n)
 Get the nth point of the file. More...
 
pnt get_point (int n, int partition)
 Get the nth point of the specified partition. More...
 
int get_num_points ()
 Get the number of points in the file. More...
 
int get_num_points (int partition)
 Get the number of points in the specified partition. More...
 
int get_num_vars ()
 Get the number of variables in the file. More...
 
string get_title ()
 Get file title if specified in file header. More...
 
int get_num_partitions ()
 Get number of partition in the file. More...
 

Protected Member Functions

void error_out (string err_ps)
 Log the string specified as an error event. More...
 
void status_out (string st_ps)
 Log the string specified as a status event. More...
 
void LogFieldMappings ()
 Log the field mapping data from the command line and stored in mFieldMappings. More...
 
int get_num_dep_vars ()
 Get number of dependent variables. More...
 
index_order get_index_order (int partition)
 

Protected Attributes

string filename
 
ifstream & infile
 
ofstream & outfile
 
bool loud
 
partition ** data_part
 
int num_partitions
 
std::vector< string > var_names
 
string title
 
int dimensions
 
std::vector< adj_mapconv_factor
 
std::vector< adj_mapnorm_val
 
std::vector< std::vector< int > > mFieldMappings
 
std::vector< index_ordermIndexOrder
 

Private Attributes

int dep_vars
 

Detailed Description

Base class for file parsing.

Definition at line 32 of file file.h.

Constructor & Destructor Documentation

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.

Parameters
infileInput file stream
outfileLog file stream
loudLog verbosity
filenameName of the input file
dimNumber of dimensions in the input file
rFieldMappingsMappings of file variables to internal representation variables
rIndexOrderThe order of variables for index creation (for each partition)
conv_factorFactors multiplied with corresponding variables in order to convert values with difference units
norm_valValues multiplied with corresponding variables in order to reverse normalization

Definition at line 5 of file file.cpp.

References conv_factor, dep_vars, dimensions, filename, loud, mFieldMappings, mIndexOrder, norm_val, and num_partitions.

9 
10  this->loud = loud;
11  this->filename = filename;
12 
13  this->conv_factor = conv_factor;
14  this->norm_val = norm_val;
15 
16  this->mFieldMappings = rFieldMappings;
17 
18  this->num_partitions = -1;
19  this->dep_vars = 0;
20 
21  this->dimensions = dim;
22 
23  this->mIndexOrder = rIndexOrder;
24 
25  //Seek to beginning of file
26  infile.clear();
27  infile.seekg(0, std::ios::beg);
28 }
int dimensions
Definition: file.h:179
ofstream & outfile
Definition: file.h:142
bool loud
Definition: file.h:143
std::vector< std::vector< int > > mFieldMappings
Definition: file.h:186
int num_partitions
Definition: file.h:167
ifstream & infile
Definition: file.h:141
std::vector< adj_map > norm_val
Definition: file.h:183
std::vector< index_order > mIndexOrder
Definition: file.h:197
int dep_vars
Definition: file.h:191
string filename
Definition: file.h:138
std::vector< adj_map > conv_factor
Definition: file.h:182
~datafile ( )
virtual

Free used data, delete the object.

Definition at line 30 of file file.cpp.

References data_part, i, and num_partitions.

30  {
31 
32  if(num_partitions > 0){
33  for(int i=0; i<num_partitions; i++)
34  delete data_part[i];
35  delete[] data_part;
36  }
37 
38 }
partition ** data_part
Definition: file.h:164
int num_partitions
Definition: file.h:167
blockLoc i
Definition: read.cpp:79
datafile ( const datafile d)

Deep copy constructor.

Parameters
dDatafile to copy

Definition at line 40 of file file.cpp.

References dep_vars, filename, loud, num_partitions, title, and var_names.

41  : infile(d.infile), outfile(d.outfile) {
42 
43  filename = d.filename;
44  loud = d.loud;
46  title = d.title;
47  dep_vars = d.dep_vars;
48 
49  var_names = d.var_names;
50 
51 }
std::vector< string > var_names
Definition: file.h:168
ofstream & outfile
Definition: file.h:142
bool loud
Definition: file.h:143
int num_partitions
Definition: file.h:167
ifstream & infile
Definition: file.h:141
int dep_vars
Definition: file.h:191
string title
Definition: file.h:169
string filename
Definition: file.h:138

Member Function Documentation

void error_out ( string  err_ps)
protected

Log the string specified as an error event.

Parameters
err_psError message

Definition at line 65 of file file.cpp.

References filename, and outfile.

Referenced by tecplot_data::parse(), and tecplot_data::zone_error_out().

65  {
66  outfile << "ERROR | File \"" << this->filename << "\": " << err_ps << std::endl;
67  cout << "ERROR | File \"" << this->filename << "\": " << err_ps << std::endl;
68 }
ofstream & outfile
Definition: file.h:142
string filename
Definition: file.h:138

Here is the caller graph for this function:

index_order get_index_order ( int  partition)
protected

Definition at line 167 of file file.cpp.

References empty(), and mIndexOrder.

Referenced by tecplot_data::parse().

167  {
168  for(int record_num = 0; record_num < mIndexOrder.size(); record_num++){
169  if(mIndexOrder[record_num].partition_number == partition){
170  return mIndexOrder[record_num];
171  }
172  }
173 
175  return empty;
176 }
boolean empty(T_VertexSet s)
Used to store index order information.
Definition: datatypedef.h:22
std::vector< index_order > mIndexOrder
Definition: file.h:197

Here is the call graph for this function:

Here is the caller graph for this function:

string get_mod_name ( )
virtual

Get class name.

Returns
Name of the class (datafile)

Reimplemented in tecplot_data.

Definition at line 53 of file file.cpp.

Referenced by parse().

53  {
54  return string("Datafile");
55 }

Here is the caller graph for this function:

int get_num_dep_vars ( )
protected

Get number of dependent variables.

Returns
Number of dependent variables

Definition at line 163 of file file.cpp.

References dimensions, and var_names.

Referenced by tecplot_data::parse().

163  {
164  return var_names.size() - dimensions;
165 }
std::vector< string > var_names
Definition: file.h:168
int dimensions
Definition: file.h:179

Here is the caller graph for this function:

int get_num_partitions ( )

Get number of partition in the file.

Returns
Number of partitions

Definition at line 151 of file file.cpp.

References num_partitions.

Referenced by get_points(), and retrievePoints().

151  {
152  return num_partitions;
153 }
int num_partitions
Definition: file.h:167

Here is the caller graph for this function:

int get_num_points ( )

Get the number of points in the file.

Returns
Number of points in file

Definition at line 130 of file file.cpp.

References data_part, partition::get_num_points(), i, and num_partitions.

Referenced by get_point().

130  {
131 
132  int ret = 0;
133 
134  //Get number of points of each partition
135  for(int i=0; i<num_partitions; i++){
136  if(data_part[i] != NULL)
137  ret += data_part[i]->get_num_points();
138  }
139 
140  return ret;
141 }
partition ** data_part
Definition: file.h:164
int num_partitions
Definition: file.h:167
blockLoc i
Definition: read.cpp:79
int get_num_points()
Definition: partition.cpp:49

Here is the call graph for this function:

Here is the caller graph for this function:

int get_num_points ( int  partition)

Get the number of points in the specified partition.

Parameters
partitionPartition number
Returns
Number of points in partition

Definition at line 143 of file file.cpp.

References data_part, and partition::get_num_points().

143  {
144 
145  if(data_part[partition] != NULL)
147  else
148  return 0;
149 }
partition ** data_part
Definition: file.h:164
int get_num_points()
Definition: partition.cpp:49

Here is the call graph for this function:

int get_num_vars ( )

Get the number of variables in the file.

Returns
Number of variables

Definition at line 159 of file file.cpp.

References var_names.

Referenced by tecplot_data::parse().

159  {
160  return var_names.size();
161 }
std::vector< string > var_names
Definition: file.h:168

Here is the caller graph for this function:

pnt get_point ( int  n)

Get the nth point of the file.

Parameters
nPoint to retrieve
Returns
nth point of the entire file

Definition at line 111 of file file.cpp.

References data_part, partition::get_num_points(), get_num_points(), partition::get_point(), i, and num_partitions.

111  {
112 
113  //Calculate the correct partition
114  int i;
115  for(i=0; i<num_partitions; i++){
116  if(data_part[i]->get_num_points() > n)
117  break;
118 
119  n = n - data_part[i]->get_num_points();
120  }
121 
122  //Retrieve point from partition
123  return data_part[i]->get_point(n);
124 }
int get_num_points()
Get the number of points in the file.
Definition: file.cpp:130
partition ** data_part
Definition: file.h:164
pnt get_point(int n)
Definition: partition.cpp:57
int num_partitions
Definition: file.h:167
blockLoc i
Definition: read.cpp:79
const NT & n
int get_num_points()
Definition: partition.cpp:49

Here is the call graph for this function:

pnt get_point ( int  n,
int  partition 
)

Get the nth point of the specified partition.

Parameters
nPoint number
partitionPartition number
Returns
nth point of partition

Definition at line 126 of file file.cpp.

References data_part, and partition::get_point().

126  {
127  return data_part[partition]->get_point(n);
128 }
partition ** data_part
Definition: file.h:164
pnt get_point(int n)
Definition: partition.cpp:57
const NT & n

Here is the call graph for this function:

points * get_points ( int  partition)

Get a partitions' points.

Parameters
partitionPartition number
Returns
Points of the specified partition

Definition at line 100 of file file.cpp.

References data_part, get_num_partitions(), and partition::get_points().

Referenced by compareFiles(), and retrievePoints().

100  {
101 
103  return NULL;
104 
105  return data_part[partition]->get_points();
106 }
points * get_points()
Definition: partition.cpp:53
partition ** data_part
Definition: file.h:164
int get_num_partitions()
Get number of partition in the file.
Definition: file.cpp:151

Here is the call graph for this function:

Here is the caller graph for this function:

string get_title ( )

Get file title if specified in file header.

Returns
File title

Definition at line 155 of file file.cpp.

References title.

155  {
156  return title;
157 }
string title
Definition: file.h:169
void LogFieldMappings ( )
protected

Log the field mapping data from the command line and stored in mFieldMappings.

Definition at line 79 of file file.cpp.

References itoa(), mFieldMappings, and status_out().

Referenced by tecplot_data::read_header().

79  {
80  for(int field=0; field<mFieldMappings.size(); field++){
81  string st_out = string("Mapping VAR ");
82  st_out += itoa(mFieldMappings[field][0]);
83  st_out += " -> VAR ";
84  st_out += itoa(mFieldMappings[field][1]);
85 
86  status_out(st_out);
87  }
88 }
void status_out(string st_ps)
Log the string specified as a status event.
Definition: file.cpp:70
string itoa(int n)
Convert an int to a string.
std::vector< std::vector< int > > mFieldMappings
Definition: file.h:186

Here is the call graph for this function:

Here is the caller graph for this function:

void parse ( )
virtual

Parse the data file.

Non functional, meant to be overriden by subclasses.

Reimplemented in tecplot_data.

Definition at line 57 of file file.cpp.

References get_mod_name(), and status_out().

Referenced by openAndParseFiles().

57  {
58 
59  //Print status
61 
62  return;
63 }
void status_out(string st_ps)
Log the string specified as a status event.
Definition: file.cpp:70
virtual string get_mod_name()
Get class name.
Definition: file.cpp:53

Here is the call graph for this function:

Here is the caller graph for this function:

int partition_layout ( int  partition,
int  n 
)

Get the size of n dimension of the specified partition.

Parameters
partitionPartition number
nDimension number
Returns
Size of n in partition

Definition at line 90 of file file.cpp.

References data_part, partition::get_layout(), and n.

90  {
91  if(data_part[partition] != NULL)
92  return data_part[partition]->get_layout()[n];
93  else
94  return 0;
95 }
partition ** data_part
Definition: file.h:164
const NT & n
std::vector< int > get_layout()
Definition: partition.cpp:17

Here is the call graph for this function:

void status_out ( string  st_ps)
protected

Log the string specified as a status event.

Parameters
st_psStatus message

Definition at line 70 of file file.cpp.

References filename, loud, and outfile.

Referenced by LogFieldMappings(), parse(), tecplot_data::parse(), tecplot_data::read_header(), and tecplot_data::zone_status_out().

70  {
71  if(loud){
72  outfile << "status | File \"" << this->filename << "\": " << st_ps << std::endl;
73  }
74 }
ofstream & outfile
Definition: file.h:142
bool loud
Definition: file.h:143
string filename
Definition: file.h:138

Here is the caller graph for this function:

Member Data Documentation

std::vector<adj_map> conv_factor
protected

Definition at line 182 of file file.h.

Referenced by datafile(), and tecplot_data::parse().

partition** data_part
protected
int dep_vars
private

Definition at line 191 of file file.h.

Referenced by datafile().

int dimensions
protected

Definition at line 179 of file file.h.

Referenced by datafile(), and get_num_dep_vars().

string filename
protected

Definition at line 138 of file file.h.

Referenced by datafile(), error_out(), and status_out().

bool loud
protected

Definition at line 143 of file file.h.

Referenced by datafile(), and status_out().

std::vector< std::vector<int> > mFieldMappings
protected

Definition at line 186 of file file.h.

Referenced by datafile(), LogFieldMappings(), and tecplot_data::parse().

std::vector<index_order> mIndexOrder
protected

Definition at line 197 of file file.h.

Referenced by datafile(), and get_index_order().

std::vector<adj_map> norm_val
protected

Definition at line 183 of file file.h.

Referenced by datafile(), and tecplot_data::parse().

int num_partitions
protected
ofstream& outfile
protected

Definition at line 142 of file file.h.

Referenced by error_out(), and status_out().

string title
protected

Definition at line 169 of file file.h.

Referenced by datafile(), get_title(), and tecplot_data::read_header().

std::vector<string> var_names
protected

Definition at line 168 of file file.h.

Referenced by datafile(), get_num_dep_vars(), get_num_vars(), and tecplot_data::read_header().


The documentation for this class was generated from the following files: