linalg.utilities#

Functions#

array_to_psydac(x, V)

Convert a NumPy array to a Vector of the space V.

petsc_to_psydac(x, Xh)

Convert a PETSc.Vec object to a StencilVector or BlockVector.

Details#

array_to_psydac(x, V)[source]#

Convert a NumPy array to a Vector of the space V. This function is designed to be the inverse of the method .toarray() of the class Vector. Note: This function works in parallel but it is very costly and should be avoided if performance is a priority.

Parameters:
xnumpy.ndarray

Array to be converted. It only contains the true data, the ghost regions must not be included.

Vpsydac.linalg.stencil.StencilVectorSpace or psydac.linalg.block.BlockVectorSpace

Space of the final Psydac Vector.

Returns:
upsydac.linalg.stencil.StencilVector or psydac.linalg.block.BlockVector

Element of space V, the coefficients of which (excluding ghost regions) are the entries of x. The ghost regions of u are up to date.

petsc_to_psydac(x, Xh)[source]#

Convert a PETSc.Vec object to a StencilVector or BlockVector. It assumes that PETSc was installed with the configuration for complex numbers. Uses the index conversion functions in psydac.linalg.topetsc.py.

Parameters:
xPETSc.Vec

PETSc vector

Returns:
upsydac.linalg.stencil.StencilVector | psydac.linalg.block.BlockVector

Psydac vector. In the case of a BlockVector, the blocks must be StencilVector. The general case is not yet implemented.