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) override;
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, vtkTypeBool);
142  vtkGetMacro(WriteOutBlockIdArray, vtkTypeBool);
143  vtkBooleanMacro(WriteOutBlockIdArray, vtkTypeBool);
144 
151  vtkSetMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
152  vtkGetMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
153  vtkBooleanMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
154 
161  vtkSetMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
162  vtkGetMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
163  vtkBooleanMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
164 
170  vtkSetMacro(WriteAllTimeSteps, vtkTypeBool);
171  vtkGetMacro(WriteAllTimeSteps, vtkTypeBool);
172  vtkBooleanMacro(WriteAllTimeSteps, vtkTypeBool);
173 
174  vtkSetStringMacro(BlockIdArrayName);
175  vtkGetStringMacro(BlockIdArrayName);
176 
182  vtkSetMacro(IgnoreMetaDataWarning, bool);
183  vtkGetMacro(IgnoreMetaDataWarning, bool);
184  vtkBooleanMacro(IgnoreMetaDataWarning, bool);
185 
186 protected:
188  ~vtkExodusIIWriter () override;
189 
191 
193 
194  char *FileName;
195  int fid;
196 
198  int MyRank;
199 
201 
209 
214 
216  std::vector< vtkSmartPointer<vtkUnstructuredGrid> > FlattenedInput;
217  std::vector< vtkSmartPointer<vtkUnstructuredGrid> > NewFlattenedInput;
218 
219  std::vector< vtkStdString > FlattenedNames;
220  std::vector< vtkStdString > NewFlattenedNames;
221 
222  std::vector< vtkIntArray* > BlockIdList;
223 
224  struct Block
225  {
226  Block ()
227  {
228  this->Name = nullptr;
229  this->Type = 0;
230  this->NumElements = 0;
231  this->ElementStartIndex = -1;
232  this->NodesPerElement = 0;
233  this->EntityCounts = std::vector<int>();
234  this->EntityNodeOffsets = std::vector<int>();
235  this->GridIndex = 0;
236  this->OutputIndex = -1;
237  this->NumAttributes = 0;
238  this->BlockAttributes = nullptr;
239  };
240  const char *Name;
241  int Type;
245  std::vector<int> EntityCounts;
246  std::vector<int> EntityNodeOffsets;
247  size_t GridIndex;
248  // std::vector<int> CellIndex;
251  float *BlockAttributes; // Owned by metamodel or null. Don't delete.
252  };
253  std::map<int, Block> BlockInfoMap;
254  int NumCells, NumPoints, MaxId;
255 
256  std::vector<vtkIdType*> GlobalElementIdList;
257  std::vector<vtkIdType*> GlobalNodeIdList;
258 
261 
263  {
265  int InIndex;
267  std::vector<std::string> OutNames;
268  };
269  std::map<std::string, VariableInfo> GlobalVariableMap;
270  std::map<std::string, VariableInfo> BlockVariableMap;
271  std::map<std::string, VariableInfo> NodeVariableMap;
275 
276  std::vector< std::vector<int> > CellToElementOffset;
277 
278  // By BlockId, and within block ID by element variable, with variables
279  // appearing in the same order in which they appear in OutputElementArrayNames
280 
283 
284  int BlockVariableTruthValue(int blockIdx, int varIdx);
285 
286  char *StrDupWithNew (const char *s);
287  void StringUppercase (std::string& str);
288 
289  int ProcessRequest (vtkInformation* request,
290  vtkInformationVector** inputVector,
291  vtkInformationVector* outputVector) override;
292 
293  int RequestInformation (vtkInformation* request,
294  vtkInformationVector** inputVector,
295  vtkInformationVector* outputVector);
296 
297  virtual int RequestUpdateExtent (vtkInformation* request,
298  vtkInformationVector** inputVector,
299  vtkInformationVector* outputVector);
300 
301  int FillInputPortInformation (int port, vtkInformation* info) override;
302 
303  int RequestData (vtkInformation* request,
304  vtkInformationVector** inputVector,
305  vtkInformationVector* outputVector) override;
306 
307  void WriteData () override;
308 
309  int FlattenHierarchy (vtkDataObject* input, const char *name, bool& changed);
310 
311  int CreateNewExodusFile ();
312  void CloseExodusFile ();
313 
314  int IsDouble ();
315  void RemoveGhostCells ();
316  int CheckParametersInternal (int NumberOfProcesses, int MyRank);
317  virtual int CheckParameters ();
318  // If writing in parallel multiple time steps exchange after each time step
319  // if we should continue the execution. Pass local continueExecution as a
320  // parameter and return the global continueExecution.
321  virtual int GlobalContinueExecuting(int localContinueExecution);
322  int CheckInputArrays ();
323  virtual void CheckBlockInfoMap();
324  int ConstructBlockInfoMap ();
325  int ConstructVariableInfoMaps ();
326  int ParseMetadata ();
327  int CreateDefaultMetadata ();
328  char *GetCellTypeName (int t);
329 
330  int CreateBlockIdMetadata(vtkModelMetadata *em);
331  int CreateBlockVariableMetadata (vtkModelMetadata* em);
332  int CreateSetsMetadata (vtkModelMetadata* em);
333 
334  void ConvertVariableNames (std::map<std::string, VariableInfo>& variableMap);
335  char **FlattenOutVariableNames (
336  int nScalarArrays,
337  const std::map<std::string, VariableInfo>& variableMap);
338  std::string CreateNameForScalarArray (const char *root,
339  int component,
340  int numComponents);
341 
342  std::map<vtkIdType, vtkIdType> *LocalNodeIdMap;
343  std::map<vtkIdType, vtkIdType> *LocalElementIdMap;
344 
345  vtkIdType GetNodeLocalId(vtkIdType id);
346  vtkIdType GetElementLocalId(vtkIdType id);
347  int GetElementType(vtkIdType id);
348 
349  int WriteInitializationParameters ();
350  int WriteInformationRecords ();
351  int WritePoints ();
352  int WriteCoordinateNames ();
353  int WriteGlobalPointIds ();
354  int WriteBlockInformation ();
355  int WriteGlobalElementIds ();
356  int WriteVariableArrayNames ();
357  int WriteNodeSetInformation ();
358  int WriteSideSetInformation ();
359  int WriteProperties ();
360  int WriteNextTimeStep ();
361  vtkIntArray* GetBlockIdArray (
362  const char* BlockIdArrayName, vtkUnstructuredGrid* input);
363  static bool SameTypeOfCells (vtkIntArray* cellToBlockId,
364  vtkUnstructuredGrid* input);
365 
366  double ExtractGlobalData (const char *name, int comp, int ts);
367  int WriteGlobalData (int timestep, vtkDataArray *buffer);
368  void ExtractCellData (const char *name, int comp, vtkDataArray *buffer);
369  int WriteCellData (int timestep, vtkDataArray *buffer);
370  void ExtractPointData (const char *name, int comp, vtkDataArray *buffer);
371  int WritePointData (int timestep, vtkDataArray *buffer);
372 
377  virtual unsigned int GetMaxNameLength();
378 
379 private:
380  vtkExodusIIWriter (const vtkExodusIIWriter&) = delete;
381  void operator= (const vtkExodusIIWriter&) = delete;
382 };
383 
384 #endif
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > NewFlattenedInput
vtkTypeBool WriteOutBlockIdArray
std::map< std::string, VariableInfo > BlockVariableMap
std::map< std::string, VariableInfo > NodeVariableMap
int * BlockElementVariableTruthTable
Store vtkAlgorithm input/output information.
std::map< vtkIdType, vtkIdType > * LocalElementIdMap
std::vector< std::vector< int > > CellToElementOffset
vtkTypeBool WriteAllTimeSteps
std::vector< vtkStdString > FlattenedNames
std::vector< vtkIdType * > GlobalNodeIdList
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > FlattenedInput
int vtkIdType
Definition: vtkType.h:347
vtkDataObject * OriginalInput
dynamic, self-adjusting array of double
int vtkTypeBool
Definition: vtkABI.h:69
std::vector< vtkIntArray * > BlockIdList
abstract class to write data to file(s)
Definition: vtkWriter.h:42
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTypeBool WriteOutGlobalNodeIdArray
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
std::vector< int > EntityCounts
std::vector< int > EntityNodeOffsets
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()
std::map< std::string, VariableInfo > GlobalVariableMap
general representation of visualization data
Definition: vtkDataObject.h:64
std::vector< vtkStdString > NewFlattenedNames
std::map< vtkIdType, vtkIdType > * LocalNodeIdMap
vtkTypeBool WriteOutGlobalElementIdArray
vtkModelMetadata * ModelMetadata