VTK  9.2.6
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 
80 #ifndef vtkExodusIIWriter_h
81 #define vtkExodusIIWriter_h
82 
83 #include "vtkIOExodusModule.h" // For export macro
84 #include "vtkSmartPointer.h" // For vtkSmartPointer
85 #include "vtkWriter.h"
86 
87 #include <map> // STL Header
88 #include <string> // STL Header
89 #include <vector> // STL Header
90 
91 class vtkModelMetadata;
92 class vtkDoubleArray;
93 class vtkIntArray;
95 
96 class VTKIOEXODUS_EXPORT vtkExodusIIWriter : public vtkWriter
97 {
98 public:
100  vtkTypeMacro(vtkExodusIIWriter, vtkWriter);
101  void PrintSelf(ostream& os, vtkIndent indent) override;
102 
114  vtkGetObjectMacro(ModelMetadata, vtkModelMetadata);
115 
125 
133  vtkSetMacro(StoreDoubles, int);
134  vtkGetMacro(StoreDoubles, int);
135 
141  vtkSetMacro(GhostLevel, int);
142  vtkGetMacro(GhostLevel, int);
143 
150  vtkSetMacro(WriteOutBlockIdArray, vtkTypeBool);
151  vtkGetMacro(WriteOutBlockIdArray, vtkTypeBool);
152  vtkBooleanMacro(WriteOutBlockIdArray, vtkTypeBool);
153 
160  vtkSetMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
161  vtkGetMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
162  vtkBooleanMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
163 
170  vtkSetMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
171  vtkGetMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
172  vtkBooleanMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
173 
179  vtkSetMacro(WriteAllTimeSteps, vtkTypeBool);
180  vtkGetMacro(WriteAllTimeSteps, vtkTypeBool);
181  vtkBooleanMacro(WriteAllTimeSteps, vtkTypeBool);
182 
183  vtkSetStringMacro(BlockIdArrayName);
184  vtkGetStringMacro(BlockIdArrayName);
185 
191  vtkSetMacro(IgnoreMetaDataWarning, bool);
192  vtkGetMacro(IgnoreMetaDataWarning, bool);
193  vtkBooleanMacro(IgnoreMetaDataWarning, bool);
194 
195 protected:
197  ~vtkExodusIIWriter() override;
198 
200 
202 
203  char* FileName;
204  int fid;
205 
207  int MyRank;
208 
210 
218 
223 
225  std::vector<vtkSmartPointer<vtkUnstructuredGrid>> FlattenedInput;
226  std::vector<vtkSmartPointer<vtkUnstructuredGrid>> NewFlattenedInput;
227 
228  std::vector<vtkStdString> FlattenedNames;
229  std::vector<vtkStdString> NewFlattenedNames;
230 
231  std::vector<vtkIntArray*> BlockIdList;
232 
233  struct Block
234  {
236  {
237  this->Name = nullptr;
238  this->Type = 0;
239  this->NumElements = 0;
240  this->ElementStartIndex = -1;
241  this->NodesPerElement = 0;
242  this->EntityCounts = std::vector<int>();
243  this->EntityNodeOffsets = std::vector<int>();
244  this->GridIndex = 0;
245  this->OutputIndex = -1;
246  this->NumAttributes = 0;
247  this->BlockAttributes = nullptr;
248  };
249  const char* Name;
250  int Type;
254  std::vector<int> EntityCounts;
255  std::vector<int> EntityNodeOffsets;
256  size_t GridIndex;
257  // std::vector<int> CellIndex;
260  float* BlockAttributes; // Owned by metamodel or null. Don't delete.
261  };
262  std::map<int, Block> BlockInfoMap;
263  int NumCells, NumPoints, MaxId;
264 
265  std::vector<vtkIdType*> GlobalElementIdList;
266  std::vector<vtkIdType*> GlobalNodeIdList;
267 
270 
272  {
274  int InIndex;
276  std::vector<std::string> OutNames;
277  };
278  std::map<std::string, VariableInfo> GlobalVariableMap;
279  std::map<std::string, VariableInfo> BlockVariableMap;
280  std::map<std::string, VariableInfo> NodeVariableMap;
284 
285  std::vector<std::vector<int>> CellToElementOffset;
286 
287  // By BlockId, and within block ID by element variable, with variables
288  // appearing in the same order in which they appear in OutputElementArrayNames
289 
292 
293  int BlockVariableTruthValue(int blockIdx, int varIdx);
294 
295  char* StrDupWithNew(const char* s);
297 
299  vtkInformationVector* outputVector) override;
300 
302  vtkInformationVector* outputVector);
303 
304  virtual int RequestUpdateExtent(vtkInformation* request, vtkInformationVector** inputVector,
305  vtkInformationVector* outputVector);
306 
308 
309  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
310  vtkInformationVector* outputVector) override;
311 
312  void WriteData() override;
313 
314  int FlattenHierarchy(vtkDataObject* input, const char* name, bool& changed);
315 
318 
319  int IsDouble();
321  int CheckParametersInternal(int numberOfProcesses, int myRank);
322  virtual int CheckParameters();
323  // If writing in parallel multiple time steps exchange after each time step
324  // if we should continue the execution. Pass local continueExecution as a
325  // parameter and return the global continueExecution.
326  virtual int GlobalContinueExecuting(int localContinueExecution);
328  virtual void CheckBlockInfoMap();
333  char* GetCellTypeName(int t);
334 
338 
339  void ConvertVariableNames(std::map<std::string, VariableInfo>& variableMap);
341  int nScalarArrays, const std::map<std::string, VariableInfo>& variableMap);
342  std::string CreateNameForScalarArray(const char* root, int component, int numComponents);
343 
344  std::map<vtkIdType, vtkIdType>* LocalNodeIdMap;
345  std::map<vtkIdType, vtkIdType>* LocalElementIdMap;
346 
350 
353  int WritePoints();
363  vtkIntArray* GetBlockIdArray(const char* BlockIdArrayName, vtkUnstructuredGrid* input);
364  static bool SameTypeOfCells(vtkIntArray* cellToBlockId, 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
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:65
general representation of visualization data
Definition: vtkDataObject.h:75
dynamic, self-adjusting array of double
Write Exodus II files.
int WriteSideSetInformation()
std::vector< std::vector< int > > CellToElementOffset
void StringUppercase(std::string &str)
static vtkExodusIIWriter * New()
std::map< vtkIdType, vtkIdType > * LocalNodeIdMap
~vtkExodusIIWriter() override
void SetModelMetadata(vtkModelMetadata *)
Specify the vtkModelMetadata object which contains the Exodus file model information (metadata) absen...
int WriteVariableArrayNames()
std::map< std::string, VariableInfo > BlockVariableMap
int WriteNodeSetInformation()
vtkIdType GetNodeLocalId(vtkIdType id)
int BlockVariableTruthValue(int blockIdx, int varIdx)
int CheckParametersInternal(int numberOfProcesses, int myRank)
void ConvertVariableNames(std::map< std::string, VariableInfo > &variableMap)
virtual int GlobalContinueExecuting(int localContinueExecution)
char ** FlattenOutVariableNames(int nScalarArrays, const std::map< std::string, VariableInfo > &variableMap)
static bool SameTypeOfCells(vtkIntArray *cellToBlockId, vtkUnstructuredGrid *input)
int GetElementType(vtkIdType id)
int CreateBlockVariableMetadata(vtkModelMetadata *em)
int WriteBlockInformation()
vtkTypeBool WriteAllTimeSteps
std::vector< vtkStdString > NewFlattenedNames
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > NewFlattenedInput
vtkModelMetadata * ModelMetadata
int WritePointData(int timestep, vtkDataArray *buffer)
vtkIdType GetElementLocalId(vtkIdType id)
virtual void CheckBlockInfoMap()
virtual int RequestUpdateExtent(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
std::vector< vtkIntArray * > BlockIdList
vtkSetFilePathMacro(FileName)
Name for the output file.
int FlattenHierarchy(vtkDataObject *input, const char *name, bool &changed)
std::string CreateNameForScalarArray(const char *root, int component, int numComponents)
int WriteGlobalElementIds()
int CreateSetsMetadata(vtkModelMetadata *em)
vtkDataObject * OriginalInput
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
vtkTypeBool WriteOutGlobalNodeIdArray
std::map< std::string, VariableInfo > GlobalVariableMap
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
int ConstructVariableInfoMaps()
std::map< std::string, VariableInfo > NodeVariableMap
double ExtractGlobalData(const char *name, int comp, int ts)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int ConstructBlockInfoMap()
virtual unsigned int GetMaxNameLength()
Get the maximum length name in the input data set.
int CreateDefaultMetadata()
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
int WriteCellData(int timestep, vtkDataArray *buffer)
int WriteInitializationParameters()
std::vector< vtkIdType * > GlobalNodeIdList
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > FlattenedInput
void WriteData() override
std::map< vtkIdType, vtkIdType > * LocalElementIdMap
char * StrDupWithNew(const char *s)
char * GetCellTypeName(int t)
void ExtractPointData(const char *name, int comp, vtkDataArray *buffer)
std::vector< vtkIdType * > GlobalElementIdList
int * BlockElementVariableTruthTable
virtual int CheckParameters()
vtkTypeBool WriteOutBlockIdArray
vtkGetFilePathMacro(FileName)
int WriteCoordinateNames()
void ExtractCellData(const char *name, int comp, vtkDataArray *buffer)
vtkIntArray * GetBlockIdArray(const char *BlockIdArrayName, vtkUnstructuredGrid *input)
std::map< int, Block > BlockInfoMap
int WriteGlobalData(int timestep, vtkDataArray *buffer)
int CreateBlockIdMetadata(vtkModelMetadata *em)
vtkTypeBool WriteOutGlobalElementIdArray
vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
int WriteInformationRecords()
std::vector< vtkStdString > FlattenedNames
a simple class to control print indentation
Definition: vtkIndent.h:49
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:55
This class encapsulates the metadata that appear in mesh-based file formats but do not appear in vtkU...
dataset represents arbitrary combinations of all possible cell types
abstract class to write data to file(s)
Definition: vtkWriter.h:46
@ component
Definition: vtkX3D.h:181
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
@ name
Definition: vtkX3D.h:225
@ string
Definition: vtkX3D.h:496
std::vector< int > EntityNodeOffsets
std::vector< int > EntityCounts
std::vector< std::string > OutNames
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332