VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "vtkIOExodusModule.h" // For export macro
74 #include "vtkWriter.h"
75 #include "vtkSmartPointer.h" // For vtkSmartPointer
76 
77 #include <vector> // STL Header
78 #include <map> // STL Header
79 #include <string> // STL Header
80 
81 class vtkModelMetadata;
82 class vtkDoubleArray;
83 class vtkIntArray;
85 
87 {
88 public:
89  static vtkExodusIIWriter *New ();
91  void PrintSelf (ostream& os, vtkIndent indent);
92 
101  void SetModelMetadata (vtkModelMetadata*);
102  vtkGetObjectMacro(ModelMetadata, vtkModelMetadata);
103 
109  vtkSetStringMacro(FileName);
110  vtkGetStringMacro(FileName);
111 
117  vtkSetMacro(StoreDoubles, int);
118  vtkGetMacro(StoreDoubles, int);
119 
123  vtkSetMacro(GhostLevel, int);
124  vtkGetMacro(GhostLevel, int);
125 
131  vtkSetMacro(WriteOutBlockIdArray, int);
132  vtkGetMacro(WriteOutBlockIdArray, int);
133  vtkBooleanMacro(WriteOutBlockIdArray, int);
134 
139  vtkSetMacro(WriteOutGlobalNodeIdArray, int);
140  vtkGetMacro(WriteOutGlobalNodeIdArray, int);
141  vtkBooleanMacro(WriteOutGlobalNodeIdArray, int);
142 
147  vtkSetMacro(WriteOutGlobalElementIdArray, int);
148  vtkGetMacro(WriteOutGlobalElementIdArray, int);
149  vtkBooleanMacro(WriteOutGlobalElementIdArray, int);
150 
154  vtkSetMacro(WriteAllTimeSteps, int);
155  vtkGetMacro(WriteAllTimeSteps, int);
156  vtkBooleanMacro(WriteAllTimeSteps, int);
157 
158  vtkSetStringMacro(BlockIdArrayName);
159  vtkGetStringMacro(BlockIdArrayName);
160 
161 protected:
163  ~vtkExodusIIWriter ();
164 
166 
168 
169  char *FileName;
170  int fid;
171 
173  int MyRank;
174 
176 
184 
188 
189 //BTX
191  std::vector< vtkSmartPointer<vtkUnstructuredGrid> > FlattenedInput;
192  std::vector< vtkSmartPointer<vtkUnstructuredGrid> > NewFlattenedInput;
193 
194  std::vector< vtkIntArray* > BlockIdList;
195 
196  struct Block
197  {
198  Block ()
199  {
200  this->Type = 0;
201  this->NumElements = 0;
202  this->ElementStartIndex = -1;
203  this->NodesPerElement = 0;
204  this->EntityCounts = std::vector<int>();
205  this->EntityNodeOffsets = std::vector<int>();
206  this->GridIndex = 0;
207  this->OutputIndex = -1;
208  this->NumAttributes = 0;
209  this->BlockAttributes = 0;
210  };
211  int Type;
215  std::vector<int> EntityCounts;
216  std::vector<int> EntityNodeOffsets;
217  size_t GridIndex;
218  // std::vector<int> CellIndex;
221  float *BlockAttributes; // Owned by metamodel or null. Don't delete.
222  };
223  std::map<int, Block> BlockInfoMap;
224  int NumCells, NumPoints, MaxId;
225 
226  std::vector<vtkIdType*> GlobalElementIdList;
227  std::vector<vtkIdType*> GlobalNodeIdList;
228 //ETX
231 
232 //BTX
234  {
236  int InIndex;
238  std::vector<std::string> OutNames;
239  };
240  std::map<std::string, VariableInfo> GlobalVariableMap;
241  std::map<std::string, VariableInfo> BlockVariableMap;
242  std::map<std::string, VariableInfo> NodeVariableMap;
246 //ETX
247 
248 //BTX
249  std::vector< std::vector<int> > CellToElementOffset;
250 //ETX
251  // By BlockId, and within block ID by element variable, with variables
252  // appearing in the same order in which they appear in OutputElementArrayNames
253 
256 
257  int BlockVariableTruthValue(int blockIdx, int varIdx);
258 
259 //BTX
260  char *StrDupWithNew (const char *s);
261  void StringUppercase (std::string& str);
262 //ETX
263 
264  int ProcessRequest (vtkInformation* request,
265  vtkInformationVector** inputVector,
266  vtkInformationVector* outputVector);
267 
268  int RequestInformation (vtkInformation* request,
269  vtkInformationVector** inputVector,
270  vtkInformationVector* outputVector);
271 
273 
274  int RequestData (vtkInformation* request,
275  vtkInformationVector** inputVector,
276  vtkInformationVector* outputVector);
277 
278  void WriteData ();
279 
280  int FlattenHierarchy (vtkDataObject* input, bool& changed);
281 
282  int CreateNewExodusFile ();
283  void CloseExodusFile ();
284 
285  int IsDouble ();
286  void RemoveGhostCells ();
287  int CheckParametersInternal (int NumberOfProcesses, int MyRank);
288  virtual int CheckParameters ();
289  int CheckInputArrays ();
290  virtual void CheckBlockInfoMap();
291  int ConstructBlockInfoMap ();
292  int ConstructVariableInfoMaps ();
293  int ParseMetadata ();
294  int CreateDefaultMetadata ();
295  char *GetCellTypeName (int t);
296 
297  int CreateBlockIdMetadata(vtkModelMetadata *em);
298  int CreateBlockVariableMetadata (vtkModelMetadata* em);
299 
300 //BTX
301  void ConvertVariableNames (std::map<std::string, VariableInfo>& variableMap);
302  char **FlattenOutVariableNames (
303  int nScalarArrays,
304  const std::map<std::string, VariableInfo>& variableMap);
305  std::string CreateNameForScalarArray (const char *root,
306  int component,
307  int numComponents);
308 
309  std::map<vtkIdType, vtkIdType> *LocalNodeIdMap;
310  std::map<vtkIdType, vtkIdType> *LocalElementIdMap;
311 //ETX
312  vtkIdType GetNodeLocalId(vtkIdType id);
313  vtkIdType GetElementLocalId(vtkIdType id);
314 
315  int WriteInitializationParameters ();
316  int WriteQARecords ();
317  int WriteInformationRecords ();
318  int WritePoints ();
319  int WriteCoordinateNames ();
320  int WriteGlobalPointIds ();
321  int WriteBlockInformation ();
322  int WriteGlobalElementIds ();
323  int WriteVariableArrayNames ();
324  int WriteNodeSetInformation ();
325  int WriteSideSetInformation ();
326  int WriteProperties ();
327  int WriteNextTimeStep ();
328 
329 //BTX
330  double ExtractGlobalData (const char *name, int comp, int ts);
331  int WriteGlobalData (int timestep, vtkDataArray *buffer);
332  void ExtractCellData (const char *name, int comp, vtkDataArray *buffer);
333  int WriteCellData (int timestep, vtkDataArray *buffer);
334  void ExtractPointData (const char *name, int comp, vtkDataArray *buffer);
335  int WritePointData (int timestep, vtkDataArray *buffer);
336 //ETX
337 
338 
339 private:
340  vtkExodusIIWriter (const vtkExodusIIWriter&); // Not Implemented
341  void operator= (const vtkExodusIIWriter&); // Not Implemented
342 };
343 
344 #endif
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > NewFlattenedInput
std::map< std::string, VariableInfo > BlockVariableMap
std::map< std::string, VariableInfo > NodeVariableMap
int * BlockElementVariableTruthTable
GLuint buffer
Definition: vtkgl.h:11839
Store vtkAlgorithm input/output information.
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
std::map< vtkIdType, vtkIdType > * LocalElementIdMap
vtkDoubleArray * TimeValues
std::vector< std::vector< int > > CellToElementOffset
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
std::vector< vtkIdType * > GlobalNodeIdList
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > FlattenedInput
int vtkIdType
Definition: vtkType.h:268
GLdouble GLdouble t
Definition: vtkgl.h:11602
virtual int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkDataObject * OriginalInput
#define vtkSetStringMacro(name)
Definition: vtkSetGet.h:94
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
dynamic, self-adjusting array of double
std::vector< vtkIntArray * > BlockIdList
abstract class to write data to file(s)
Definition: vtkWriter.h:44
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
GLuint const GLchar * name
Definition: vtkgl.h:11983
a simple class to control print indentation
Definition: vtkIndent.h:38
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
std::vector< int > EntityCounts
#define VTKIOEXODUS_EXPORT
std::vector< int > EntityNodeOffsets
#define vtkGetStringMacro(name)
Definition: vtkSetGet.h:120
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
virtual int FillInputPortInformation(int port, vtkInformation *info)
std::vector< std::string > OutNames
This class encapsulates the metadata that appear in mesh-based file formats but do not appear in vtkU...
std::map< int, Block > BlockInfoMap
std::vector< vtkIdType * > GlobalElementIdList
Write Exodus II files.
GLdouble s
Definition: vtkgl.h:11594
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
virtual void WriteData()=0
std::map< std::string, VariableInfo > GlobalVariableMap
general representation of visualization data
Definition: vtkDataObject.h:64
std::map< vtkIdType, vtkIdType > * LocalNodeIdMap
GLsizei const GLchar ** string
Definition: vtkgl.h:12011
void PrintSelf(ostream &os, vtkIndent indent)
vtkModelMetadata * ModelMetadata
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69