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