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 
70 #ifndef vtkExodusIIWriter_h
71 #define vtkExodusIIWriter_h
72 
73 #include "vtkIOExodusModule.h" // For export macro
74 #include "vtkWriter.h"
75 #include "vtkSmartPointer.h" // For vtkSmartPointer
76 
77 #include <vector> // STL Header
78 #include <map> // STL Header
79 #include <string> // STL Header
80 
81 class vtkModelMetadata;
82 class vtkDoubleArray;
83 class vtkIntArray;
85 
87 {
88 public:
89  static vtkExodusIIWriter *New ();
91  void PrintSelf (ostream& os, vtkIndent indent);
92 
103 
109  vtkSetStringMacro(FileName);
110  vtkGetStringMacro(FileName);
111 
117  vtkSetMacro(StoreDoubles, int);
118  vtkGetMacro(StoreDoubles, int);
119 
123  vtkSetMacro(GhostLevel, int);
124  vtkGetMacro(GhostLevel, int);
125 
131  vtkSetMacro(WriteOutBlockIdArray, int);
132  vtkGetMacro(WriteOutBlockIdArray, int);
133  vtkBooleanMacro(WriteOutBlockIdArray, int);
134 
139  vtkSetMacro(WriteOutGlobalNodeIdArray, int);
140  vtkGetMacro(WriteOutGlobalNodeIdArray, int);
141  vtkBooleanMacro(WriteOutGlobalNodeIdArray, int);
142 
147  vtkSetMacro(WriteOutGlobalElementIdArray, int);
148  vtkGetMacro(WriteOutGlobalElementIdArray, int);
149  vtkBooleanMacro(WriteOutGlobalElementIdArray, int);
150 
154  vtkSetMacro(WriteAllTimeSteps, int);
155  vtkGetMacro(WriteAllTimeSteps, int);
156  vtkBooleanMacro(WriteAllTimeSteps, int);
157 
158  vtkSetStringMacro(BlockIdArrayName);
159  vtkGetStringMacro(BlockIdArrayName);
160 
161 protected:
164 
166 
168 
169  char *FileName;
170  int fid;
171 
173  int MyRank;
174 
176 
184 
189 
190 //BTX
192  std::vector< vtkSmartPointer<vtkUnstructuredGrid> > FlattenedInput;
193  std::vector< vtkSmartPointer<vtkUnstructuredGrid> > NewFlattenedInput;
194 
195  std::vector< vtkIntArray* > BlockIdList;
196 
197  struct Block
198  {
199  Block ()
200  {
201  this->Type = 0;
202  this->NumElements = 0;
203  this->ElementStartIndex = -1;
204  this->NodesPerElement = 0;
205  this->EntityCounts = std::vector<int>();
206  this->EntityNodeOffsets = std::vector<int>();
207  this->GridIndex = 0;
208  this->OutputIndex = -1;
209  this->NumAttributes = 0;
210  this->BlockAttributes = 0;
211  };
212  int Type;
216  std::vector<int> EntityCounts;
217  std::vector<int> EntityNodeOffsets;
218  size_t GridIndex;
219  // std::vector<int> CellIndex;
222  float *BlockAttributes; // Owned by metamodel or null. Don't delete.
223  };
224  std::map<int, Block> BlockInfoMap;
225  int NumCells, NumPoints, MaxId;
226 
227  std::vector<vtkIdType*> GlobalElementIdList;
228  std::vector<vtkIdType*> GlobalNodeIdList;
229 //ETX
232 
233 //BTX
235  {
237  int InIndex;
239  std::vector<std::string> OutNames;
240  };
241  std::map<std::string, VariableInfo> GlobalVariableMap;
242  std::map<std::string, VariableInfo> BlockVariableMap;
243  std::map<std::string, VariableInfo> NodeVariableMap;
247 //ETX
248 
249 //BTX
250  std::vector< std::vector<int> > CellToElementOffset;
251 //ETX
252  // By BlockId, and within block ID by element variable, with variables
253  // appearing in the same order in which they appear in OutputElementArrayNames
254 
257 
258  int BlockVariableTruthValue(int blockIdx, int varIdx);
259 
260 //BTX
261  char *StrDupWithNew (const char *s);
263 //ETX
264 
266  vtkInformationVector** inputVector,
267  vtkInformationVector* outputVector);
268 
270  vtkInformationVector** inputVector,
271  vtkInformationVector* outputVector);
272 
273  virtual int RequestUpdateExtent (vtkInformation* request,
274  vtkInformationVector** inputVector,
275  vtkInformationVector* outputVector);
276 
278 
280  vtkInformationVector** inputVector,
281  vtkInformationVector* outputVector);
282 
283  void WriteData ();
284 
285  int FlattenHierarchy (vtkDataObject* input, bool& changed);
286 
289 
290  int IsDouble ();
292  int CheckParametersInternal (int NumberOfProcesses, int MyRank);
293  virtual int CheckParameters ();
294  // If writing in parallel multiple time steps exchange after each time step
295  // if we should continue the execution. Pass local continueExecution as a
296  // parameter and return the global continueExecution.
297  virtual int GlobalContinueExecuting(int localContinueExecution);
299  virtual void CheckBlockInfoMap();
304  char *GetCellTypeName (int t);
305 
309 
310 //BTX
311  void ConvertVariableNames (std::map<std::string, VariableInfo>& variableMap);
313  int nScalarArrays,
314  const std::map<std::string, VariableInfo>& variableMap);
316  int component,
317  int numComponents);
318 
319  std::map<vtkIdType, vtkIdType> *LocalNodeIdMap;
320  std::map<vtkIdType, vtkIdType> *LocalElementIdMap;
321 //ETX
325 
328  int WritePoints ();
339  const char* BlockIdArrayName, vtkUnstructuredGrid* input);
340  static bool SameTypeOfCells (vtkIntArray* cellToBlockId,
342 
343 //BTX
344  double ExtractGlobalData (const char *name, int comp, int ts);
345  int WriteGlobalData (int timestep, vtkDataArray *buffer);
346  void ExtractCellData (const char *name, int comp, vtkDataArray *buffer);
347  int WriteCellData (int timestep, vtkDataArray *buffer);
348  void ExtractPointData (const char *name, int comp, vtkDataArray *buffer);
349  int WritePointData (int timestep, vtkDataArray *buffer);
350 //ETX
351 
352 
353 private:
354  vtkExodusIIWriter (const vtkExodusIIWriter&); // Not Implemented
355  void operator= (const vtkExodusIIWriter&); // Not Implemented
356 };
357 
358 #endif
vtkExodusIIWriter::VariableInfo::ScalarOutOffset
int ScalarOutOffset
Definition: vtkExodusIIWriter.h:238
vtkExodusIIWriter::Block::OutputIndex
int OutputIndex
Definition: vtkExodusIIWriter.h:220
vtkExodusIIWriter::WriteInitializationParameters
int WriteInitializationParameters()
vtkGetObjectMacro
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:232
vtkExodusIIWriter::AtLeastOneGlobalNodeIdList
int AtLeastOneGlobalNodeIdList
Definition: vtkExodusIIWriter.h:231
vtkExodusIIWriter::LocalNodeIdMap
std::map< vtkIdType, vtkIdType > * LocalNodeIdMap
Definition: vtkExodusIIWriter.h:319
vtkExodusIIWriter::Block::NumElements
int NumElements
Definition: vtkExodusIIWriter.h:213
vtkExodusIIWriter::Block::GridIndex
size_t GridIndex
Definition: vtkExodusIIWriter.h:218
vtkExodusIIWriter::WriteGlobalElementIds
int WriteGlobalElementIds()
vtkX3D::component
@ component
Definition: vtkX3D.h:175
vtkExodusIIWriter::CheckParameters
virtual int CheckParameters()
vtkExodusIIWriter::NodeVariableMap
std::map< std::string, VariableInfo > NodeVariableMap
Definition: vtkExodusIIWriter.h:243
vtkExodusIIWriter::TimeValues
vtkDoubleArray * TimeValues
Definition: vtkExodusIIWriter.h:185
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkExodusIIWriter::WriteCellData
int WriteCellData(int timestep, vtkDataArray *buffer)
vtkExodusIIWriter::FlattenedInput
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > FlattenedInput
Definition: vtkExodusIIWriter.h:192
vtkExodusIIWriter::FileTimeOffset
int FileTimeOffset
Definition: vtkExodusIIWriter.h:187
vtkModelMetadata
This class encapsulates the metadata that appear in mesh-based file formats but do not appear in vtkU...
Definition: vtkModelMetadata.h:87
vtkExodusIIWriter::Block::EntityNodeOffsets
std::vector< int > EntityNodeOffsets
Definition: vtkExodusIIWriter.h:217
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkExodusIIWriter::BlockElementVariableTruthTable
int * BlockElementVariableTruthTable
Definition: vtkExodusIIWriter.h:255
vtkExodusIIWriter::NumberOfProcesses
int NumberOfProcesses
Definition: vtkExodusIIWriter.h:172
vtkExodusIIWriter::NumberOfTimeSteps
int NumberOfTimeSteps
Definition: vtkExodusIIWriter.h:183
vtkExodusIIWriter::WriteProperties
int WriteProperties()
vtkExodusIIWriter::Block::ElementStartIndex
int ElementStartIndex
Definition: vtkExodusIIWriter.h:214
vtkExodusIIWriter::LocalElementIdMap
std::map< vtkIdType, vtkIdType > * LocalElementIdMap
Definition: vtkExodusIIWriter.h:320
vtkIOExodusModule.h
vtkgl::s
GLdouble s
Definition: vtkgl.h:11594
vtkExodusIIWriter::NumberOfScalarGlobalArrays
int NumberOfScalarGlobalArrays
Definition: vtkExodusIIWriter.h:244
vtkExodusIIWriter::PassDoubles
int PassDoubles
Definition: vtkExodusIIWriter.h:175
vtkExodusIIWriter::BlockVariableMap
std::map< std::string, VariableInfo > BlockVariableMap
Definition: vtkExodusIIWriter.h:242
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkExodusIIWriter::Block::NumAttributes
int NumAttributes
Definition: vtkExodusIIWriter.h:221
vtkExodusIIWriter::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info)
vtkExodusIIWriter::WritePointData
int WritePointData(int timestep, vtkDataArray *buffer)
vtkExodusIIWriter::New
static vtkExodusIIWriter * New()
vtkExodusIIWriter::SetModelMetadata
void SetModelMetadata(vtkModelMetadata *)
vtkExodusIIWriter::BlockIdList
std::vector< vtkIntArray * > BlockIdList
Definition: vtkExodusIIWriter.h:195
vtkExodusIIWriter
Write Exodus II files.
Definition: vtkExodusIIWriter.h:87
vtkExodusIIWriter::RequestData
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkExodusIIWriter::CheckBlockInfoMap
virtual void CheckBlockInfoMap()
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkgl::input
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
vtkExodusIIWriter::Block
Definition: vtkExodusIIWriter.h:198
vtkExodusIIWriter::WriteCoordinateNames
int WriteCoordinateNames()
vtkExodusIIWriter::GlobalNodeIdList
std::vector< vtkIdType * > GlobalNodeIdList
Definition: vtkExodusIIWriter.h:228
vtkExodusIIWriter::GetNodeLocalId
vtkIdType GetNodeLocalId(vtkIdType id)
vtkExodusIIWriter::CellToElementOffset
std::vector< std::vector< int > > CellToElementOffset
Definition: vtkExodusIIWriter.h:250
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:191
vtkExodusIIWriter::RequestInformation
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkExodusIIWriter::VariableInfo::OutNames
std::vector< std::string > OutNames
Definition: vtkExodusIIWriter.h:239
vtkX3D::port
@ port
Definition: vtkX3D.h:447
vtkExodusIIWriter::WriteInformationRecords
int WriteInformationRecords()
vtkExodusIIWriter::VariableInfo::InIndex
int InIndex
Definition: vtkExodusIIWriter.h:237
vtkgl::name
GLuint const GLchar * name
Definition: vtkgl.h:11983
vtkExodusIIWriter::WriteSideSetInformation
int WriteSideSetInformation()
vtkExodusIIWriter::VariableInfo
Definition: vtkExodusIIWriter.h:235
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::CheckParametersInternal
int CheckParametersInternal(int NumberOfProcesses, int MyRank)
vtkExodusIIWriter::GetBlockIdArray
vtkIntArray * GetBlockIdArray(const char *BlockIdArrayName, vtkUnstructuredGrid *input)
vtkExodusIIWriter::GhostLevel
int GhostLevel
Definition: vtkExodusIIWriter.h:178
vtkExodusIIWriter::ProcessRequest
int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkExodusIIWriter::SameTypeOfCells
static bool SameTypeOfCells(vtkIntArray *cellToBlockId, vtkUnstructuredGrid *input)
vtkExodusIIWriter::WriteNodeSetInformation
int WriteNodeSetInformation()
vtkExodusIIWriter::CreateDefaultMetadata
int CreateDefaultMetadata()
vtkExodusIIWriter::CloseExodusFile
void CloseExodusFile()
vtkExodusIIWriter::MyRank
int MyRank
Definition: vtkExodusIIWriter.h:173
vtkExodusIIWriter::BlockInfoMap
std::map< int, Block > BlockInfoMap
Definition: vtkExodusIIWriter.h:224
vtkExodusIIWriter::ExtractCellData
void ExtractCellData(const char *name, int comp, vtkDataArray *buffer)
vtkExodusIIWriter::ConstructVariableInfoMaps
int ConstructVariableInfoMaps()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkSetStringMacro
#define vtkSetStringMacro(name)
Definition: vtkSetGet.h:104
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:53
vtkExodusIIWriter::FlattenOutVariableNames
char ** FlattenOutVariableNames(int nScalarArrays, const std::map< std::string, VariableInfo > &variableMap)
vtkExodusIIWriter::FileName
char * FileName
Definition: vtkExodusIIWriter.h:169
vtkWriter
abstract class to write data to file(s)
Definition: vtkWriter.h:45
vtkExodusIIWriter::CheckInputArrays
int CheckInputArrays()
vtkSmartPointer.h
vtkExodusIIWriter::~vtkExodusIIWriter
~vtkExodusIIWriter()
vtkExodusIIWriter::Block::EntityCounts
std::vector< int > EntityCounts
Definition: vtkExodusIIWriter.h:216
vtkExodusIIWriter::CreateBlockIdMetadata
int CreateBlockIdMetadata(vtkModelMetadata *em)
vtkExodusIIWriter::CurrentTimeIndex
int CurrentTimeIndex
Definition: vtkExodusIIWriter.h:186
vtkExodusIIWriter::vtkExodusIIWriter
vtkExodusIIWriter()
vtkExodusIIWriter::WriteOutGlobalNodeIdArray
int WriteOutGlobalNodeIdArray
Definition: vtkExodusIIWriter.h:180
vtkExodusIIWriter::WriteOutBlockIdArray
int WriteOutBlockIdArray
Definition: vtkExodusIIWriter.h:179
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkExodusIIWriter::StringUppercase
void StringUppercase(std::string &str)
vtkExodusIIWriter::ParseMetadata
int ParseMetadata()
vtkGetStringMacro
vtkGetStringMacro(ExtensionsString)
vtkExodusIIWriter::WriteOutGlobalElementIdArray
int WriteOutGlobalElementIdArray
Definition: vtkExodusIIWriter.h:181
vtkExodusIIWriter::BlockIdArrayName
char * BlockIdArrayName
Definition: vtkExodusIIWriter.h:167
VTKIOEXODUS_EXPORT
#define VTKIOEXODUS_EXPORT
Definition: vtkIOExodusModule.h:15
vtkExodusIIWriter::fid
int fid
Definition: vtkExodusIIWriter.h:170
vtkExodusIIWriter::BlockVariableTruthValue
int BlockVariableTruthValue(int blockIdx, int varIdx)
vtkExodusIIWriter::StrDupWithNew
char * StrDupWithNew(const char *s)
vtkExodusIIWriter::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkExodusIIWriter::Block::BlockAttributes
float * BlockAttributes
Definition: vtkExodusIIWriter.h:222
vtkExodusIIWriter::RequestUpdateExtent
virtual int RequestUpdateExtent(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkExodusIIWriter::AtLeastOneGlobalElementIdList
int AtLeastOneGlobalElementIdList
Definition: vtkExodusIIWriter.h:230
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkExodusIIWriter::GlobalContinueExecuting
virtual int GlobalContinueExecuting(int localContinueExecution)
vtkgl::t
GLdouble GLdouble t
Definition: vtkgl.h:11602
vtkExodusIIWriter::Block::Block
Block()
Definition: vtkExodusIIWriter.h:199
vtkWriter.h
vtkExodusIIWriter::NumberOfScalarElementArrays
int NumberOfScalarElementArrays
Definition: vtkExodusIIWriter.h:245
vtkExodusIIWriter::WriteGlobalPointIds
int WriteGlobalPointIds()
vtkgl::buffer
GLuint buffer
Definition: vtkgl.h:11839
vtkExodusIIWriter::Block::Type
int Type
Definition: vtkExodusIIWriter.h:211
vtkExodusIIWriter::ModelMetadata
vtkModelMetadata * ModelMetadata
Definition: vtkExodusIIWriter.h:165
vtkExodusIIWriter::WriteGlobalData
int WriteGlobalData(int timestep, vtkDataArray *buffer)
vtkExodusIIWriter::CreateNewExodusFile
int CreateNewExodusFile()
vtkExodusIIWriter::FlattenHierarchy
int FlattenHierarchy(vtkDataObject *input, bool &changed)
vtkExodusIIWriter::NumberOfScalarNodeArrays
int NumberOfScalarNodeArrays
Definition: vtkExodusIIWriter.h:246
vtkExodusIIWriter::ExtractGlobalData
double ExtractGlobalData(const char *name, int comp, int ts)
vtkExodusIIWriter::NumPoints
int NumPoints
Definition: vtkExodusIIWriter.h:225
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:49
vtkExodusIIWriter::WritePoints
int WritePoints()
vtkExodusIIWriter::WriteAllTimeSteps
int WriteAllTimeSteps
Definition: vtkExodusIIWriter.h:182
vtkUnstructuredGrid
dataset represents arbitrary combinations of all possible cell types
Definition: vtkUnstructuredGrid.h:82
vtkExodusIIWriter::NewFlattenedInput
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > NewFlattenedInput
Definition: vtkExodusIIWriter.h:193
vtkExodusIIWriter::TopologyChanged
bool TopologyChanged
Definition: vtkExodusIIWriter.h:188
vtkExodusIIWriter::IsDouble
int IsDouble()
vtkExodusIIWriter::StoreDoubles
int StoreDoubles
Definition: vtkExodusIIWriter.h:177
vtkExodusIIWriter::GlobalElementIdList
std::vector< vtkIdType * > GlobalElementIdList
Definition: vtkExodusIIWriter.h:227
vtkExodusIIWriter::GetElementType
int GetElementType(vtkIdType id)
vtkExodusIIWriter::WriteNextTimeStep
int WriteNextTimeStep()
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:65
vtkExodusIIWriter::WriteBlockInformation
int WriteBlockInformation()
vtkExodusIIWriter::GlobalVariableMap
std::map< std::string, VariableInfo > GlobalVariableMap
Definition: vtkExodusIIWriter.h:241
vtkgl::string
GLsizei const GLchar ** string
Definition: vtkgl.h:12011
vtkExodusIIWriter::Block::NodesPerElement
int NodesPerElement
Definition: vtkExodusIIWriter.h:215
vtkExodusIIWriter::VariableInfo::NumComponents
int NumComponents
Definition: vtkExodusIIWriter.h:236
vtkExodusIIWriter::RemoveGhostCells
void RemoveGhostCells()
vtkExodusIIWriter::AllVariablesDefinedInAllBlocks
int AllVariablesDefinedInAllBlocks
Definition: vtkExodusIIWriter.h:256
vtkExodusIIWriter::WriteData
void WriteData()
vtkExodusIIWriter::CreateBlockVariableMetadata
int CreateBlockVariableMetadata(vtkModelMetadata *em)
vtkExodusIIWriter::WriteVariableArrayNames
int WriteVariableArrayNames()
vtkExodusIIWriter::ExtractPointData
void ExtractPointData(const char *name, int comp, vtkDataArray *buffer)