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->NodesPerElements = 0;
00203 this->GridIndex = 0;
00204 this->OutputIndex = -1;
00205 this->NumAttributes = 0;
00206 this->BlockAttributes = 0;
00207 };
00208 int Type;
00209 int NumElements;
00210 int ElementStartIndex;
00211 int NodesPerElements;
00212 size_t GridIndex;
00213
00214 int OutputIndex;
00215 int NumAttributes;
00216 float *BlockAttributes;
00217 };
00218 vtkstd::map<int, Block> BlockInfoMap;
00219 int NumCells, NumPoints, MaxId;
00220
00221 vtkstd::vector<vtkIdType*> GlobalElementIdList;
00222 vtkstd::vector<vtkIdType*> GlobalNodeIdList;
00223
00224 int AtLeastOneGlobalElementIdList;
00225 int AtLeastOneGlobalNodeIdList;
00226
00227
00228 struct VariableInfo
00229 {
00230 int NumComponents;
00231 int InIndex;
00232 int ScalarOutOffset;
00233 vtkstd::vector<vtkstd::string> OutNames;
00234 };
00235 vtkstd::map<vtkstd::string, VariableInfo> GlobalVariableMap;
00236 vtkstd::map<vtkstd::string, VariableInfo> BlockVariableMap;
00237 vtkstd::map<vtkstd::string, VariableInfo> NodeVariableMap;
00238 int NumberOfScalarGlobalArrays;
00239 int NumberOfScalarElementArrays;
00240 int NumberOfScalarNodeArrays;
00241
00242
00243
00244 vtkstd::vector< vtkstd::vector<int> > CellToElementOffset;
00245
00246
00247
00248
00249 int *BlockElementVariableTruthTable;
00250 int AllVariablesDefinedInAllBlocks;
00251
00252 int BlockVariableTruthValue(int blockIdx, int varIdx);
00253
00254
00255 char *StrDupWithNew (const char *s);
00256 void StringUppercase (vtkstd::string& str);
00257
00258
00259 int ProcessRequest (vtkInformation* request,
00260 vtkInformationVector** inputVector,
00261 vtkInformationVector* outputVector);
00262
00263 int RequestInformation (vtkInformation* request,
00264 vtkInformationVector** inputVector,
00265 vtkInformationVector* outputVector);
00266
00267 int FillInputPortInformation (int port, vtkInformation* info);
00268
00269 int RequestData (vtkInformation* request,
00270 vtkInformationVector** inputVector,
00271 vtkInformationVector* outputVector);
00272
00273 void WriteData ();
00274
00275 int FlattenHierarchy (vtkDataObject* input, bool& changed);
00276
00277 int CreateNewExodusFile ();
00278 void CloseExodusFile ();
00279
00280 int IsDouble ();
00281 void RemoveGhostCells ();
00282 int CheckParameters ();
00283 int CheckInputArrays ();
00284 int ConstructBlockInfoMap ();
00285 int ConstructVariableInfoMaps ();
00286 int ParseMetadata ();
00287 int CreateDefaultMetadata ();
00288 char *GetCellTypeName (int t);
00289
00290 int CreateBlockIdMetadata(vtkModelMetadata *em);
00291 int CreateBlockVariableMetadata (vtkModelMetadata* em);
00292
00293
00294 void ConvertVariableNames (vtkstd::map<vtkstd::string, VariableInfo>& variableMap);
00295 char **FlattenOutVariableNames (
00296 int nScalarArrays,
00297 const vtkstd::map<vtkstd::string, VariableInfo>& variableMap);
00298 vtkstd::string CreateNameForScalarArray (const char *root,
00299 int component,
00300 int numComponents);
00301
00302 vtkstd::map<vtkIdType, vtkIdType> *LocalNodeIdMap;
00303 vtkstd::map<vtkIdType, vtkIdType> *LocalElementIdMap;
00304
00305 vtkIdType GetNodeLocalId(vtkIdType id);
00306 vtkIdType GetElementLocalId(vtkIdType id);
00307
00308 int WriteInitializationParameters ();
00309 int WriteQARecords ();
00310 int WriteInformationRecords ();
00311 int WritePoints ();
00312 int WriteCoordinateNames ();
00313 int WriteGlobalPointIds ();
00314 int WriteBlockInformation ();
00315 int WriteGlobalElementIds ();
00316 int WriteVariableArrayNames ();
00317 int WriteNodeSetInformation ();
00318 int WriteSideSetInformation ();
00319 int WriteProperties ();
00320 int WriteNextTimeStep ();
00321
00322
00323 double ExtractGlobalData (const char *name, int comp, int ts);
00324 int WriteGlobalData (int timestep, vtkDataArray *buffer);
00325 void ExtractCellData (const char *name, int comp, vtkDataArray *buffer);
00326 int WriteCellData (int timestep, vtkDataArray *buffer);
00327 void ExtractPointData (const char *name, int comp, vtkDataArray *buffer);
00328 int WritePointData (int timestep, vtkDataArray *buffer);
00329
00330
00331
00332 private:
00333 vtkExodusIIWriter (const vtkExodusIIWriter&);
00334 void operator= (const vtkExodusIIWriter&);
00335 };
00336
00337 #endif