See the post: How to apply a boundary condition to a range of DOFs? - #7 by dokken
on how to map global input node index to a degree of freedom: How to apply a boundary condition to a range of DOFs? - #7 by dokken
For your second question I cannot give many pointers, as I do not use PetscBinaryIO.