Numerical computation of optimal control for a class of distributed parameter systems