------------------------------------------------------------------------------
| 37 | |
| 38 | //------------------------------------------------------------------------------ |
| 39 | vtkMPICommunicator* vtkMPI4PyCommunicator::ConvertToVTK(PyObject* comm) |
| 40 | { |
| 41 | // Import mpi4py if it does not exist. |
| 42 | if (!PyMPIComm_Get) |
| 43 | { |
| 44 | if (import_mpi4py() < 0) |
| 45 | { |
| 46 | return nullptr; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | if (!comm || !PyObject_TypeCheck(comm, &PyMPIComm_Type)) |
| 51 | { |
| 52 | return nullptr; |
| 53 | } |
| 54 | |
| 55 | MPI_Comm* mpiComm = PyMPIComm_Get(comm); |
| 56 | vtkMPICommunicator* vtkComm = vtkMPICommunicator::New(); |
| 57 | vtkMPICommunicatorOpaqueComm opaqueComm(mpiComm); |
| 58 | if (!vtkComm->InitializeExternal(&opaqueComm)) |
| 59 | { |
| 60 | vtkComm->Delete(); |
| 61 | return nullptr; |
| 62 | } |
| 63 | |
| 64 | return vtkComm; |
| 65 | } |
| 66 | |
| 67 | //------------------------------------------------------------------------------ |
| 68 | void vtkMPI4PyCommunicator::PrintSelf(ostream& os, vtkIndent indent) |
nothing calls this directly
no test coverage detected