Skip to main content
`Ctrl`+`K`

# PetscSFCreateStridedSF

Create an `PetscSF` to communicate interleaved blocks of data

## Synopsis

    #include "petscsf.h"
    PetscErrorCode PetscSFCreateStridedSF(PetscSF sf, PetscInt bs, PetscInt ldr, PetscInt ldl, PetscSF *vsf)

Collective

## Input Parameters

- sf - star forest

- bs - stride

- ldr - leading dimension of root space

- ldl - leading dimension of leaf space

## Output Parameter

- vsf - the new `PetscSF`

## Notes

This can be useful to perform communications on multiple right-hand sides stored in a Fortran-style two dimensional array. For example, the calling sequence

      c_datatype *roots, *leaves;
      for i in [0,bs) do
        PetscSFBcastBegin(sf, mpi_datatype, roots + i*ldr, leaves + i*ldl, op)
        PetscSFBcastEnd(sf, mpi_datatype, roots + i*ldr, leaves + i*ldl, op)

is equivalent to

      c_datatype *roots, *leaves;
      PetscSFCreateStridedSF(sf, bs, ldr, ldl, &vsf)
      PetscSFBcastBegin(vsf, mpi_datatype, roots, leaves, op)
      PetscSFBcastEnd(vsf, mpi_datatype, roots, leaves, op)

## Developer Notes

Should this functionality be handled with a new API instead of creating a new object?

## See Also

PetscSF - an alternative to low-level MPI calls for data communication, `PetscSF`, `PetscSFCreate()`, `PetscSFSetGraph()`

## Level

intermediate

## Location

src/vec/is/sf/utils/sfutils.c

## Examples

src/vec/is/sf/tutorials/ex1.c

Index of all PetscSF routines
Table of Contents for all manual pages
Index of all manual pages