Re = 1./nu Re_tau = 180. utau = nu * Re_tau N = array([2**M, 2**M, 2]) L = array([2, 4*pi, 4*pi/3.]) dx = (L / N).astype(float) comm = MPI.COMM_WORLD num_processes = comm.Get_size() rank = comm.Get_rank() Np = N / num_processes # Get points and weights for Chebyshev weighted integrals ST = ShenDirichletBasis(quad="GC") SN = ShenNeumannBasis(quad="GL") points, weights = ST.points_and_weights(N[0]) pointsp, weightsp = SN.points_and_weights(N[0]) x1 = arange(N[1], dtype=float)*L[1]/N[1] x2 = arange(N[2], dtype=float)*L[2]/N[2] # Get grid for velocity points X = array(meshgrid(points[rank*Np[0]:(rank+1)*Np[0]], x1, x2, indexing='ij'), dtype=float) Nf = N[2]/2+1 # Number of independent complex wavenumbers in z-direction Nu = N[0]-2 # Number of velocity modes in Shen basis Nq = N[0]-3 # Number of pressure modes in Shen basis u_slice = slice(0, Nu) p_slice = slice(1, Nu) U = empty((3, Np[0], N[1], N[2])) U_hat = empty((3, N[0], Np[1], Nf), dtype="complex")
Re = 1. / nu Re_tau = 180. utau = nu * Re_tau N = array([2**M, 2**M, 2]) L = array([2, 4 * pi, 4 * pi / 3.]) dx = (L / N).astype(float) comm = MPI.COMM_WORLD num_processes = comm.Get_size() rank = comm.Get_rank() Np = N / num_processes # Get points and weights for Chebyshev weighted integrals ST = ShenDirichletBasis(quad="GL") SN = ShenNeumannBasis(quad="GC") points, weights = ST.points_and_weights(N[0]) pointsp, weightsp = SN.points_and_weights(N[0]) x1 = arange(N[1], dtype=float) * L[1] / N[1] x2 = arange(N[2], dtype=float) * L[2] / N[2] # Get grid for velocity points X = array(meshgrid(points[rank * Np[0]:(rank + 1) * Np[0]], x1, x2, indexing='ij'), dtype=float) Nf = N[2] / 2 + 1 # Number of independent complex wavenumbers in z-direction Nu = N[0] - 2 # Number of velocity modes in Shen basis Nq = N[0] - 3 # Number of pressure modes in Shen basis u_slice = slice(0, Nu)
weighted L_w norm (u, v)_w = \int_{-1}^{1} u v / \sqrt(1-x^2) dx (\nabla^ u, \phi_k)_w = (f, \phi_k)_w """ # Use sympy to compute a rhs, given an analytical solution x = Symbol("x") u = cos(np.pi*x) f = u.diff(x, 2) N = 40 banded = False ST = ShenNeumannBasis() points, weights = ST.points_and_weights(N) k = ST.wavenumbers(N) # Gauss-Chebyshev quadrature to compute rhs (zero mean) fj = np.array([f.subs(x, j) for j in points], dtype=float) # Get f on quad points fj -= np.dot(fj, weights)/weights.sum() def solve_neumann(f): if banded: A = np.zeros((N-2, N-2)) A[-1, :] = -2*np.pi*(k+1)*k**2/(k+2) for i in range(2, N-3, 2): A[-i-1, i:] = -4*np.pi*(k[:-i]+i)**2*(k[:-i]+1)/(k[:-i]+2)**2 uk_hat = solve_banded((0, N-4), A[1:, 1:], f)
weighted L_w norm (u, v)_w = \int_{-1}^{1} u v / \sqrt(1-x^2) dx (\nabla^ u, \phi_k)_w = (f, \phi_k)_w """ # Use sympy to compute a rhs, given an analytical solution x = Symbol("x") u = cos(np.pi * x) f = u.diff(x, 2) N = 40 banded = False ST = ShenNeumannBasis() points, weights = ST.points_and_weights(N) k = ST.wavenumbers(N) # Gauss-Chebyshev quadrature to compute rhs (zero mean) fj = np.array([f.subs(x, j) for j in points], dtype=float) # Get f on quad points fj -= np.dot(fj, weights) / weights.sum() def solve_neumann(f): if banded: A = np.zeros((N - 2, N - 2)) A[-1, :] = -2 * np.pi * (k + 1) * k**2 / (k + 2) for i in range(2, N - 3, 2): A[-i - 1,