Exemple #1
0
gpu.drawGrid(gr)

gpu.labelCenter(gr, nzones / 2, r"$i$")
gpu.labelCenter(gr, nzones / 2 - 1, r"$i-1$")
gpu.labelCenter(gr, nzones / 2 + 1, r"$i+1$")
gpu.labelCenter(gr, nzones / 2 - 2, r"$i-2$")
gpu.labelCenter(gr, nzones / 2 + 2, r"$i+2$")

n = 0
while (n < nzones):
    gpu.drawCellAvg(gr, n, a[n], color="0.5")
    n += 1

# compute the slopes
da = gpu.lslopes(a, nolimit=1)
lda = gpu.lslopes(a)

n = 2
while (n < nzones - 2):
    gpu.drawSlope(gr, n, da[n], a[n], color="r", ls=":")
    gpu.drawSlope(gr, n, lda[n], a[n], color="r")
    n += 1

pylab.axis([gr.xmin - 0.5 * gr.dx, gr.xmax + 0.5 * gr.dx, -0.25, 1.2])
pylab.axis("off")

pylab.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)

f = pylab.gcf()
f.set_size_inches(8.0, 2.0)
def riemann():

    # grid info
    xmin = 0.0
    xmax = 1.0

    nzones = 4
    ng = 2

    gr = gpu.grid(nzones, ng=ng)

    # interior
    atemp = numpy.array([0.8, 0.7, 0.4, 0.5])

    a = numpy.zeros(2 * gr.ng + gr.nx, dtype=numpy.float64)

    # fill interior and ghost cells
    a[gr.ilo:gr.ihi + 1] = atemp[:]
    a[0:gr.ilo] = a[gr.ihi - 1:gr.ihi + 1]
    a[gr.ihi:2 * gr.ng + gr.nx] = a[gr.ihi]

    #------------------------------------------------------------------------
    # plot a domain without ghostcells
    gpu.drawGrid(gr, emphasizeEnd=1, drawGhost=1)

    gpu.labelCenter(gr, gr.ng - 2, r"$\mathrm{lo-2}$")
    gpu.labelCenter(gr, gr.ng - 1, r"$\mathrm{lo-1}$")
    gpu.labelCenter(gr, gr.ng, r"$\mathrm{lo}$")
    gpu.labelCenter(gr, gr.ng + 1, r"$\mathrm{lo+1}$")

    gpu.labelEdge(gr, gr.ng, r"$\mathrm{lo}-1/2$")

    # draw cell averages
    n = 0
    while n < gr.ng + gr.nx:
        gpu.drawCellAvg(gr, n, a[n], color="0.5", ls=":")
        n += 1

    # get slopes
    lda = gpu.lslopes(a, nolimit=1)

    n = gr.ilo - 1
    while (n <= gr.ihi):
        gpu.drawSlope(gr, n, lda[n], a[n], color="r")
        n += 1

    # compute the states to the left and right of lo-1/2
    C = 0.7  # CFL
    al = a[gr.ilo - 1] + 0.5 * gr.dx * (1.0 - C) * lda[gr.ilo - 1]
    ar = a[gr.ilo] - 0.5 * gr.dx * (1.0 + C) * lda[gr.ilo]

    # L
    gpu.markCellRightState(gr,
                           ng - 1,
                           r"$a_{\mathrm{lo}+1/2,L}^{n+1/2}$",
                           value=al,
                           vertical="top",
                           color="b")

    # R
    gpu.markCellLeftState(gr,
                          ng,
                          r"$a_{\mathrm{lo}+1/2,R}^{n+1/2}$",
                          value=ar,
                          vertical="top",
                          color="b")

    pylab.xlim(gr.xl[0] - 0.15 * gr.dx, gr.xr[ng + 1] + 0.15 * gr.dx)
    pylab.ylim(-0.25, 1.1)
    pylab.axis("off")

    pylab.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)

    f = pylab.gcf()
    f.set_size_inches(8.0, 2.0)

    pylab.tight_layout()

    pylab.savefig("riemann-bc.png")
    pylab.savefig("riemann-bc.eps")
Exemple #3
0
pylab.subplots_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)

f = pylab.gcf()
f.set_size_inches(8.0,2.0)

pylab.savefig("rea-start.eps")
pylab.savefig("rea-start.png")



#-----------------------------------------------------------------------------
# second frame -- reconstruction

# compute the slopes
#lda = gpu.lslopes(a, nolimit=1)
lda = gpu.lslopes(a)

