Newer
Older
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* EnginePy.h
*
* Created on: Mar 15, 2017
* Author: wgodoy
*/
#ifndef ENGINEPY_H_
#define ENGINEPY_H_
#include "boost/python.hpp"
#include "boost/python/numpy.hpp"
#endif
#ifdef HAVE_PYBIND11
#include "pybind11/numpy.h"
#include "ADIOSPy.h"
#include "VariablePy.h"
namespace adios
{
using dtype = boost::python::numpy::dtype;
#endif
#ifdef HAVE_PYBIND11
using pyArray = pybind11::array;
using dtype = pybind11::dtype;
class EnginePy
{
public:
void WritePy(VariablePy &variable, const pyArray &array);
ADIOSPy &m_ADIOSPy;
bool m_IsVariableTypeDefined = false;
template <class T> void DefineVariableInADIOS(VariablePy &variable)
{
auto &var = m_ADIOSPy.DefineVariable<T>(
variable.m_Name, variable.m_LocalDimensions,
variable.m_GlobalDimensions, variable.m_GlobalOffsets);
variable.m_VariablePtr = &var;
variable.m_IsVariableDefined = true;
}
template <class T>
void WriteVariableInADIOS(VariablePy &variable, const pyArray &array)
{
m_Engine->Write(*reinterpret_cast<Variable<T> *>(variable.m_VariablePtr),
PyArrayToPointer<T>(array));
}