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

#include <tecplotwriter.h>

Inheritance diagram for TecplotOrderedWriter:
Collaboration diagram for TecplotOrderedWriter:

Public Member Functions

 TecplotOrderedWriter ()
 Default constructor. More...
 
 TecplotOrderedWriter (string rFilename)
 Constructor. More...
 
virtual ~TecplotOrderedWriter ()
 Destructor. More...
 
bool writeFile (string rTitle, std::vector< string > rVariableNames)
 Write all information to file. More...
 
bool addOrderedPartition (string rTitle, indexed_points *rpPoints, int rPartitionVariable)
 Add ordered partition of points to the file write queue Points are written after WriteFile call Partitions must have the same number of variables. More...
 
- Public Member Functions inherited from TecplotWriter
 TecplotWriter ()
 Default constructor. More...
 
 TecplotWriter (string rFilename)
 Constructor. More...
 
 ~TecplotWriter ()
 Destructor. More...
 
void setOutputFilename (string rFilename)
 Set filename. More...
 
string getOutputFilename ()
 Get filename. More...
 
bool init ()
 Initialize writer. More...
 

Private Member Functions

bool writePartition (int rPartitionNum)
 Write partition to file. More...
 
bool writePoints (int rPartitionNum)
 Write the points of the partition specified to file. More...
 

Private Attributes

std::vector< indexed_points * > mPartitionPoints
 
std::vector< string > mPartitionTitles
 
std::vector< int > mPartitionVariable
 

Static Private Attributes

static const int POINT_WIDTH = 5
 Number of points per line. More...
 

Additional Inherited Members

- Protected Attributes inherited from TecplotWriter
string mFilename
 
ofstream mFileHandle
 

Detailed Description

Definition at line 83 of file tecplotwriter.h.

Constructor & Destructor Documentation

Default constructor.

Definition at line 69 of file tecplotwriter.cpp.

69  : TecplotWriter(){
70  return;
71 }
TecplotWriter()
Default constructor.
TecplotOrderedWriter ( string  rFilename)

Constructor.

Parameters
rFilenameOutput filename

Definition at line 77 of file tecplotwriter.cpp.

77  : TecplotWriter(rFilename){
78  return;
79 }
TecplotWriter()
Default constructor.
~TecplotOrderedWriter ( )
virtual

Destructor.

Definition at line 84 of file tecplotwriter.cpp.

84  {
85  return;
86 }

Member Function Documentation

bool addOrderedPartition ( string  rTitle,
indexed_points rpPoints,
int  rPartitionVariable 
)

Add ordered partition of points to the file write queue Points are written after WriteFile call Partitions must have the same number of variables.

Parameters
rTitleTitle of partition
rpPointsDatapoints to write to file
rPartitionVariableVariable number to write (after the independent variables). If -1, all variables will be written

Definition at line 127 of file tecplotwriter.cpp.

References points::get_num_indep_vars(), points::get_num_vars(), mPartitionPoints, mPartitionTitles, and mPartitionVariable.

127  {
128 
129  if(rpPoints == NULL)
130  return false;
131 
132  if(mPartitionPoints.size() != 0){
133 
134  //Calculate the number of vars in the supplied dataset
135  int curr_num_vars = -1;
136  if(rPartitionVariable == -1)
137  curr_num_vars = rpPoints->get_num_vars();
138  else
139  curr_num_vars = rpPoints->get_num_indep_vars() + 1;
140 
141  //Calculate the number of vars in the previous dataset
142  int prev_var = mPartitionVariable.back();
143  int prev_num_vars = -1;
144  if(prev_var == -1)
145  prev_num_vars = mPartitionPoints.back()->get_num_vars();
146  else
147  prev_num_vars = mPartitionPoints.back()->get_num_indep_vars() + 1;
148 
149  //Check variable consistency
150  if(curr_num_vars != prev_num_vars)
151  return false;
152  }
153 
154  mPartitionPoints.push_back(rpPoints);
155  mPartitionTitles.push_back(rTitle);
156  mPartitionVariable.push_back(rPartitionVariable);
157  return true;
158 }
int get_num_vars()
Definition: points.cpp:121
std::vector< indexed_points * > mPartitionPoints
std::vector< int > mPartitionVariable
int get_num_indep_vars()
Definition: points.cpp:125
std::vector< string > mPartitionTitles

Here is the call graph for this function:

bool writeFile ( string  rTitle,
std::vector< string >  rVariableNames 
)

Write all information to file.

Parameters
rTitleDataset Title
rVariableNamesVariable names for header
Returns
True if write is successful, otherwise false

Definition at line 94 of file tecplotwriter.cpp.

References TecplotWriter::mFileHandle, mPartitionPoints, and writePartition().

94  {
95 
96  //Check file handle
97  if(!mFileHandle.is_open())
98  return false;
99 
100  //Check to make sure the number of variables match
101  if(mPartitionPoints.size() != 0){
102  if(rVariableNames.size() != mPartitionPoints[0]->get_num_vars())
103  return false;
104  }
105 
106  mFileHandle << "TITLE = \"" << rTitle << "\"" << endl;
107 
108  //Write variable names to file
109  mFileHandle << "VARIABLES = ";
110 
111  for(int var_num = 0; var_num < rVariableNames.size(); var_num++){
112  mFileHandle << "\"" << rVariableNames[var_num] << "\"" << endl;
113  }
114 
115  //Write partitions to file
116  for(int partition_num = 0; partition_num < mPartitionPoints.size(); partition_num++){
117  writePartition(partition_num);
118  }
119 
120  return false;
121 }
std::vector< indexed_points * > mPartitionPoints
ofstream mFileHandle
Definition: tecplotwriter.h:74
bool writePartition(int rPartitionNum)
Write partition to file.

