VTK
vtkADIOSWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkADIOSWriter.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 =========================================================================*/
24 #ifndef vtkADIOSWriter_h
25 #define vtkADIOSWriter_h
26 
27 #include <map> // For independently stepped array indexing
28 #include <string> // For independently stepped array indexing
29 #include <vector> // For independently stepped array indexing
30 
31 #include "vtkDataObjectAlgorithm.h"
32 #include "vtkMultiProcessController.h" // For the MPI controller member
33 #include "vtkSetGet.h" // For property get/set macros
34 
35 #include "ADIOSDefs.h" // For enum definitions
36 
37 #include "vtkIOADIOSModule.h" // For export macro
38 
39 namespace ADIOS
40 {
41  class Writer;
42 }
43 
44 class vtkAbstractArray;
45 class vtkCellArray;
46 class vtkDataArray;
47 class vtkDataObject;
48 class vtkDataSet;
49 class vtkFieldData;
50 class vtkImageData;
51 class vtkPolyData;
53 
54 class VTKIOADIOS_EXPORT vtkADIOSWriter : public vtkDataObjectAlgorithm
55 {
56 public:
57  static vtkADIOSWriter* New();
59  virtual void PrintSelf(ostream& os, vtkIndent indent);
60 
61  const char* GetDefaultFileExtension();
62 
64 
65  vtkGetStringMacro(FileName)
66  vtkSetStringMacro(FileName)
68 
70 
71  vtkGetMacro(TransportMethod, int);
72  vtkSetClampMacro(TransportMethod, int,
73  static_cast<int>(ADIOS::TransportMethod_NULL),
74  static_cast<int>(ADIOS::TransportMethod_NetCDF4));
75  void SetTransportMethodToNULL() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_NULL)); }
76  void SetTransportMethodToPOSIX() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_POSIX)); }
77  void SetTransportMethodToMPI() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_MPI)); }
78  void SetTransportMethodToMPILustre() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_MPI_LUSTRE)); }
79  void SetTransportMethodToMPIAggregate() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_MPI_AGGREGATE)); }
80  void SetTransportMethodToVarMerge() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_VAR_MERGE)); }
81  void SetTransportMethodToDataSpaces() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_DataSpaces)); }
82  void SetTransportMethodToDIMES() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_DIMES)); }
83  void SetTransportMethodToFlexPath() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_FlexPath)); }
84  void SetTransportMethodToPHDF5() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_PHDF5)); }
85  void SetTransportMethodToNetCDF4() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_NetCDF4)); }
87 
89 
91  vtkSetStringMacro(TransportMethodArguments)
92  vtkGetStringMacro(TransportMethodArguments)
94 
96 
97  vtkGetMacro(Transform, int);
98  vtkSetClampMacro(Transform, int,
99  static_cast<int>(ADIOS::Transform_NONE),
100  static_cast<int>(ADIOS::Transform_SZIP));
101  void SetTransformToNone() { this->SetTransform(static_cast<int>(ADIOS::Transform_NONE)); }
102  void SetTransformToZLib() { this->SetTransform(static_cast<int>(ADIOS::Transform_ZLIB)); }
103  void SetTransformToBZip2() { this->SetTransform(static_cast<int>(ADIOS::Transform_BZLIB2)); }
104  void SetTransformToSZip() { this->SetTransform(static_cast<int>(ADIOS::Transform_SZIP)); }
106 
107  enum
108  {
109  Always = 0,
110  OnChange = 1
111  };
112 
114 
115  vtkGetMacro(WriteMode, int);
116  vtkSetClampMacro(WriteMode, int, Always, OnChange);
117  void SetWriteModeToAlways() { this->SetWriteMode(Always); }
118  void SetWriteModeToOnChange() { this->SetWriteMode(OnChange); }
120 
122 
124  vtkSetMacro(WriteAllTimeSteps, bool);
125  vtkGetMacro(WriteAllTimeSteps, bool);
126  vtkBooleanMacro(WriteAllTimeSteps, bool);
128 
130 
131  void SetController(vtkMultiProcessController*);
134 
136 
140 
143  void Write() { return this->Update(); }
144 
145 protected:
146 
148 
149  void Define(const std::string& path, const vtkAbstractArray* value);
150  void Define(const std::string& path, const vtkDataArray* value);
151  void Define(const std::string& path, const vtkCellArray* value);
152  void Define(const std::string& path, const vtkFieldData* value);
153  void Define(const std::string& path, const vtkDataSet* value);
154  void Define(const std::string& path, const vtkImageData* value);
155  void Define(const std::string& path, const vtkPolyData* value);
156  void Define(const std::string& path, const vtkUnstructuredGrid* value);
158 
160 
164  void OpenFile();
165  void CloseFile();
167 
169 
170  void Write(const std::string& path, const vtkAbstractArray* value);
171  void Write(const std::string& path, const vtkDataArray* value);
172  void Write(const std::string& path, const vtkCellArray* value);
173  void Write(const std::string& path, const vtkFieldData* value);
174  void Write(const std::string& path, const vtkDataSet* value);
175  void Write(const std::string& path, const vtkImageData* value);
176  void Write(const std::string& path, const vtkPolyData* value);
177  void Write(const std::string& path, const vtkUnstructuredGrid* value);
179 
180  char *FileName;
185  int Rank;
187  typedef std::map<std::string, size_t> NameIdMap;
189  std::vector<vtkTypeInt64> BlockStepIndex;
191  ADIOS::Writer *Writer;
193 
194  vtkADIOSWriter();
195  ~vtkADIOSWriter();
196 
197 protected:
198  // Used to implement vtkAlgorithm
199 
201 
202  virtual int RequestInformation(vtkInformation *request,
204  vtkInformationVector *output);
205  virtual int RequestUpdateExtent(vtkInformation *request,
207  vtkInformationVector *output);
208  virtual int RequestData(vtkInformation *request,
210  vtkInformationVector *output);
211 
216  std::vector<double> TimeSteps;
218  int RequestExtent[6];
219 
220  // Used to determine whether or not the data getting written is stale
221  bool UpdateMTimeTable(const std::string path, const vtkObject* value);
222  std::map<std::string, unsigned long> LastUpdated;
223 private:
224  // Synchronize the block step index map across all processes
225  std::string GatherBlockStepIdMap();
226 
227  bool WriteInternal();
228 
229  template<typename T>
230  bool DefineAndWrite(vtkDataObject *input);
231 
232  vtkADIOSWriter(const vtkADIOSWriter&); // Not implemented.
233  void operator=(const vtkADIOSWriter&); // Not implemented.
234 };
235 
236 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:61
Store vtkAlgorithm input/output information.
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
void SetWriteModeToOnChange()
abstract class to specify dataset behavior
Definition: vtkDataSet.h:59
Abstract superclass for all arrays.
static vtkDataObjectAlgorithm * New()
void SetTransportMethodToMPIAggregate()
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
vtkMultiProcessController * Controller
void PrintSelf(ostream &os, vtkIndent indent)
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:133
void SetTransportMethodToMPI()
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
#define vtkSetStringMacro(name)
Definition: vtkSetGet.h:94
void SetTransportMethodToNetCDF4()
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
Write ADIOS files.
void SetTransportMethodToDataSpaces()
void SetTransformToZLib()
void SetWriteModeToAlways()
void SetTransportMethodToPHDF5()
char * TransportMethodArguments
a simple class to control print indentation
Definition: vtkIndent.h:38
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
std::map< std::string, unsigned long > LastUpdated
void SetTransformToBZip2()
std::vector< double > TimeSteps
dataset represents arbitrary combinations of all possible cell types
std::map< std::string, size_t > NameIdMap
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
void SetTransportMethodToPOSIX()
void SetTransportMethodToVarMerge()
virtual int FillInputPortInformation(int port, vtkInformation *info)
void SetTransportMethodToDIMES()
virtual void Update()
GLsizei const GLchar ** path
Definition: vtkgl.h:13835
#define vtkGetStringMacro(name)
Definition: vtkSetGet.h:120
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
Superclass for algorithms that produce only data object as output.
object to represent cell connectivity
Definition: vtkCellArray.h:49
void SetTransformToSZip()
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
virtual int ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
NameIdMap BlockStepIndexIdMap
std::vector< vtkTypeInt64 > BlockStepIndex
Store zero or more vtkInformation instances.
void SetTransportMethodToMPILustre()
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
void SetTransportMethodToFlexPath()
ADIOS::Writer * Writer
general representation of visualization data
Definition: vtkDataObject.h:64
GLsizei const GLchar ** string
Definition: vtkgl.h:12011
represent and manipulate fields of data
Definition: vtkFieldData.h:55
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69
Multiprocessing communication superclass.