# draw

pylab.clf()

gpu.drawGrid(gr)

gpu.labelCenter(gr, gr.ng + nzones/2,   r"$i$")
gpu.labelCenter(gr, gr.ng + nzones/2-1, r"$i-1$")
gpu.labelCenter(gr, gr.ng + nzones/2+1, r"$i+1$")
gpu.labelCenter(gr, gr.ng + nzones/2-2, r"$i-2$")
gpu.labelCenter(gr, gr.ng + nzones/2+2, r"$i+2$")


# draw cell averages
Exemple #4
0
gpu.drawGrid(gr)

gpu.labelCenter(gr, nzones/2,   r"$i$")
gpu.labelCenter(gr, nzones/2-1, r"$i-1$")
gpu.labelCenter(gr, nzones/2+1, r"$i+1$")
gpu.labelCenter(gr, nzones/2-2, r"$i-2$")
gpu.labelCenter(gr, nzones/2+2, r"$i+2$")


n = 0
while (n < nzones):
    gpu.drawCellAvg(gr, n, a[n], color="0.5")
    n += 1

# compute the slopes
da = gpu.lslopes(a, nolimit=1)
lda = gpu.lslopes(a)

n = 2
while (n < nzones-2):
    gpu.drawSlope(gr, n, da[n], a[n], color="r", ls=":")
    gpu.drawSlope(gr, n, lda[n], a[n], color="r")
    n += 1


pylab.axis([gr.xmin-0.5*gr.dx,gr.xmax+0.5*gr.dx, -0.25, 1.2])
pylab.axis("off")

pylab.subplots_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)

