# Produces 0.lcp
    rc = run_regen(base_file,0)
    assert(0==rc)

    iterations = 5
    
    for I in xrange(0,2*iterations,2):
        print 'Iteration',I
        iterfile = base_file + '.' + str(I)
        refined_iterfile = base_file + '.' + str(I+1)
        tetgened_iterfile = base_file + '.' + str(I+2)

        # SOLVE THE LCP
        # Consumes I.lcp
        # Produces I.sol
        solve_lcp_file(iterfile + '.lcp')

        # PLOT THE SOLUTION
        print "Converting ",\
            iterfile + '.ctri to',\
            iterfile + '.mesh'
        convert_ctri_to_mesh(iterfile + '.ctri',
                             iterfile + '.mesh')
        
        # REFINE
        # Consumes I.sol, I.ctri
        # Produces I+1.ctri
        rc = run_refine(base_file,I)
        assert(0==rc)

        # Consumes I+1.ctri
    assert(0==rc)

    plt.figure(1)
    plt.subplot(1,2,1)
    tmv.plot_bare_mesh(base_file + '.0')
    plt.title('Initial mesh')
    plt.draw()

    show_plots = True
    iterations = 12
    
    for I in xrange(iterations):
        print 'Iteration',I

        # SOLVE THE LCP
        solve_lcp_file(base_file + '.' + str(I) + '.lcp') # Generates .sol

        # PLOT THE SOLUTION
        if show_plots:
            plot_solution(base_file,I)
            plt.draw()

        # REFINE
        rc = run_refine(base_file,I)
        assert(0==rc)
        # PLOT THE HEURISTICS
        if show_plots:
            plot_refine_stats(base_file,I) 
            plt.draw()
        # Generate the LCP based on the refined mesh
        rc = run_regen(base_file,I+1)