Efficient calculation of divergence of velocity