00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00070 #ifndef __vtkExodusIIWriter_h
00071 #define __vtkExodusIIWriter_h
00072
00073 #include "vtkWriter.h"
00074 #include "vtkSmartPointer.h"
00075
00076 #include <vtkstd/vector>
00077 #include <vtkstd/map>
00078 #include <vtkstd/string>
00079
00080 class vtkModelMetadata;
00081 class vtkDoubleArray;
00082 class vtkIntArray;
00083 class vtkUnstructuredGrid;
00084
00085 class VTK_PARALLEL_EXPORT vtkExodusIIWriter : public vtkWriter
00086 {
00087 public:
00088 static vtkExodusIIWriter *New ();
00089 vtkTypeMacro(vtkExodusIIWriter,vtkWriter);
00090 void PrintSelf (ostream& os, vtkIndent indent);
00091
00100 void SetModelMetadata (vtkModelMetadata*);
00101 vtkGetObjectMacro(ModelMetadata, vtkModelMetadata);
00102
00108 vtkSetStringMacro(FileName);
00109 vtkGetStringMacro(FileName);
00110
00116 vtkSetMacro(StoreDoubles, int);
00117 vtkGetMacro(StoreDoubles, int);
00118
00122 vtkSetMacro(GhostLevel, int);
00123 vtkGetMacro(GhostLevel, int);
00124
00130 vtkSetMacro(WriteOutBlockIdArray, int);
00131 vtkGetMacro(WriteOutBlockIdArray, int);
00132 vtkBooleanMacro(WriteOutBlockIdArray, int);
00133
00138 vtkSetMacro(WriteOutGlobalNodeIdArray, int);
00139 vtkGetMacro(WriteOutGlobalNodeIdArray, int);
00140 vtkBooleanMacro(WriteOutGlobalNodeIdArray, int);
00141
00146 vtkSetMacro(WriteOutGlobalElementIdArray, int);
00147 vtkGetMacro(WriteOutGlobalElementIdArray, int);
00148 vtkBooleanMacro(WriteOutGlobalElementIdArray, int);
00149
00153 vtkSetMacro(WriteAllTimeSteps, int);
00154 vtkGetMacro(WriteAllTimeSteps, int);
00155 vtkBooleanMacro(WriteAllTimeSteps, int);
00156
00157 vtkSetStringMacro(BlockIdArrayName);
00158 vtkGetStringMacro(BlockIdArrayName);
00159
00160 protected:
00161 vtkExodusIIWriter ();
00162 ~vtkExodusIIWriter ();
00163
00164 vtkModelMetadata* ModelMetadata;
00165
00166 char *BlockIdArrayName;
00167
00168 char *FileName;
00169 int fid;
00170
00171 int NumberOfProcesses;
00172 int MyRank;
00173
00174 int PassDoubles;
00175
00176 int StoreDoubles;
00177 int GhostLevel;
00178 int WriteOutBlockIdArray;
00179 int WriteOutGlobalNodeIdArray;
00180 int WriteOutGlobalElementIdArray;
00181 int WriteAllTimeSteps;
00182 int NumberOfTimeSteps;
00183
00184 vtkDoubleArray* TimeValues;
00185 int CurrentTimeIndex;
00186 int FileTimeOffset;
00187
00188
00189 vtkDataObject *OriginalInput;
00190 vtkstd::vector< vtkSmartPointer<vtkUnstructuredGrid> > FlattenedInput;
00191 vtkstd::vector< vtkSmartPointer<vtkUnstructuredGrid> > NewFlattenedInput;
00192
00193 vtkstd::vector< vtkIntArray* > BlockIdList;
00194
00195 struct Block
00196 {
00197 Block ()
00198 {
00199 this->Type = 0;
00200 this->NumElements = 0;
00201 this->ElementStartIndex = -1;
00202 this->NodesPerElement = 0;
00203 this->EntityCounts = std::vector<int>();
00204 this->EntityNodeOffsets = std::vector<int>();
00205 this->GridIndex = 0;
00206 this->OutputIndex = -1;
00207 this->NumAttributes = 0;
00208 this->BlockAttributes = 0;
00209 };
00210 int Type;
00211 int NumElements;
00212 int ElementStartIndex;
00213 int NodesPerElement;
00214 std::vector<int> EntityCounts;
00215 std::vector<int> EntityNodeOffsets;
00216 size_t GridIndex;
00217
00218 int OutputIndex;
00219 int NumAttributes;
00220 float *BlockAttributes;
00221 };
00222 vtkstd::map<int, Block> BlockInfoMap;
00223 int NumCells, NumPoints, MaxId;
00224
00225 vtkstd::vector<vtkIdType*> GlobalElementIdList;
00226 vtkstd::vector<vtkIdType*> GlobalNodeIdList;
00227
00228 int AtLeastOneGlobalElementIdList;
00229 int AtLeastOneGlobalNodeIdList;
00230
00231
00232 struct VariableInfo
00233 {
00234 int NumComponents;
00235 int InIndex;
00236 int ScalarOutOffset;
00237 vtkstd::vector<vtkstd::string> OutNames;
00238 };
00239 vtkstd::map<vtkstd::string, VariableInfo> GlobalVariableMap;
00240 vtkstd::map<vtkstd::string, VariableInfo> BlockVariableMap;
00241 vtkstd::map<vtkstd::string, VariableInfo> NodeVariableMap;
00242 int NumberOfScalarGlobalArrays;
00243 int NumberOfScalarElementArrays;
00244 int NumberOfScalarNodeArrays;
00245
00246
00247
00248 vtkstd::vector< vtkstd::vector<int> > CellToElementOffset;
00249
00250
00251
00252
00253 int *BlockElementVariableTruthTable;
00254 int AllVariablesDefinedInAllBlocks;
00255
00256 int BlockVariableTruthValue(int blockIdx, int varIdx);
00257
00258
00259 char *StrDupWithNew (const char *s);
00260 void StringUppercase (vtkstd::string& str);
00261
00262
00263 int ProcessRequest (vtkInformation* request,
00264 vtkInformationVector** inputVector,
00265 vtkInformationVector* outputVector);
00266
00267 int RequestInformation (vtkInformation* request,
00268 vtkInformationVector** inputVector,
00269 vtkInformationVector* outputVector);
00270
00271 int FillInputPortInformation (int port, vtkInformation* info);
00272
00273 int RequestData (vtkInformation* request,
00274 vtkInformationVector** inputVector,
00275 vtkInformationVector* outputVector);
00276
00277 void WriteData ();
00278
00279 int FlattenHierarchy (vtkDataObject* input, bool& changed);
00280
00281 int CreateNewExodusFile ();
00282 void CloseExodusFile ();
00283
00284 int IsDouble ();
00285 void RemoveGhostCells ();
00286 int CheckParameters ();
00287 int CheckInputArrays ();
00288 int ConstructBlockInfoMap ();
00289 int ConstructVariableInfoMaps ();
00290 int ParseMetadata ();
00291 int CreateDefaultMetadata ();
00292 char *GetCellTypeName (int t);
00293
00294 int CreateBlockIdMetadata(vtkModelMetadata *em);
00295 int CreateBlockVariableMetadata (vtkModelMetadata* em);
00296
00297
00298 void ConvertVariableNames (vtkstd::map<vtkstd::string, VariableInfo>& variableMap);
00299 char **FlattenOutVariableNames (
00300 int nScalarArrays,
00301 const vtkstd::map<vtkstd::string, VariableInfo>& variableMap);
00302 vtkstd::string CreateNameForScalarArray (const char *root,
00303 int component,
00304 int numComponents);
00305
00306 vtkstd::map<vtkIdType, vtkIdType> *LocalNodeIdMap;
00307 vtkstd::map<vtkIdType, vtkIdType> *LocalElementIdMap;
00308
00309 vtkIdType GetNodeLocalId(vtkIdType id);
00310 vtkIdType GetElementLocalId(vtkIdType id);
00311
00312 int WriteInitializationParameters ();
00313 int WriteQARecords ();
00314 int WriteInformationRecords ();
00315 int WritePoints ();
00316 int WriteCoordinateNames ();
00317 int WriteGlobalPointIds ();
00318 int WriteBlockInformation ();
00319 int WriteGlobalElementIds ();
00320 int WriteVariableArrayNames ();
00321 int WriteNodeSetInformation ();
00322 int WriteSideSetInformation ();
00323 int WriteProperties ();
00324 int WriteNextTimeStep ();
00325
00326
00327 double ExtractGlobalData (const char *name, int comp, int ts);
00328 int WriteGlobalData (int timestep, vtkDataArray *buffer);
00329 void ExtractCellData (const char *name, int comp, vtkDataArray *buffer);
00330 int WriteCellData (int timestep, vtkDataArray *buffer);
00331 void ExtractPointData (const char *name, int comp, vtkDataArray *buffer);
00332 int WritePointData (int timestep, vtkDataArray *buffer);
00333
00334
00335
00336 private:
00337 vtkExodusIIWriter (const vtkExodusIIWriter&);
00338 void operator= (const vtkExodusIIWriter&);
00339 };
00340
00341 #endif