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

#include <partition.h>

Inheritance diagram for tpz_ordered:
Collaboration diagram for tpz_ordered:

Public Member Functions

 tpz_ordered (string *zheader, string *zdata)
 
 ~tpz_ordered ()
 
virtual void parse_layout ()
 
virtual bool parse_data (int num_dep_vars, int num_vars, std::vector< std::vector< int > > rFieldMappings, index_order rIndexOrder, std::vector< adj_map > conv_factor, std::vector< adj_map > norm_val)
 
- Public Member Functions inherited from tpzone
 tpzone (string *zheader, string *zdata)
 
virtual ~tpzone ()
 
- Public Member Functions inherited from partition
 partition ()
 
virtual ~partition ()
 
std::vector< int > get_layout ()
 
string get_error ()
 
string get_status ()
 
int get_num_points ()
 
pointsget_points ()
 
pnt get_point (int n)
 

Private Member Functions

void build_point_index (std::vector< std::vector< int > > rFieldMappings)
 
int get_index_value (int i, int j, int k, index_order rIndexOrder)
 

Private Attributes

manual_index_ptsdata_pts_local
 

Additional Inherited Members

- Protected Member Functions inherited from partition
long double get_adj (std::vector< adj_map > adj, int var)
 
int GetFieldMapping (std::vector< std::vector< int > > rFieldMapping, int rSearchField)
 
- Protected Attributes inherited from tpzone
string * zheader
 
string * zdata
 
- Protected Attributes inherited from partition
std::vector< int > p_layout
 
string error
 
string status
 
pointsdata_pts
 
bool data_pts_set
 

Detailed Description

Definition at line 79 of file partition.h.

Constructor & Destructor Documentation

tpz_ordered ( string *  zheader,
string *  zdata 
)

Definition at line 108 of file partition.cpp.

References partition::data_pts, data_pts_local, and partition::data_pts_set.

108  : tpzone(zheader, zdata){
111 
112  data_pts_set = true;
113 }
bool data_pts_set
Definition: partition.h:54
string * zdata
Definition: partition.h:75
tpzone(string *zheader, string *zdata)
Definition: partition.cpp:85
points * data_pts
Definition: partition.h:53
string * zheader
Definition: partition.h:74
manual_index_pts * data_pts_local
Definition: partition.h:99

Definition at line 115 of file partition.cpp.

115  {
116  return;
117 }

Member Function Documentation

void build_point_index ( std::vector< std::vector< int > >  rFieldMappings)
private

Definition at line 249 of file partition.cpp.

References data_pts_local, partition::get_point(), partition::GetFieldMapping(), i, j, k, n, partition::p_layout, manual_index_pts::set_index(), and manual_index_pts::set_layout().

Referenced by parse_data().

249  {
250 
251  int dimension_0 = GetFieldMapping(rFieldMappings, 0);
252  int dimension_1 = GetFieldMapping(rFieldMappings, 1);
253  int dimension_2 = GetFieldMapping(rFieldMappings, 2);
254 
255  std::vector<int> point_layout;
256  for(int i=0; i<p_layout.size(); i++){
257  point_layout.push_back(p_layout[i]);
258  }
259 
260  //Set layout
261  data_pts_local->set_layout(point_layout);
262 
263  //Build index
264  int n=0;
265  for(int i=0; i < p_layout[0]; i++){
266  for(int j=0; j < p_layout[1]; j++){
267  for(int k=0; k < p_layout[2]; k++){
268 
269  std::vector<int> loc;
270 
271  loc.push_back(i);
272  loc.push_back(j);
273  loc.push_back(k);
274 
275  data_pts_local->set_index(n, loc);
276  pnt curr = get_point(n);
277 
278  n++;
279  }
280  }
281  }
282 
283 }
j indices k indices k
Definition: Indexing.h:6
std::vector< int > p_layout
Definition: partition.h:46
void set_index(int point_num, std::vector< int > loc)
Definition: points.cpp:555
Point object that represents a single point.
Definition: datatypedef.h:68
int GetFieldMapping(std::vector< std::vector< int > > rFieldMapping, int rSearchField)
Definition: partition.cpp:70
pnt get_point(int n)
Definition: partition.cpp:57
blockLoc i
Definition: read.cpp:79
const NT & n
j indices j
Definition: Indexing.h:6
void set_layout(std::vector< int > index_layout)
Definition: points.cpp:541
manual_index_pts * data_pts_local
Definition: partition.h:99

