예제 #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="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
예제 #2
0
polynomial of first kind. Solve using spectral Galerkin and the
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):