L.zeroEntries() VS loc_L.set(0)

See, e.g., VecZeroEntries and what Vec.localForm() calls which in turn implements VecGhostGetLocalForm.

Use whichever makes sense regarding how you want to handle the ghost entries.

PS: Why is there always 78 ways to do the same thing in Python? (XD)

petsc4py is the python binding for PETSc, not necessarily a python issue. Also these two methods enact different functionality. It’s very challenging to make function and method names which clearly highlight these differences for the uninitiated. The documentation should help, but sometimes I have to read the source code to decipher functions’ utilities.

3 Likes