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
vtkExodusIIWriter::VariableInfo::ScalarOutOffset
int ScalarOutOffset
Definition: vtkExodusIIWriter.h:282
vtkExodusIIWriter::Block::OutputIndex
int OutputIndex
Definition: vtkExodusIIWriter.h:265
vtkExodusIIWriter::WriteInitializationParameters
int WriteInitializationParameters()
vtkExodusIIWriter::AtLeastOneGlobalNodeIdList
int AtLeastOneGlobalNodeIdList
Definition: vtkExodusIIWriter.h:276
vtkExodusIIWriter::~vtkExodusIIWriter
~vtkExodusIIWriter() override
vtkExodusIIWriter::LocalNodeIdMap
std::map< vtkIdType, vtkIdType > * LocalNodeIdMap
Definition: vtkExodusIIWriter.h:351
vtkExodusIIWriter::Block::NumElements
int NumElements
Definition: vtkExodusIIWriter.h:258
vtkExodusIIWriter::Block::GridIndex
size_t GridIndex
Definition: vtkExodusIIWriter.h:263
vtkExodusIIWriter::WriteGlobalElementIds
int WriteGlobalElementIds()
vtkX3D::component
@ component
Definition: vtkX3D.h:181
vtkExodusIIWriter::CheckParameters
virtual int CheckParameters()
vtkExodusIIWriter::NodeVariableMap
std::map< std::string, VariableInfo > NodeVariableMap
Definition: vtkExodusIIWriter.h:287
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkExodusIIWriter::WriteCellData
int WriteCellData(int timestep, vtkDataArray *buffer)
vtkExodusIIWriter::FileTimeOffset
int FileTimeOffset
Definition: vtkExodusIIWriter.h:227
vtkExodusIIWriter::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkModelMetadata
This class encapsulates the metadata that appear in mesh-based file formats but do not appear in vtkU...
Definition: vtkModelMetadata.h:90
vtkExodusIIWriter::WriteAllTimeSteps
vtkTypeBool WriteAllTimeSteps
Definition: vtkExodusIIWriter.h:223
vtkExodusIIWriter::Block::EntityNodeOffsets
std::vector< int > EntityNodeOffsets
Definition: vtkExodusIIWriter.h:262
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
vtkExodusIIWriter::BlockElementVariableTruthTable
int * BlockElementVariableTruthTable
Definition: vtkExodusIIWriter.h:297
vtkExodusIIWriter::NumberOfProcesses
int NumberOfProcesses
Definition: vtkExodusIIWriter.h:213
vtkExodusIIWriter::NumberOfTimeSteps
int NumberOfTimeSteps
Definition: vtkExodusIIWriter.h:224
vtkExodusIIWriter::WriteProperties
int WriteProperties()
vtkExodusIIWriter::Block::ElementStartIndex
int ElementStartIndex
Definition: vtkExodusIIWriter.h:259
vtkExodusIIWriter::LocalElementIdMap
std::map< vtkIdType, vtkIdType > * LocalElementIdMap
Definition: vtkExodusIIWriter.h:352
vtkExodusIIWriter::BlockIdList
std::vector< vtkIntArray * > BlockIdList
Definition: vtkExodusIIWriter.h:238
vtkExodusIIWriter::NumberOfScalarGlobalArrays
int NumberOfScalarGlobalArrays
Definition: vtkExodusIIWriter.h:288
vtkExodusIIWriter::PassDoubles
int PassDoubles
Definition: vtkExodusIIWriter.h:216
vtkExodusIIWriter::BlockVariableMap
std::map< std::string, VariableInfo > BlockVariableMap
Definition: vtkExodusIIWriter.h:286
vtkExodusIIWriter::Block::NumAttributes
int NumAttributes
Definition: vtkExodusIIWriter.h:266
vtkExodusIIWriter::WritePointData
int WritePointData(int timestep, vtkDataArray *buffer)
vtkExodusIIWriter::New
static vtkExodusIIWriter * New()
vtkExodusIIWriter::SetModelMetadata
void SetModelMetadata(vtkModelMetadata *)
Specify the vtkModelMetadata object which contains the Exodus file model information (metadata) absen...
vtkExodusIIWriter::ProcessRequest
vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
vtkExodusIIWriter
Write Exodus II files.
Definition: vtkExodusIIWriter.h:104
vtkExodusIIWriter::CheckBlockInfoMap
virtual void CheckBlockInfoMap()
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkExodusIIWriter::FlattenHierarchy
int FlattenHierarchy(vtkDataObject *input, const char *name, bool &changed)
detail::Type
Type
Definition: TestQtCommon.h:19
vtkExodusIIWriter::Block
Definition: vtkExodusIIWriter.h:241
vtkExodusIIWriter::WriteCoordinateNames
int WriteCoordinateNames()
vtkExodusIIWriter::GlobalNodeIdList
std::vector< vtkIdType * > GlobalNodeIdList
Definition: vtkExodusIIWriter.h:273
vtkExodusIIWriter::GetNodeLocalId
vtkIdType GetNodeLocalId(vtkIdType id)
vtkExodusIIWriter::WriteOutGlobalNodeIdArray
vtkTypeBool WriteOutGlobalNodeIdArray
Definition: vtkExodusIIWriter.h:221
vtkExodusIIWriter::vtkGetFilePathMacro
vtkGetFilePathMacro(FileName)
vtkExodusIIWriter::GetMaxNameLength
virtual unsigned int GetMaxNameLength()
Get the maximum length name in the input data set.
vtkExodusIIWriter::ConstructBlockInfoMap
int ConstructBlockInfoMap()
vtkExodusIIWriter::ConvertVariableNames
void ConvertVariableNames(std::map< std::string, VariableInfo > &variableMap)
vtkExodusIIWriter::GetCellTypeName
char * GetCellTypeName(int t)
vtkExodusIIWriter::OriginalInput
vtkDataObject * OriginalInput
Definition: vtkExodusIIWriter.h:231
vtkExodusIIWriter::RequestInformation
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkExodusIIWriter::VariableInfo::OutNames
std::vector< std::string > OutNames
Definition: vtkExodusIIWriter.h:283
vtkX3D::port
@ port
Definition: vtkX3D.h:453
vtkExodusIIWriter::WriteInformationRecords
int WriteInformationRecords()
vtkExodusIIWriter::VariableInfo::InIndex
int InIndex
Definition: vtkExodusIIWriter.h:281
vtkExodusIIWriter::WriteSideSetInformation
int WriteSideSetInformation()
vtkExodusIIWriter::VariableInfo
Definition: vtkExodusIIWriter.h:279
vtkExodusIIWriter::CreateNameForScalarArray
std::string CreateNameForScalarArray(const char *root, int component, int numComponents)
vtkExodusIIWriter::CreateSetsMetadata
int CreateSetsMetadata(vtkModelMetadata *em)
vtkExodusIIWriter::GetElementLocalId
vtkIdType GetElementLocalId(vtkIdType id)
vtkExodusIIWriter::GetBlockIdArray
vtkIntArray * GetBlockIdArray(const char *BlockIdArrayName, vtkUnstructuredGrid *input)
vtkExodusIIWriter::GhostLevel
int GhostLevel
Definition: vtkExodusIIWriter.h:219
vtkExodusIIWriter::SameTypeOfCells
static bool SameTypeOfCells(vtkIntArray *cellToBlockId, vtkUnstructuredGrid *input)
vtkExodusIIWriter::WriteData
void WriteData() override
vtkExodusIIWriter::WriteNodeSetInformation
int WriteNodeSetInformation()
vtkExodusIIWriter::CreateDefaultMetadata
int CreateDefaultMetadata()
vtkExodusIIWriter::CloseExodusFile
void CloseExodusFile()
vtkExodusIIWriter::MyRank
int MyRank
Definition: vtkExodusIIWriter.h:214
vtkExodusIIWriter::BlockInfoMap
std::map< int, Block > BlockInfoMap
Definition: vtkExodusIIWriter.h:269
vtkExodusIIWriter::ExtractCellData
void ExtractCellData(const char *name, int comp, vtkDataArray *buffer)
vtkExodusIIWriter::CheckParametersInternal
int CheckParametersInternal(int numberOfProcesses, int myRank)
vtkExodusIIWriter::ConstructVariableInfoMaps
int ConstructVariableInfoMaps()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:149
vtkExodusIIWriter::FlattenOutVariableNames
char ** FlattenOutVariableNames(int nScalarArrays, const std::map< std::string, VariableInfo > &variableMap)
vtkExodusIIWriter::FileName
char * FileName
Definition: vtkExodusIIWriter.h:210
vtkWriter
abstract class to write data to file(s)
Definition: vtkWriter.h:46
vtkExodusIIWriter::CheckInputArrays
int CheckInputArrays()
vtkSmartPointer.h
vtkExodusIIWriter::CellToElementOffset
std::vector< std::vector< int > > CellToElementOffset
Definition: vtkExodusIIWriter.h:292
vtkExodusIIWriter::RequestData
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
vtkExodusIIWriter::Block::EntityCounts
std::vector< int > EntityCounts
Definition: vtkExodusIIWriter.h:261
vtkExodusIIWriter::CreateBlockIdMetadata
int CreateBlockIdMetadata(vtkModelMetadata *em)
vtkExodusIIWriter::CurrentTimeIndex
int CurrentTimeIndex
Definition: vtkExodusIIWriter.h:226
vtkExodusIIWriter::vtkExodusIIWriter
vtkExodusIIWriter()
vtkExodusIIWriter::StringUppercase
void StringUppercase(std::string &str)
vtkExodusIIWriter::ParseMetadata
int ParseMetadata()
vtkExodusIIWriter::vtkSetFilePathMacro
vtkSetFilePathMacro(FileName)
Name for the output file.
vtkExodusIIWriter::BlockIdArrayName
char * BlockIdArrayName
Definition: vtkExodusIIWriter.h:208
vtkExodusIIWriter::NewFlattenedInput
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > NewFlattenedInput
Definition: vtkExodusIIWriter.h:233
vtkExodusIIWriter::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkExodusIIWriter::fid
int fid
Definition: vtkExodusIIWriter.h:211
vtkExodusIIWriter::BlockVariableTruthValue
int BlockVariableTruthValue(int blockIdx, int varIdx)
vtkExodusIIWriter::StrDupWithNew
char * StrDupWithNew(const char *s)
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkExodusIIWriter::Block::BlockAttributes
float * BlockAttributes
Definition: vtkExodusIIWriter.h:267
vtkExodusIIWriter::FlattenedInput
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > FlattenedInput
Definition: vtkExodusIIWriter.h:232
vtkExodusIIWriter::RequestUpdateExtent
virtual int RequestUpdateExtent(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkExodusIIWriter::AtLeastOneGlobalElementIdList
int AtLeastOneGlobalElementIdList
Definition: vtkExodusIIWriter.h:275
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkExodusIIWriter::GlobalContinueExecuting
virtual int GlobalContinueExecuting(int localContinueExecution)
vtkExodusIIWriter::Block::Block
Block()
Definition: vtkExodusIIWriter.h:242
vtkWriter.h
vtkExodusIIWriter::NumberOfScalarElementArrays
int NumberOfScalarElementArrays
Definition: vtkExodusIIWriter.h:289
vtkExodusIIWriter::WriteGlobalPointIds
int WriteGlobalPointIds()
vtkExodusIIWriter::Block::Type
int Type
Definition: vtkExodusIIWriter.h:257
vtkExodusIIWriter::FlattenedNames
std::vector< vtkStdString > FlattenedNames
Definition: vtkExodusIIWriter.h:235
vtkExodusIIWriter::ModelMetadata
vtkModelMetadata * ModelMetadata
Definition: vtkExodusIIWriter.h:206
vtkExodusIIWriter::WriteGlobalData
int WriteGlobalData(int timestep, vtkDataArray *buffer)
vtkExodusIIWriter::CreateNewExodusFile
int CreateNewExodusFile()
vtkExodusIIWriter::NumberOfScalarNodeArrays
int NumberOfScalarNodeArrays
Definition: vtkExodusIIWriter.h:290
vtkExodusIIWriter::ExtractGlobalData
double ExtractGlobalData(const char *name, int comp, int ts)
vtkExodusIIWriter::NumPoints
int NumPoints
Definition: vtkExodusIIWriter.h:270
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:145
vtkExodusIIWriter::WritePoints
int WritePoints()
vtkUnstructuredGrid
dataset represents arbitrary combinations of all possible cell types
Definition: vtkUnstructuredGrid.h:204
vtkExodusIIWriter::Block::Name
const char * Name
Definition: vtkExodusIIWriter.h:255
vtkExodusIIWriter::TopologyChanged
bool TopologyChanged
Definition: vtkExodusIIWriter.h:228
vtkExodusIIWriter::IsDouble
int IsDouble()
vtkExodusIIWriter::StoreDoubles
int StoreDoubles
Definition: vtkExodusIIWriter.h:218
vtkExodusIIWriter::GlobalElementIdList
std::vector< vtkIdType * > GlobalElementIdList
Definition: vtkExodusIIWriter.h:272
vtkExodusIIWriter::GetElementType
int GetElementType(vtkIdType id)
vtkExodusIIWriter::WriteNextTimeStep
int WriteNextTimeStep()
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkExodusIIWriter::WriteBlockInformation
int WriteBlockInformation()
vtkExodusIIWriter::GlobalVariableMap
std::map< std::string, VariableInfo > GlobalVariableMap
Definition: vtkExodusIIWriter.h:285
vtkExodusIIWriter::NewFlattenedNames
std::vector< vtkStdString > NewFlattenedNames
Definition: vtkExodusIIWriter.h:236
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkExodusIIWriter::Block::NodesPerElement
int NodesPerElement
Definition: vtkExodusIIWriter.h:260
vtkExodusIIWriter::VariableInfo::NumComponents
int NumComponents
Definition: vtkExodusIIWriter.h:280
vtkExodusIIWriter::RemoveGhostCells
void RemoveGhostCells()
vtkExodusIIWriter::AllVariablesDefinedInAllBlocks
int AllVariablesDefinedInAllBlocks
Definition: vtkExodusIIWriter.h:298
vtkExodusIIWriter::IgnoreMetaDataWarning
bool IgnoreMetaDataWarning
Definition: vtkExodusIIWriter.h:229
vtkExodusIIWriter::WriteOutGlobalElementIdArray
vtkTypeBool WriteOutGlobalElementIdArray
Definition: vtkExodusIIWriter.h:222
vtkExodusIIWriter::CreateBlockVariableMetadata
int CreateBlockVariableMetadata(vtkModelMetadata *em)
vtkExodusIIWriter::WriteVariableArrayNames
int WriteVariableArrayNames()
vtkExodusIIWriter::ExtractPointData
void ExtractPointData(const char *name, int comp, vtkDataArray *buffer)
vtkExodusIIWriter::WriteOutBlockIdArray
vtkTypeBool WriteOutBlockIdArray
Definition: vtkExodusIIWriter.h:220