f = pylab.gcf()
def evolve(gr, a, C, num, nolimit=1):

    #-------------------------------------------------------------------------
    # first frame -- the original cell-averages

    pylab.clf()

    gpu.drawGrid(gr)

    gpu.labelCenter(gr, gr.ng + nzones / 2, r"$i$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 - 1, r"$i-1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 + 1, r"$i+1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 - 2, r"$i-2$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 + 2, r"$i+2$", fontsize="medium")

    # draw cell averages
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawCellAvg(gr, n, a[n], color="r")
        n += 1

    pylab.axis([gr.xmin - 0.5 * gr.dx, gr.xmax + 0.5 * gr.dx, -1.25, 2.0])
    pylab.axis("off")

    print gr.xmin - 0.5 * gr.dx, gr.xmax + 0.5 * gr.dx

    pylab.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)

    ax = pylab.gca()

    pylab.text(0.5,
               0.75,
               "initial state (cell averages)",
               horizontalalignment="center",
               fontsize=16,
               color="b",
               transform=ax.transAxes)

    pylab.text(0.5,
               0.95,
               "Piecewise Linear Method for Linear Advection",
               horizontalalignment="center",
               fontsize=20,
               color="k",
               transform=ax.transAxes)

    f = pylab.gcf()
    f.set_size_inches(12.8, 7.2)

    if (nolimit):
        pylab.savefig("rea-nolimit-start_%3.3d.png" % (num))
        pylab.savefig("rea-nolimit-start_%3.3d.eps" % (num))
    else:
        pylab.savefig("rea-start_%3.3d.png" % (num))
        pylab.savefig("rea-start_%3.3d.eps" % (num))

    #-------------------------------------------------------------------------
    # second frame -- reconstruction

    # compute the slopes
    lda = gpu.lslopes(a, nolimit=nolimit)

    # draw
    pylab.clf()

    gpu.drawGrid(gr)

    gpu.labelCenter(gr, gr.ng + nzones / 2, r"$i$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 - 1, r"$i-1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 + 1, r"$i+1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 - 2, r"$i-2$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 + 2, r"$i+2$", fontsize="medium")

    # draw cell averages
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawCellAvg(gr, n, a[n], color="0.5", ls=":")
        n += 1

    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawSlope(gr, n, lda[n], a[n], color="r")
        n += 1

    pylab.axis([gr.xmin - 0.5 * gr.dx, gr.xmax + 0.5 * gr.dx, -1.25, 2.0])
    pylab.axis("off")

    pylab.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)

    pylab.text(0.5,
               0.75,
               "reconstructed slopes",
               horizontalalignment="center",
               fontsize=16,
               color="b",
               transform=ax.transAxes)

    pylab.text(0.5,
               0.95,
               "Piecewise Linear Method for Linear Advection",
               horizontalalignment="center",
               fontsize=20,
               color="k",
               transform=ax.transAxes)

    f = pylab.gcf()
    f.set_size_inches(12.8, 7.2)

    if (nolimit):
        pylab.savefig("rea-nolimit-reconstruction_%3.3d.png" % (num))
        pylab.savefig("rea-nolimit-reconstruction_%3.3d.eps" % (num))
    else:
        pylab.savefig("rea-reconstruction_%3.3d.png" % (num))
        pylab.savefig("rea-reconstruction_%3.3d.eps" % (num))

    #-------------------------------------------------------------------------
    # third frame -- evolve

    # draw

    pylab.clf()

    gpu.drawGrid(gr)

    gpu.labelCenter(gr, gr.ng + nzones / 2, r"$i$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 - 1, r"$i-1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 + 1, r"$i+1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 - 2, r"$i-2$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 + 2, r"$i+2$", fontsize="medium")

    # draw cell slopes
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawSlope(gr, n, lda[n], a[n], color="0.75", ls=":")
        n += 1

    # evolve
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.evolveToRight(gr, n, lda, a, C, color="r")
        n += 1

    pylab.axis([gr.xmin - 0.5 * gr.dx, gr.xmax + 0.5 * gr.dx, -1.25, 2.0])
    pylab.axis("off")

    print gr.xmin - 0.5 * gr.dx, gr.xmax + 0.5 * gr.dx

    pylab.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)

    pylab.text(0.5,
               0.75,
               "evolved with C = {}".format(C),
               horizontalalignment="center",
               fontsize=16,
               color="b",
               transform=ax.transAxes)

    pylab.text(0.5,
               0.95,
               "Piecewise Linear Method for Linear Advection",
               horizontalalignment="center",
               fontsize=20,
               color="k",
               transform=ax.transAxes)

    f = pylab.gcf()
    f.set_size_inches(12.8, 7.2)

    if (nolimit):
        pylab.savefig("rea-nolimit-evolve_%3.3d.png" % (num))
        pylab.savefig("rea-nolimit-evolve_%3.3d.eps" % (num))
    else:
        pylab.savefig("rea-evolve_%3.3d.png" % (num))
        pylab.savefig("rea-evolve_%3.3d.eps" % (num))

    #-------------------------------------------------------------------------
    # fourth frame -- re-average

    # left states (we don't need the right state when u > 0)
    al = numpy.zeros(2 * gr.ng + gr.nx, dtype=numpy.float64)

    n = gr.ilo
    while (n <= gr.ihi + 1):
        al[n] = a[n - 1] + 0.5 * (1 - C) * lda[n - 1]
        n += 1

    # the Riemann problem just picks the left state.  Do a conservative
    # update
    anew = numpy.zeros(2 * gr.ng + gr.nx, dtype=numpy.float64)

    anew[gr.ilo:gr.ihi+1] = a[gr.ilo:gr.ihi+1] + \
        C*(al[gr.ilo:gr.ihi+1] - al[gr.ilo+1:gr.ihi+2])

    pylab.clf()

    gpu.drawGrid(gr)

    gpu.labelCenter(gr, gr.ng + nzones / 2, r"$i$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 - 1, r"$i-1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 + 1, r"$i+1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 - 2, r"$i-2$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones / 2 + 2, r"$i+2$", fontsize="medium")

    # show the evolved profiles from the old time
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.evolveToRight(gr, n, lda, a, C, color="0.5", ls=":")
        n += 1

    # draw new averages
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawCellAvg(gr, n, anew[n], color="red")
        n += 1

    pylab.axis([gr.xmin - 0.5 * gr.dx, gr.xmax + 0.5 * gr.dx, -1.25, 2.0])
    pylab.axis("off")

    print gr.xmin - 0.5 * gr.dx, gr.xmax + 0.5 * gr.dx

    pylab.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)

    pylab.text(0.5,
               0.75,
               "averaged profile (final state)",
               horizontalalignment="center",
               fontsize=16,
               color="b",
               transform=ax.transAxes)

    pylab.text(0.5,
               0.95,
               "Piecewise Linear Method for Linear Advection",
               horizontalalignment="center",
               fontsize=20,
               color="k",
               transform=ax.transAxes)

    f = pylab.gcf()
    f.set_size_inches(12.8, 7.2)

    if (nolimit):
        pylab.savefig("rea-nolimit-final_%3.3d.png" % (num))
        pylab.savefig("rea-nolimit-final_%3.3d.eps" % (num))
    else:
        pylab.savefig("rea-final_%3.3d.png" % (num))
        pylab.savefig("rea-final_%3.3d.eps" % (num))

    return anew
