#-------------------------
# ts: 
#-------------------------

# alternative way to get the top/bottom middle dof using slicing of FEGrid:
# i.e. get the element which is placed right for the center and then get the lower left node

#bottom_middle_dof = domain[shape[0]/2, 0, 0, 0].dofs[0,0,1]
#top_middle_dof    = domain[shape[0]/2,-1, 0,-1].dofs[0,0,1]

top_middle_dofs, top_middle_dof_points = domain.get_top_middle_dofs()
top_middle_dof = top_middle_dofs[0,1]
print 'top_middle_dof', top_middle_dof

bottom_middle_dofs, bottom_middle_dof_points = domain.get_bottom_middle_dofs()
bottom_middle_dof = bottom_middle_dofs[0,1]
print 'bottom_middle_dof', bottom_middle_dof

tstepper = TS( dof_resultants = True,
               sdomain = domain,
     bcond_list =  [ BCDof( var='u', value = u_max, dof = top_middle_dof ),
                     BCDofGroup( var='u', value = 0., dims = [0,1],
                              get_dof_method = domain.get_bottom_left_dofs ),
                     BCDofGroup( var='u', value = 0., dims = [1],
                              get_dof_method = domain.get_bottom_right_dofs ) ],
     rtrace_list =  [
                 RTraceGraph(name = 'Fi at top over u at bottom (iteration)' ,
                             var_y = 'F_int', idx_y = top_middle_dof,
                             var_x = 'U_k', idx_x = bottom_middle_dof,
                             transform_x = '-x',