Here is the call graph for this function:

bool writePartition ( int  rPartitionNum)
private

Write partition to file.

Parameters
rPartitionPointsPartition datapoints
Returns
True if write is successful, otherwise false

Definition at line 165 of file tecplotwriter.cpp.

References indexed_points::get_dim(), i, j, k, TecplotWriter::mFileHandle, mPartitionPoints, mPartitionTitles, and writePoints().

Referenced by writeFile().

165  {
166 
167  //Sanity check
168  if(rPartitionNum >= mPartitionPoints.size() || rPartitionNum > mPartitionTitles.size())
169  return false;
170 
171  indexed_points *curr_points = mPartitionPoints[rPartitionNum];
172 
173  //Zone and title
174  mFileHandle << "ZONE ";
175  mFileHandle << "T = \"" << mPartitionTitles[rPartitionNum] << "\"" << endl;
176 
177  //Don't know what this is...
178  mFileHandle << "STRANDID=0, SOLUTIONTIME=0" << endl;
179 
180  if(curr_points->get_dim().size() < 3)
181  return false;
182 
183  //Write i,j,k values
184  int i = curr_points->get_dim()[0];
185  int j = curr_points->get_dim()[1];
186  int k = curr_points->get_dim()[2];
187 
188  mFileHandle << "I=" << i << ", ";
189  mFileHandle << "J=" << j << ", ";
190  mFileHandle << "K=" << k << ", ";
191 
192  //Write other properties
193  mFileHandle << "ZONETYPE=Ordered" << endl;
194  mFileHandle << "DATAPACKING=BLOCK" << endl;
195 
196  mFileHandle << "DT=(SINGLE SINGLE SINGLE SINGLE )" << endl;
197 
198 
199  return writePoints(rPartitionNum);
200 }
j indices k indices k
Definition: Indexing.h:6
bool writePoints(int rPartitionNum)
Write the points of the partition specified to file.
std::vector< indexed_points * > mPartitionPoints
virtual std::vector< int > get_dim()
Definition: points.cpp:512
ofstream mFileHandle
Definition: tecplotwriter.h:74
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
std::vector< string > mPartitionTitles

Here is the call graph for this function:

Here is the caller graph for this function:

bool writePoints ( int  rPartitionNum)
private

Write the points of the partition specified to file.

Points are written in block format.

Parameters
rPartitionNumIndex of the parition's points in local storage
Returns
True on success, otherwise false

Definition at line 207 of file tecplotwriter.cpp.

References indexed_points::get_dim(), points::get_num_indep_vars(), points::get_num_points(), points::get_num_vars(), points::get_point(), TecplotWriter::mFileHandle, mPartitionPoints, mPartitionVariable, POINT_WIDTH, pnt::vals, x, y, and z.

Referenced by writePartition().

207  {
208 
209  if(mPartitionPoints.size() <= rPartitionNum)
210  return false;
211 
212  indexed_points *curr_points = mPartitionPoints[rPartitionNum];
213 
214  int num_pts = curr_points->get_num_points();
215  int vars = curr_points->get_num_vars();
216 
217  int values_printed = 0;
218 
219  //Loop through and write points
220  for(int var_num = 0; var_num < vars; var_num++){
221 
222  if(mPartitionVariable[rPartitionNum] != -1 && var_num >= curr_points->get_num_indep_vars()){
223  if(var_num != mPartitionVariable[rPartitionNum])
224  continue;
225  }
226 
227  for(int z = 0; z < curr_points->get_dim()[2]; z++){
228  for(int y = 0; y < curr_points->get_dim()[1]; y++){
229  for(int x = 0; x < curr_points->get_dim()[0]; x++){
230 
231  //Line break after every POINT_WIDTH values are written
232  if(values_printed == POINT_WIDTH){
233  mFileHandle << endl;
234  values_printed = 0;
235  }
236 
237  //Calculate value index (see tecplot docs)
238  int index = x * curr_points->get_dim()[1]
239  + y * curr_points->get_dim()[2]
240  + z;
241 
242  mFileHandle << " " << std::uppercase << std::scientific << curr_points->get_point(index).vals[var_num];
243 
244  values_printed++;
245 
246  }
247  }
248  }
249  }
250 
251  mFileHandle << std::endl;
252 
253  return false;
254 
255 }
int get_num_vars()
Definition: points.cpp:121
void int int REAL REAL * y
Definition: read.cpp:74
long double * vals
Definition: datatypedef.h:69
std::vector< indexed_points * > mPartitionPoints
virtual std::vector< int > get_dim()
Definition: points.cpp:512
pnt get_point(int n)
Definition: points.cpp:183
ofstream mFileHandle
Definition: tecplotwriter.h:74
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
std::vector< int > mPartitionVariable
int get_num_indep_vars()
Definition: points.cpp:125
int get_num_points()
Definition: points.cpp:117
static const int POINT_WIDTH
Number of points per line.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::vector<indexed_points *> mPartitionPoints
private

Definition at line 139 of file tecplotwriter.h.

Referenced by addOrderedPartition(), writeFile(), writePartition(), and writePoints().

std::vector<string> mPartitionTitles
private

Definition at line 140 of file tecplotwriter.h.

Referenced by addOrderedPartition(), and writePartition().

std::vector<int> mPartitionVariable
private

Definition at line 141 of file tecplotwriter.h.

Referenced by addOrderedPartition(), and writePoints().

const int POINT_WIDTH = 5
staticprivate

Number of points per line.

Definition at line 144 of file tecplotwriter.h.

Referenced by writePoints().


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