/*========================================================================= Program: Visualization Toolkit Module: ADIOSWriter.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME ADIOSWriter - The utility class performing ADIOS Write operations #ifndef _ADIOSWriter_h #define _ADIOSWriter_h #include #include #include #include #include #include #include "ADIOSDefs.h" #include "ADIOSUtilities.h" namespace ADIOS { // An array dimension as either a string or integer struct ArrayDim { ArrayDim(size_t i) : ValueI(i), ValueS("") { } ArrayDim(const std::string& var) : ValueI(0), ValueS(var) { } size_t ValueI; std::string ValueS; }; class Writer { public: static bool SetCommunicator(MPI_Comm); public: Writer(ADIOS::TransportMethod transport, const std::string& transportArgs); ~Writer(); // Description: // Define scalar attributes template void DefineAttribute(const std::string& path, const TN& value) { std::stringstream ss; ss << value; this->DefineAttribute(path, Type::NativeToADIOS(), ss.str()); } // Description: // Define scalars for later writing template int DefineScalar(const std::string& path) { return this->DefineScalar(path, Type::NativeToADIOS()); } // Define an array for later writing template int DefineLocalArray(const std::string& path, const std::vector& dims, Transform xfm = Transform_NONE) { return this->DefineLocalArray(path, Type::NativeToADIOS(), dims, xfm); } int DefineLocalArray(const std::string& path, ADIOS_DATATYPES adiosType, const std::vector& dims, Transform xfm = Transform_NONE); // Description: // Enqueue a scalar for writing template void WriteScalar(const std::string& path, const TN& val) { this->WriteScalar(path, Type::NativeToADIOS(), &val); } void WriteScalar(const std::string& path, ADIOS_DATATYPES adiosType, const void* val); // Description: // Enqueue an array for writing void WriteArray(const std::string& path, const void* val); // Description: // Perform all writes for the current time step void Commit(const std::string& fileName, bool append = false); private: struct InitContext; InitContext *Ctx; struct WriterImpl; WriterImpl *Impl; void DefineAttribute(const std::string& path, ADIOS_DATATYPES adiosType, const std::string& value); int DefineScalar(const std::string& path, ADIOS_DATATYPES adiosType); }; } #endif // _ADIOSWriter_h