Numerical investigations on vortex-induced vibration (VIV) of a flexible cylinder with different length to diameter ratios, named the aspect ratio (L/D), ranging from 167 to 667 in an oscillatory flow have been conducted by the viv-FOAM-SJTU solver. The solver is developed based on the open source toolbox OpenFOAM and the two-dimensional (2D) strip theory. Hydrodynamic forces are calculated through the PIMPLE algorithm in each 2D fluid strip. The Finite Element Method (FEM) combined with the Newmark-β method are used to calculate vibrations of the flexible cylinder in both crossflow and inline directions. The cylinder model is pinned at both ends with top and bottom support frames forced to harmonically oscillate in the inline direction, which contributes to the generation of a relative oscillatory flow between the still water and the flexible cylinder. Mesh and fluid strip convergence studies are conducted to choose the appropriate computational model for subsequent simulations. Simulation results and experiment results are in good agreement that verifies the validity of the solver. Comparisons among simulations with different aspect ratios are analyzed detailedly. The maximum vibration amplitude, the dominant vibration mode and the non-dimensional dominant vibration frequency in both directions are enlarged apparently with the increase of the cylinder aspect ratio. The typical vibration trajectory changes from the butterfly type to the stripe type with L/D increases.