Judge Rita F. Lin ordered the National Science Foundation to restore grants awarded to the university, which she said had been suspended in defiance of the court.