Introduced in this work is a relation that captures the behavior of grain size with the varying process parameters in friction stir processing of AZ31B. The relation was based on the results of a 3D FE model that was used to run simulations of the process at different tool rotational and traverse speeds. The model was validated by comparing its state variable outputs to experimental results found in the literature. The coefficients of the proposed relation were determined for magnesium alloy AZ31B. This proposed relation will aid in controlling the output grain size in computerized friction stir processes.