astrovascpy.scipy_petsc_conversions

Functions

BinaryIO2PETScMat(L[, file_name])

param L:

Numpy/SciPy array/matrix [on process 0]

BinaryIO2PETScVec(v[, file_name])

param v:

Numpy array/vector [on process 0]

BinaryIO2array(x[, file_name])

param x:

a distributed PETSc Vec

PETScMat2coo(A[, dest_rank])

Converts a distributed PETSc sparse matrice to a scipy coo sparse matrix on a specified rank

PETScVec2array(x[, dest_rank])

Converts (copies) a distributed PETSc Vec to a sequential array on specified rank

array2PETScVec(v)

Converts (copies) a sequential array/vector on process 0 to a distributed PETSc Vec

coomatrix2PETScMat(L)

Converts a sequential scipy sparse matrix (on process 0) to a PETSc Mat ('aij') matrix distributed on all processes

distribute_array(v[, array_type])

Scatter a NumPy array from rank 0 to all ranks using PETSc automatic chunk selection routine.

astrovascpy.scipy_petsc_conversions.BinaryIO2PETScMat(L, file_name='tempMat.dat')
Parameters:
  • L – Numpy/SciPy array/matrix [on process 0]

  • file_name – file name for the temporary container

Returns:

PETScMat [distributed across ranks] -> it uses the PetscBinaryIO interface (read/write from/to disk)

astrovascpy.scipy_petsc_conversions.BinaryIO2PETScVec(v, file_name='tempVec.dat')
Parameters:
  • v – Numpy array/vector [on process 0]

  • file_name – file name for the temporary container

Returns:

PETSc Vec [distributed across ranks] -> it uses the PetscBinaryIO interface (read/write from/to disk)

astrovascpy.scipy_petsc_conversions.BinaryIO2array(x, file_name='tempVec.dat')
Parameters:
  • x – a distributed PETSc Vec

  • file_name – file name for the temporary container

Returns:

numpy array on proc 0 -> it uses the PetscBinaryIO interface (read/write from/to disk)

astrovascpy.scipy_petsc_conversions.PETScMat2coo(A, dest_rank=0)

Converts a distributed PETSc sparse matrice to a scipy coo sparse matrix on a specified rank

Parameters:
  • A – PETSc Mat distributed on all procs

  • dest_rank – MPI rank receiving the coo sparse matrix

Returns:

scipy coo sparse matrix on the specified rank

astrovascpy.scipy_petsc_conversions.PETScVec2array(x, dest_rank=0)

Converts (copies) a distributed PETSc Vec to a sequential array on specified rank

Parameters:
  • x – PETSc Vec distributed on all procs

  • dest_rank – MPI rank receiving the numpy array

Returns:

NumPy array on proc 0

astrovascpy.scipy_petsc_conversions.array2PETScVec(v)

Converts (copies) a sequential array/vector on process 0 to a distributed PETSc Vec

Parameters:

v – NumPy array on proc 0, None (or whatever) on other proc

Returns:

distributed array on all procs.

Return type:

petsc4py.PETSc.Vec

astrovascpy.scipy_petsc_conversions.coomatrix2PETScMat(L)

Converts a sequential scipy sparse matrix (on process 0) to a PETSc Mat (‘aij’) matrix distributed on all processes

Parameters:

L – scipy sparse matrix on proc 0 (COO format)

Returns:

PETSc matrix distributed on all procs

astrovascpy.scipy_petsc_conversions.distribute_array(v, array_type=None)

Scatter a NumPy array from rank 0 to all ranks using PETSc automatic chunk selection routine.

Parameters:
  • v – NumPy array on rank 0, None (or whatever) on other ranks

  • array_type – set the type of the distributed array If None, it keeps the same type as v.

Returns:

distributed array on all processors

Return type:

numpy.ndarray