1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkPExodusIIReader.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 /*---------------------------------------------------------------------------- 16 Copyright (c) Sandia Corporation 17 See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. 18 ----------------------------------------------------------------------------*/ 19 20 /** 21 * @class vtkPExodusIIReader 22 * @brief Read Exodus II files (.exii) 23 * 24 * vtkPExodusIIReader is a unstructured grid source object that reads 25 * ExodusII files. Most of the meta data associated with the 26 * file is loaded when UpdateInformation is called. This includes 27 * information like Title, number of blocks, number and names of 28 * arrays. This data can be retrieved from methods in this 29 * reader. Separate arrays that are meant to be a single vector, are 30 * combined internally for convenience. To be combined, the array 31 * names have to be identical except for a trailing X,Y and Z (or 32 * x,y,z). By default all cell and point arrays are loaded. However, 33 * the user can flag arrays not to load with the methods 34 * "SetPointDataArrayLoadFlag" and "SetCellDataArrayLoadFlag". The 35 * reader responds to piece requests by loading only a range of the 36 * possible blocks. Unused points are filtered out internally. 37 */ 38 39 #ifndef vtkPExodusIIReader_h 40 #define vtkPExodusIIReader_h 41 42 #include "vtkIOParallelExodusModule.h" // For export macro 43 #include "vtkExodusIIReader.h" 44 45 #include <vector> // Required for vector 46 47 class vtkTimerLog; 48 class vtkMultiProcessController; 49 50 class VTKIOPARALLELEXODUS_EXPORT vtkPExodusIIReader : public vtkExodusIIReader 51 { 52 public: 53 static vtkPExodusIIReader* New(); 54 vtkTypeMacro(vtkPExodusIIReader,vtkExodusIIReader); 55 void PrintSelf( ostream& os, vtkIndent indent ) override; 56 57 //@{ 58 /** 59 * Set/get the communication object used to relay a list of files 60 * from the rank 0 process to all others. This is the only interprocess 61 * communication required by vtkPExodusIIReader. 62 */ 63 void SetController(vtkMultiProcessController* c); 64 vtkGetObjectMacro(Controller, vtkMultiProcessController); 65 //@} 66 67 //@{ 68 /** 69 * These methods tell the reader that the data is distributed across 70 * multiple files. This is for distributed execution. It this case, 71 * pieces are mapped to files. The pattern should have one %d to 72 * format the file number. FileNumberRange is used to generate file 73 * numbers. I was thinking of having an arbitrary list of file 74 * numbers. This may happen in the future. (That is why there is no 75 * GetFileNumberRange method. 76 */ 77 vtkSetStringMacro(FilePattern); 78 vtkGetStringMacro(FilePattern); 79 vtkSetStringMacro(FilePrefix); 80 vtkGetStringMacro(FilePrefix); 81 //@} 82 83 //@{ 84 /** 85 * Set the range of files that are being loaded. The range for single 86 * file should add to 0. 87 */ 88 void SetFileRange( int, int ); SetFileRange(int * r)89 void SetFileRange( int* r ) { this->SetFileRange( r[0], r[1] ); } 90 vtkGetVector2Macro(FileRange,int); 91 //@} 92 93 /** 94 * Provide an arbitrary list of file names instead of a prefix, 95 * pattern and range. Overrides any prefix, pattern and range 96 * that is specified. vtkPExodusIIReader makes it's own copy 97 * of your file names. 98 */ 99 void SetFileNames( int nfiles, const char** names ); 100 101 void SetFileName( const char* name ) override; 102 103 /** 104 * Return pointer to list of file names set in SetFileNames 105 */ GetFileNames()106 char** GetFileNames() { return this->FileNames; } 107 108 /** 109 * Return number of file names set in SetFileNames 110 */ GetNumberOfFileNames()111 int GetNumberOfFileNames() { return this->NumberOfFileNames; } 112 113 //@{ 114 /** 115 * Return the number of files to be read. 116 */ 117 vtkGetMacro(NumberOfFiles,int); 118 //@} 119 120 vtkIdType GetTotalNumberOfElements() override; 121 vtkIdType GetTotalNumberOfNodes() override; 122 123 /** 124 * Sends metadata (that read from the input file, not settings modified 125 * through this API) from the rank 0 node to all other processes in a job. 126 */ 127 virtual void Broadcast( vtkMultiProcessController* ctrl ); 128 129 //@{ 130 /** 131 * The size of the variable cache in MegaByes. This represents the maximum 132 * size of cache that a single partition reader can have while reading. When 133 * a reader is finished its cache size will be set to a fraction of this based 134 * on the number of partitions. 135 * The Default for this is 100MiB. 136 * Note that because each reader still holds 137 * a fraction of the cache size after reading the total amount of data cached 138 * can be at most twice this size. 139 */ 140 vtkGetMacro(VariableCacheSize,double); 141 vtkSetMacro(VariableCacheSize,double); 142 //@} 143 144 protected: 145 vtkPExodusIIReader(); 146 ~vtkPExodusIIReader() override; 147 148 //@{ 149 /** 150 * Try to "guess" the pattern of files. 151 */ 152 int DeterminePattern( const char* file ); 153 static int DetermineFileId( const char* file ); 154 //@} 155 156 //holds the size of the variable cache in GigaBytes 157 double VariableCacheSize; 158 159 // **KEN** Previous discussions concluded with std classes in header 160 // files is bad. Perhaps we should change ReaderList. 161 162 vtkMultiProcessController* Controller; 163 vtkIdType ProcRank; 164 vtkIdType ProcSize; 165 char* FilePattern; 166 char* CurrentFilePattern; 167 char* FilePrefix; 168 char* CurrentFilePrefix; 169 char* MultiFileName; 170 int FileRange[2]; 171 int CurrentFileRange[2]; 172 int NumberOfFiles; 173 char **FileNames; 174 int NumberOfFileNames; 175 176 std::vector<vtkExodusIIReader*> ReaderList; 177 std::vector<int> NumberOfPointsPerFile; 178 std::vector<int> NumberOfCellsPerFile; 179 180 int LastCommonTimeStep; 181 182 int Timing; 183 vtkTimerLog *TimerLog; 184 185 int RequestInformation( vtkInformation*, vtkInformationVector**, vtkInformationVector* ) override; 186 int RequestData( vtkInformation*, vtkInformationVector**, vtkInformationVector* ) override; 187 188 private: 189 vtkPExodusIIReader( const vtkPExodusIIReader& ) = delete; 190 void operator = ( const vtkPExodusIIReader& ) = delete; 191 }; 192 193 #endif 194