Casting magnesium alloys with microvoids is investigated based on its representative volume element. The representative volume element is idealized as a single spherical void in an incompressible spherical cell. Through the analysis on the microscopic velocity and strain fields of the cell, the constitutive equation for casting magnesium alloys is obtained. Void evolution equation is also presented by combining void nucleation rate with void growth rate. The corresponding numerical algorithm and finite element approach are developed and applied to the analyses of the stress response and the porosity of casting magnesium alloy ZL305 under elastoplastic deformation. The computational results show good agreement with experimental data. (C) 2004 Elsevier B.V. All rights reserved.