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 
71 #ifndef vtkExodusIIWriter_h
72 #define vtkExodusIIWriter_h
73 
74 #include "vtkIOExodusModule.h" // For export macro
75 #include "vtkWriter.h"
76 #include "vtkSmartPointer.h" // For vtkSmartPointer
77 
78 #include <vector> // STL Header
79 #include <map> // STL Header
80 #include <string> // STL Header
81 
82 class vtkModelMetadata;
83 class vtkDoubleArray;
84 class vtkIntArray;
86 
87 class VTKIOEXODUS_EXPORT vtkExodusIIWriter : public vtkWriter
88 {
89 public:
90  static vtkExodusIIWriter *New ();
92  void PrintSelf (ostream& os, vtkIndent indent);
93 
104  void SetModelMetadata (vtkModelMetadata*);
105  vtkGetObjectMacro(ModelMetadata, vtkModelMetadata);
106 
114  vtkSetStringMacro(FileName);
115  vtkGetStringMacro(FileName);
116 
124  vtkSetMacro(StoreDoubles, int);
125  vtkGetMacro(StoreDoubles, int);
126 
132  vtkSetMacro(GhostLevel, int);
133  vtkGetMacro(GhostLevel, int);
134 
141  vtkSetMacro(WriteOutBlockIdArray, int);
142  vtkGetMacro(WriteOutBlockIdArray, int);
143  vtkBooleanMacro(WriteOutBlockIdArray, int);
144 
151  vtkSetMacro(WriteOutGlobalNodeIdArray, int);
152  vtkGetMacro(WriteOutGlobalNodeIdArray, int);
153  vtkBooleanMacro(WriteOutGlobalNodeIdArray, int);
154 
161  vtkSetMacro(WriteOutGlobalElementIdArray, int);
162  vtkGetMacro(WriteOutGlobalElementIdArray, int);
163  vtkBooleanMacro(WriteOutGlobalElementIdArray, int);
164 
170  vtkSetMacro(WriteAllTimeSteps, int);
171  vtkGetMacro(WriteAllTimeSteps, int);
172  vtkBooleanMacro(WriteAllTimeSteps, int);
173 
174  vtkSetStringMacro(BlockIdArrayName);
175  vtkGetStringMacro(BlockIdArrayName);
176 
177 protected:
179  ~vtkExodusIIWriter ();
180 
182 
184 
185  char *FileName;
186  int fid;
187 
189  int MyRank;
190 
192 
200 
205 
207  std::vector< vtkSmartPointer<vtkUnstructuredGrid> > FlattenedInput;
208  std::vector< vtkSmartPointer<vtkUnstructuredGrid> > NewFlattenedInput;
209 
210  std::vector< vtkStdString > FlattenedNames;
211  std::vector< vtkStdString > NewFlattenedNames;
212 
213  std::vector< vtkIntArray* > BlockIdList;
214 
215  struct Block
216  {
217  Block ()
218  {
219  this->Name = 0;
220  this->Type = 0;
221  this->NumElements = 0;
222  this->ElementStartIndex = -1;
223  this->NodesPerElement = 0;
224  this->EntityCounts = std::vector<int>();
225  this->EntityNodeOffsets = std::vector<int>();
226  this->GridIndex = 0;
227  this->OutputIndex = -1;
228  this->NumAttributes = 0;
229  this->BlockAttributes = 0;
230  };
231  const char *Name;
232  int Type;
236  std::vector<int> EntityCounts;
237  std::vector<int> EntityNodeOffsets;
238  size_t GridIndex;
239  // std::vector<int> CellIndex;
242  float *BlockAttributes; // Owned by metamodel or null. Don't delete.
243  };
244  std::map<int, Block> BlockInfoMap;
245  int NumCells, NumPoints, MaxId;
246 
247  std::vector<vtkIdType*> GlobalElementIdList;
248  std::vector<vtkIdType*> GlobalNodeIdList;
249 
252 
254  {
256  int InIndex;
258  std::vector<std::string> OutNames;
259  };
260  std::map<std::string, VariableInfo> GlobalVariableMap;
261  std::map<std::string, VariableInfo> BlockVariableMap;
262  std::map<std::string, VariableInfo> NodeVariableMap;
266 
267  std::vector< std::vector<int> > CellToElementOffset;
268 
269  // By BlockId, and within block ID by element variable, with variables
270  // appearing in the same order in which they appear in OutputElementArrayNames
271 
274 
275  int BlockVariableTruthValue(int blockIdx, int varIdx);
276 
277  char *StrDupWithNew (const char *s);
278  void StringUppercase (std::string& str);
279 
280  int ProcessRequest (vtkInformation* request,
281  vtkInformationVector** inputVector,
282  vtkInformationVector* outputVector);
283 
284  int RequestInformation (vtkInformation* request,
285  vtkInformationVector** inputVector,
286  vtkInformationVector* outputVector);
287 
288  virtual int RequestUpdateExtent (vtkInformation* request,
289  vtkInformationVector** inputVector,
290  vtkInformationVector* outputVector);
291 
293 
294  int RequestData (vtkInformation* request,
295  vtkInformationVector** inputVector,
296  vtkInformationVector* outputVector);
297 
298  void WriteData ();
299 
300  int FlattenHierarchy (vtkDataObject* input, const char *name, bool& changed);
301 
302  int CreateNewExodusFile ();
303  void CloseExodusFile ();
304 
305  int IsDouble ();
306  void RemoveGhostCells ();
307  int CheckParametersInternal (int NumberOfProcesses, int MyRank);
308  virtual int CheckParameters ();
309  // If writing in parallel multiple time steps exchange after each time step
310  // if we should continue the execution. Pass local continueExecution as a
311  // parameter and return the global continueExecution.
312  virtual int GlobalContinueExecuting(int localContinueExecution);
313  int CheckInputArrays ();
314  virtual void CheckBlockInfoMap();
315  int ConstructBlockInfoMap ();
316  int ConstructVariableInfoMaps ();
317  int ParseMetadata ();
318  int CreateDefaultMetadata ();
319  char *GetCellTypeName (int t);
320 
321  int CreateBlockIdMetadata(vtkModelMetadata *em);
322  int CreateBlockVariableMetadata (vtkModelMetadata* em);
323  int CreateSetsMetadata (vtkModelMetadata* em);
324 
325  void ConvertVariableNames (std::map<std::string, VariableInfo>& variableMap);
326  char **FlattenOutVariableNames (
327  int nScalarArrays,
328  const std::map<std::string, VariableInfo>& variableMap);
329  std::string CreateNameForScalarArray (const char *root,
330  int component,
331  int numComponents);
332 
333  std::map<vtkIdType, vtkIdType> *LocalNodeIdMap;
334  std::map<vtkIdType, vtkIdType> *LocalElementIdMap;
335 
336  vtkIdType GetNodeLocalId(vtkIdType id);
337  vtkIdType GetElementLocalId(vtkIdType id);
338  int GetElementType(vtkIdType id);
339 
340  int WriteInitializationParameters ();
341  int WriteInformationRecords ();
342  int WritePoints ();
343  int WriteCoordinateNames ();
344  int WriteGlobalPointIds ();
345  int WriteBlockInformation ();
346  int WriteGlobalElementIds ();
347  int WriteVariableArrayNames ();
348  int WriteNodeSetInformation ();
349  int WriteSideSetInformation ();
350  int WriteProperties ();
351  int WriteNextTimeStep ();
352  vtkIntArray* GetBlockIdArray (
353  const char* BlockIdArrayName, vtkUnstructuredGrid* input);
354  static bool SameTypeOfCells (vtkIntArray* cellToBlockId,
355  vtkUnstructuredGrid* input);
356 
357  double ExtractGlobalData (const char *name, int comp, int ts);
358  int WriteGlobalData (int timestep, vtkDataArray *buffer);
359  void ExtractCellData (const char *name, int comp, vtkDataArray *buffer);
360  int WriteCellData (int timestep, vtkDataArray *buffer);
361  void ExtractPointData (const char *name, int comp, vtkDataArray *buffer);
362  int WritePointData (int timestep, vtkDataArray *buffer);
363 
364 private:
365  vtkExodusIIWriter (const vtkExodusIIWriter&) VTK_DELETE_FUNCTION;
366  void operator= (const vtkExodusIIWriter&) VTK_DELETE_FUNCTION;
367 };
368 
369 #endif
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > NewFlattenedInput
std::map< std::string, VariableInfo > BlockVariableMap
std::map< std::string, VariableInfo > NodeVariableMap
int * BlockElementVariableTruthTable
Store vtkAlgorithm input/output information.
std::map< vtkIdType, vtkIdType > * LocalElementIdMap
vtkDoubleArray * TimeValues
std::vector< std::vector< int > > CellToElementOffset
std::vector< vtkStdString > FlattenedNames
std::vector< vtkIdType * > GlobalNodeIdList
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > FlattenedInput
int vtkIdType
Definition: vtkType.h:287
virtual int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
vtkDataObject * OriginalInput
dynamic, self-adjusting array of double
std::vector< vtkIntArray * > BlockIdList
abstract class to write data to file(s)
Definition: vtkWriter.h:42
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
a simple class to control print indentation
Definition: vtkIndent.h:39
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
std::vector< int > EntityCounts
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
std::vector< int > EntityNodeOffsets
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
virtual void WriteData()=0
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
std::map< std::string, VariableInfo > GlobalVariableMap
general representation of visualization data
Definition: vtkDataObject.h:64
std::vector< vtkStdString > NewFlattenedNames
std::map< vtkIdType, vtkIdType > * LocalNodeIdMap
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkModelMetadata * ModelMetadata