In petsc, there are already SetValues(Local) methods.  But when does one need GetArray methods? A related question: to copy a portion of a Mat/Vec to part of another Mat/Vec, it is usually suggested that one use a Scatter object.  Is using scatter always better than the GetArray method?
When is MatGetArray/VecGetArray useful?
petsc
MatGetArray() is an advanced (should be developer) level routine that depends on the matrix format and is best avoided. It is only used with dense matrices within PETSc; there is no reason to use it otherwise. It's existence comes from users that stubbornly insist on having the function, not from meaningful use cases.VecGetArray(), on the other hand, is the recommended way to write nonlinear residuals and other functions that need direct access to vector entries. You can use a VecScatter to obtain a local vector that contains ghost points needed during assembly, and to assemble contributions from element-partitioned subdomains (as with finite element methods). There are many examples of this in PETSc, many use DMDAVecGetArray() to also provide convenient indexing.