MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / _zero_vector

Function _zero_vector

python/dolfinx/la/petsc.py:45–54  ·  view source on GitHub ↗

Helper function for zeroing out PETSc vectors.

(x: PETSc.Vec)

Source from the content-addressed store, hash-verified

43
44
45def _zero_vector(x: PETSc.Vec): # type: ignore[name-defined]
46 """Helper function for zeroing out PETSc vectors."""
47 if x.getType() == PETSc.Vec.Type.NEST: # type: ignore[attr-defined]
48 for x_sub in x.getNestSubVecs():
49 with x_sub.localForm() as x_sub_local:
50 x_sub_local.set(0.0)
51 x_sub.destroy()
52 else:
53 with x.localForm() as x_local:
54 x_local.set(0.0)
55
56
57def create_vector_wrap(x: Vector) -> PETSc.Vec: # type: ignore[name-defined]

Callers

nothing calls this directly

Calls 1

setMethod · 0.45

Tested by

no test coverage detected