Here is the call graph for this function:

Here is the caller graph for this function:

int get_index_value ( int  i,
int  j,
int  k,
index_order  rIndexOrder 
)
private

Definition at line 287 of file partition.cpp.

References i, j, k, index_order::order, and partition::p_layout.

Referenced by parse_data().

287  {
288 
289  if(rIndexOrder.order.size() <= 0 || rIndexOrder.order.size() > 3){
290 
291  int index_val = i * p_layout[ 1 ]
292  + j * p_layout[ 2 ]
293  + k;
294 
295  return index_val;
296  }
297 
298  int vars[3] = {i, j, k};
299  int layout[3] = {0, 1, 2};
300 
301  for(int dim = 0; dim < rIndexOrder.order.size(); dim++){
302  switch( rIndexOrder.order[dim] ){
303  case 0 :
304  vars[dim] = i;
305  layout[dim] = 0;
306  break;
307 
308  case 1 :
309  vars[dim] = j;
310  layout[dim] = 1;
311  break;
312 
313  case 2 :
314  vars[dim] = k;
315  layout[dim] = 2;
316  break;
317 
318  default :
319  break;
320  }
321  }
322 /*
323  std::cout << "------------------------" << std::endl << std::endl;
324 
325  for(int m=0; m<3; m++){
326  std::cout << m << ": " << layout[m] << " | " << p_layout[ layout[m] ] << std::endl;
327  }
328  std::cout << "===========" << std::endl;
329  std::cout << "i | " << i << ": " << vars[0] << std::endl;
330  std::cout << "j | " << j << ": " << vars[1] << std::endl;
331  std::cout << "k | " << k << ": " << vars[2] << std::endl;
332  std::cout << std::endl;
333 */
334  int index_val = vars[0] * p_layout[ layout[1] ]
335  + vars[1] * p_layout[ layout[2] ]
336  + vars[2];
337 
338  return index_val;
339 
340 }
j indices k indices k
Definition: Indexing.h:6
std::vector< int > p_layout
Definition: partition.h:46
std::vector< int > order
Definition: datatypedef.h:23
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6

Here is the caller graph for this function:

bool parse_data ( int  num_dep_vars,
int  num_vars,
std::vector< std::vector< int > >  rFieldMappings,
index_order  rIndexOrder,
std::vector< adj_map conv_factor,
std::vector< adj_map norm_val 
)
virtual

Reimplemented from partition.

Definition at line 172 of file partition.cpp.

References build_point_index(), partition::data_pts, data_pts_local, partition::get_adj(), get_index_value(), partition::GetFieldMapping(), i, itoa(), Mesquite::length(), n, nvc::norm(), partition::p_layout, read(), points::set_num_indep_vars(), points::set_num_points(), points::set_num_vars(), points::set_point_val(), partition::status, x, y, z, and tpzone::zdata.

