linalg.utilities#
Functions#
|
Convert a NumPy array to a Vector of the space V. |
|
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.
- 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.
Notes
This function works in parallel but it is very costly and should be avoided if performance is a priority.
- petsc_to_psydac(x, Xh, out=None)[source]#
Convert a PETSc.Vec object to a StencilVector or BlockVector. It assumes that PETSc was installed with the configuration for complex numbers. It uses the index conversion functions in psydac.linalg.topetsc.
- Parameters:
- xPETSc.Vec
PETSc vector
- Xhpsydac.linalg.stencil.StencilVectorSpace | psydac.linalg.block.BlockVectorSpace
Space of the coefficients of the PSYDAC vector.
- outpsydac.linalg.stencil.StencilVector | psydac.linalg.block.BlockVector, optional
The PSYDAC vector where to store the result.
- Returns:
- upsydac.linalg.stencil.StencilVector | psydac.linalg.block.BlockVector
PSYDAC vector. In the case of a BlockVector, the blocks must be of type StencilVector. The general case is not yet implemented.