This work presents the development of a weakly compressible smoothed particle hydrodynamics (WCSPH) model for simulating two-dimensional transient viscoelastic free surface flow which has extensive applications in polymer processing industries. As an illustration for the capability of the model, the extrudate or die swell behaviors of second-order and Olyroyd-B polymeric fluids are studied. A systematic study has been carried out to compare constitutive models for second-order fluids available in literature in terms of their ability to capture the physics behind the swelling phenomenon. The effects of various process and rheological parameters on the die swell such as the extrusion velocity, normal stress coefficients, and Reynolds and Deborah numbers have also been investigated. The models developed here can predict both swelling and contraction of the extrudate successfully. The die swell of a second-order fluid was solved for a wide range of Deborah numbers and for two different Reynolds numbers. The numerical approach was validated through the solution of fully developed Newtonian and non-Newtonian viscoelastic flows in a two-dimensional channel as well as modeling the die swell of a Newtonian fluid. The results of these three benchmark problems were compared with analytic solutions and numerical results in literature when pertinent, and good agreements were obtained.