From f661e4a30d8b7085e4839bd931ff7df7dffbac57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Fri, 8 Feb 2019 14:14:19 +0100 Subject: [PATCH] distribute --- libsrc/meshing/python_mesh.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 45929e4b..1c8ce9c5 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -521,15 +521,22 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m) */ .def_property_readonly("_timestamp", &Mesh::GetTimeStamp) - .def("Distribute", [](Mesh & self, shared_ptr pycomm) { - MPI_Comm comm = pycomm!=nullptr ? pycomm->comm : self.GetCommunicator(); - self.SetCommunicator(comm); - if(MyMPI_GetNTasks(comm)==1) return; + .def("Distribute", [](shared_ptr self, shared_ptr pycomm) { + MPI_Comm comm = pycomm!=nullptr ? pycomm->comm : self->GetCommunicator(); + self->SetCommunicator(comm); + if(MyMPI_GetNTasks(comm)==1) return self; if(MyMPI_GetNTasks(comm)==2) throw NgException("Sorry, cannot handle communicators with NP=2!"); cout << " rank " << MyMPI_GetId(comm) << " of " << MyMPI_GetNTasks(comm) << " called Distribute " << endl; - if(MyMPI_GetId(comm)==0) self.Distribute(); - else self.SendRecvMesh(); + if(MyMPI_GetId(comm)==0) self->Distribute(); + else self->SendRecvMesh(); + return self; }, py::arg("comm")=nullptr) + .def("Receive", [](shared_ptr pycomm) { + auto mesh = make_shared(); + mesh->SetCommunicator(pycomm->comm); + mesh->SendRecvMesh(); + return mesh; + }) .def("Load", FunctionPointer ([](Mesh & self, const string & filename) {