VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkADIOSWriter.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00024 #ifndef vtkADIOSWriter_h 00025 #define vtkADIOSWriter_h 00026 00027 #include <map> // For independently stepped array indexing 00028 #include <string> // For independently stepped array indexing 00029 #include <vector> // For independently stepped array indexing 00030 00031 #include "vtkDataObjectAlgorithm.h" 00032 #include "vtkMultiProcessController.h" // For the MPI controller member 00033 #include "vtkSetGet.h" // For property get/set macros 00034 00035 #include "ADIOSDefs.h" // For enum definitions 00036 00037 #include "vtkIOADIOSModule.h" // For export macro 00038 00039 namespace ADIOS 00040 { 00041 class Writer; 00042 } 00043 00044 class vtkAbstractArray; 00045 class vtkCellArray; 00046 class vtkDataArray; 00047 class vtkDataObject; 00048 class vtkDataSet; 00049 class vtkFieldData; 00050 class vtkImageData; 00051 class vtkPolyData; 00052 class vtkUnstructuredGrid; 00053 00054 class VTKIOADIOS_EXPORT vtkADIOSWriter : public vtkDataObjectAlgorithm 00055 { 00056 public: 00057 static vtkADIOSWriter* New(); 00058 vtkTypeMacro(vtkADIOSWriter,vtkDataObjectAlgorithm); 00059 virtual void PrintSelf(ostream& os, vtkIndent indent); 00060 00061 const char* GetDefaultFileExtension(); 00062 00064 00065 vtkGetStringMacro(FileName) 00066 vtkSetStringMacro(FileName) 00068 00070 00071 vtkGetMacro(TransportMethod, int); 00072 vtkSetClampMacro(TransportMethod, int, 00073 static_cast<int>(ADIOS::TransportMethod_NULL), 00074 static_cast<int>(ADIOS::TransportMethod_NetCDF4)); 00075 void SetTransportMethodToNULL() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_NULL)); } 00076 void SetTransportMethodToPOSIX() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_POSIX)); } 00077 void SetTransportMethodToMPI() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_MPI)); } 00078 void SetTransportMethodToMPILustre() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_MPI_LUSTRE)); } 00079 void SetTransportMethodToMPIAggregate() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_MPI_AGGREGATE)); } 00080 void SetTransportMethodToVarMerge() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_VAR_MERGE)); } 00081 void SetTransportMethodToDataSpaces() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_DataSpaces)); } 00082 void SetTransportMethodToDIMES() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_DIMES)); } 00083 void SetTransportMethodToFlexPath() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_FlexPath)); } 00084 void SetTransportMethodToPHDF5() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_PHDF5)); } 00085 void SetTransportMethodToNetCDF4() { this->SetTransportMethod(static_cast<int>(ADIOS::TransportMethod_NetCDF4)); } 00087 00089 00091 vtkSetStringMacro(TransportMethodArguments) 00092 vtkGetStringMacro(TransportMethodArguments) 00094 00096 00097 vtkGetMacro(Transform, int); 00098 vtkSetClampMacro(Transform, int, 00099 static_cast<int>(ADIOS::Transform_NONE), 00100 static_cast<int>(ADIOS::Transform_SZIP)); 00101 void SetTransformToNone() { this->SetTransform(static_cast<int>(ADIOS::Transform_NONE)); } 00102 void SetTransformToZLib() { this->SetTransform(static_cast<int>(ADIOS::Transform_ZLIB)); } 00103 void SetTransformToBZip2() { this->SetTransform(static_cast<int>(ADIOS::Transform_BZLIB2)); } 00104 void SetTransformToSZip() { this->SetTransform(static_cast<int>(ADIOS::Transform_SZIP)); } 00106 00107 enum 00108 { 00109 Always = 0, 00110 OnChange = 1 00111 }; 00112 00114 00115 vtkGetMacro(WriteMode, int); 00116 vtkSetClampMacro(WriteMode, int, Always, OnChange); 00117 void SetWriteModeToAlways() { this->SetWriteMode(Always); } 00118 void SetWriteModeToOnChange() { this->SetWriteMode(OnChange); } 00120 00122 00124 vtkSetMacro(WriteAllTimeSteps, bool); 00125 vtkGetMacro(WriteAllTimeSteps, bool); 00126 vtkBooleanMacro(WriteAllTimeSteps, bool); 00128 00130 00131 void SetController(vtkMultiProcessController*); 00132 vtkGetObjectMacro(Controller, vtkMultiProcessController); 00134 00136 00137 virtual int ProcessRequest(vtkInformation*, vtkInformationVector**, 00138 vtkInformationVector*); 00140 00143 void Write() { return this->Update(); } 00144 00145 protected: 00146 00148 00149 void Define(const std::string& path, const vtkAbstractArray* value); 00150 void Define(const std::string& path, const vtkDataArray* value); 00151 void Define(const std::string& path, const vtkCellArray* value); 00152 void Define(const std::string& path, const vtkFieldData* value); 00153 void Define(const std::string& path, const vtkDataSet* value); 00154 void Define(const std::string& path, const vtkImageData* value); 00155 void Define(const std::string& path, const vtkPolyData* value); 00156 void Define(const std::string& path, const vtkUnstructuredGrid* value); 00158 00160 00164 void OpenFile(); 00165 void CloseFile(); 00167 00169 00170 void Write(const std::string& path, const vtkAbstractArray* value); 00171 void Write(const std::string& path, const vtkDataArray* value); 00172 void Write(const std::string& path, const vtkCellArray* value); 00173 void Write(const std::string& path, const vtkFieldData* value); 00174 void Write(const std::string& path, const vtkDataSet* value); 00175 void Write(const std::string& path, const vtkImageData* value); 00176 void Write(const std::string& path, const vtkPolyData* value); 00177 void Write(const std::string& path, const vtkUnstructuredGrid* value); 00179 00180 char *FileName; 00181 int TransportMethod; 00182 char *TransportMethodArguments; 00183 int Transform; 00184 int WriteMode; 00185 int Rank; 00186 int CurrentStep; 00187 typedef std::map<std::string, size_t> NameIdMap; 00188 NameIdMap BlockStepIndexIdMap; 00189 std::vector<vtkTypeInt64> BlockStepIndex; 00190 vtkMultiProcessController *Controller; 00191 ADIOS::Writer *Writer; 00192 int BLOCKDEBUG; 00193 00194 vtkADIOSWriter(); 00195 ~vtkADIOSWriter(); 00196 00197 protected: 00198 // Used to implement vtkAlgorithm 00199 00200 int FillInputPortInformation(int port, vtkInformation* info); 00201 00202 virtual int RequestInformation(vtkInformation *request, 00203 vtkInformationVector **input, 00204 vtkInformationVector *output); 00205 virtual int RequestUpdateExtent(vtkInformation *request, 00206 vtkInformationVector **input, 00207 vtkInformationVector *output); 00208 virtual int RequestData(vtkInformation *request, 00209 vtkInformationVector **input, 00210 vtkInformationVector *output); 00211 00212 int NumberOfPieces; 00213 int RequestPiece; 00214 int NumberOfGhostLevels; 00215 bool WriteAllTimeSteps; 00216 std::vector<double> TimeSteps; 00217 int CurrentTimeStepIndex; 00218 int RequestExtent[6]; 00219 00220 // Used to determine whether or not the data getting written is stale 00221 bool UpdateMTimeTable(const std::string path, const vtkObject* value); 00222 std::map<std::string, unsigned long> LastUpdated; 00223 private: 00224 // Synchronize the block step index map across all processes 00225 std::string GatherBlockStepIdMap(); 00226 00227 bool WriteInternal(); 00228 00229 template<typename T> 00230 bool DefineAndWrite(vtkDataObject *input); 00231 00232 vtkADIOSWriter(const vtkADIOSWriter&); // Not implemented. 00233 void operator=(const vtkADIOSWriter&); // Not implemented. 00234 }; 00235 00236 #endif