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

vtkExodusIIWriter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkExodusIIWriter.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 
00068 #ifndef __vtkExodusIIWriter_h
00069 #define __vtkExodusIIWriter_h
00070 
00071 
00072 #include "vtkWriter.h"
00073 
00074 #include <vtkstd/map> // For the map
00075 
00076 class vtkUnstructuredGrid;
00077 class vtkFloatArray;
00078 class vtkDoubleArray;
00079 class vtkDataArray;
00080 class vtkUnsignedCharArray;
00081 class vtkIntArray;
00082 class vtkModelMetadata;
00083 
00084 class VTK_PARALLEL_EXPORT vtkExodusIIWriter : public vtkWriter
00085 {
00086 public:
00087   static vtkExodusIIWriter *New();
00088   vtkTypeRevisionMacro(vtkExodusIIWriter,vtkWriter);
00089   void PrintSelf(ostream& os, vtkIndent indent);
00090 
00093   void SetInput(vtkUnstructuredGrid *ug);
00094   vtkUnstructuredGrid *GetInput();
00095 
00104   virtual void SetModelMetadata(vtkModelMetadata*);
00105   vtkGetObjectMacro(ModelMetadata, vtkModelMetadata);
00106 
00116   vtkModelMetadata* GetOrCreateModelMetadata();
00117 
00123   vtkSetStringMacro(FileName);
00124   vtkGetStringMacro(FileName);
00125 
00131   vtkSetMacro(StoreDoubles, int);
00132   vtkGetMacro(StoreDoubles, int);
00133 
00137   vtkSetMacro(GhostLevel, int);
00138   vtkGetMacro(GhostLevel, int);
00139 
00148   vtkSetStringMacro(BlockIdArrayName);
00149   vtkGetStringMacro(BlockIdArrayName);
00150 
00155   vtkSetMacro(WriteOutBlockIdArray, int);
00156   vtkGetMacro(WriteOutBlockIdArray, int);
00157   vtkBooleanMacro(WriteOutBlockIdArray, int);
00158 
00164   vtkSetStringMacro(GlobalNodeIdArrayName);
00165   vtkGetStringMacro(GlobalNodeIdArrayName);
00166 
00171   vtkSetMacro(WriteOutGlobalNodeIdArray, int);
00172   vtkGetMacro(WriteOutGlobalNodeIdArray, int);
00173   vtkBooleanMacro(WriteOutGlobalNodeIdArray, int);
00174 
00180   vtkSetStringMacro(GlobalElementIdArrayName);
00181   vtkGetStringMacro(GlobalElementIdArrayName);
00182 
00187   vtkSetMacro(WriteOutGlobalElementIdArray, int);
00188   vtkGetMacro(WriteOutGlobalElementIdArray, int);
00189   vtkBooleanMacro(WriteOutGlobalElementIdArray, int);
00190 
00197   void SetTimeStepValues(int NumberOfTimeSteps, float *v);
00198   float *GetTimeStepValues(){return this->InputTimeStepValues;}
00199   int GetNumberOfTimeSteps(){return this->InputNumberOfTimeSteps;}
00200 
00210   void SetCurrentTimeStep(int ts);
00211   int GetCurrentTimeStep(){return this->InputCurrentTimeStep;}
00212 
00218   void SetAllBlockIds(int numEntries, int *blockIds);
00219 
00225   vtkSetMacro(ErrorStatus, int);
00226   vtkGetMacro(ErrorStatus, int);
00227 
00228 protected:
00229 
00230   vtkExodusIIWriter();
00231   ~vtkExodusIIWriter();
00232 
00233   virtual int FillInputPortInformation(int port, vtkInformation* info);
00234 
00235   void WriteData();     
00236 
00237   vtkExodusIIWriter(const vtkExodusIIWriter&); // Not implemented
00238   void operator=(const vtkExodusIIWriter&); // Not implemented
00239 
00240   vtkSetStringMacro(MyFileName);
00241   vtkGetStringMacro(MyFileName);
00242 
00244 
00247   vtkSetMacro(MyRank, int);
00248   vtkGetMacro(MyRank, int);
00250 
00251 private:
00252   static char *StrDupWithNew(const char *s);
00253 
00254   void RemoveGhostCells();
00255 
00256   void SetPassDoubles();
00257 
00258   int CheckParameters();
00259   int CreateExodusModel();
00260   int CreateBlockIdInformationFromCellTypes(vtkModelMetadata *em);
00261   int CreateBlockIdInformation(vtkModelMetadata *em);
00262 
00263   static char **FlattenOutVariableNames(int narrays, int nScalarArrays, 
00264                                   char **nms, int *numComponents);
00265   static void CreateNamesForScalarArrays(const char *root, char **nms, 
00266                                          int numComponents);
00267   static char *GetCellTypeName(int t);
00268   static int FindCellType(int blockId, int *blockIdList, unsigned char *cellTypeList, 
00269                  int nCells);
00270 
00271   int CreateNewExodusFile();
00272   int OpenExodusFile();
00273   void CloseExodusFile();
00274 
00275   void InitializeVariableArrayNames();
00276   void ClearVariableArrayNames();
00277   void SetNewNodeVariableNames(vtkDataArray *da, char **nm);
00278   void SetNewElementVariableNames(vtkDataArray *da, char **nm);
00279 
00280   void InitializeBlockLists();
00281   void ClearBlockLists();
00282   int WriteBlockVariables();
00283 //BTX
00284   vtkstd::map<int, int> *BuildBlockElementSearchStructure(int block);
00285 //ETX
00286 
00287   int WriteInitializationParameters();
00288   int WriteQARecords();
00289   int WriteInformationRecords();
00290   int WritePoints();
00291   int WriteCoordinateNames();
00292   int WriteGlobalPointIds();
00293   int WriteGlobalElementIds();
00294   int WriteBlockInformation();
00295   int WriteVariableArrayNames();
00296   int WriteNodeSetInformation();
00297   int WriteSideSetInformation();
00298   int WriteProperties();
00299 
00300   int GetTimeStepIndex();
00301   float GetTimeStepValue(int timeStepIndex);
00302   int WriteNextTimeStep();
00303   float *ExtractComponentF(vtkDataArray *da, int comp, int *idx);
00304   double *ExtractComponentD(vtkDataArray *da, int comp, int *idx);
00305 
00306   vtkModelMetadata *ModelMetadata;
00307 
00308   int PassDoubles; // If set, we have to pass doubles to exodus library.
00309                    // If not set, we have to pass floats.
00310   int StoreDoubles;// If set, Exodus library will store doubles.
00311                    // If not set, Exodus library will store floats.
00312   int fid;
00313 
00314   char *FileName;    // base file name
00315   char *MyFileName;  // base plus number of processes and my rank  
00316 
00317   // The block IDs, the time step values, and the current time step index
00318   // may be provided if there is not vtkModelMetadata object.  The time
00319   // step may also be provided if only a subset (like every other one)
00320   // of the time steps are being written out.
00321 
00322   int *InputBlockIds;
00323   int InputBlockIdsLength;
00324 
00325   int InputNumberOfTimeSteps;
00326   float *InputTimeStepValues;
00327   int InputCurrentTimeStep;   
00328   int LastTimeStepWritten;
00329 
00330   // List of the global element ID of each cell in input
00331 
00332   char *GlobalElementIdArrayName;
00333   int *GlobalElementIdList;
00334 //BTX
00335   vtkstd::map<int, int> *LocalElementIdMap;
00336 //ETX
00337   int GetElementLocalId(int i);
00338   int WriteOutGlobalElementIdArray;
00339 
00340   // List of the global node ID of each cell in input
00341 
00342   char *GlobalNodeIdArrayName;
00343   int *GlobalNodeIdList;
00344 //BTX
00345   vtkstd::map<int, int> *LocalNodeIdMap;
00346 //ETX
00347   int GetNodeLocalId(int i);
00348   int WriteOutGlobalNodeIdArray;
00349 
00350   // Exodus II element blocks
00351 
00352   char *BlockIdArrayName;    // List of block ID of each cell in input
00353   int *BlockIdList;
00354   int WriteOutBlockIdArray;
00355 
00356   int NumberOfElementBlocks;
00357   int *BlockIds;             // list of every block ID in dataset
00358 //BTX
00359   vtkstd::map<int, int> *LocalBlockIndexMap; // block ID -> block index
00360 //ETX
00361   int GetBlockLocalIndex(int i);
00362   int *BlockElementStart;
00363   int *ElementIndex;
00364 
00365   char **BlockElementType;
00366   int *NumberOfElementsPerBlock;
00367   int *NumberOfNodesPerElementInBlock;
00368   int *NumberOfAttributesPerElementInBlock;
00369   float **BlockElementAttributesF;
00370   double **BlockElementAttributesD;
00371   int **BlockElementConnectivity;
00372 
00373   // By BlockId, and within block ID by element variable, with variables
00374   // appearing in the same order in which they appear in OutputElementArrayNames
00375 
00376   int *BlockElementVariableTruthTable;
00377   int AllVariablesDefinedInAllBlocks;
00378 
00379   int BlockVariableTruthValue(int blockIdx, int varIdx);
00380 
00381   // Element variable arrays
00382 
00383   int NumberOfScalarElementArrays;
00384   char **InputElementArrayNames;    // input names (including vectors)
00385   char **OutputElementArrayNames;         // output names (all scalars)
00386   int *InputElementArrayComponent;
00387 
00388   // Point variable arrays
00389 
00390   int NumberOfScalarNodeArrays;
00391   char **InputNodeArrayNames;
00392   char **OutputNodeArrayNames;
00393   int *InputNodeArrayComponent;
00394 
00395   // Global application information
00396 
00397   int NumberOfProcesses;
00398   int MyRank;
00399 
00400   // The input less ghost cells
00401 
00402   vtkUnstructuredGrid *MyInput;
00403 
00404   // we don't use this variable - it's for ParaView
00405 
00406   int GhostLevel;
00407 
00408   int ErrorStatus;
00409 };
00410 
00411 #endif

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