Commit 53612e23 authored by Michaël Sghaïer's avatar Michaël Sghaïer
Browse files

Make the ProxyDataHandle class more generic, parameterized by a pybind11::object

parent 23ee322a
......@@ -121,7 +121,7 @@ namespace Dune
// ProxyDataHandle for parallel communication:
// --------------------------------------
class ProxyDataHandle : public Dune::CommDataHandleIF<ProxyDataHandle, double>
class ProxyDataHandle : public Dune::CommDataHandleIF<ProxyDataHandle, py::object>
{
public:
ProxyDataHandle() {}
......@@ -159,8 +159,12 @@ namespace Dune
auto list_ptr = PyObject_CallMethod(dataHandle_.ptr(), "gather", "O", e_obj.ptr());
py::list py_buff(list_ptr, true);
for (const auto& x : py_buff)
buff.write(x.cast<double>());
auto sz = py_buff.size();
for (decltype(sz) i = 0; i < sz; i++)
{
const py::object x = static_cast<py::object>(py_buff[i]);
buff.write(x);
}
}
template<class MessageBuffer, class EntityType>
......@@ -171,10 +175,10 @@ namespace Dune
for (std::size_t i = 0; i < n; i++)
{
double x;
py::object x;
buff.read(x);
ret.append(py::cast(x));
ret.append(x);
}
PyObject_CallMethod(dataHandle_.ptr(), "scatter", "OO", e_obj.ptr(), ret.ptr());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment