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

Function _

python/dolfinx/la/petsc.py:193–221  ·  view source on GitHub ↗

Assign PETSc vector ``x0`` values to (blocked) array(s) ``x1``. This function performs the reverse of the assignment performed by the version of :func:`.assign(x0: (npt.NDArray[np.inexact] | list[npt.NDArray[np.inexact]]), x1: PETSc.Vec)`. Args: x0: Vector that will have it

(
    x0: PETSc.Vec,  # type: ignore[name-defined]
    x1: npt.NDArray[np.inexact] | Sequence[npt.NDArray[np.inexact]],
)

Source from the content-addressed store, hash-verified

191
192@assign.register
193def _(
194 x0: PETSc.Vec, # type: ignore[name-defined]
195 x1: npt.NDArray[np.inexact] | Sequence[npt.NDArray[np.inexact]],
196):
197 """Assign PETSc vector ``x0`` values to (blocked) array(s) ``x1``.
198
199 This function performs the reverse of the assignment performed by
200 the version of :func:`.assign(x0: (npt.NDArray[np.inexact] |
201 list[npt.NDArray[np.inexact]]), x1: PETSc.Vec)`.
202
203 Args:
204 x0: Vector that will have its values assigned to ``x1``.
205 x1: An array or list of arrays to assign to.
206 """
207 if x0.getType() == PETSc.Vec.Type().NEST: # type: ignore[attr-defined]
208 x0_nest = x0.getNestSubVecs()
209 for _x0, _x1 in zip(x0_nest, x1):
210 with _x0.localForm() as x:
211 _x1[:] = x.array_r[:] # type: ignore[index]
212 else:
213 with x0.localForm() as _x0:
214 if isinstance(x1, Sequence):
215 start = 0
216 for _x1 in x1:
217 end = start + _x1.shape[0]
218 _x1[:] = _x0.array_r[start:end]
219 start = end
220 else:
221 x1[:] = _x0.array_r[:]
222
223
224def _assign_block_data(maps: Iterable[tuple[IndexMap, int]], vec: PETSc.Vec): # type: ignore[name-defined]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected