You did the right thing.

The way NumericVectors work is that you queue up a bunch of changes to their entries (in this case your `set()` calls)... but those changes actually don't happen until you do a `close()`.  This allows you to do a bunch of manipulation to a vector and then only do parallel communication at the end when you `close()`.

I know that you know PETSc so just think of this as calling `VecAssemblyBegin` and `VecAssemblyEnd`