Grain refinement of magnesium