VTK  9.1.0
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 
87 #ifndef vtkExodusIIWriter_h
88 #define vtkExodusIIWriter_h
89 
90 #include "vtkIOExodusModule.h" // For export macro
91 #include "vtkSmartPointer.h" // For vtkSmartPointer
92 #include "vtkWriter.h"
93 
94 #include <map> // STL Header
95 #include <string> // STL Header
96 #include <vector> // STL Header
97 
98 class vtkModelMetadata;
99 class vtkDoubleArray;
100 class vtkIntArray;
101 class vtkUnstructuredGrid;
102 
103 class VTKIOEXODUS_EXPORT vtkExodusIIWriter : public vtkWriter
104 {
105 public:
107  vtkTypeMacro(vtkExodusIIWriter, vtkWriter);
108  void PrintSelf(ostream& os, vtkIndent indent) override;
109 
121  vtkGetObjectMacro(ModelMetadata, vtkModelMetadata);
122 
132 
140  vtkSetMacro(StoreDoubles, int);
141  vtkGetMacro(StoreDoubles, int);
142 
148  vtkSetMacro(GhostLevel, int);
149  vtkGetMacro(GhostLevel, int);
150 
157  vtkSetMacro(WriteOutBlockIdArray, vtkTypeBool);
158  vtkGetMacro(WriteOutBlockIdArray, vtkTypeBool);
159  vtkBooleanMacro(WriteOutBlockIdArray, vtkTypeBool);
160 
167  vtkSetMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
168  vtkGetMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
169  vtkBooleanMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
170 
177  vtkSetMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
178  vtkGetMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
179  vtkBooleanMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
180 
186  vtkSetMacro(WriteAllTimeSteps, vtkTypeBool);
187  vtkGetMacro(WriteAllTimeSteps, vtkTypeBool);
188  vtkBooleanMacro(WriteAllTimeSteps, vtkTypeBool);
189 
190  vtkSetStringMacro(BlockIdArrayName);
191  vtkGetStringMacro(BlockIdArrayName);
192 
198  vtkSetMacro(IgnoreMetaDataWarning, bool);
199  vtkGetMacro(IgnoreMetaDataWarning, bool);
200  vtkBooleanMacro(IgnoreMetaDataWarning, bool);
201 
202 protected:
204  ~vtkExodusIIWriter() override;
205 
207 
209 
210  char* FileName;
211  int fid;
212 
214  int MyRank;
215 
217 
225 
230 
232  std::vector<vtkSmartPointer<vtkUnstructuredGrid>> FlattenedInput;
233  std::vector<vtkSmartPointer<vtkUnstructuredGrid>> NewFlattenedInput;
234 
235  std::vector<vtkStdString> FlattenedNames;
236  std::vector<vtkStdString> NewFlattenedNames;
237 
238  std::vector<vtkIntArray*> BlockIdList;
239 
240  struct Block
241  {
243  {
244  this->Name = nullptr;
245  this->Type = 0;
246  this->NumElements = 0;
247  this->ElementStartIndex = -1;
248  this->NodesPerElement = 0;
249  this->EntityCounts = std::vector<int>();
250  this->EntityNodeOffsets = std::vector<int>();
251  this->GridIndex = 0;
252  this->OutputIndex = -1;
253  this->NumAttributes = 0;
254  this->BlockAttributes = nullptr;
255  };
256  const char* Name;
257  int Type;
261  std::vector<int> EntityCounts;
262  std::vector<int> EntityNodeOffsets;
263  size_t GridIndex;
264  // std::vector<int> CellIndex;
267  float* BlockAttributes; // Owned by metamodel or null. Don't delete.
268  };
269  std::map<int, Block> BlockInfoMap;
270  int NumCells, NumPoints, MaxId;
271 
272  std::vector<vtkIdType*> GlobalElementIdList;
273  std::vector<vtkIdType*> GlobalNodeIdList;
274 
277 
279  {
281  int InIndex;
283  std::vector<std::string> OutNames;
284  };
285  std::map<std::string, VariableInfo> GlobalVariableMap;
286  std::map<std::string, VariableInfo> BlockVariableMap;
287  std::map<std::string, VariableInfo> NodeVariableMap;
291 
292  std::vector<std::vector<int>> CellToElementOffset;
293 
294  // By BlockId, and within block ID by element variable, with variables
295  // appearing in the same order in which they appear in OutputElementArrayNames
296 
299 
300  int BlockVariableTruthValue(int blockIdx, int varIdx);
301 
302  char* StrDupWithNew(const char* s);
304 
306  vtkInformationVector* outputVector) override;
307 
309  vtkInformationVector* outputVector);
310 
311  virtual int RequestUpdateExtent(vtkInformation* request, vtkInformationVector** inputVector,
312  vtkInformationVector* outputVector);
313 
315 
316  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
317  vtkInformationVector* outputVector) override;
318 
319  void WriteData() override;
320 
321  int FlattenHierarchy(vtkDataObject* input, const char* name, bool& changed);
322 
325 
326  int IsDouble();
328  int CheckParametersInternal(int numberOfProcesses, int myRank);
329  virtual int CheckParameters();
330  // If writing in parallel multiple time steps exchange after each time step
331  // if we should continue the execution. Pass local continueExecution as a
332  // parameter and return the global continueExecution.
333  virtual int GlobalContinueExecuting(int localContinueExecution);
335  virtual void CheckBlockInfoMap();
340  char* GetCellTypeName(int t);
341 
345 
346  void ConvertVariableNames(std::map<std::string, VariableInfo>& variableMap);
348  int nScalarArrays, const std::map<std::string, VariableInfo>& variableMap);
349  std::string CreateNameForScalarArray(const char* root, int component, int numComponents);
350 
351  std::map<vtkIdType, vtkIdType>* LocalNodeIdMap;
352  std::map<vtkIdType, vtkIdType>* LocalElementIdMap;
353 
357 
360  int WritePoints();
370  vtkIntArray* GetBlockIdArray(const char* BlockIdArrayName, vtkUnstructuredGrid* input);
371  static bool SameTypeOfCells(vtkIntArray* cellToBlockId, vtkUnstructuredGrid* input);
372 
373  double ExtractGlobalData(const char* name, int comp, int ts);
374  int WriteGlobalData(int timestep, vtkDataArray* buffer);
375  void ExtractCellData(const char* name, int comp, vtkDataArray* buffer);
376  int WriteCellData(int timestep, vtkDataArray* buffer);
377  void ExtractPointData(const char* name, int comp, vtkDataArray* buffer);
378  int WritePointData(int timestep, vtkDataArray* buffer);
379 
384  virtual unsigned int GetMaxNameLength();
385 
386 private:
387  vtkExodusIIWriter(const vtkExodusIIWriter&) = delete;
388  void operator=(const vtkExodusIIWriter&) = delete;
389 };
390 
391 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
general representation of visualization data
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:113
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:149
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:43
@ 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