def riemann():

    # grid info
    xmin = 0.0
    xmax = 1.0

    nzones = 4
    ng = 2

    gr = gpu.grid(nzones, ng=ng)

    # interior
    atemp = numpy.array([0.8, 0.7, 0.4, 0.5])

    a = numpy.zeros(2*gr.ng + gr.nx, dtype=numpy.float64)

    # fill interior and ghost cells
    a[gr.ilo:gr.ihi+1] = atemp[:]
    a[0:gr.ilo] = a[gr.ihi-1:gr.ihi+1]
    a[gr.ihi:2*gr.ng+gr.nx] = a[gr.ihi]



    #------------------------------------------------------------------------
    # plot a domain without ghostcells
    gpu.drawGrid(gr, emphasizeEnd=1, drawGhost=1)

    gpu.labelCenter(gr, gr.ng-2, r"$\mathrm{lo-2}$")
    gpu.labelCenter(gr, gr.ng-1, r"$\mathrm{lo-1}$")
    gpu.labelCenter(gr, gr.ng, r"$\mathrm{lo}$")
    gpu.labelCenter(gr, gr.ng+1, r"$\mathrm{lo+1}$")

    gpu.labelEdge(gr, gr.ng, r"$\mathrm{lo}-1/2$")
    
    # draw cell averages
    n = 0
    while n < gr.ng+gr.nx:
        gpu.drawCellAvg(gr, n, a[n], color="0.5", ls=":")
        n += 1

    # get slopes
    lda = gpu.lslopes(a, nolimit=1)

    n = gr.ilo-1
    while (n <= gr.ihi):
        gpu.drawSlope(gr, n, lda[n], a[n], color="r")
        n += 1

    # compute the states to the left and right of lo-1/2
    C = 0.7 # CFL
    al = a[gr.ilo-1] + 0.5*gr.dx*(1.0 - C)*lda[gr.ilo-1]
    ar = a[gr.ilo] - 0.5*gr.dx*(1.0 + C)*lda[gr.ilo]

    # L
    gpu.markCellRightState(gr, ng-1, r"$a_{\mathrm{lo}+1/2,L}^{n+1/2}$", 
                           value=al, vertical="top", color="b")

    # R
    gpu.markCellLeftState(gr, ng, r"$a_{\mathrm{lo}+1/2,R}^{n+1/2}$", 
                          value=ar, vertical="top", color="b")



    pylab.xlim(gr.xl[0]-0.15*gr.dx,gr.xr[ng+1]+0.15*gr.dx)
    pylab.ylim(-0.25, 1.1)
    pylab.axis("off")

    pylab.subplots_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)

    f = pylab.gcf()
    f.set_size_inches(8.0,2.0)

    pylab.tight_layout()

    pylab.savefig("riemann-bc.png")
    pylab.savefig("riemann-bc.eps")
