Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkExodusReader.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkExodusReader.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*----------------------------------------------------------------------------
00016  Copyright (c) Sandia Corporation
00017  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
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" //for USE_EXO_DSP_FILTERS
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 //BTX
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 //ETX
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 //BTX
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 //ETX
00323 
00325   int IsValidVariable( const char *type, const char *name );
00326 
00327 //BTX
00329 
00330   int GetNumberOfArrays( vtkExodusReader::ArrayType type );
00331   const char *GetArrayName( vtkExodusReader::ArrayType type, int id );
00333 //ETX
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 //BTX
00346   void SetAllArrayStatus ( vtkExodusReader::ArrayType type, int flag );
00347   void SetArrayStatus ( vtkExodusReader::ArrayType type, const char *name, 
00348       int flag );
00349 //ETX
00350   void SetArrayStatus ( const char *type, const char *name, int flag )
00351     {
00352     this->SetArrayStatus( this->GetArrayTypeID(type), name, flag );
00353     }
00354 //BTX
00355   int  GetArrayStatus ( vtkExodusReader::ArrayType type, const char *name );
00356 //ETX
00357   int  GetArrayStatus ( const char *type, const char *name )
00358     {
00359     return this->GetArrayStatus( this->GetArrayTypeID( type ), name );
00360     }
00361 
00362   // Helper functions
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   // time series query functions
00368   int GetTimeSeriesData( int ID, const char *vName, const char *vType, 
00369                          vtkFloatArray *result );
00370   
00371 
00372   //begin USE_EXO_DSP_FILTERS
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 //BTX
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 //ETX
00400 
00401   vtkDSPFilterDefinition *AddingFilter;
00402   int DSPFilteringIsEnabled;
00403   vtkDSPFilterGroup **DSPFilters;
00404   //end USE_EXO_DSP_FILTERS
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   // helper for finding IDs
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   // This method is a helper for determining the
00434   // number of additional cell scalar field
00435   // values needed to 'pad' for node and side sets
00436   int GetExtraCellCountForNodeSideSets();
00437   
00438   // This method generates arrays like blockid, global nodeid
00439   // and global element id
00440   void GenerateExtraArrays(vtkUnstructuredGrid* output);
00441 
00442   // Parameters for controlling what is read in.
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   // Information specific for exodus files.
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   //1=display Block names
00471   //2=display Part names
00472   //3=display Material names
00473   int DisplayType;
00474   
00475   //Parser that understands the xml part and material file
00476   vtkExodusXMLParser *Parser;
00477 
00478   // **KEN** By VTK convention, metaData should be Metadata.
00479  
00481   // Scalar Array and Block Info
00483   vtkExodusMetadata *MetaData;
00484   
00485  
00487 
00488   int CurrentHandle;
00489   char* CurrentFileName;
00490   char* CurrentXMLFileName;
00491   vtkSetStringMacro(CurrentFileName);
00492   vtkSetStringMacro(CurrentXMLFileName);
00494 
00495   // Open the exodus file, and set some basic information
00496   int OpenCurrentFile();
00497 
00498   // Close the exodus file
00499   void CloseCurrentFile();
00500 
00501   
00503   int TimeStepRange[2];
00504 
00505   // DataCache: this object keeps the points and cells
00506   // around so they don't need to be re-read when the
00507   // timestep changes or an scalar array is switched
00508   vtkUnstructuredGrid *DataCache;
00509 
00510   // Should I re-read in the geometry and topology of the dataset
00511   int RemakeDataCacheFlag;
00512 
00513   // vtkExodusModel needs to count changes in geometry, so it knows
00514   //   if geometry has changed since it last updated model data.
00515 
00516   int NewGeometryCount;
00517 
00518   // PointMap keeps track of which points are actually
00519   // used by the cells that are read in (blocks)
00520   vtkIntArray *PointMap;
00521   vtkIntArray *ReversePointMap;
00522   void SetUpPointMap(int num_points);
00523   int GetPointMapIndex(int point_id);
00524 
00525   // Global element ID cache
00526   int *GlobalElementIdCache;
00527   void SetGlobalElementIdCache(int *list);
00528 
00529   // Time query function. Called by ExecuteInformation().
00530   // Fills the TimestepValues array.
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&); // Not implemented
00544   void operator=(const vtkExodusReader&); // Not implemented
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

Generated on Mon Jan 21 23:07:27 2008 for VTK by  doxygen 1.4.3-20050530