VTK
dox/Hybrid/vtkExodusIIReaderPrivate.h
Go to the documentation of this file.
00001 #ifndef __vtkExodusIIReaderPrivate_h
00002 #define __vtkExodusIIReaderPrivate_h
00003 
00004 // Do not include this file directly. It is only for use
00005 // from inside the ExodusII reader and its descendants.
00006 
00007 #include "vtkToolkits.h" // make sure VTK_USE_PARALLEL is properly set
00008 #include "vtkExodusIICache.h"
00009 #ifdef VTK_USE_PARALLEL
00010 #  include "vtkMultiProcessController.h"
00011 #else // VTK_USE_PARALLEL
00012 class vtkMultiProcessController;
00013 #endif // VTK_USE_PARALLEL
00014 
00015 #include "vtksys/RegularExpression.hxx"
00016 
00017 #include <map>
00018 #include <vector>
00019 
00020 #include "vtk_exodusII.h"
00021 
00022 class vtkExodusIIReaderParser;
00023 class vtkMutableDirectedGraph;
00024 
00028 class vtkExodusIIReaderPrivate : public vtkObject
00029 {
00030 public:
00031   static vtkExodusIIReaderPrivate* New();
00032   void PrintData( ostream& os, vtkIndent indent );
00033   vtkTypeMacro(vtkExodusIIReaderPrivate,vtkObject);
00034   //virtual void Modified();
00035 
00037   int OpenFile( const char* filename );
00038 
00040   int CloseFile();
00041 
00043   int RequestInformation();
00044 
00046   vtkMutableDirectedGraph* GetSIL()
00047     { return this->SIL; }
00048 
00050   void Broadcast( vtkMultiProcessController* controller );
00051 
00053   void Receive( vtkMultiProcessController* controller );
00054 
00056   int RequestData( vtkIdType timeStep, vtkMultiBlockDataSet* output );
00057 
00062   int SetUpEmptyGrid( vtkMultiBlockDataSet* output );
00063 
00075   void Reset();
00076 
00081   void ResetSettings();
00082 
00084   void ResetCache();
00085 
00087   void SetCacheSize(double size);  
00088 
00090   vtkGetMacro(CacheSize, double);
00091 
00096   int GetNumberOfTimeSteps() { return (int) this->Times.size(); }
00097 
00099   vtkGetMacro(TimeStep,int);
00100 
00102   vtkSetMacro(TimeStep,int);
00103 
00106   vtkGetMacro(SqueezePoints,int);
00107 
00110   void SetSqueezePoints( int sp );
00111 
00114   vtkBooleanMacro(SqueezePoints,int);
00115 
00117   int GetNumberOfNodes();
00118 
00123   int GetNumberOfObjectsOfType( int otype );
00124 
00135   int GetNumberOfObjectArraysOfType( int otype );
00136 
00141   const char* GetObjectName( int otype, int i );
00142 
00147   int GetObjectId( int otype, int i );
00148 
00155   int GetObjectSize( int otype, int i );
00156 
00161   int GetObjectStatus( int otype, int i );
00162 
00168   int GetUnsortedObjectStatus( int otype, int i );
00169 
00174   void SetObjectStatus( int otype, int i, int stat );
00175 
00181   void SetUnsortedObjectStatus( int otype, int i, int stat );
00182 
00187   const char* GetObjectArrayName( int otype, int i );
00188 
00193   int GetNumberOfObjectArrayComponents( int otype, int i );
00194 
00199   int GetObjectArrayStatus( int otype, int i );
00200 
00205   void SetObjectArrayStatus( int otype, int i, int stat );
00206 
00213   int GetNumberOfObjectAttributes( int objectType, int objectIndex );
00214   const char* GetObjectAttributeName( int objectType, 
00215                                       int objectIndex, 
00216                                       int attributeIndex );
00217   int GetObjectAttributeIndex( int objectType, 
00218                                int objectIndex, 
00219                                const char* attribName );
00220   int GetObjectAttributeStatus( int objectType, 
00221                                 int objectIndex, 
00222                                 int attribIndex );
00223   void SetObjectAttributeStatus( int objectType, 
00224                                  int objectIndex, 
00225                                  int attribIndex, int status );
00226 
00228   vtkGetMacro(GenerateObjectIdArray,int);
00229   vtkSetMacro(GenerateObjectIdArray,int);
00230   static const char* GetObjectIdArrayName() { return "ObjectId"; }
00231 
00232   vtkSetMacro(GenerateGlobalElementIdArray,int);
00233   vtkGetMacro(GenerateGlobalElementIdArray,int);
00234   static const char* GetGlobalElementIdArrayName() { return "GlobalElementId"; }  
00235 
00236   vtkSetMacro(GenerateGlobalNodeIdArray,int);
00237   vtkGetMacro(GenerateGlobalNodeIdArray,int);
00238   static const char* GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }  
00239 
00240   vtkSetMacro(GenerateImplicitElementIdArray,int);
00241   vtkGetMacro(GenerateImplicitElementIdArray,int);
00242   static const char* GetImplicitElementIdArrayName() { return "ImplicitElementId"; }  
00243 
00244   vtkSetMacro(GenerateImplicitNodeIdArray,int);
00245   vtkGetMacro(GenerateImplicitNodeIdArray,int);
00246   static const char* GetImplicitNodeIdArrayName() { return "ImplicitNodeId"; }  
00247 
00251   vtkSetMacro(GenerateFileIdArray,int);
00252   vtkGetMacro(GenerateFileIdArray,int);
00253   static const char* GetFileIdArrayName() { return "FileId"; }  
00254 
00256   vtkSetMacro(FileId,int);
00257   vtkGetMacro(FileId,int);
00258 
00259   static const char *GetGlobalVariableValuesArrayName() 
00260     { return "GlobalVariableValues"; }  
00261   static const char *GetGlobalVariableNamesArrayName() 
00262     { return "GlobalVariableNames"; }  
00263 
00264   virtual void SetApplyDisplacements( int d );
00265   vtkGetMacro(ApplyDisplacements,int);
00266 
00267   virtual void SetDisplacementMagnitude( double s );
00268   vtkGetMacro(DisplacementMagnitude,double);
00269 
00270   vtkSetMacro(HasModeShapes,int);
00271   vtkGetMacro(HasModeShapes,int);
00272 
00273   vtkSetMacro(ModeShapeTime,double);
00274   vtkGetMacro(ModeShapeTime,double);
00275 
00276   vtkSetMacro(AnimateModeShapes, int);
00277   vtkGetMacro(AnimateModeShapes, int);
00278 
00279   vtkDataArray* FindDisplacementVectors( int timeStep );
00280 
00281   const struct ex_init_params* GetModelParams() const 
00282     { return &this->ModelParameters; }
00283 
00285   struct ArrayInfoType {
00287     vtkStdString Name;
00289     int Components;
00296     int GlomType;
00299     int StorageType;
00301     int Source;
00303     int Status;
00306     std::vector<vtkStdString> OriginalNames;
00309     std::vector<int> OriginalIndices;
00318     std::vector<int> ObjectTruth;
00320     void Reset();
00321   };
00322 
00324   struct ObjectInfoType {
00326     int Size;
00328     int Status;
00330     int Id;
00332     vtkStdString Name;
00333   };
00334 
00336   struct MapInfoType : public ObjectInfoType {
00337   };
00338 
00341   struct BlockSetInfoType : public ObjectInfoType {
00343     vtkIdType FileOffset;
00348     std::map<vtkIdType,vtkIdType> PointMap;
00353     std::map<vtkIdType,vtkIdType> ReversePointMap;
00357     vtkIdType NextSqueezePoint;
00359     vtkUnstructuredGrid* CachedConnectivity;
00360 
00361     BlockSetInfoType(){this->CachedConnectivity=0;}
00362     BlockSetInfoType(const BlockSetInfoType& block);
00363     ~BlockSetInfoType();
00364   };
00365 
00367   struct BlockInfoType : public BlockSetInfoType {
00368     vtkStdString OriginalName; // useful to reset the name if XML metadata is invalid.
00369     vtkStdString TypeName;
00370     // number of boundaries per entry
00371     // The index is the dimensionality of the entry. 0=node, 1=edge, 2=face
00372     int BdsPerEntry[3]; 
00373     int AttributesPerEntry;
00374     std::vector<vtkStdString> AttributeNames;
00375     std::vector<int> AttributeStatus;
00376     // VTK cell type (a function of TypeName and BdsPerEntry...)
00377     int CellType; 
00378     // Number of points per cell as used by VTK 
00379     // -- not what's in the file (i.e., BdsPerEntry[0] >= PointsPerCell)
00380     int PointsPerCell;
00381   };
00382 
00384   struct PartInfoType : public ObjectInfoType {
00385     std::vector<int> BlockIndices;
00386   };
00387   struct AssemblyInfoType : public ObjectInfoType {
00388     std::vector<int> BlockIndices;
00389   };
00390   struct MaterialInfoType : public ObjectInfoType {
00391     std::vector<int> BlockIndices;
00392   };
00393 
00395   struct SetInfoType : public BlockSetInfoType {
00396     int DistFact;     // Number of distribution factors 
00397                       // (for the entire block, not per array or entry)
00398   };
00399 
00402   enum GlomTypes {
00403     Scalar=0,          
00404     Vector2=1,         
00405     Vector3=2,         
00406     SymmetricTensor=3, 
00407                        //   (order xx, yy, zz, xy, yz, zx)
00408     IntegrationPoint=4 
00409   };
00410 
00412   enum ArraySourceTypes {
00413     Result=0,        
00414                      //   (that vary over time)
00415     Attribute=1,     
00416                      //   (constants over time)
00417     Map=2,           
00418     Generated=3      
00419   };
00420 
00422   vtkTimeStamp InformationTimeStamp;
00423  
00424   friend class vtkExodusIIReader;
00425   friend class vtkPExodusIIReader;
00426 
00427   virtual void SetParser( vtkExodusIIReaderParser* );
00428   vtkGetObjectMacro(Parser,vtkExodusIIReaderParser);
00429 
00430   // Because Parts, Materials, and assemblies are not stored as arrays,
00431   // but rather as maps to the element blocks they make up,  
00432   // we cannot use the Get|SetObject__() methods directly.
00433 
00434   int GetNumberOfParts();
00435   const char* GetPartName(int idx);
00436   const char* GetPartBlockInfo(int idx);
00437   int GetPartStatus(int idx);
00438   int GetPartStatus(vtkStdString name);
00439   void SetPartStatus(int idx, int on);
00440   void SetPartStatus(vtkStdString name, int flag);
00441     
00442   int GetNumberOfMaterials();
00443   const char* GetMaterialName(int idx);
00444   int GetMaterialStatus(int idx);
00445   int GetMaterialStatus(vtkStdString name);
00446   void SetMaterialStatus(int idx, int on);
00447   void SetMaterialStatus(vtkStdString name, int flag);
00448 
00449   int GetNumberOfAssemblies();
00450   const char* GetAssemblyName(int idx);
00451   int GetAssemblyStatus(int idx);
00452   int GetAssemblyStatus(vtkStdString name);
00453   void SetAssemblyStatus(int idx, int on);
00454   void SetAssemblyStatus(vtkStdString name, int flag);
00455 
00456   void SetFastPathObjectType(vtkExodusIIReader::ObjectType type)
00457     {this->FastPathObjectType = type;};
00458   void SetFastPathObjectId(vtkIdType id){this->FastPathObjectId = id;};
00459   vtkSetStringMacro(FastPathIdType);
00460 
00461   bool IsXMLMetadataValid();
00462 
00470   void GetInitialObjectStatus( int otype, ObjectInfoType *info );
00471 
00479   void GetInitialObjectArrayStatus( int otype, ArrayInfoType *info );
00480 
00487   void SetInitialObjectStatus( int otype, const char *name, int stat );
00488 
00494   void SetInitialObjectArrayStatus( int otype, const char *name, int stat );
00495 
00496   int UpdateTimeInformation();
00497 
00498   bool ProducedFastPathOutput;
00499 
00500 protected:
00501   vtkExodusIIReaderPrivate();
00502   ~vtkExodusIIReaderPrivate();
00503 
00505   void BuildSIL();
00506 
00509   int VerifyIntegrationPointGlom( int nn, 
00510                                   char** np, 
00511                                   vtksys::RegularExpression& re, 
00512                                   vtkStdString& field, 
00513                                   vtkStdString& ele );
00514 
00516   void GlomArrayNames( int i, 
00517                        int num_obj, 
00518                        int num_vars, 
00519                        char** var_names, 
00520                        int* truth_tab );
00521 
00523   void PrepareGeneratedArrayInfo();
00524 
00540   int AssembleOutputConnectivity( vtkIdType timeStep,
00541     int otyp, int oidx, int conntypidx, BlockSetInfoType* bsinfop,
00542     vtkUnstructuredGrid* output );
00549   int AssembleOutputPoints( vtkIdType timeStep,
00550     BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00554   int AssembleOutputPointArrays( vtkIdType timeStep,
00555     BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00559   int AssembleOutputCellArrays( vtkIdType timeStep,
00560     int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00565   int AssembleOutputProceduralArrays( vtkIdType timeStep, 
00566     int otyp, int oidx, vtkUnstructuredGrid* output );
00568   int AssembleOutputGlobalArrays( vtkIdType timeStep,
00569     int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00576   int AssembleOutputPointMaps( vtkIdType timeStep,
00577     BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00578   int AssembleOutputCellMaps( vtkIdType timeStep,
00579     int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00582   int AssembleArraysOverTime(vtkMultiBlockDataSet* output);
00583 
00585   void InsertBlockCells(
00586     int otyp, int obj, int conn_type, int timeStep, BlockInfoType* binfop );
00587 
00589   void InsertSetCells(
00590     int otyp, int obj, int conn_type, int timeStep, SetInfoType* sinfop );
00591 
00593   void AddPointArray(
00594     vtkDataArray* src, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00595 
00597   void InsertSetNodeCopies(
00598     vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo );
00599 
00601   void InsertSetCellCopies(
00602     vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo );
00603 
00605   void InsertSetSides(
00606     vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo );
00607 
00613   vtkDataArray* GetCacheOrRead( vtkExodusIICacheKey );
00614 
00619   int GetConnTypeIndexFromConnType( int ctyp );
00620 
00625   int GetObjectTypeIndexFromObjectType( int otyp );
00626 
00632   int GetNumberOfObjectsAtTypeIndex( int typeIndex );
00633 
00641   ObjectInfoType* GetObjectInfo( int typeIndex, int objectIndex );
00642 
00649   ObjectInfoType* GetSortedObjectInfo( int objectType, int objectIndex );
00650 
00657   ObjectInfoType* GetUnsortedObjectInfo( int objectType, int objectIndex );
00658 
00663   int GetBlockIndexFromFileGlobalId( int otyp, int refId );
00664 
00669   BlockInfoType* GetBlockFromFileGlobalId( int otyp, int refId );
00670 
00674   vtkIdType GetSqueezePointId( BlockSetInfoType* bsinfop, int i );
00675 
00677   void DetermineVtkCellType( BlockInfoType& binfo );
00678 
00682   ArrayInfoType* FindArrayInfoByName( int otyp, const char* name );
00683 
00687   int IsObjectTypeBlock( int otyp );
00688   int IsObjectTypeSet( int otyp );
00689   int IsObjectTypeMap( int otyp );
00690 
00694   int GetObjectTypeFromMapType( int mtyp );
00695   int GetMapTypeFromObjectType( int otyp );
00696   int GetTemporalTypeFromObjectType( int otyp );
00697 
00701   int GetSetTypeFromSetConnType( int sctyp );
00702 
00706   int GetBlockConnTypeFromBlockType( int btyp );
00707 
00713   void RemoveBeginningAndTrailingSpaces( int len, char **names );
00714 
00716   void ClearConnectivityCaches();
00717 
00721   std::map<int,std::vector<BlockInfoType> > BlockInfo;
00725   std::map<int,std::vector<SetInfoType> > SetInfo;
00731   std::map<int,std::vector<MapInfoType> > MapInfo;
00732 
00733   std::vector<PartInfoType> PartInfo;
00734   std::vector<MaterialInfoType> MaterialInfo;
00735   std::vector<AssemblyInfoType> AssemblyInfo;
00736 
00741   std::map<int,std::vector<int> > SortedObjectIndices;
00743   //  defined on that type.
00744   std::map<int,std::vector<ArrayInfoType> > ArrayInfo;
00745 
00750   std::map<int,std::vector<ArrayInfoType> > InitialArrayInfo;
00751 
00756   std::map<int,std::vector<ObjectInfoType> > InitialObjectInfo;
00757 
00759   int AppWordSize;
00760   int DiskWordSize;
00761 
00765   float ExodusVersion;
00766 
00768   int Exoid;
00769 
00771   struct ex_init_params ModelParameters;
00772 
00774   std::vector<double> Times;
00775 
00777   int TimeStep;
00778 
00782   double ModeShapeTime;
00783 
00784   int GenerateObjectIdArray;
00785   int GenerateGlobalIdArray;
00786   int GenerateFileIdArray;
00787   int GenerateGlobalElementIdArray;
00788   int GenerateGlobalNodeIdArray;
00789   int GenerateImplicitElementIdArray;
00790   int GenerateImplicitNodeIdArray;
00791 
00795   int FileId;
00796 
00798   vtkExodusIICache* Cache;
00799   //
00801   double CacheSize;
00802 
00803   int ApplyDisplacements;
00804   float DisplacementMagnitude;
00805   int HasModeShapes;
00806   int AnimateModeShapes;
00807 
00819   int SqueezePoints;
00820 
00824   vtkExodusIIReader* Parent;
00825 
00826   vtkExodusIIReaderParser* Parser;
00827 
00828   vtkExodusIIReader::ObjectType FastPathObjectType;
00829   vtkIdType FastPathObjectId;
00830   char* FastPathIdType;
00831 
00832   vtkMutableDirectedGraph* SIL;
00833 private:
00834   vtkExodusIIReaderPrivate( const vtkExodusIIReaderPrivate& ); // Not implemented.
00835   void operator = ( const vtkExodusIIReaderPrivate& ); // Not implemented.
00836 };
00837 
00838 #endif // __vtkExodusIIReaderPrivate_h