3D cellular automata simulations of intra and intergranular corrosion