A three-dimensional computational model for intergranular cracking