Multiscale gradient computation for flow in heterogeneous porous media