Notes

If the Amat matrix and Pmat matrix are different you must call MatAssemblyBegin/End() on
each matrix.

If you know the operator Amat has a null space you can use MatSetNullSpace() and MatSetTransposeNullSpace() to supply the null
space to Amat and the KSP solvers will automatically use that null space as needed during the solution process.

Other defect-correction schemes can be used by computing a different matrix in place of the Jacobian. One common
example is to use the "Picard linearization" which only differentiates through the highest order parts of each term.