linalg.topetsc#

Functions#

get_index_shift_per_block_per_process(V)

get_npts_local(V)

Compute the local number of nodes per dimension owned by the actual process.

get_npts_per_block(V)

Compute the number of nodes per block, process and dimension.

mat_topetsc(mat)

Convert operator from Psydac format to a PETSc.Mat object.

petsc_local_to_psydac(V, petsc_index)

Convert the PETSc local index (starting from 0 in each process) to a Psydac local index (natural multi-index, as grid coordinates).

psydac_to_petsc_global(V, block_indices, ...)

Convert the Psydac local index (natural multi-index, as grid coordinates) to a PETSc global index.

toIJVrowmap(mat_block, bd, bc, I, J, V, ...)

vec_topetsc(vec)

Convert vector from Psydac format to a PETSc.Vec object.

Details#

petsc_local_to_psydac(V: VectorSpace, petsc_index: int)[source]#

Convert the PETSc local index (starting from 0 in each process) to a Psydac local index (natural multi-index, as grid coordinates).

Parameters:
VVectorSpace

The vector space to which the Psydac vector belongs. This defines the number of blocks, the size of each block, and how each block is distributed across MPI processes.

petsc_indexint

The local PETSc index. The 0 index is only owned by every process.

Returns:
block: tuple

The block where the Psydac multi-index belongs to.

psydac_indextuple

The Psydac local multi-index. This index is local the block.

psydac_to_petsc_global(V: VectorSpace, block_indices, ndarray_indices) int[source]#

Convert the Psydac local index (natural multi-index, as grid coordinates) to a PETSc global index. Performs a search to find the process owning the multi-index.

Parameters:
VVectorSpace

The vector space to which the Psydac vector belongs. This defines the number of blocks, the size of each block, and how each block is distributed across MPI processes.

block_indicestuple[int]

The indices which identify the block in a (possibly nested) block vector. In the case of a StencilVector this is an empty tuple.

ndarray_indicestuple[int]

The multi-index which identifies an element in the _data array, excluding the ghost regions.

Returns:
petsc_indexint

The global PETSc index. The 0 index is only owned by the first process.

get_npts_local(V: VectorSpace) list[source]#

Compute the local number of nodes per dimension owned by the actual process. This is a local variable, its value will be different for each process.

Returns:
list

Local number of nodes per dimension owned by the actual process. In case of a StencilVectorSpace the list contains a single list with length equal the number of dimensions in the domain. In case of a BlockVectorSpace the list has length equal the number of blocks.

get_npts_per_block(V: VectorSpace) list[source]#

Compute the number of nodes per block, process and dimension. This is a global variable, its value is the same for all processes.

Returns:
list

Number of nodes per block, process and dimension.

vec_topetsc(vec)[source]#

Convert vector from Psydac format to a PETSc.Vec object.

Parameters:
vecpsydac.linalg.stencil.StencilVector | psydac.linalg.block.BlockVector

Psydac StencilVector or BlockVector. In the case of a BlockVector, only the case where the blocks are StencilVector is implemented.

Returns:
gvecPETSc.Vec

PETSc vector

mat_topetsc(mat)[source]#

Convert operator from Psydac format to a PETSc.Mat object.

Parameters:
matpsydac.linalg.stencil.StencilMatrix | psydac.linalg.block.BlockLinearOperator

Psydac operator. In the case of a BlockLinearOperator, only the case where the blocks are StencilMatrix is implemented.

Returns:
gmatPETSc.Mat

PETSc Matrix