VTK  9.0.1
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 
68 #ifndef vtkExodusIIWriter_h
69 #define vtkExodusIIWriter_h
70 
71 #include "vtkIOExodusModule.h" // For export macro
72 #include "vtkSmartPointer.h" // For vtkSmartPointer
73 #include "vtkWriter.h"
74 
75 #include <map> // STL Header
76 #include <string> // STL Header
77 #include <vector> // STL Header
78 
79 class vtkModelMetadata;
80 class vtkDoubleArray;
81 class vtkIntArray;
83 
84 class VTKIOEXODUS_EXPORT vtkExodusIIWriter : public vtkWriter
85 {
86 public:
87  static vtkExodusIIWriter* New();
88  vtkTypeMacro(vtkExodusIIWriter, vtkWriter);
89  void PrintSelf(ostream& os, vtkIndent indent) override;
90 
101  void SetModelMetadata(vtkModelMetadata*);
102  vtkGetObjectMacro(ModelMetadata, vtkModelMetadata);
103 
111  vtkSetStringMacro(FileName);
112  vtkGetStringMacro(FileName);
113 
121  vtkSetMacro(StoreDoubles, int);
122  vtkGetMacro(StoreDoubles, int);
123 
129  vtkSetMacro(GhostLevel, int);
130  vtkGetMacro(GhostLevel, int);
131 
138  vtkSetMacro(WriteOutBlockIdArray, vtkTypeBool);
139  vtkGetMacro(WriteOutBlockIdArray, vtkTypeBool);
140  vtkBooleanMacro(WriteOutBlockIdArray, vtkTypeBool);
141 
148  vtkSetMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
149  vtkGetMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
150  vtkBooleanMacro(WriteOutGlobalNodeIdArray, vtkTypeBool);
151 
158  vtkSetMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
159  vtkGetMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
160  vtkBooleanMacro(WriteOutGlobalElementIdArray, vtkTypeBool);
161 
167  vtkSetMacro(WriteAllTimeSteps, vtkTypeBool);
168  vtkGetMacro(WriteAllTimeSteps, vtkTypeBool);
169  vtkBooleanMacro(WriteAllTimeSteps, vtkTypeBool);
170 
171  vtkSetStringMacro(BlockIdArrayName);
172  vtkGetStringMacro(BlockIdArrayName);
173 
179  vtkSetMacro(IgnoreMetaDataWarning, bool);
180  vtkGetMacro(IgnoreMetaDataWarning, bool);
181  vtkBooleanMacro(IgnoreMetaDataWarning, bool);
182 
183 protected:
185  ~vtkExodusIIWriter() override;
186 
188 
190 
191  char* FileName;
192  int fid;
193 
195  int MyRank;
196 
198 
206 
211 
213  std::vector<vtkSmartPointer<vtkUnstructuredGrid> > FlattenedInput;
214  std::vector<vtkSmartPointer<vtkUnstructuredGrid> > NewFlattenedInput;
215 
216  std::vector<vtkStdString> FlattenedNames;
217  std::vector<vtkStdString> NewFlattenedNames;
218 
219  std::vector<vtkIntArray*> BlockIdList;
220 
221  struct Block
222  {
224  {
225  this->Name = nullptr;
226  this->Type = 0;
227  this->NumElements = 0;
228  this->ElementStartIndex = -1;
229  this->NodesPerElement = 0;
230  this->EntityCounts = std::vector<int>();
231  this->EntityNodeOffsets = std::vector<int>();
232  this->GridIndex = 0;
233  this->OutputIndex = -1;
234  this->NumAttributes = 0;
235  this->BlockAttributes = nullptr;
236  };
237  const char* Name;
238  int Type;
242  std::vector<int> EntityCounts;
243  std::vector<int> EntityNodeOffsets;
244  size_t GridIndex;
245  // std::vector<int> CellIndex;
248  float* BlockAttributes; // Owned by metamodel or null. Don't delete.
249  };
250  std::map<int, Block> BlockInfoMap;
251  int NumCells, NumPoints, MaxId;
252 
253  std::vector<vtkIdType*> GlobalElementIdList;
254  std::vector<vtkIdType*> GlobalNodeIdList;
255 
258 
260  {
262  int InIndex;
264  std::vector<std::string> OutNames;
265  };
266  std::map<std::string, VariableInfo> GlobalVariableMap;
267  std::map<std::string, VariableInfo> BlockVariableMap;
268  std::map<std::string, VariableInfo> NodeVariableMap;
272 
273  std::vector<std::vector<int> > CellToElementOffset;
274 
275  // By BlockId, and within block ID by element variable, with variables
276  // appearing in the same order in which they appear in OutputElementArrayNames
277 
280 
281  int BlockVariableTruthValue(int blockIdx, int varIdx);
282 
283  char* StrDupWithNew(const char* s);
284  void StringUppercase(std::string& str);
285 
287  vtkInformationVector* outputVector) override;
288 
289  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
290  vtkInformationVector* outputVector);
291 
292  virtual int RequestUpdateExtent(vtkInformation* request, vtkInformationVector** inputVector,
293  vtkInformationVector* outputVector);
294 
295  int FillInputPortInformation(int port, vtkInformation* info) override;
296 
297  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
298  vtkInformationVector* outputVector) override;
299 
300  void WriteData() override;
301 
302  int FlattenHierarchy(vtkDataObject* input, const char* name, bool& changed);
303 
304  int CreateNewExodusFile();
305  void CloseExodusFile();
306 
307  int IsDouble();
308  void RemoveGhostCells();
309  int CheckParametersInternal(int NumberOfProcesses, int MyRank);
310  virtual int CheckParameters();
311  // If writing in parallel multiple time steps exchange after each time step
312  // if we should continue the execution. Pass local continueExecution as a
313  // parameter and return the global continueExecution.
314  virtual int GlobalContinueExecuting(int localContinueExecution);
315  int CheckInputArrays();
316  virtual void CheckBlockInfoMap();
317  int ConstructBlockInfoMap();
318  int ConstructVariableInfoMaps();
319  int ParseMetadata();
320  int CreateDefaultMetadata();
321  char* GetCellTypeName(int t);
322 
323  int CreateBlockIdMetadata(vtkModelMetadata* em);
324  int CreateBlockVariableMetadata(vtkModelMetadata* em);
325  int CreateSetsMetadata(vtkModelMetadata* em);
326 
327  void ConvertVariableNames(std::map<std::string, VariableInfo>& variableMap);
328  char** FlattenOutVariableNames(
329  int nScalarArrays, const std::map<std::string, VariableInfo>& variableMap);
330  std::string CreateNameForScalarArray(const char* root, int component, int numComponents);
331 
332  std::map<vtkIdType, vtkIdType>* LocalNodeIdMap;
333  std::map<vtkIdType, vtkIdType>* LocalElementIdMap;
334 
335  vtkIdType GetNodeLocalId(vtkIdType id);
336  vtkIdType GetElementLocalId(vtkIdType id);
337  int GetElementType(vtkIdType id);
338 
339  int WriteInitializationParameters();
340  int WriteInformationRecords();
341  int WritePoints();
342  int WriteCoordinateNames();
343  int WriteGlobalPointIds();
344  int WriteBlockInformation();
345  int WriteGlobalElementIds();
346  int WriteVariableArrayNames();
347  int WriteNodeSetInformation();
348  int WriteSideSetInformation();
349  int WriteProperties();
350  int WriteNextTimeStep();
351  vtkIntArray* GetBlockIdArray(const char* BlockIdArrayName, vtkUnstructuredGrid* input);
352  static bool SameTypeOfCells(vtkIntArray* cellToBlockId, vtkUnstructuredGrid* input);
353 
354  double ExtractGlobalData(const char* name, int comp, int ts);
355  int WriteGlobalData(int timestep, vtkDataArray* buffer);
356  void ExtractCellData(const char* name, int comp, vtkDataArray* buffer);
357  int WriteCellData(int timestep, vtkDataArray* buffer);
358  void ExtractPointData(const char* name, int comp, vtkDataArray* buffer);
359  int WritePointData(int timestep, vtkDataArray* buffer);
360 
365  virtual unsigned int GetMaxNameLength();
366 
367 private:
368  vtkExodusIIWriter(const vtkExodusIIWriter&) = delete;
369  void operator=(const vtkExodusIIWriter&) = delete;
370 };
371 
372 #endif
vtkExodusIIWriter::VariableInfo::ScalarOutOffset
int ScalarOutOffset
Definition: vtkExodusIIWriter.h:263
vtkExodusIIWriter::Block::OutputIndex
int OutputIndex
Definition: vtkExodusIIWriter.h:246
vtkWriter::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkExodusIIWriter::AtLeastOneGlobalNodeIdList
int AtLeastOneGlobalNodeIdList
Definition: vtkExodusIIWriter.h:257
vtkExodusIIWriter::LocalNodeIdMap
std::map< vtkIdType, vtkIdType > * LocalNodeIdMap
Definition: vtkExodusIIWriter.h:332
vtkExodusIIWriter::Block::NumElements
int NumElements
Definition: vtkExodusIIWriter.h:239
vtkExodusIIWriter::Block::GridIndex
size_t GridIndex
Definition: vtkExodusIIWriter.h:244
vtkX3D::component
@ component
Definition: vtkX3D.h:181
vtkExodusIIWriter::NodeVariableMap
std::map< std::string, VariableInfo > NodeVariableMap
Definition: vtkExodusIIWriter.h:268
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkExodusIIWriter::FileTimeOffset
int FileTimeOffset
Definition: vtkExodusIIWriter.h:208
vtkModelMetadata
This class encapsulates the metadata that appear in mesh-based file formats but do not appear in vtkU...
Definition: vtkModelMetadata.h:89
vtkExodusIIWriter::WriteAllTimeSteps
vtkTypeBool WriteAllTimeSteps
Definition: vtkExodusIIWriter.h:204
vtkExodusIIWriter::Block::EntityNodeOffsets
std::vector< int > EntityNodeOffsets
Definition: vtkExodusIIWriter.h:243
vtkAlgorithm::FillInputPortInformation
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
vtkWriter::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkExodusIIWriter::BlockElementVariableTruthTable
int * BlockElementVariableTruthTable
Definition: vtkExodusIIWriter.h:278
vtkExodusIIWriter::NumberOfProcesses
int NumberOfProcesses
Definition: vtkExodusIIWriter.h:194
vtkExodusIIWriter::NumberOfTimeSteps
int NumberOfTimeSteps
Definition: vtkExodusIIWriter.h:205
vtkWriter::ProcessRequest
vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
vtkExodusIIWriter::Block::ElementStartIndex
int ElementStartIndex
Definition: vtkExodusIIWriter.h:240
vtkExodusIIWriter::LocalElementIdMap
std::map< vtkIdType, vtkIdType > * LocalElementIdMap
Definition: vtkExodusIIWriter.h:333
vtkExodusIIWriter::BlockIdList
std::vector< vtkIntArray * > BlockIdList
Definition: vtkExodusIIWriter.h:219
vtkExodusIIWriter::NumberOfScalarGlobalArrays
int NumberOfScalarGlobalArrays
Definition: vtkExodusIIWriter.h:269
vtkExodusIIWriter::PassDoubles
int PassDoubles
Definition: vtkExodusIIWriter.h:197
vtkExodusIIWriter::BlockVariableMap
std::map< std::string, VariableInfo > BlockVariableMap
Definition: vtkExodusIIWriter.h:267
vtkExodusIIWriter::Block::NumAttributes
int NumAttributes
Definition: vtkExodusIIWriter.h:247
vtkExodusIIWriter
Write Exodus II files.
Definition: vtkExodusIIWriter.h:84
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
detail::Type
Type
Definition: TestQtCommon.h:21
vtkExodusIIWriter::Block
Definition: vtkExodusIIWriter.h:221
vtkExodusIIWriter::GlobalNodeIdList
std::vector< vtkIdType * > GlobalNodeIdList
Definition: vtkExodusIIWriter.h:254
vtkExodusIIWriter::WriteOutGlobalNodeIdArray
vtkTypeBool WriteOutGlobalNodeIdArray
Definition: vtkExodusIIWriter.h:202
vtkExodusIIWriter::OriginalInput
vtkDataObject * OriginalInput
Definition: vtkExodusIIWriter.h:212
vtkExodusIIWriter::VariableInfo::OutNames
std::vector< std::string > OutNames
Definition: vtkExodusIIWriter.h:264
vtkX3D::port
@ port
Definition: vtkX3D.h:453
vtkExodusIIWriter::VariableInfo::InIndex
int InIndex
Definition: vtkExodusIIWriter.h:262
vtkExodusIIWriter::VariableInfo
Definition: vtkExodusIIWriter.h:259
vtkExodusIIWriter::GhostLevel
int GhostLevel
Definition: vtkExodusIIWriter.h:200
vtkWriter::WriteData
virtual void WriteData()=0
vtkExodusIIWriter::MyRank
int MyRank
Definition: vtkExodusIIWriter.h:195
vtkExodusIIWriter::BlockInfoMap
std::map< int, Block > BlockInfoMap
Definition: vtkExodusIIWriter.h:250
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkExodusIIWriter::FileName
char * FileName
Definition: vtkExodusIIWriter.h:191
vtkWriter
abstract class to write data to file(s)
Definition: vtkWriter.h:45
vtkSmartPointer.h
vtkExodusIIWriter::CellToElementOffset
std::vector< std::vector< int > > CellToElementOffset
Definition: vtkExodusIIWriter.h:273
vtkExodusIIWriter::Block::EntityCounts
std::vector< int > EntityCounts
Definition: vtkExodusIIWriter.h:242
vtkExodusIIWriter::CurrentTimeIndex
int CurrentTimeIndex
Definition: vtkExodusIIWriter.h:207
vtkExodusIIWriter::BlockIdArrayName
char * BlockIdArrayName
Definition: vtkExodusIIWriter.h:189
vtkExodusIIWriter::NewFlattenedInput
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > NewFlattenedInput
Definition: vtkExodusIIWriter.h:214
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkExodusIIWriter::fid
int fid
Definition: vtkExodusIIWriter.h:192
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkExodusIIWriter::Block::BlockAttributes
float * BlockAttributes
Definition: vtkExodusIIWriter.h:248
vtkExodusIIWriter::FlattenedInput
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > FlattenedInput
Definition: vtkExodusIIWriter.h:213
vtkExodusIIWriter::AtLeastOneGlobalElementIdList
int AtLeastOneGlobalElementIdList
Definition: vtkExodusIIWriter.h:256
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkExodusIIWriter::Block::Block
Block()
Definition: vtkExodusIIWriter.h:223
vtkWriter.h
vtkExodusIIWriter::NumberOfScalarElementArrays
int NumberOfScalarElementArrays
Definition: vtkExodusIIWriter.h:270
vtkExodusIIWriter::Block::Type
int Type
Definition: vtkExodusIIWriter.h:238
vtkExodusIIWriter::FlattenedNames
std::vector< vtkStdString > FlattenedNames
Definition: vtkExodusIIWriter.h:216
vtkExodusIIWriter::ModelMetadata
vtkModelMetadata * ModelMetadata
Definition: vtkExodusIIWriter.h:187
vtkExodusIIWriter::NumberOfScalarNodeArrays
int NumberOfScalarNodeArrays
Definition: vtkExodusIIWriter.h:271
vtkExodusIIWriter::NumPoints
int NumPoints
Definition: vtkExodusIIWriter.h:251
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkUnstructuredGrid
dataset represents arbitrary combinations of all possible cell types
Definition: vtkUnstructuredGrid.h:92
vtkExodusIIWriter::TopologyChanged
bool TopologyChanged
Definition: vtkExodusIIWriter.h:209
vtkExodusIIWriter::StoreDoubles
int StoreDoubles
Definition: vtkExodusIIWriter.h:199
vtkExodusIIWriter::GlobalElementIdList
std::vector< vtkIdType * > GlobalElementIdList
Definition: vtkExodusIIWriter.h:253
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkExodusIIWriter::GlobalVariableMap
std::map< std::string, VariableInfo > GlobalVariableMap
Definition: vtkExodusIIWriter.h:266
vtkExodusIIWriter::NewFlattenedNames
std::vector< vtkStdString > NewFlattenedNames
Definition: vtkExodusIIWriter.h:217
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkExodusIIWriter::Block::NodesPerElement
int NodesPerElement
Definition: vtkExodusIIWriter.h:241
vtkExodusIIWriter::VariableInfo::NumComponents
int NumComponents
Definition: vtkExodusIIWriter.h:261
vtkExodusIIWriter::AllVariablesDefinedInAllBlocks
int AllVariablesDefinedInAllBlocks
Definition: vtkExodusIIWriter.h:279
vtkExodusIIWriter::IgnoreMetaDataWarning
bool IgnoreMetaDataWarning
Definition: vtkExodusIIWriter.h:210
vtkExodusIIWriter::WriteOutGlobalElementIdArray
vtkTypeBool WriteOutGlobalElementIdArray
Definition: vtkExodusIIWriter.h:203
vtkExodusIIWriter::WriteOutBlockIdArray
vtkTypeBool WriteOutBlockIdArray
Definition: vtkExodusIIWriter.h:201