1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtkEnSightWriter
* @brief write vtk unstructured grid data as an EnSight file
*
* vtkEnSightWriter is a source object that writes binary
* unstructured grid data files in EnSight format. See EnSight Manual for
* format details
*
* @warning
* Binary files written on one system may not be readable on other systems.
* Be sure to specify the endian-ness of the file when reading it into EnSight
*/
#ifndef vtkEnSightWriter_h
#define vtkEnSightWriter_h
#include "vtkIOParallelModule.h" // For export macro
#include "vtkWriter.h"
VTK_ABI_NAMESPACE_BEGIN
class vtkUnstructuredGrid;
class VTKIOPARALLEL_EXPORT vtkEnSightWriter : public vtkWriter
{
public:
vtkTypeMacro(vtkEnSightWriter, vtkWriter);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
*/
static vtkEnSightWriter* New();
///@{
/**
* Specify which process this writer is
*/
vtkSetMacro(ProcessNumber, int);
vtkGetMacro(ProcessNumber, int);
///@}
///@{
/**
* Specify path of EnSight data files to write.
*/
vtkSetFilePathMacro(Path);
vtkGetFilePathMacro(Path);
///@}
///@{
/**
* Specify base name of EnSight data files to write.
*/
vtkSetStringMacro(BaseName);
vtkGetStringMacro(BaseName);
///@}
///@{
/**
* Specify the path and base name of the output files.
*/
vtkSetFilePathMacro(FileName);
vtkGetFilePathMacro(FileName);
///@}
///@{
/**
* Specify the Timestep that this data is for
*/
vtkSetMacro(TimeStep, int);
vtkGetMacro(TimeStep, int);
///@}
///@{
/**
* Specify the number of ghost levels to include in output files
*/
vtkSetMacro(GhostLevel, int);
vtkGetMacro(GhostLevel, int);
///@}
///@{
/**
* Specify whether the geometry changes each timestep
* if false, geometry is only written at timestep 0
*/
vtkSetMacro(TransientGeometry, bool);
vtkGetMacro(TransientGeometry, bool);
///@}
///@{
/**
* set the number of block ID's
*/
vtkSetMacro(NumberOfBlocks, int);
vtkGetMacro(NumberOfBlocks, int);
///@}
///@{
/**
* Turn on/off writing node IDs (default: on).
* If this is on, geometry files will contain node IDs for each part
* (<code>node id given</code>), otherwise node IDs are omitted
* (<code>node id off</code>).
*
* The EnSight node IDs correspond to VTK point IDs in the input dataset.
*/
vtkBooleanMacro(WriteNodeIDs, bool);
vtkSetMacro(WriteNodeIDs, bool);
vtkGetMacro(WriteNodeIDs, bool);
///@}
///@{
/**
* Turn on/off writing element IDs (default: on).
* If this is on, geometry files will contain element IDs for each part
* (<code>element id given</code>), otherwise element IDs are omitted
* (<code>element id off</code>).
*
* The EnSight element IDs correspond to VTK cell IDs in the input dataset.
*/
vtkBooleanMacro(WriteElementIDs, bool);
vtkSetMacro(WriteElementIDs, bool);
vtkGetMacro(WriteElementIDs, bool);
///@}
///@{
/**
* set the array of Block ID's
* this class keeps a reference to the array and will not delete it
*/
virtual void SetBlockIDs(int* val) { BlockIDs = val; }
virtual int* GetBlockIDs() { return BlockIDs; }
///@}
///@{
/**
* Specify the input data or filter.
*/
virtual void SetInputData(vtkUnstructuredGrid* input);
virtual vtkUnstructuredGrid* GetInput();
///@}
///@{
/**
* Writes the case file that EnSight is capable of reading
* The other data files must be written before the case file
* and the input must be one of the time steps
* variables must be the same for all time steps or the case file will be
* missing variables
*/
virtual void WriteCaseFile(int TotalTimeSteps);
virtual void WriteSOSCaseFile(int NumProcs);
///@}
protected:
vtkEnSightWriter();
~vtkEnSightWriter() override;
int FillInputPortInformation(int port, vtkInformation* info) override;
int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
void WriteData() override; // method to allow this class to be instantiated and delegated to
virtual void WriteStringToFile(const char* string, FILE* file);
virtual void WriteTerminatedStringToFile(const char* string, FILE* file);
virtual void WriteIntToFile(int i, FILE* file);
virtual void WriteFloatToFile(float f, FILE* file);
virtual void WriteElementTypeToFile(int ElementType, FILE* fd);
virtual bool ShouldWriteGeometry();
virtual void SanitizeFileName(char* name);
virtual FILE* OpenFile(char* name);
void ComputeNames();
void DefaultNames();
int GetExodusModelIndex(int* ElementArray, int NumberElements, int PartID);
static int GetDestinationComponent(int srcComponent, int numComponents);
char* Path;
char* BaseName;
char* FileName;
int TimeStep;
int GhostLevelMultiplier;
int ProcessNumber;
int NumberOfProcesses;
int NumberOfBlocks;
int* BlockIDs;
bool TransientGeometry;
int GhostLevel;
bool WriteNodeIDs;
bool WriteElementIDs;
vtkUnstructuredGrid* TmpInput;
vtkEnSightWriter(const vtkEnSightWriter&) = delete;
void operator=(const vtkEnSightWriter&) = delete;
};
VTK_ABI_NAMESPACE_END
#endif
|