1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: $RCSfile: vtkPPhastaReader.h,v $ 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 // .NAME vtkPPhastaReader - parallel Phasta meta-file reader 16 // vtkPPhastaReader reads XML based Phasta meta-files and the underlying 17 // Phasta files. The meta-file has the following form: 18 // @verbatim 19 // <?xml version="1.0" ?> 20 // 21 // <PhastaMetaFile number_of_pieces="2"> 22 // <GeometryFileNamePattern pattern="geombc.dat.%d" 23 // has_piece_entry="1" 24 // has_time_entry="0"/> 25 // <FieldFileNamePattern pattern="restart.%d.%d" 26 // has_piece_entry="1" 27 // has_time_entry="1"/> 28 // 29 // <TimeSteps number_of_steps="2" 30 // auto_generate_indices="1" 31 // start_index="0" 32 // increment_index_by="20" 33 // start_value="0." 34 // increment_value_by="20."> 35 // <TimeStep index="0" geometry_index="" field_index="0" value="0.0"/> 36 // <TimeStep index="1" geometry_index="" field_index="20" value="20.0"/> 37 // </TimeSteps> 38 // <Fields number_of_fields="2"> 39 // <Field paraview_field_tag="velocity" 40 // phasta_field_tag="solution" 41 // start_index_in_phasta_array="1" 42 // number_of_componenets="3" 43 // datadependency="0" 44 // data_type="double"/> 45 // <Field paraview_field_tag="average speed" 46 // phasta_field_tag="ybar" 47 // start_index_in_phasta_array="4" 48 // number_of_componenets="1"/> 49 // </Fields> 50 //</PhastaMetaFile> 51 // @endverbatim 52 // The GeometryFileNamePattern and FieldFileNamePattern elements have 53 // three attributes: 54 // @verbatim 55 // 1. pattern: This is the pattern used to get the Phasta filenames. 56 // The %d placeholders will be replaced by appropriate 57 // indices. The first index is time (if specified), the 58 // second one is piece. 59 // 2. has_piece_entry (0 or 1): Specifies whether the pattern has a 60 // piece placeholder. The piece placeholder is replaced by the 61 // update piece number. 62 // 3. has_time_entry (0 or 1): Specified whether the pattern has a 63 // time placeholder. The time placeholder is replaced by an index 64 // specified in the TimeSteps element 65 // 66 // The TimeSteps element contains TimeStep sub-elements. Each TimeStep 67 // element specifies an index (index attribute), an index used in the 68 // geometry filename pattern (geometry_index), an index used in the 69 // field filename pattern (field_index) and a time value (float). 70 // In the example above, there are two timesteps. The first one is 71 // stored in files named geombc.dat.(0,1), restart.(0,20).(0,1). 72 // The time placeholders are substituted with the the geometry_index 73 // and field_index attribute values. 74 // 75 // Normally there is one TimeStep element per timestep. However, it 76 // is possible to ask the reader to automatically generate timestep 77 // entries. This is done with setting the (optional) auto_generate_indices 78 // to 1. In this case, the reader will generate number_of_steps entries. 79 // The geometry_index and field_index of these entries will start at 80 // start_index and will be incremented by increment_index_by. 81 // The time value of these entries will start at start_value and 82 // will be incremented by increment_value_by. 83 // Note that it is possible to use a combination of both approaches. 84 // Any values specified with the TimeStep elements will overwrite anything 85 // automatically computed. A common use of this is to let the reader 86 // compute all indices for field files and overwrite the geometry indices 87 // with TimeStep elements. 88 // 89 // The Fields element contain number_of_fields Field sub-element. 90 // Each Field element specifies tag attribute to be used in paraview, 91 // tag under which the field is stored in phasta files, start index of 92 // the array in phasta files, number of components of the field, data 93 // dependency, i.e., either 0 for nodal or 1 for elemental and 94 // data type, i.e., "double" (as of now supports only 1, 3 & 9 for number 95 // of components, i.e., scalars, vectors & tensors, and "double" for 96 // type of data). 97 // In the example above, there are two fields to be visualized 98 // one is velocity field stored under tag solution from index 1 to 3 99 // in phasta files which is a vector field defined on nodes with 100 // double values, and the other field is average speed scalar field 101 // stored under tag ybar at index 4 in phasta files 102 // If any Field element is specified then default attribute values are : 103 // (phasta_field_tag is mandatory) 104 // paraview_field_tag = Field <number> 105 // start_index_in_phasta_array = 0 106 // number_of_components = 1 107 // data_dependency = 0 108 // data_type = double 109 // If no Field(s) is/are specfied then the default is following 3 fields : 110 // pressure (index 0 under solution), 111 // velocity (index 1-3 under solution) 112 // temperature (index 4 under soltuion) 113 // 114 // .SECTION See Also 115 // vtkPhastaReader 116 117 ///////////// 118 #ifndef PHASTA_NEW_IO 119 #define PHASTA_NEW_IO 120 extern int NUM_PIECES; 121 extern int NUM_FILES; 122 extern int TIME_STEP; 123 extern char * FILE_PATH; 124 extern int PART_ID; 125 extern int FILE_ID; 126 extern double opentime_total; 127 #endif 128 //////////// 129 130 #ifndef __vtkPPhastaReader_h 131 #define __vtkPPhastaReader_h 132 133 #include "vtkMultiBlockDataSetAlgorithm.h" 134 135 class vtkPVXMLParser; 136 class vtkPhastaReader; 137 138 139 //BTX 140 struct vtkPPhastaReaderInternal; 141 //ETX 142 143 class VTK_EXPORT vtkPPhastaReader : public vtkMultiBlockDataSetAlgorithm 144 { 145 public: 146 static vtkPPhastaReader* New(); 147 vtkTypeRevisionMacro(vtkPPhastaReader, vtkMultiBlockDataSetAlgorithm); 148 void PrintSelf(ostream& os, vtkIndent indent); 149 150 // Description: 151 // Set and get the Phasta meta file name 152 vtkSetStringMacro(FileName); 153 vtkGetStringMacro(FileName); 154 155 // Description: 156 // Set the step number for the geometry. 157 vtkSetClampMacro(TimeStepIndex, int, 0, VTK_LARGE_INTEGER); 158 vtkGetMacro(TimeStepIndex, int); 159 160 // Description: 161 // The min and max values of timesteps. 162 vtkGetVector2Macro(TimeStepRange, int); 163 164 static int CanReadFile(const char *filename); 165 166 167 protected: 168 vtkPPhastaReader(); 169 ~vtkPPhastaReader(); 170 171 virtual int RequestInformation(vtkInformation* request, 172 vtkInformationVector** inputVector, 173 vtkInformationVector* outputVector); 174 virtual int RequestData(vtkInformation* request, 175 vtkInformationVector** inputVector, 176 vtkInformationVector* outputVector); 177 178 char* FileName; 179 180 int TimeStepIndex; 181 182 // Descriptions: 183 // Store the range of time steps 184 int TimeStepRange[2]; 185 186 vtkPhastaReader* Reader; 187 vtkPVXMLParser* Parser; 188 189 int ActualTimeStep; 190 191 private: 192 vtkPPhastaReaderInternal* Internal; 193 194 vtkPPhastaReader(const vtkPPhastaReader&); // Not implemented. 195 void operator=(const vtkPPhastaReader&); // Not implemented. 196 }; 197 198 #endif 199 200