Set and get local values in dolfinx vs dolfin

Hello,

I am new to FEniCS/FEniCSx and trying to switch a model from dolfin implementation to dolfinx.
I believe I was able to translate method ‘function.vector.set_local’ using ‘function.vector.setValueLocal’.
Is there also a dolfinx equivalent to ‘function.vector.get_local’ ?
If not, has the implementation changed in such a way that these operations should be interpreted differently?

Many thanks

You can either use u.vector which is simply a PETScVector:

In [1]: u.vector.setValueLocal?
Docstring: Vec.setValueLocal(self, index, value, addv=None)
Type:      builtin_function_or_method
```python
In [3]: u.vector.getArray?
Docstring: Vec.getArray(self, readonly=False)
Type:      builtin_function_or_method

However, if you are only setting values that are local to your process (either owned or ghosted values), you can simply use

u.x.array[local_index] = some_value

Thank you very much Dokken.
Will the getArray method always return the local values then?

Yes, see: VecGetArray

Perfect, thank you very much for your quick answer .