Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
main.h
Go to the documentation of this file.
1 #ifndef _MAIN_H_
2 #define _MAIN_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 <getopt.h>
12 #include <vector>
13 #include <limits>
14 
15 #include "file.h"
16 #include "fileselect.h"
17 #include "metric.h"
18 #include "interpolation.h"
19 #include "datatypedef.h"
20 #include "util.h"
21 
22 #include "BoundingBox.hpp"
23 
24 using std::string;
25 using std::ofstream;
26 using std::ifstream;
27 
28 using namespace std;
29 
30 
31 
32 class ComSwitch {
33 
34  public:
35 
39  ComSwitch();
40 
46  ComSwitch(int rArgc, char *rpArgv[]);
47 
51  ~ComSwitch();
52 
58  bool parseOptions();
59 
65  void setArguments(int rArgc, char *rpArgv[]);
66 
72  bool requiredArgsSet();
73 
79  int getFileDimensions(int rFile);
80 
86  std::vector<adj_map> getConvFactor(int rFile);
87 
93  std::vector<adj_map> getNormVal(int rFile);
94 
100  bool getVerbosity();
101 
107  ifstream & getInputFile(int rFile);
108 
114  string getFileName(int rFile);
115 
120  ofstream & getLogFile();
121 
126  string getOutPrefix();
127 
133  inline bool isRangeSpecified( )
134  {
135  return this ->restrictToRange;
136  };
137 
145  {
146  return this ->mRange;
147  }
152  std::vector<cmp_map> getComparisonList();
153 
160  std::vector< std::vector<int> > getFieldMappings(int rFile);
161 
167  std::vector<index_order> getIndexOrder(int rFile);
168 
169  private:
170 
174  void setDefaultVars();
175 
182  bool readOptions();
183 
191  bool parseValuesFromArguments(string rOptString,
192  const struct option *rLongOpts);
193 
199  bool initializeFileStreams();
200 
206  bool writeLogHeader();
207 
211  bool mHelp;
212 
213  int mArgc;
214  char **mpArgv;
215  bool mBadSwitch;
222  std::vector<adj_map> mFile1ConversionFactor;
223  std::vector<adj_map> mFile2ConversionFactor;
224 
225  std::vector<adj_map> mFile1Norm;
226  std::vector<adj_map> mFile2Norm;
227 
228  ofstream mLog;
229  string mOutPrefix;
230 
231  string mInfileName1;
232  string mInfileName2;
233 
234  ifstream mInfile1;
235  ifstream mInfile2;
236 
237  std::vector<cmp_map> mComparisonList;
238 
239  std::vector< std::vector<int> > mFieldMappingsFile1;
240  std::vector< std::vector<int> > mFieldMappingsFile2;
241 
242  std::vector<index_order> mIndexOrderFile1;
243  std::vector<index_order> mIndexOrderFile2;
244 
245  bool mLoud;
246 
247 };
248 
249 
250 string gUsage("Usage: [--outfile | -o] <output file prefix>\n\t"
251  "[--infile1 | -1] <intput file 1 name>:<dimensions>\n\t"
252  "[--infile2 | -2] <intput file 2 name>:<dimensions>\n\t"
253  "[--fieldmap | -f] <File (1,2)>:<File Dimension>/<Mapped Dimension or \"null\">\n\t"
254  "[--index-order | -i] <File (1,2)>:<Partition>:<Dimension 1>,<Dimension 2>,...\n\t"
255  "[--conv | -c] <File (1,2)>:<Variable>:<Conversion Factor> \n\t"
256  "[--norm | -n] <File (1,2)>:<Variable>:<Normalization Factor> \n\t"
257  "[--range | -r] <xmin>,<ymin>,<zmin>,<xmax>,<ymax>,<zmax> \n\t"
258  "[--metric | -m] <metric number>=<file 1 partition 1>,<file 1 partition 2>,...:<file 1 variable>/\n\t"
259  " <file 2 partition>:<file 2 variable>\n\t"
260  "[--verbose | -v]\n" );
261 
266 void printUsage(string rErrorMessage);
267 
273 vector<datafile*> openAndParseFiles();
274 
279 void compareFiles(vector<datafile*> pFiles);
280 
285 std::vector<points*> retrievePoints(datafile* pFile, vector<int> rPartitions);
286 
290 void printPointValues(points* pPoints);
291 
298 long double calcAverageValue(points *pPoints, int rVar);
299 
300 
306 long double minPoint(points *pPoints, int rVar);
307 
308 
314 long double maxPoint(points *pPoints, int rVar);
315 
316 
317 #endif
BoundingBox getRange()
Returns a bounding box corresponding to the range of the region of interest.
Definition: main.h:144
string mInfileName1
Definition: main.h:231
void compareFiles(vector< datafile * > pFiles)
Compare the two files, interpolating the points from the second onto the first mesh.
Definition: main.cpp:95
A concrete object that provides the functionality for representing a bounding box geometric primitive...
Definition: BoundingBox.hpp:21
int mInfile2Dimensions
Infile 1 independent variable dimensions.
Definition: main.h:217
bool restrictToRange
Infile 2 independent variable dimensions.
Definition: main.h:219
std::vector< adj_map > mFile1Norm
Definition: main.h:225
ifstream mInfile1
Definition: main.h:234
const char * option(const char *const name, const int argc, const char *const *const argv, const char *defaut, const char *const usage=0)
Definition: CImg.h:5604
long double maxPoint(points *pPoints, int rVar)
Find the maximum value.
Definition: main.cpp:309
Base class for file parsing.
Definition: file.h:32
string gUsage("Usage: [--outfile | -o] <output file prefix>\n\t""[--infile1 | -1] <intput file 1 name>:<dimensions>\n\t""[--infile2 | -2] <intput file 2 name>:<dimensions>\n\t""[--fieldmap | -f] <File (1,2)>:<File Dimension>/<Mapped Dimension or \"null\">\n\t""[--index-order | -i] <File (1,2)>:<Partition>:<Dimension 1>,<Dimension 2>,...\n\t""[--conv | -c] <File (1,2)>:<Variable>:<Conversion Factor> \n\t""[--norm | -n] <File (1,2)>:<Variable>:<Normalization Factor> \n\t""[--range | -r] <xmin>,<ymin>,<zmin>,<xmax>,<ymax>,<zmax> \n\t""[--metric | -m] <metric number>=<file 1 partition 1>,<file 1 partition 2>,...:<file 1 variable>/\n\t"" <file 2 partition>:<file 2 variable>\n\t""[--verbose | -v]\n")
Definition: points.h:30
std::vector< cmp_map > mComparisonList
Definition: main.h:237
long double minPoint(points *pPoints, int rVar)
Find the minimum value.
Definition: main.cpp:293
bool mLoud
Definition: main.h:245
void printUsage(const char *why)
Definition: makeflo.cpp:68
bool isRangeSpecified()
Returns a flag that indicates whether a range was supplied to this instance of CommSwitch.
Definition: main.h:133
std::vector< index_order > mIndexOrderFile2
Definition: main.h:243
BoundingBox mRange
Flag used to indicate if the metrics will be restricted to a given range.
Definition: main.h:220
bool mHelp
Help flag is set from command line options.
Definition: main.h:211
ofstream mLog
Definition: main.h:228
std::vector< std::vector< int > > mFieldMappingsFile1
Definition: main.h:239
std::vector< points * > retrievePoints(datafile *pFile, vector< int > rPartitions)
Construct a vector of pointers to datasets (point objects) from a list of partition numbers...
Definition: main.cpp:240
string mOutPrefix
Definition: main.h:229
char ** mpArgv
Number of arguments.
Definition: main.h:214
int mInfile1Dimensions
Bad command line switch detection.
Definition: main.h:216
std::vector< adj_map > mFile2ConversionFactor
Definition: main.h:223
long double calcAverageValue(points *pPoints, int rVar)
Calculates the average value of the points.
Definition: main.cpp:276
string mInfileName2
Definition: main.h:232
Definition: main.h:32
std::vector< std::vector< int > > mFieldMappingsFile2
Definition: main.h:240
vector< datafile * > openAndParseFiles()
Open the files specified at the command line and parse them.
Definition: main.cpp:40
ifstream mInfile2
Definition: main.h:235
int mArgc
Definition: main.h:213
std::vector< adj_map > mFile1ConversionFactor
Range of region of interest.
Definition: main.h:222
std::vector< index_order > mIndexOrderFile1
Definition: main.h:242
void printPointValues(points *pPoints)
Write point values to standard out.
Definition: main.cpp:259
std::vector< adj_map > mFile2Norm
Definition: main.h:226
bool mBadSwitch
The actual command line arguments.
Definition: main.h:215