pass velocity to residual and dx functions