Exemplo n.º 1
0
elif case == "MKK":
    nu = 2e-5
    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)
Exemplo n.º 2
0
    
    Au + kx^2*Bu = f

"""

# Use sympy to compute a rhs, given an analytical solution
x = Symbol("x")
u = (1-x**2)**2*cos(np.pi*x)*(x-0.25)**2
kx = np.sqrt(2)
f = -u.diff(x, 2) + kx**2*u

# Choices
solver = "sparse"
N = 32

ST = ShenDirichletBasis(quad="GC")
points, weights = ST.points_and_weights(N) 

# Gauss-Chebyshev quadrature to compute rhs
fj = np.array([f.subs(x, j) for j in points], dtype=float)     # Get f on quad points

#@profile
def solve(fk):
    
    k = ST.wavenumbers(N)
        
    if solver == "sparse":
        #aij = [2*np.pi*(k+1)*(k+2)]
        #for i in range(2, N-2, 2):
            #aij.append(np.array(4*np.pi*(k[:-i]+1)))    
        #A = diags(aij, range(0, N-2, 2))
Exemplo n.º 3
0
    (\nabla^ u, \phi_k)_w = (f, \phi_k)_w 
    

"""

# Use sympy to compute a rhs, given an analytical solution
x = Symbol("x")
u = (1-x**2)**2*cos(np.pi*x)*(x-0.25)**2
f = u.diff(x, 2) 

# Choices
solver = "bs"
N = 20

ST = ShenDirichletBasis(quad="GC")
points, weights = ST.points_and_weights(N) 

# Gauss-Chebyshev quadrature to compute rhs
fj = np.array([f.subs(x, j) for j in points], dtype=float)     # Get f on quad points

#@profile
def solve(fk):
    
    N = len(fk)+2
    k = ST.wavenumbers(N)
    if solver == "banded":
        A = np.zeros((N-2, N-2))
        A[-1, :] = -2*np.pi*(k+1)*(k+2)
        for i in range(2, N-2, 2):
            A[-i-1, i:] = -4*np.pi*(k[:-i]+1)
Exemplo n.º 4
0
elif case == "MKK":
    nu = 2e-5
    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
Exemplo n.º 5
0
    (\nabla^ u, \phi_k)_w = (f, \phi_k)_w 
    

"""

# Use sympy to compute a rhs, given an analytical solution
x = Symbol("x")
u = (1 - x**2)**2 * cos(np.pi * x) * (x - 0.25)**2
f = u.diff(x, 2)

# Choices
solver = "bs"
N = 20

ST = ShenDirichletBasis(quad="GC")
points, weights = ST.points_and_weights(N)

# Gauss-Chebyshev quadrature to compute rhs
fj = np.array([f.subs(x, j) for j in points],
              dtype=float)  # Get f on quad points


#@profile
def solve(fk):

    N = len(fk) + 2
    k = ST.wavenumbers(N)
    if solver == "banded":
        A = np.zeros((N - 2, N - 2))
        A[-1, :] = -2 * np.pi * (k + 1) * (k + 2)