00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00036 #ifndef __vtkExodusReader_h
00037 #define __vtkExodusReader_h
00038
00039 #define ARRAY_TYPE_NAMES_IN_CXX_FILE
00040
00041 #include "vtkUnstructuredGridAlgorithm.h"
00042
00043 class vtkIntArray;
00044 class vtkFloatArray;
00045 class vtkDataArray;
00046 class vtkDataSet;
00047 class vtkPoints;
00048 class vtkExodusMetadata;
00049 class vtkExodusModel;
00050 class vtkExodusXMLParser;
00051
00052
00053 #include "vtkDSPFilterGroup.h"
00054
00055
00056 class VTK_HYBRID_EXPORT vtkExodusReader : public vtkUnstructuredGridAlgorithm
00057 {
00058 public:
00059 static vtkExodusReader *New();
00060 vtkTypeRevisionMacro(vtkExodusReader,vtkUnstructuredGridAlgorithm);
00061 void PrintSelf(ostream& os, vtkIndent indent);
00062
00064
00065 vtkSetStringMacro(FileName);
00066 vtkGetStringMacro(FileName);
00068
00070
00071 void SetXMLFileName(const char *filename);
00072 vtkGetStringMacro(XMLFileName);
00074
00076
00077 vtkSetMacro(TimeStep, int);
00078 vtkGetMacro(TimeStep, int);
00080
00082
00085 vtkSetMacro(GenerateBlockIdCellArray, int);
00086 vtkGetMacro(GenerateBlockIdCellArray, int);
00087 vtkBooleanMacro(GenerateBlockIdCellArray, int);
00088 const char *GetBlockIdArrayName() { return "BlockId"; }
00090
00091
00093
00096 vtkSetMacro(GenerateGlobalElementIdArray, int);
00097 vtkGetMacro(GenerateGlobalElementIdArray, int);
00098 vtkBooleanMacro(GenerateGlobalElementIdArray, int);
00100
00101 enum {
00102 SEARCH_TYPE_ELEMENT=0,
00103 SEARCH_TYPE_NODE,
00104 SEARCH_TYPE_ELEMENT_THEN_NODE,
00105 SEARCH_TYPE_NODE_THEN_ELEMENT,
00106 ID_NOT_FOUND=-234121312
00107 };
00108
00109 static const char *GetGlobalElementIdArrayName() { return "GlobalElementId"; }
00110 static int GetGlobalElementID( vtkDataSet *data, int localID );
00111 static int GetGlobalElementID ( vtkDataSet *data, int localID,
00112 int searchType );
00113
00115
00119 vtkSetMacro(GenerateGlobalNodeIdArray, int);
00120 vtkGetMacro(GenerateGlobalNodeIdArray, int);
00121 vtkBooleanMacro(GenerateGlobalNodeIdArray, int);
00122 static const char *GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }
00123 static int GetGlobalNodeID( vtkDataSet *data, int localID );
00124 static int GetGlobalNodeID( vtkDataSet *data, int localID,
00125 int searchType );
00127
00129
00133 vtkSetMacro(ApplyDisplacements, int);
00134 vtkGetMacro(ApplyDisplacements, int);
00135 vtkBooleanMacro(ApplyDisplacements, int);
00136 vtkSetMacro(DisplacementMagnitude, float);
00137 vtkGetMacro(DisplacementMagnitude, float);
00139
00141
00142 vtkGetStringMacro(Title);
00143 vtkGetMacro(Dimensionality, int);
00144 vtkGetMacro(NumberOfTimeSteps, int);
00145 int GetNumberOfElements() { return this->NumberOfUsedElements; }
00146 vtkGetMacro(NumberOfNodeSets, int);
00147 vtkGetMacro(NumberOfSideSets, int);
00148 vtkGetMacro(NumberOfBlocks, int);
00149 vtkGetVector2Macro(TimeStepRange, int);
00150 vtkSetVector2Macro(TimeStepRange, int);
00151 int GetNumberOfNodes() { return this->NumberOfUsedNodes; }
00152 int GetNumberOfElementsInBlock(int block_idx);
00153 int GetBlockId(int block_idx);
00155
00156
00158
00163 int GetNumberOfPointArrays();
00164 const char *GetPointArrayName(int index);
00165 int GetPointArrayID( const char *name );
00166 int GetPointArrayNumberOfComponents(int index);
00167 void SetPointArrayStatus(int index, int flag);
00168 void SetPointArrayStatus(const char*, int flag);
00169 int GetPointArrayStatus(int index);
00170 int GetPointArrayStatus(const char*);
00172
00173 int GetNumberOfCellArrays();
00174 const char *GetCellArrayName(int index);
00175 int GetCellArrayID( const char *name );
00176 int GetCellArrayNumberOfComponents(int index);
00177 void SetCellArrayStatus(int index, int flag);
00178 void SetCellArrayStatus(const char*, int flag);
00179 int GetCellArrayStatus(int index);
00180 int GetCellArrayStatus(const char*);
00181
00183
00187 int GetNumberOfBlockArrays();
00188 const char *GetBlockArrayName(int index);
00189 int GetBlockArrayID( const char *name );
00190 void SetBlockArrayStatus(int index, int flag);
00191 void SetBlockArrayStatus(const char*, int flag);
00192 int GetBlockArrayStatus(int index);
00193 int GetBlockArrayStatus(const char*);
00195
00196
00198
00205 int GetNumberOfNodeSetArrays(){return this->GetNumberOfNodeSets();}
00206 int GetNodeSetArrayStatus(int index);
00207 int GetNodeSetArrayStatus(const char* name);
00208 void SetNodeSetArrayStatus(int index, int flag);
00209 void SetNodeSetArrayStatus(const char* name, int flag);
00210 const char *GetNodeSetArrayName(int index);
00212
00213 int GetNumberOfSideSetArrays(){return this->GetNumberOfSideSets();}
00214 int GetSideSetArrayStatus(int index);
00215 int GetSideSetArrayStatus(const char* name);
00216 void SetSideSetArrayStatus(int index, int flag);
00217 void SetSideSetArrayStatus(const char* name, int flag);
00218 const char *GetSideSetArrayName(int index);
00219
00221
00225 int GetNumberOfPartArrays();
00226 const char *GetPartArrayName(int arrayIdx);
00227 int GetPartArrayID( const char *name );
00228 const char *GetPartBlockInfo(int arrayIdx);
00229 void SetPartArrayStatus(int index, int flag);
00230 void SetPartArrayStatus(const char*, int flag);
00231 int GetPartArrayStatus(int index);
00232 int GetPartArrayStatus(const char*);
00234
00235
00237
00241 int GetNumberOfMaterialArrays();
00242 const char *GetMaterialArrayName(int arrayIdx);
00243 int GetMaterialArrayID( const char *name );
00244 void SetMaterialArrayStatus(int index, int flag);
00245 void SetMaterialArrayStatus(const char*, int flag);
00246 int GetMaterialArrayStatus(int index);
00247 int GetMaterialArrayStatus(const char*);
00249
00251
00255 int GetNumberOfAssemblyArrays();
00256 const char *GetAssemblyArrayName(int arrayIdx);
00257 int GetAssemblyArrayID( const char *name );
00258 void SetAssemblyArrayStatus(int index, int flag);
00259 void SetAssemblyArrayStatus(const char*, int flag);
00260 int GetAssemblyArrayStatus(int index);
00261 int GetAssemblyArrayStatus(const char*);
00263
00265
00272 int GetNumberOfHierarchyArrays();
00273 const char *GetHierarchyArrayName(int arrayIdx);
00274 void SetHierarchyArrayStatus(int index, int flag);
00275 void SetHierarchyArrayStatus(const char*, int flag);
00276 int GetHierarchyArrayStatus(int index);
00277 int GetHierarchyArrayStatus(const char*);
00279
00280 vtkGetMacro(DisplayType,int);
00281 virtual void SetDisplayType(int type);
00282
00288 vtkBooleanMacro(ExodusModelMetadata, int);
00289 vtkSetMacro(ExodusModelMetadata, int);
00290 vtkGetMacro(ExodusModelMetadata, int);
00291
00294 vtkExodusModel *GetExodusModel(){return this->ExodusModel;}
00295
00303 vtkSetMacro(PackExodusModelOntoOutput, int);
00304 vtkGetMacro(PackExodusModelOntoOutput, int);
00305 vtkBooleanMacro(PackExodusModelOntoOutput, int);
00306
00307
00309
00310 enum ArrayType {
00311 CELL=0,
00312 POINT,
00313 BLOCK,
00314 PART,
00315 MATERIAL,
00316 ASSEMBLY,
00317 HIERARCHY,
00318 NUM_ARRAY_TYPES,
00319 UNKNOWN_TYPE
00320 };
00322
00323
00325 int IsValidVariable( const char *type, const char *name );
00326
00327
00329
00330 int GetNumberOfArrays( vtkExodusReader::ArrayType type );
00331 const char *GetArrayName( vtkExodusReader::ArrayType type, int id );
00333
00334
00336 int GetVariableID ( const char *type, const char *name );
00337
00338 void SetAllAssemblyArrayStatus( int status );
00339 void SetAllBlockArrayStatus( int status );
00340 void SetAllCellArrayStatus( int status );
00341 void SetAllHierarchyArrayStatus( int status );
00342 void SetAllMaterialArrayStatus( int status );
00343 void SetAllPartArrayStatus( int status );
00344 void SetAllPointArrayStatus( int status );
00345
00346 void SetAllArrayStatus ( vtkExodusReader::ArrayType type, int flag );
00347 void SetArrayStatus ( vtkExodusReader::ArrayType type, const char *name,
00348 int flag );
00349
00350 void SetArrayStatus ( const char *type, const char *name, int flag )
00351 {
00352 this->SetArrayStatus( this->GetArrayTypeID(type), name, flag );
00353 }
00354
00355 int GetArrayStatus ( vtkExodusReader::ArrayType type, const char *name );
00356
00357 int GetArrayStatus ( const char *type, const char *name )
00358 {
00359 return this->GetArrayStatus( this->GetArrayTypeID( type ), name );
00360 }
00361
00362
00363 static int StringsEqual(const char* s1, char* s2);
00364 static void StringUppercase(const char* str, char* upperstr);
00365 static char *StrDupWithNew(const char *s);
00366
00367
00368 int GetTimeSeriesData( int ID, const char *vName, const char *vType,
00369 vtkFloatArray *result );
00370
00371
00372
00373 int GetNumberOfVariableArrays();
00374 const char *GetVariableArrayName(int a_which);
00375 void EnableDSPFiltering();
00376 void AddFilter(vtkDSPFilterDefinition *a_filter);
00377 void StartAddingFilter();
00378 void AddFilterInputVar(char *name);
00379 void AddFilterOutputVar(char *name);
00380 void AddFilterNumeratorWeight(double weight);
00381 void AddFilterForwardNumeratorWeight(double weight);
00382 void AddFilterDenominatorWeight(double weight);
00383 void FinishAddingFilter();
00384 void RemoveFilter(char *a_outputVariableName);
00385 void GetDSPOutputArrays(int exoid, vtkUnstructuredGrid* output);
00386
00387 vtkExodusReader::ArrayType GetArrayTypeID( const char *type );
00388
00389 #ifdef ARRAY_TYPE_NAMES_IN_CXX_FILE
00390 static const char *GetArrayTypeName( vtkExodusReader::ArrayType type );
00391 #else
00392 static const char *ArrayTypeNames[NUM_ARRAY_TYPES];
00393
00394 static const char *GetArrayTypeName( vtkExodusReader::ArrayType type )
00395 {
00396 return ArrayTypeNames[type];
00397 }
00398 #endif
00399
00400
00401 vtkDSPFilterDefinition *AddingFilter;
00402 int DSPFilteringIsEnabled;
00403 vtkDSPFilterGroup **DSPFilters;
00404
00405
00406
00407
00408 protected:
00409 vtkExodusReader();
00410 ~vtkExodusReader();
00411
00412 void NewExodusModel();
00413
00414 void ReadGeometry(int exoid, vtkUnstructuredGrid* output);
00415 void ReadCells(int exoid, vtkUnstructuredGrid* output);
00416 void ReadPoints(int exoid, vtkUnstructuredGrid* output);
00417 void ReadArrays(int exoid, vtkUnstructuredGrid* output);
00418 void ReadNodeAndSideSets(int exoid, vtkUnstructuredGrid* output);
00419 vtkDataArray *ReadPointArray(int exoid, int varIndex);
00420 vtkDataArray *ReadPointVector(int handle, int varIndex, int dim);
00421 vtkDataArray *ReadCellArray(int exoid, int varIndex);
00422 vtkDataArray *ReadCellVector(int handle, int varIndex, int dim);
00423 void ReadNodeSetMetadata();
00424 void ReadSideSetMetadata();
00425
00426
00427 static int GetIDHelper ( const char *arrayName, vtkDataSet *data, int localID,
00428 int searchType );
00429 static int GetGlobalID( const char *arrayName, vtkDataSet *data, int localID,
00430 int searchType );
00431
00432
00433
00434
00435
00436 int GetExtraCellCountForNodeSideSets();
00437
00438
00439
00440 void GenerateExtraArrays(vtkUnstructuredGrid* output);
00441
00442
00443 char *FileName;
00444 char *XMLFileName;
00445 int TimeStep;
00446 int ActualTimeStep;
00447 int GenerateBlockIdCellArray;
00448 int GenerateGlobalElementIdArray;
00449 int GenerateGlobalNodeIdArray;
00450 int ApplyDisplacements;
00451 double DisplacementMagnitude;
00452
00453
00454 vtkSetStringMacro(Title);
00455 char *Title;
00456 int Dimensionality;
00457 int NumberOfNodeSets;
00458 int NumberOfSideSets;
00459 int NumberOfBlocks;
00460 int NumberOfUsedNodes;
00461 int NumberOfNodesInFile;
00462 int NumberOfUsedElements;
00463 int NumberOfElementsInFile;
00464 int NumberOfTimeSteps;
00465 int ExodusCPUWordSize;
00466 int ExodusIOWordSize;
00467 float ExodusVersion;
00468 vtkIntArray *CellVarTruthTable;
00469
00470
00471
00472
00473 int DisplayType;
00474
00475
00476 vtkExodusXMLParser *Parser;
00477
00478
00479
00481
00483 vtkExodusMetadata *MetaData;
00484
00485
00487
00488 int CurrentHandle;
00489 char* CurrentFileName;
00490 char* CurrentXMLFileName;
00491 vtkSetStringMacro(CurrentFileName);
00492 vtkSetStringMacro(CurrentXMLFileName);
00494
00495
00496 int OpenCurrentFile();
00497
00498
00499 void CloseCurrentFile();
00500
00501
00503 int TimeStepRange[2];
00504
00505
00506
00507
00508 vtkUnstructuredGrid *DataCache;
00509
00510
00511 int RemakeDataCacheFlag;
00512
00513
00514
00515
00516 int NewGeometryCount;
00517
00518
00519
00520 vtkIntArray *PointMap;
00521 vtkIntArray *ReversePointMap;
00522 void SetUpPointMap(int num_points);
00523 int GetPointMapIndex(int point_id);
00524
00525
00526 int *GlobalElementIdCache;
00527 void SetGlobalElementIdCache(int *list);
00528
00529
00530
00531 void GetAllTimes(vtkInformationVector *);
00532
00533 vtkExodusModel *ExodusModel;
00534 int PackExodusModelOntoOutput;
00535 int ExodusModelMetadata;
00536
00537 int RequestInformation(
00538 vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00539 int RequestData(
00540 vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00541
00542 private:
00543 vtkExodusReader(const vtkExodusReader&);
00544 void operator=(const vtkExodusReader&);
00545
00546 void AddDisplacements(vtkUnstructuredGrid* output);
00547 void RemoveBeginningAndTrailingSpaces(char **names, int len);
00548
00549 void FixMetadataTruthTable(int *table, int len);
00550 };
00551
00552 #endif