1010from time import time
1111import numpy as np
1212from mpi4py import MPI
13- from mpi4py_fft . mpifft import PFFT , Function
13+ from mpi4py_fft import PFFT , getDarray
1414
1515# Set viscosity, end time and time step
1616nu = 0.000625
2828FFT_pad = FFT
2929
3030# Declare variables needed to solve Navier-Stokes
31- U = Function (FFT , False , tensor = 3 ) # Velocity
32- U_hat = Function (FFT , tensor = 3 ) # Velocity transformed
33- P = Function (FFT , False ) # Pressure (scalar)
34- P_hat = Function (FFT ) # Pressure transformed
35- U_hat0 = Function (FFT , tensor = 3 ) # Runge-Kutta work array
36- U_hat1 = Function (FFT , tensor = 3 ) # Runge-Kutta work array
37- a = [1. / 6. , 1. / 3. , 1. / 3. , 1. / 6. ] # Runge-Kutta parameter
38- b = [0.5 , 0.5 , 1. ] # Runge-Kutta parameter
39- dU = Function (FFT , tensor = 3 ) # Right hand side of ODEs
40- curl = Function (FFT , False , tensor = 3 )
41- U_pad = Function (FFT_pad , False , tensor = 3 )
42- curl_pad = Function (FFT_pad , False , tensor = 3 )
31+ U = getDarray (FFT , False , rank = 1 ) # Velocity
32+ U_hat = getDarray (FFT , rank = 1 ) # Velocity transformed
33+ P = getDarray (FFT , False ) # Pressure (scalar)
34+ P_hat = getDarray (FFT ) # Pressure transformed
35+ U_hat0 = getDarray (FFT , rank = 1 ) # Runge-Kutta work array
36+ U_hat1 = getDarray (FFT , rank = 1 ) # Runge-Kutta work array
37+ a = [1. / 6. , 1. / 3. , 1. / 3. , 1. / 6. ] # Runge-Kutta parameter
38+ b = [0.5 , 0.5 , 1. ] # Runge-Kutta parameter
39+ dU = getDarray (FFT , rank = 1 ) # Right hand side of ODEs
40+ curl = getDarray (FFT , False , rank = 1 )
41+ U_pad = getDarray (FFT_pad , False , rank = 1 )
42+ curl_pad = getDarray (FFT_pad , False , rank = 1 )
4343
4444def get_local_mesh (FFT , L ):
4545 """Returns local mesh."""
@@ -52,10 +52,8 @@ def get_local_mesh(FFT, L):
5252
5353def get_local_wavenumbermesh (FFT , L ):
5454 """Returns local wavenumber mesh."""
55-
5655 s = FFT .local_slice ()
5756 N = FFT .shape ()
58-
5957 # Set wavenumbers in grid
6058 k = [np .fft .fftfreq (n , 1. / n ).astype (int ) for n in N [:- 1 ]]
6159 k .append (np .fft .rfftfreq (N [- 1 ], 1. / N [- 1 ]).astype (int ))
0 commit comments