def __init__(self, N, L, MPI, precision, P1=None, padsize=1.5): self.params = params self.N = N assert len(L) == 3 assert len(N) == 3 self.Nf = Nf = N[2]/2+1 # Number of independent complex wavenumbers in z-direction self.MPI = MPI self.comm = comm = MPI.COMM_WORLD self.float, self.complex, self.mpitype = float, complex, mpitype = datatypes(precision) self.num_processes = comm.Get_size() assert self.num_processes > 1 self.L = L.astype(float) self.dealias = None self.padsize = padsize self.rank = comm.Get_rank() if P1 is None: P1 = self.num_processes / 2 self.P1 = P1 self.P2 = P2 = self.num_processes / P1 self.N1 = N1 = N / P1 self.N2 = N2 = N / P2 self.comm0 = comm.Split(self.rank/P1) self.comm1 = comm.Split(self.rank%P1) self.comm0_rank = self.comm0.Get_rank() self.comm1_rank = self.comm1.Get_rank() self.N1f = self.N1[2]/2 if self.comm0_rank < self.P1-1 else self.N1[2]/2+1 if self.params['method'] == 'Nyquist': self.N1f = self.N1[2]/2 if not (self.num_processes % 2 == 0 or self.num_processes == 1): raise IOError("Number of cpus must be even") if ((P1 % 2 != 0) or (P2 % 2 != 0)): raise IOError("Number of cpus in each direction must be even power of 2")
def __init__(self, N, L, MPI, precision): self.N = N # The global size of the problem self.L = L assert len(L) == 2 assert len(N) == 2 self.MPI = MPI self.comm = comm = MPI.COMM_WORLD self.float, self.complex, self.mpitype = float, complex, mpitype = datatypes( precision) self.num_processes = comm.Get_size() self.rank = comm.Get_rank() # Each cpu gets ownership of Np indices self.Np = N / self.num_processes self.Nf = N[1] / 2 + 1 self.Npf = self.Np[ 1] / 2 + 1 if self.rank + 1 == self.num_processes else self.Np[ 1] / 2 self.dealias = None self.U_recv = empty((self.N[0], self.Np[1] / 2), dtype=complex) self.fft_y = empty(N[0], dtype=complex) self.fft_x = empty(N[0], dtype=complex) self.plane_recv = empty(self.Np[0], dtype=complex) self.Uc_hat = empty((N[0], self.Npf), dtype=complex) self.Uc_hatT = empty((self.Np[0], self.Nf), dtype=complex) self.U_send = empty((self.num_processes, self.Np[0], self.Np[1] / 2), dtype=complex) self.U_sendr = self.U_send.reshape((N[0], self.Np[1] / 2))
def __init__(self, N, L, MPI, precision, communication="alltoall", padsize=1.5): assert len(L) == 3 assert len(N) == 3 self.N = N self.Nf = N[ 2] / 2 + 1 # Number of independent complex wavenumbers in z-direction self.Nfp = int( padsize * N[2] / 2 + 1 ) # Number of independent complex wavenumbers in z-direction for padded array self.MPI = MPI self.comm = comm = MPI.COMM_WORLD self.float, self.complex, self.mpitype = datatypes(precision) self.communication = communication self.num_processes = comm.Get_size() self.rank = comm.Get_rank() self.Np = N / self.num_processes self.L = L.astype(self.float) self.Uc_hat = None self.Upad_hat = np.zeros(0) self.dealias = np.zeros(0) self.padsize = padsize self.transform = 'r2c/c2r' self.work_arrays = work_arrays() self.ks = (fftfreq(N[1]) * N[1]).astype(int) if not self.num_processes in [ 2**i for i in range(int(np.log2(N[0])) + 1) ]: raise IOError("Number of cpus must be in ", [2**i for i in range(int(np.log2(N[0])) + 1)])
def __init__(self, N, L, MPI, precision): self.N = N # The global size of the problem self.L = L assert len(L) == 2 assert len(N) == 2 self.MPI = MPI self.comm = comm = MPI.COMM_WORLD self.float, self.complex, self.mpitype = float, complex, mpitype = datatypes(precision) self.num_processes = comm.Get_size() self.rank = comm.Get_rank() # Each cpu gets ownership of Np indices self.Np = N / self.num_processes self.Nf = N[1]/2+1 self.Npf = self.Np[1]/2+1 if self.rank+1 == self.num_processes else self.Np[1]/2 self.dealias = zeros(0) self.work_arrays = work_arrays() self.fft_y = empty(N[0], dtype=complex) self.fft_x = empty(N[0], dtype=complex) self.plane_recv = empty(self.Np[0], dtype=complex)
def __init__(self, N, L, MPI, precision, communication="alltoall", padsize=1.5): assert len(L) == 3 assert len(N) == 3 self.N = N self.Nf = N[2]/2+1 # Number of independent complex wavenumbers in z-direction self.Nfp = int(padsize*N[2]/2+1) # Number of independent complex wavenumbers in z-direction for padded array self.MPI = MPI self.comm = comm = MPI.COMM_WORLD self.float, self.complex, self.mpitype = datatypes(precision) self.communication = communication self.num_processes = comm.Get_size() self.rank = comm.Get_rank() self.Np = N / self.num_processes self.L = L.astype(self.float) self.Uc_hat = None self.Upad_hat = np.zeros(0) self.dealias = np.zeros(0) self.padsize = padsize self.transform = 'r2c/c2r' self.work_arrays = work_arrays() self.ks = (fftfreq(N[1])*N[1]).astype(int) if not self.num_processes in [2**i for i in range(int(np.log2(N[0]))+1)]: raise IOError("Number of cpus must be in ", [2**i for i in range(int(np.log2(N[0]))+1)])
def __init__(self, N, L, MPI, precision, P1=None, padsize=1.5): self.params = params self.N = N assert len(L) == 3 assert len(N) == 3 self.Nf = Nf = N[2]/2+1 # Number of independent complex wavenumbers in z-direction self.MPI = MPI self.comm = comm = MPI.COMM_WORLD self.float, self.complex, self.mpitype = float, complex, mpitype = datatypes(precision) self.num_processes = comm.Get_size() assert self.num_processes > 1 self.L = L.astype(float) self.dealias = np.zeros(0) self.padsize = padsize self.rank = comm.Get_rank() if P1 is None: P1, P2 = MPI.Compute_dims(self.num_processes, 2) self.P1, self.P2 = P1, P2 else: self.P1 = P1 self.P2 = P2 = self.num_processes / P1 self.N1 = N1 = N / P1 self.N2 = N2 = N / P2 self.comm0 = comm.Split(self.rank/P1) self.comm1 = comm.Split(self.rank%P1) self.comm0_rank = self.comm0.Get_rank() self.comm1_rank = self.comm1.Get_rank() self.work_arrays = work_arrays() self.N1f = self.N1[2]/2 if self.comm0_rank < self.P1-1 else self.N1[2]/2+1 if self.params['method'] == 'Nyquist': self.N1f = self.N1[2]/2 if not (self.num_processes % 2 == 0 or self.num_processes == 1): raise IOError("Number of cpus must be even") if ((P1 % 2 != 0) or (P2 % 2 != 0)): raise IOError("Number of cpus in each direction must be even power of 2")