VTK
vtkExodusIIWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkExodusIIWriter.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*----------------------------------------------------------------------------
16  Copyright (c) Sandia Corporation
17  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
18 ----------------------------------------------------------------------------*/
19 
70 #ifndef __vtkExodusIIWriter_h
71 #define __vtkExodusIIWriter_h
72 
73 #include "vtkWriter.h"
74 #include "vtkSmartPointer.h" // For vtkSmartPointer
75 
76 #include <vtkstd/vector> // STL Header
77 #include <vtkstd/map> // STL Header
78 #include <vtkstd/string> // STL Header
79 
80 class vtkModelMetadata;
81 class vtkDoubleArray;
82 class vtkIntArray;
84 
86 {
87 public:
88  static vtkExodusIIWriter *New ();
90  void PrintSelf (ostream& os, vtkIndent indent);
91 
100  void SetModelMetadata (vtkModelMetadata*);
101  vtkGetObjectMacro(ModelMetadata, vtkModelMetadata);
102 
108  vtkSetStringMacro(FileName);
109  vtkGetStringMacro(FileName);
110 
116  vtkSetMacro(StoreDoubles, int);
117  vtkGetMacro(StoreDoubles, int);
118 
122  vtkSetMacro(GhostLevel, int);
123  vtkGetMacro(GhostLevel, int);
124 
130  vtkSetMacro(WriteOutBlockIdArray, int);
131  vtkGetMacro(WriteOutBlockIdArray, int);
132  vtkBooleanMacro(WriteOutBlockIdArray, int);
133 
138  vtkSetMacro(WriteOutGlobalNodeIdArray, int);
139  vtkGetMacro(WriteOutGlobalNodeIdArray, int);
140  vtkBooleanMacro(WriteOutGlobalNodeIdArray, int);
141 
146  vtkSetMacro(WriteOutGlobalElementIdArray, int);
147  vtkGetMacro(WriteOutGlobalElementIdArray, int);
148  vtkBooleanMacro(WriteOutGlobalElementIdArray, int);
149 
153  vtkSetMacro(WriteAllTimeSteps, int);
154  vtkGetMacro(WriteAllTimeSteps, int);
155  vtkBooleanMacro(WriteAllTimeSteps, int);
156 
157  vtkSetStringMacro(BlockIdArrayName);
158  vtkGetStringMacro(BlockIdArrayName);
159 
160 protected:
162  ~vtkExodusIIWriter ();
163 
165 
167 
168  char *FileName;
169  int fid;
170 
172  int MyRank;
173 
175 
183 
187 
188 //BTX
190  vtkstd::vector< vtkSmartPointer<vtkUnstructuredGrid> > FlattenedInput;
191  vtkstd::vector< vtkSmartPointer<vtkUnstructuredGrid> > NewFlattenedInput;
192 
193  vtkstd::vector< vtkIntArray* > BlockIdList;
194 
195  struct Block
196  {
197  Block ()
198  {
199  this->Type = 0;
200  this->NumElements = 0;
201  this->ElementStartIndex = -1;
202  this->NodesPerElement = 0;
203  this->EntityCounts = std::vector<int>();
204  this->EntityNodeOffsets = std::vector<int>();
205  this->GridIndex = 0;
206  this->OutputIndex = -1;
207  this->NumAttributes = 0;
208  this->BlockAttributes = 0;
209  };
210  int Type;
214  std::vector<int> EntityCounts;
215  std::vector<int> EntityNodeOffsets;
216  size_t GridIndex;
217  // vtkstd::vector<int> CellIndex;
220  float *BlockAttributes; // Owned by metamodel or null. Don't delete.
221  };
222  vtkstd::map<int, Block> BlockInfoMap;
223  int NumCells, NumPoints, MaxId;
224 
225  vtkstd::vector<vtkIdType*> GlobalElementIdList;
226  vtkstd::vector<vtkIdType*> GlobalNodeIdList;
227 //ETX
230 
231 //BTX
233  {
235  int InIndex;
237  vtkstd::vector<vtkstd::string> OutNames;
238  };
239  vtkstd::map<vtkstd::string, VariableInfo> GlobalVariableMap;
240  vtkstd::map<vtkstd::string, VariableInfo> BlockVariableMap;
241  vtkstd::map<vtkstd::string, VariableInfo> NodeVariableMap;
245 //ETX
246 
247 //BTX
248  vtkstd::vector< vtkstd::vector<int> > CellToElementOffset;
249 //ETX
250  // By BlockId, and within block ID by element variable, with variables
251  // appearing in the same order in which they appear in OutputElementArrayNames
252 
255 
256  int BlockVariableTruthValue(int blockIdx, int varIdx);
257 
258 //BTX
259  char *StrDupWithNew (const char *s);
260  void StringUppercase (vtkstd::string& str);
261 //ETX
262 
263  int ProcessRequest (vtkInformation* request,
264  vtkInformationVector** inputVector,
265  vtkInformationVector* outputVector);
266 
267  int RequestInformation (vtkInformation* request,
268  vtkInformationVector** inputVector,
269  vtkInformationVector* outputVector);
270 
272 
273  int RequestData (vtkInformation* request,
274  vtkInformationVector** inputVector,
275  vtkInformationVector* outputVector);
276 
277  void WriteData ();
278 
279  int FlattenHierarchy (vtkDataObject* input, bool& changed);
280 
281  int CreateNewExodusFile ();
282  void CloseExodusFile ();
283 
284  int IsDouble ();
285  void RemoveGhostCells ();
286  int CheckParameters ();
287  int CheckInputArrays ();
288  int ConstructBlockInfoMap ();
289  int ConstructVariableInfoMaps ();
290  int ParseMetadata ();
291  int CreateDefaultMetadata ();
292  char *GetCellTypeName (int t);
293 
294  int CreateBlockIdMetadata(vtkModelMetadata *em);
295  int CreateBlockVariableMetadata (vtkModelMetadata* em);
296 
297 //BTX
298  void ConvertVariableNames (vtkstd::map<vtkstd::string, VariableInfo>& variableMap);
299  char **FlattenOutVariableNames (
300  int nScalarArrays,
301  const vtkstd::map<vtkstd::string, VariableInfo>& variableMap);
302  vtkstd::string CreateNameForScalarArray (const char *root,
303  int component,
304  int numComponents);
305 
306  vtkstd::map<vtkIdType, vtkIdType> *LocalNodeIdMap;
307  vtkstd::map<vtkIdType, vtkIdType> *LocalElementIdMap;
308 //ETX
309  vtkIdType GetNodeLocalId(vtkIdType id);
310  vtkIdType GetElementLocalId(vtkIdType id);
311 
312  int WriteInitializationParameters ();
313  int WriteQARecords ();
314  int WriteInformationRecords ();
315  int WritePoints ();
316  int WriteCoordinateNames ();
317  int WriteGlobalPointIds ();
318  int WriteBlockInformation ();
319  int WriteGlobalElementIds ();
320  int WriteVariableArrayNames ();
321  int WriteNodeSetInformation ();
322  int WriteSideSetInformation ();
323  int WriteProperties ();
324  int WriteNextTimeStep ();
325 
326 //BTX
327  double ExtractGlobalData (const char *name, int comp, int ts);
328  int WriteGlobalData (int timestep, vtkDataArray *buffer);
329  void ExtractCellData (const char *name, int comp, vtkDataArray *buffer);
330  int WriteCellData (int timestep, vtkDataArray *buffer);
331  void ExtractPointData (const char *name, int comp, vtkDataArray *buffer);
332  int WritePointData (int timestep, vtkDataArray *buffer);
333 //ETX
334 
335 
336 private:
337  vtkExodusIIWriter (const vtkExodusIIWriter&); // Not Implemented
338  void operator= (const vtkExodusIIWriter&); // Not Implemented
339 };
340 
341 #endif