Fix an invalid array access if WorkVec is reallocated
This branch fixes an invalid array access which may happen if the work vector is reallocated during the assembly of the residual vector because the workspace size was exceeded.
This branch fixes an invalid array access which may happen if the work vector is reallocated during the assembly of the residual vector because the workspace size was exceeded.