コード例 #1
0
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
quad = "GC"
BC1 = array([1,0,0, 1,0,0])
BC2 = array([0,1,0, 0,1,0])
BC3 = array([0,1,0, 1,0,0])
SC = ChebyshevTransform(quad)
ST = ShenBasis(BC1, quad)
SN = ShenBasis(BC2, quad, Neumann = True)
SR = ShenBasis(BC3, quad)
SB = ShenBiharmonicBasis(quad, fast_transform=False)

points, weights = ST.points_and_weights(N[0])
pointsN, weightsN = 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)
Y = array(meshgrid(pointsN[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

U     = empty((3, Np[0], N[1], N[2]))
U_hat = empty((3, N[0], Np[1], Nf), dtype="complex")
P     = empty((Np[0], N[1], N[2]))
コード例 #2
0
    M = 2 ** 3
    quad = "GL"
    BC1 = array([1, 0, 0, 1, 0, 0])
    BC2 = array([0, 1, 0, 0, 1, 0])
    BC3 = array([0, 1, 0, 1, 0, 0])
    SC = ChebyshevTransform(quad)
    ST = ShenBasis(BC1, quad)
    SN = ShenBasis(BC2, quad, Neumann=True)
    SR = ShenBasis(BC3, quad)
    SB = ShenBiharmonicBasis(quad, fast_transform=False)

    if test == "0":
        v_exact = zeros(M)
        f = zeros(M)
        points, weights = SN.points_and_weights(M)
        f[:] = (-8.0 / 3.0) * points  # -((pi/2.)**2)*sin(pi*points/2.)
        v_exact = -(4.0 / 9.0) * (points ** 3 - 3.0 * points)  # sin(pi*points/2.)
        v = Poisson1DNeumann(M, f, quad, SC, SN, BC2)

        print "Error: ", linalg.norm(v - v_exact, inf)
        assert allclose(v, v_exact)
        pl.plot(points, v_exact, points, v)
        pl.show()
    elif test == "1":
        v_exact = zeros(M)
        f = zeros(M)
        points, weights = ST.points_and_weights(M)
        f[:] = -4.0
        v_exact = 2 * (1.0 - points ** 2)
        v = Poisson1D(M, f, quad, SC, ST, BC1)