Pass PETSc a separate workspace so that linesearches work.
Safeguard the SNES solve: make it more robust.

If the residual at a point is NaN, then instead change that
to 1e100 in the objective evaluation, so that PETSc doesn't
crash straight away, but instead has an opportunity to
backtrack via linesearching.
Merge branch 'master' into pefarrell/snes-linesearch-fixes