174  {
175 
176  std::stringstream data(std::stringstream::in | std::stringstream::out);
177  data << *zdata;
178 
179  //Get the length of each dimension
180  int length = 1;
181  for(int i=0; i < 3; i++){
182  length *= p_layout[i];
183  }
184 
185  //Initialize storage
186  data_pts->set_num_points(length);
187  data_pts->set_num_vars(num_vars);
188  data_pts->set_num_indep_vars(num_vars - num_dep_vars);
189 
190  //Read Data
191  string out;
192 
193  bool swi = false;
194 
195  for(int n=0; n<(num_vars); n++){
196 
197  long double conv = get_adj(conv_factor, n);
198  long double norm = get_adj(norm_val, n);
199 
200  int var_location = GetFieldMapping(rFieldMappings, n);
201 
202  for(int z=0; z<p_layout[ 2 ]; z++){
203  for(int y=0; y<p_layout[ 1 ]; y++){
204  for(int x=0; x<p_layout[ 0 ]; x++){
205 
206  //Read the value
207  data >> out;
208 
209  //Discard data if dimension is mapped to null
210  if(var_location < 0)
211  continue;
212 
213  long double read = strtold(out.c_str(), NULL);
214 
215  //Apply conversion and normalization values
216  read = read * conv * norm;
217 
218  //Calculate the storage index
219  int index_val = get_index_value(x, y, z, rIndexOrder);
220 
221 /*
222  std::cout << index_val << " (" << var_location << ") ";
223  std::cout << ": " << "(" << x << ", " << y << ", " << z << ") > ";
224  std::cout << read << std::endl;
225 */
226 
227  //Store the point
228  data_pts_local->set_point_val(index_val, var_location, read);
229 
230  }
231  }
232  }
233  //std::cout << std::endl;
234  }
235 
236  //std::cout << "=====================================================" << std::endl << std::endl;
237 
238  //Write Status
239  string zs_out("Extracted ");
240  zs_out += itoa(length) + " datapoints";
241  status = zs_out;
242 
243  //Build point index
244  build_point_index(rFieldMappings);
245 
246  return true;
247 }
string * zdata
Definition: partition.h:75
void int int REAL REAL * y
Definition: read.cpp:74
void set_num_indep_vars(int indep_vars)
Definition: points.cpp:113
std::vector< int > p_layout
Definition: partition.h:46
T norm(const NVec< DIM, T > &v)
void set_point_val(int point_number, int var, long double val)
Definition: points.cpp:129
void build_point_index(std::vector< std::vector< int > > rFieldMappings)
Definition: partition.cpp:249
double length(Vector3D *const v, int n)
void set_num_points(int n)
Definition: points.cpp:84
string itoa(int n)
Convert an int to a string.
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int GetFieldMapping(std::vector< std::vector< int > > rFieldMapping, int rSearchField)
Definition: partition.cpp:70
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
points * data_pts
Definition: partition.h:53
const NT & n
string status
Definition: partition.h:50
int get_index_value(int i, int j, int k, index_order rIndexOrder)
Definition: partition.cpp:287
long double get_adj(std::vector< adj_map > adj, int var)
Definition: partition.cpp:61
void read(std::istream &is, T &t, const io_Read_write &)
Definition: io.h:132
manual_index_pts * data_pts_local
Definition: partition.h:99
void set_num_vars(int n)
Definition: points.cpp:109

Here is the call graph for this function:

void parse_layout ( )
virtual

Reimplemented from partition.

Definition at line 119 of file partition.cpp.

References check_non_numeric_str(), partition::error, itoa(), partition::p_layout, readCommaExpression(), partition::status, and tpzone::zheader.

119  {
120 
121  //Get I value
122  std::vector<string> i_val = readCommaExpression( *zheader, string("I") );
123 
124  if(i_val.size() == 1){
125  if( !check_non_numeric_str(string(i_val[0])) )
126  p_layout.push_back(atoi(i_val[0].c_str()));
127  }
128  else{
129  error = string("Unable to read I value from zone header");
130 
131  p_layout.erase(p_layout.begin(), p_layout.end());
132  return;
133  }
134 
135 
136  //Get J value
137  std::vector<string> j_val = readCommaExpression(*zheader, string("J"));
138 
139  if(j_val.size() == 1){
140  if( !check_non_numeric_str(string(j_val[0])) )
141  p_layout.push_back(atoi(j_val[0].c_str()));
142  }
143  else{
144  error = string("Unable to read J value from zone header");
145 
146  p_layout.erase(p_layout.begin(), p_layout.end());
147  return;
148  }
149 
150 
151  //Get K value
152  std::vector<string> k_val = readCommaExpression(*zheader, string("K"));
153 
154  if(k_val.size() == 1){
155  if( !check_non_numeric_str(string(k_val[0])) )
156  p_layout.push_back(atoi(k_val[0].c_str()));
157  }
158  else{
159  error = string("Unable to read K value from zone header");
160 
161  p_layout.erase(p_layout.begin(), p_layout.end());
162  return;
163  }
164 
165  status = "I = " + itoa(p_layout[0]);
166  status += ", J = " + itoa(p_layout[1]);
167  status += ", K = " + itoa(p_layout[2]);
168 }
std::vector< int > p_layout
Definition: partition.h:46
string error
Definition: partition.h:49
std::vector< string > readCommaExpression(string rStack, string rNeedle)
string itoa(int n)
Convert an int to a string.
string status
Definition: partition.h:50
string * zheader
Definition: partition.h:74
bool check_non_numeric_str(string test_str)

Here is the call graph for this function:

Member Data Documentation

manual_index_pts* data_pts_local
private

Definition at line 99 of file partition.h.

Referenced by build_point_index(), parse_data(), and tpz_ordered().


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