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 <vtkstd/map>
00018 #include <vtkstd/vector>
00019 
00020 #include "vtkExodusII.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 
00058   // Description:
00059   // Prepare a data set with the proper structure and arrays but no cells.
00060   // This is used by the parallel reader when a process has no files assigned to it.
00061   int SetUpEmptyGrid( vtkMultiBlockDataSet* output );
00062 
00074   void Reset();
00075 
00080   void ResetSettings();
00081 
00083   void ResetCache();
00084 
00089   int GetNumberOfTimeSteps() { return (int) this->Times.size(); }
00090 
00092   vtkGetMacro(TimeStep,int);
00093 
00095   vtkSetMacro(TimeStep,int);
00096 
00099   vtkGetMacro(SqueezePoints,int);
00100 
00103   void SetSqueezePoints( int sp );
00104 
00107   vtkBooleanMacro(SqueezePoints,int);
00108 
00110   int GetNumberOfNodes();
00111 
00116   int GetNumberOfObjectsOfType( int otype );
00117 
00128   int GetNumberOfObjectArraysOfType( int otype );
00129 
00134   const char* GetObjectName( int otype, int i );
00135 
00140   int GetObjectId( int otype, int i );
00141 
00148   int GetObjectSize( int otype, int i );
00149 
00154   int GetObjectStatus( int otype, int i );
00155 
00161   int GetUnsortedObjectStatus( int otype, int i );
00162 
00167   void SetObjectStatus( int otype, int i, int stat );
00168 
00174   void SetUnsortedObjectStatus( int otype, int i, int stat );
00175 
00180   const char* GetObjectArrayName( int otype, int i );
00181 
00186   int GetNumberOfObjectArrayComponents( int otype, int i );
00187 
00192   int GetObjectArrayStatus( int otype, int i );
00193 
00198   void SetObjectArrayStatus( int otype, int i, int stat );
00199 
00206   int GetNumberOfObjectAttributes( int objectType, int objectIndex );
00207   const char* GetObjectAttributeName( int objectType, 
00208                                       int objectIndex, 
00209                                       int attributeIndex );
00210   int GetObjectAttributeIndex( int objectType, 
00211                                int objectIndex, 
00212                                const char* attribName );
00213   int GetObjectAttributeStatus( int objectType, 
00214                                 int objectIndex, 
00215                                 int attribIndex );
00216   void SetObjectAttributeStatus( int objectType, 
00217                                  int objectIndex, 
00218                                  int attribIndex, int status );
00219 
00221   vtkGetMacro(GenerateObjectIdArray,int);
00222   vtkSetMacro(GenerateObjectIdArray,int);
00223   static const char* GetObjectIdArrayName() { return "ObjectId"; }
00224 
00225   vtkSetMacro(GenerateGlobalElementIdArray,int);
00226   vtkGetMacro(GenerateGlobalElementIdArray,int);
00227   static const char* GetGlobalElementIdArrayName() { return "GlobalElementId"; }  
00228 
00229   vtkSetMacro(GenerateGlobalNodeIdArray,int);
00230   vtkGetMacro(GenerateGlobalNodeIdArray,int);
00231   static const char* GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }  
00232 
00233   vtkSetMacro(GenerateImplicitElementIdArray,int);
00234   vtkGetMacro(GenerateImplicitElementIdArray,int);
00235   static const char* GetImplicitElementIdArrayName() { return "ImplicitElementId"; }  
00236 
00237   vtkSetMacro(GenerateImplicitNodeIdArray,int);
00238   vtkGetMacro(GenerateImplicitNodeIdArray,int);
00239   static const char* GetImplicitNodeIdArrayName() { return "ImplicitNodeId"; }  
00240 
00244   vtkSetMacro(GenerateFileIdArray,int);
00245   vtkGetMacro(GenerateFileIdArray,int);
00246   static const char* GetFileIdArrayName() { return "FileId"; }  
00247 
00249   vtkSetMacro(FileId,int);
00250   vtkGetMacro(FileId,int);
00251 
00252   static const char *GetGlobalVariableValuesArrayName() 
00253     { return "GlobalVariableValues"; }  
00254   static const char *GetGlobalVariableNamesArrayName() 
00255     { return "GlobalVariableNames"; }  
00256 
00257   virtual void SetApplyDisplacements( int d );
00258   vtkGetMacro(ApplyDisplacements,int);
00259 
00260   virtual void SetDisplacementMagnitude( double s );
00261   vtkGetMacro(DisplacementMagnitude,double);
00262 
00263   vtkSetMacro(HasModeShapes,int);
00264   vtkGetMacro(HasModeShapes,int);
00265 
00266   vtkSetMacro(ModeShapeTime,double);
00267   vtkGetMacro(ModeShapeTime,double);
00268 
00269   vtkSetMacro(AnimateModeShapes, int);
00270   vtkGetMacro(AnimateModeShapes, int);
00271 
00272   vtkDataArray* FindDisplacementVectors( int timeStep );
00273 
00274   vtkSetMacro(EdgeFieldDecorations,int);
00275   vtkGetMacro(EdgeFieldDecorations,int);
00276 
00277   vtkSetMacro(FaceFieldDecorations,int);
00278   vtkGetMacro(FaceFieldDecorations,int);
00279 
00280   const struct ex_init_params* GetModelParams() const 
00281     { return &this->ModelParameters; }
00282 
00284   struct ArrayInfoType {
00286     vtkStdString Name;
00288     int Components;
00295     int GlomType;
00298     int StorageType;
00300     int Source;
00302     int Status;
00305     vtkstd::vector<vtkStdString> OriginalNames;
00308     vtkstd::vector<int> OriginalIndices;
00317     vtkstd::vector<int> ObjectTruth;
00319     void Reset();
00320   };
00321 
00323   struct ObjectInfoType {
00325     int Size;
00327     int Status;
00329     int Id;
00331     vtkStdString Name;
00332   };
00333 
00335   struct MapInfoType : public ObjectInfoType {
00336   };
00337 
00340   struct BlockSetInfoType : public ObjectInfoType {
00342     vtkIdType FileOffset;
00347     vtkstd::map<vtkIdType,vtkIdType> PointMap;
00352     vtkstd::map<vtkIdType,vtkIdType> ReversePointMap;
00356     vtkIdType NextSqueezePoint;
00358     vtkUnstructuredGrid* CachedConnectivity;
00359 
00360     BlockSetInfoType() { this->CachedConnectivity = 0; }
00361   };
00362 
00364   struct BlockInfoType : public BlockSetInfoType {
00365     vtkStdString OriginalName; // useful to reset the name if XML metadata is invalid.
00366     vtkStdString TypeName;
00367     // number of boundaries per entry
00368     // The index is the dimensionality of the entry. 0=node, 1=edge, 2=face
00369     int BdsPerEntry[3]; 
00370     int AttributesPerEntry;
00371     vtkstd::vector<vtkStdString> AttributeNames;
00372     vtkstd::vector<int> AttributeStatus;
00373     // VTK cell type (a function of TypeName and BdsPerEntry...)
00374     int CellType; 
00375     // Number of points per cell as used by VTK 
00376     // -- not what's in the file (i.e., BdsPerEntry[0] >= PointsPerCell)
00377     int PointsPerCell; 
00378   };
00379 
00381   struct PartInfoType : public ObjectInfoType {
00382     vtkstd::vector<int> BlockIndices;
00383   };
00384   struct AssemblyInfoType : public ObjectInfoType {
00385     vtkstd::vector<int> BlockIndices;
00386   };
00387   struct MaterialInfoType : public ObjectInfoType {
00388     vtkstd::vector<int> BlockIndices;
00389   };
00390 
00392   struct SetInfoType : public BlockSetInfoType {
00393     int DistFact;     // Number of distribution factors 
00394                       // (for the entire block, not per array or entry)
00395   };
00396 
00399   enum GlomTypes {
00400     Scalar=0,          
00401     Vector2=1,         
00402     Vector3=2,         
00403     SymmetricTensor=3, 
00404                        //   (order xx, yy, zz, xy, yz, zx)
00405     IntegrationPoint=4 
00406   };
00407 
00409   enum ArraySourceTypes {
00410     Result=0,        
00411                      //   (that vary over time)
00412     Attribute=1,     
00413                      //   (constants over time)
00414     Map=2,           
00415     Generated=3      
00416   };
00417 
00419   vtkTimeStamp InformationTimeStamp;
00420  
00421   friend class vtkExodusIIReader;
00422 
00423   virtual void SetParser( vtkExodusIIReaderParser* );
00424   vtkGetObjectMacro(Parser,vtkExodusIIReaderParser);
00425 
00426   // Because Parts, Materials, and assemblies are not stored as arrays,
00427   // but rather as maps to the element blocks they make up,  
00428   // we cannot use the Get|SetObject__() methods directly.
00429 
00430   int GetNumberOfParts();
00431   const char* GetPartName(int idx);
00432   const char* GetPartBlockInfo(int idx);
00433   int GetPartStatus(int idx);
00434   int GetPartStatus(vtkStdString name);
00435   void SetPartStatus(int idx, int on);
00436   void SetPartStatus(vtkStdString name, int flag);
00437     
00438   int GetNumberOfMaterials();
00439   const char* GetMaterialName(int idx);
00440   int GetMaterialStatus(int idx);
00441   int GetMaterialStatus(vtkStdString name);
00442   void SetMaterialStatus(int idx, int on);
00443   void SetMaterialStatus(vtkStdString name, int flag);
00444 
00445   int GetNumberOfAssemblies();
00446   const char* GetAssemblyName(int idx);
00447   int GetAssemblyStatus(int idx);
00448   int GetAssemblyStatus(vtkStdString name);
00449   void SetAssemblyStatus(int idx, int on);
00450   void SetAssemblyStatus(vtkStdString name, int flag);
00451 
00452   void SetFastPathObjectType(vtkExodusIIReader::ObjectType type)
00453     {this->FastPathObjectType = type;};
00454   void SetFastPathObjectId(vtkIdType id){this->FastPathObjectId = id;};
00455   vtkSetStringMacro(FastPathIdType);
00456 
00457   bool IsXMLMetadataValid();
00458 
00466   void GetInitialObjectStatus( int otype, ObjectInfoType *info );
00467 
00475   void GetInitialObjectArrayStatus( int otype, ArrayInfoType *info );
00476 
00483   void SetInitialObjectStatus( int otype, const char *name, int stat );
00484 
00490   void SetInitialObjectArrayStatus( int otype, const char *name, int stat );
00491 
00492   int UpdateTimeInformation();
00493 
00494   bool ProducedFastPathOutput;
00495 
00496 protected:
00497   vtkExodusIIReaderPrivate();
00498   ~vtkExodusIIReaderPrivate();
00499 
00501   void BuildSIL();
00502 
00505   int VerifyIntegrationPointGlom( int nn, 
00506                                   char** np, 
00507                                   vtksys::RegularExpression& re, 
00508                                   vtkStdString& field, 
00509                                   vtkStdString& ele );
00510 
00512   void GlomArrayNames( int i, 
00513                        int num_obj, 
00514                        int num_vars, 
00515                        char** var_names, 
00516                        int* truth_tab );
00517 
00519   void PrepareGeneratedArrayInfo();
00520 
00536   int AssembleOutputConnectivity( vtkIdType timeStep,
00537     int otyp, int oidx, int conntypidx, BlockSetInfoType* bsinfop,
00538     vtkUnstructuredGrid* output );
00545   int AssembleOutputPoints( vtkIdType timeStep,
00546     BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00550   int AssembleOutputPointArrays( vtkIdType timeStep,
00551     BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00555   int AssembleOutputCellArrays( vtkIdType timeStep,
00556     int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00561   int AssembleOutputProceduralArrays( vtkIdType timeStep, 
00562     int otyp, int oidx, vtkUnstructuredGrid* output );
00564   int AssembleOutputGlobalArrays( vtkIdType timeStep,
00565     int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00572   int AssembleOutputPointMaps( vtkIdType timeStep,
00573     BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00574   int AssembleOutputCellMaps( vtkIdType timeStep,
00575     int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00578   int AssembleArraysOverTime(vtkMultiBlockDataSet* output);
00579 
00580   // Generate the decorations for edge fields.
00581   void AssembleOutputEdgeDecorations();
00582 
00583   // Generate the decorations for face fields.
00584   void AssembleOutputFaceDecorations();
00585 
00587   void InsertBlockCells(
00588     int otyp, int obj, int conn_type, int timeStep, BlockInfoType* binfop );
00589 
00591   void InsertSetCells(
00592     int otyp, int obj, int conn_type, int timeStep, SetInfoType* sinfop );
00593 
00595   void AddPointArray(
00596     vtkDataArray* src, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00597 
00599   void InsertSetNodeCopies(
00600     vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo );
00601 
00603   void InsertSetCellCopies(
00604     vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo );
00605 
00607   void InsertSetSides(
00608     vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo );
00609 
00615   vtkDataArray* GetCacheOrRead( vtkExodusIICacheKey );
00616 
00621   int GetConnTypeIndexFromConnType( int ctyp );
00622 
00627   int GetObjectTypeIndexFromObjectType( int otyp );
00628 
00634   int GetNumberOfObjectsAtTypeIndex( int typeIndex );
00635 
00643   ObjectInfoType* GetObjectInfo( int typeIndex, int objectIndex );
00644 
00651   ObjectInfoType* GetSortedObjectInfo( int objectType, int objectIndex );
00652 
00659   ObjectInfoType* GetUnsortedObjectInfo( int objectType, int objectIndex );
00660 
00665   int GetBlockIndexFromFileGlobalId( int otyp, int refId );
00666 
00671   BlockInfoType* GetBlockFromFileGlobalId( int otyp, int refId );
00672 
00676   vtkIdType GetSqueezePointId( BlockSetInfoType* bsinfop, int i );
00677 
00679   void DetermineVtkCellType( BlockInfoType& binfo );
00680 
00684   ArrayInfoType* FindArrayInfoByName( int otyp, const char* name );
00685 
00689   int IsObjectTypeBlock( int otyp );
00690   int IsObjectTypeSet( int otyp );
00691   int IsObjectTypeMap( int otyp );
00692 
00696   int GetObjectTypeFromMapType( int mtyp );
00697   int GetMapTypeFromObjectType( int otyp );
00698   int GetTemporalTypeFromObjectType( int otyp );
00699 
00703   int GetSetTypeFromSetConnType( int sctyp );
00704 
00708   int GetBlockConnTypeFromBlockType( int btyp );
00709 
00715   void RemoveBeginningAndTrailingSpaces( int len, char **names );
00716 
00718   void ClearConnectivityCaches();
00719 
00723   vtkstd::map<int,vtkstd::vector<BlockInfoType> > BlockInfo;
00727   vtkstd::map<int,vtkstd::vector<SetInfoType> > SetInfo;
00733   vtkstd::map<int,vtkstd::vector<MapInfoType> > MapInfo;
00734 
00735   vtkstd::vector<PartInfoType> PartInfo;
00736   vtkstd::vector<MaterialInfoType> MaterialInfo;
00737   vtkstd::vector<AssemblyInfoType> AssemblyInfo;
00738 
00743   vtkstd::map<int,vtkstd::vector<int> > SortedObjectIndices;
00745   //  defined on that type.
00746   vtkstd::map<int,vtkstd::vector<ArrayInfoType> > ArrayInfo;
00747 
00752   vtkstd::map<int,vtkstd::vector<ArrayInfoType> > InitialArrayInfo;
00753 
00758   vtkstd::map<int,vtkstd::vector<ObjectInfoType> > InitialObjectInfo;
00759 
00761   int AppWordSize;
00762   int DiskWordSize;
00763 
00767   float ExodusVersion;
00768 
00770   int Exoid;
00771 
00773   struct ex_init_params ModelParameters;
00774 
00776   vtkstd::vector<double> Times;
00777 
00779   int TimeStep;
00780 
00784   double ModeShapeTime;
00785 
00786   int GenerateObjectIdArray;
00787   int GenerateGlobalIdArray;
00788   int GenerateFileIdArray;
00789   int GenerateGlobalElementIdArray;
00790   int GenerateGlobalNodeIdArray;
00791   int GenerateImplicitElementIdArray;
00792   int GenerateImplicitNodeIdArray;
00793 
00797   int FileId;
00798 
00800   vtkExodusIICache* Cache;
00801 
00802   int ApplyDisplacements;
00803   float DisplacementMagnitude;
00804   int HasModeShapes;
00805   int AnimateModeShapes;
00806 
00807   // Specify how to decorate edge and face variables.
00808   int EdgeFieldDecorations;
00809   int FaceFieldDecorations;
00810 
00811   // Meshes to support edge and face glyph decorations.
00812   vtkPolyData* EdgeDecorationMesh;
00813   vtkPolyData* FaceDecorationMesh;
00814 
00826   int SqueezePoints;
00827 
00831   vtkExodusIIReader* Parent;
00832 
00833   vtkExodusIIReaderParser* Parser;
00834 
00835   vtkExodusIIReader::ObjectType FastPathObjectType;
00836   vtkIdType FastPathObjectId;
00837   char* FastPathIdType;
00838 
00839   vtkMutableDirectedGraph* SIL;
00840 private:
00841   vtkExodusIIReaderPrivate( const vtkExodusIIReaderPrivate& ); // Not implemented.
00842   void operator = ( const vtkExodusIIReaderPrivate& ); // Not implemented.
00843 };
00844 
00845 #endif // __vtkExodusIIReaderPrivate_h