Computer modelling of grain microstructure in three dimensions