1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // VPICGlobal class contains common information for a single VPICDataSet run
4 // including information about the directory structure, file names, problem
5 // size physical and grid information, variable information
6 //
7 /////////////////////////////////////////////////////////////////////////////
8 
9 #ifndef VPICGlobal_h
10 #define VPICGlobal_h
11 
12 #include "VPICDefinition.h"
13 #include "VPICHeader.h"
14 
15 #include <iostream>
16 #include <string>
17 #include <vector>
18 
19 using namespace std;
20 
21 class VPIC_EXPORT VPICGlobal {
22 public:
23    VPICGlobal();
24    ~VPICGlobal();
25 
26    // Read basic information about files, sizes and variables from .vpc file
27    void readGlobal(const string& inFile);
28    void readFieldVariables(ifstream& inStr);
29    void readSpeciesVariables(ifstream& inStr);
30    void getKeyword(char* inBuf, string& keyword, string& rest);
31 
32    // Build the directory structure for accessing data files
33    void buildFileNames();
34 
35    // Build the file decomposition structure for file access
36    void buildFileLayoutTable();
37 
38    // Gather information about variables for general use in reader
39    void initializeVariables();
40 
41    // For dynamic viewing of a running VPIC, to collect new time steps
42    void addNewTimeSteps();
43 
44    // Variable information
getNumberOfVariables()45    int    getNumberOfVariables()        { return this->numberOfVariables; }
getVariableName(int var)46    string getVariableName(int var)      { return this->variableName[var]; }
getVariableStruct(int var)47    int    getVariableStruct(int var)    { return this->variableStruct[var]; }
getVariableKind(int var)48    int    getVariableKind(int var)      { return this->variableKind[var]; }
getVariableType(int var)49    int    getVariableType(int var)      { return this->variableType[var]; }
getVariableByteCount(int var)50    int    getVariableByteCount(int var) { return this->variableByteCount[var]; }
getVariableOffset(int var,int comp)51    long int getVariableOffset(int var, int comp)
52                                 { return this->variableOffset[var][comp]; }
53 
54    // File information
getLayoutSize()55    int*   getLayoutSize()               { return this->layoutSize; }
getLayoutID()56    int*** getLayoutID()                 { return this->layoutID; }
getPartSize()57    int*   getPartSize()                 { return this->partSize; }
getNumberOfParts()58    int    getNumberOfParts()            { return this->numberOfFiles; }
59 
getNumberOfDirectories()60    int    getNumberOfDirectories()      { return this->numberOfDirectories; }
getNumberOfTimeSteps()61    int    getNumberOfTimeSteps()        { return this->numberOfTimeSteps; }
62 
getDirectoryName(int i)63    string getDirectoryName(int i)       { return this->directoryName[i]; }
getBaseFileName(int i)64    string getBaseFileName(int i)        { return this->baseFileName[i]; }
getDumpName(int time)65    string getDumpName(int time)         { return this->dumpName[time]; }
getDumpTime(int time)66    int    getDumpTime(int time)         { return this->dumpTime[time]; }
67 
getTimeFieldLen()68    int    getTimeFieldLen()             { return this->timeFieldLen; }
getProcFieldLen()69    int    getProcFieldLen()             { return this->procFieldLen; }
70 
71    // Grid and physical grid information
getPhysicalOrigin()72    float* getPhysicalOrigin()           { return this->physicalOrigin; }
getPhysicalStep()73    float* getPhysicalStep()             { return this->physicalStep; }
74 
75    void   PrintSelf(ostream& os, int indent);
76 
77 private:
78    string   globalFile;                 // Name of .vpc file
79    string   headerVersion;              // Version of VPIC
80    int      headerSize;                 // Size of header on every data file
81    VPICHeader header;                   // Header information
82 
83    // File information
84    int      numberOfDirectories;        // Field plus species directories
85    string*  directoryName;              // Full name of field and species dirs
86    string*  baseFileName;               // Base file name matching directory
87    int      numberOfFiles;              // Number of data files for problem
88 
89    int      layoutSize[DIMENSION];      // Simulation decomposition of files
90    int***   layoutID;                   // Numerical ID of file
91    int      partSize[DIMENSION];        // Size of data on each file
92 
93    // Physical information
94    float    physicalExtent[DIMENSION*2];
95    float    physicalOrigin[DIMENSION];
96    float    physicalStep[DIMENSION];
97 
98    // Field variable information
99    string   fieldDirectory;             // Directory
100    string   fieldBaseName;              // Start of every file name
101    int      fieldVarCount;              // Number of variables
102    string*  fieldName;                  // Variable name
103    int*     fieldStructType;            // SCALAR, VECTOR, TENSOR
104    int*     fieldCompSize;              // Number of components
105    int*     fieldBasicType;             // FLOAT, INTEGER
106    int*     fieldByteCount;             // Bytes per basic type
107 
108    // Species variable information
109    int      speciesCount;               // Number of other data directories
110    string*  speciesDirectory;           // Directory
111    string*  speciesBaseName;            // Start of every file name
112    int*     speciesVarCount;            // Number of variables
113    string** speciesName;                // Variable name
114    int**    speciesStructType;          // SCALAR, VECTOR, TENSOR
115    int**    speciesCompSize;            // Number of components
116    int**    speciesBasicType;           // FLOAT, INTEGER
117    int**    speciesByteCount;           // Bytes per basic type
118 
119    // Time information
120    int      numberOfTimeSteps;          // Number of time steps
121    vector<string> dumpName;             // Dump subdirectory names
122    vector<int>    dumpTime;             // Dump subdirectory times
123    int      procFieldLen;               // fields.tttttt.pppp part names
124    int      timeFieldLen;               // fields.tttttt.pppp part names
125 
126    // Variable information
127    int      numberOfVariables;          // All field and species variables
128    string*  variableName;               // Names of variables for reader
129    int*     variableStruct;             // SCALAR, VECTOR, TENSOR
130    int*     variableType;               // DOUBLE, FLOAT, INTEGER
131    int*     variableByteCount;          // Bytes per basic type
132    int*     variableKind;               // Field or which species
133    long int** variableOffset;           // Offset in file to variable for fseek
134 };
135 
136 #endif
137