def evolve(gr, a, C, num, nolimit=1):
    
    #-------------------------------------------------------------------------
    # first frame -- the original cell-averages

    pylab.clf()

    gpu.drawGrid(gr)

    gpu.labelCenter(gr, gr.ng + nzones/2,   r"$i$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2-1, r"$i-1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2+1, r"$i+1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2-2, r"$i-2$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2+2, r"$i+2$", fontsize="medium")


    # draw cell averages
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawCellAvg(gr, n, a[n], color="r")
        n += 1

    pylab.axis([gr.xmin-0.5*gr.dx,gr.xmax+0.5*gr.dx, -0.25, 1.2])
    pylab.axis("off")

    print gr.xmin-0.5*gr.dx, gr.xmax+0.5*gr.dx

    pylab.subplots_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)

    f = pylab.gcf()
    f.set_size_inches(8.0,2.0)

    if (nolimit):
        pylab.savefig("rea-nolimit-start_%3.3d.png" % (num))
        pylab.savefig("rea-nolimit-start_%3.3d.eps" % (num))
    else:
        pylab.savefig("rea-start_%3.3d.png" % (num))
        pylab.savefig("rea-start_%3.3d.eps" % (num))

    #-------------------------------------------------------------------------
    # second frame -- reconstruction

    # compute the slopes
    lda = gpu.lslopes(a, nolimit=nolimit)

    # draw
    pylab.clf()

    gpu.drawGrid(gr)

    gpu.labelCenter(gr, gr.ng + nzones/2,   r"$i$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2-1, r"$i-1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2+1, r"$i+1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2-2, r"$i-2$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2+2, r"$i+2$", fontsize="medium")


    # draw cell averages
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawCellAvg(gr, n, a[n], color="0.5", ls=":")
        n += 1

    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawSlope(gr, n, lda[n], a[n], color="r")
        n += 1

    pylab.axis([gr.xmin-0.5*gr.dx,gr.xmax+0.5*gr.dx, -0.25, 1.2])
    pylab.axis("off")


    pylab.subplots_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)

    f = pylab.gcf()
    f.set_size_inches(8.0,2.0)

    if (nolimit):
        pylab.savefig("rea-nolimit-reconstruction_%3.3d.png" % (num))
        pylab.savefig("rea-nolimit-reconstruction_%3.3d.eps" % (num))
    else:
        pylab.savefig("rea-reconstruction_%3.3d.png" % (num))
        pylab.savefig("rea-reconstruction_%3.3d.eps" % (num))


    #-------------------------------------------------------------------------
    # third frame -- evolve

    # draw

    pylab.clf()

    gpu.drawGrid(gr)

    gpu.labelCenter(gr, gr.ng + nzones/2,   r"$i$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2-1, r"$i-1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2+1, r"$i+1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2-2, r"$i-2$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2+2, r"$i+2$", fontsize="medium")


    # draw cell slopes
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawSlope(gr, n, lda[n], a[n], color="0.75", ls=":")
        n += 1

    # evolve
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.evolveToRight(gr, n, lda, a, C, color="r")
        n += 1


    pylab.axis([gr.xmin-0.5*gr.dx,gr.xmax+0.5*gr.dx, -0.25, 1.2])
    pylab.axis("off")

    print gr.xmin-0.5*gr.dx, gr.xmax+0.5*gr.dx
    
    pylab.subplots_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)

    f = pylab.gcf()
    f.set_size_inches(8.0,2.0)

    if (nolimit):
        pylab.savefig("rea-nolimit-evolve_%3.3d.png" % (num))
        pylab.savefig("rea-nolimit-evolve_%3.3d.eps" % (num))
    else:
        pylab.savefig("rea-evolve_%3.3d.png" % (num))
        pylab.savefig("rea-evolve_%3.3d.eps" % (num))


    #-------------------------------------------------------------------------
    # fourth frame -- re-average

    # left states (we don't need the right state when u > 0)
    al = numpy.zeros(2*gr.ng + gr.nx, dtype=numpy.float64)

    n = gr.ilo
    while (n <= gr.ihi+1):
        al[n] = a[n-1] + 0.5*(1 - C)*lda[n-1]
        n += 1


    # the Riemann problem just picks the left state.  Do a conservative
    # update
    anew = numpy.zeros(2*gr.ng + gr.nx, dtype=numpy.float64)

    anew[gr.ilo:gr.ihi+1] = a[gr.ilo:gr.ihi+1] + \
        C*(al[gr.ilo:gr.ihi+1] - al[gr.ilo+1:gr.ihi+2])


    pylab.clf()

    gpu.drawGrid(gr)

    gpu.labelCenter(gr, gr.ng + nzones/2,   r"$i$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2-1, r"$i-1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2+1, r"$i+1$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2-2, r"$i-2$", fontsize="medium")
    gpu.labelCenter(gr, gr.ng + nzones/2+2, r"$i+2$", fontsize="medium")


    # show the evolved profiles from the old time
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.evolveToRight(gr, n, lda, a, C, color="0.5", ls=":")
        n += 1

    # draw new averages
    n = gr.ilo
    while (n <= gr.ihi):
        gpu.drawCellAvg(gr, n, anew[n], color="red")
        n += 1

    pylab.axis([gr.xmin-0.5*gr.dx,gr.xmax+0.5*gr.dx, -0.25, 1.2])
    pylab.axis("off")

    print gr.xmin-0.5*gr.dx, gr.xmax+0.5*gr.dx

    pylab.subplots_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)

    f = pylab.gcf()
    f.set_size_inches(8.0,2.0)

    if (nolimit):
        pylab.savefig("rea-nolimit-final_%3.3d.png" % (num))
        pylab.savefig("rea-nolimit-final_%3.3d.eps" % (num))
    else:
        pylab.savefig("rea-final_%3.3d.png" % (num))
        pylab.savefig("rea-final_%3.3d.eps" % (num))

    return anew