Skip to content

Commit f67555f

Browse files
committed
Fix passing MPI communicators Participant
1 parent 1a46978 commit f67555f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

cyprecice/cyprecice.pyx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ cimport cyprecice
99
cimport numpy
1010
import numpy as np
1111
from mpi4py import MPI
12+
from mpi4py cimport MPI
13+
from mpi4py cimport libmpi
14+
1215
import warnings
1316
from libcpp.string cimport string
1417
from libcpp.vector cimport vector
@@ -63,7 +66,7 @@ cdef class Participant:
6366
Rank of the process
6467
solver_process_size : int
6568
Size of the process
66-
communicator: mpi4py.MPI.Intracomm, optional
69+
communicator: mpi4py.MPI.Comm, optional
6770
Custom MPI communicator to use
6871
6972
Returns
@@ -82,10 +85,10 @@ cdef class Participant:
8285
pass
8386

8487
def __cinit__ (self, solver_name, configuration_file_name, solver_process_index, solver_process_size, communicator=None):
85-
cdef void* communicator_ptr
88+
cdef libmpi.MPI_Comm c_comm
8689
if communicator:
87-
communicator_ptr = <void*> communicator
88-
self.thisptr = new CppParticipant.Participant (convert(solver_name), convert(configuration_file_name), solver_process_index, solver_process_size, communicator_ptr)
90+
c_comm = (<MPI.Comm?>communicator).ob_mpi
91+
self.thisptr = new CppParticipant.Participant (convert(solver_name), convert(configuration_file_name), solver_process_index, solver_process_size, <void*>&c_comm)
8992
else:
9093
self.thisptr = new CppParticipant.Participant (convert(solver_name), convert(configuration_file_name), solver_process_index, solver_process_size)
9194
pass

0 commit comments

Comments
 (0)