Exemple #1
0
    def reconstruct(self, q, qm, qp, qq, **kwargs):
        weno = self.weno

        # flux and source reconstructions at cell boundaries
        weno.smoothness(q[:,0])

        weno.weights('left')
        for m in (0, 1, 2):
            weno.reconstruct(q[:,m], 'left', qp[:,m], False)

        weno.weights('right')
        for m in (0, 1, 2):
            weno.reconstruct(q[:,m], 'right', qm[:,m], False)

        # source reconstructions at quadrature points (see cshallowwater.pyx)
        weno.weights('gauss_quad3')
        weno.reconstruct(q[:,0], 'gauss_quad3', qq[:,:,0], compute_weights=False)
        weno.reconstruct(q[:,2], 'gauss_quad3', qq[:,:,1], compute_weights=False)

        weno.weights('d|gauss_quad3')
        weno.reconstruct(q[:,2], 'd|gauss_quad3', qq[:,:,2], compute_weights=False)

        qm[1:,:] = qm[:-1,:]            # XXX, tweak PyWENO so we don't have to do this
Exemple #2
0
def test_reconstruction():

    K = (5, 7)
    x = np.linspace(0.0, 2 * np.pi, 51)

    # average of f (we're testing striding too, hence the extra component)
    q = np.zeros((3, x.size - 1))
    q[0, :] = F(x[:-1], x[1:])

    for k in K:
        qr = reconstruct(q[0, :], k, 'left')
        err = np.log10(1e-30 + abs(qr[k:-k] - f(x[:-1])[k:-k]).max())

        print 'k: %d, error: %lf' % (k, err)

        assert err < max(-k, -13), "WENO (k=%d, left) is broken" % (k)
Exemple #3
0
def test_reconstruction():

  K = (5, 7)
  x = np.linspace(0.0, 2*np.pi, 51)

  # average of f (we're testing striding too, hence the extra component)
  q      = np.zeros((3,x.size-1))
  q[0,:] = F(x[:-1], x[1:])

  for k in K:
    qr = reconstruct(q[0,:], k, 'left')
    err = np.log10(1e-30 + abs(qr[k:-k] - f(x[:-1])[k:-k]).max())

    print 'k: %d, error: %lf' % (k, err)

    assert err < max(-k, -13), "WENO (k=%d, left) is broken" % (k)