# PetscSFCreate
create a star forest communication context 
## Synopsis
```
#include "petscsf.h" 
PetscErrorCode PetscSFCreate(MPI_Comm comm, PetscSF *sf)
```
Collective


## Input Parameter

- ***comm -*** communicator on which the star forest will operate



## Output Parameter

- ***sf -*** new star forest context



## Options Database Keys

- ***-sf_type type -*** value of type may be


```none
    basic     -Use MPI persistent Isend/Irecv for communication (Default)
    window    -Use MPI-3 one-sided window for communication
    neighbor  -Use MPI-3 neighborhood collectives for communication
```





## Note
When one knows the communication graph is one of the predefined graph, such as `MPI_Alltoall()`, `MPI_Allgatherv()`,
`MPI_Gatherv()`, one can create a `PetscSF` and then set its graph with `PetscSFSetGraphWithPattern()`. These special
`SF`s are optimized and they have better performance than general `SF`s.


## See Also
 `PetscSF`, `PetscSFSetGraph()`, `PetscSFSetGraphWithPattern()`, `PetscSFDestroy()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/interface/sf.c.html#PetscSFCreate">src/vec/is/sf/interface/sf.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/tutorials/ex1.c.html">src/vec/is/sf/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/tutorials/ex1f.F90.html">src/vec/is/sf/tutorials/ex1f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/tutorials/ex2.c.html">src/vec/is/sf/tutorials/ex2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/tutorials/ex3.c.html">src/vec/is/sf/tutorials/ex3.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/allgather/sfallgather.c.html#PetscSFCreate_Allgather">PetscSFCreate_Allgather in src/vec/is/sf/impls/basic/allgather/sfallgather.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/allgatherv/sfallgatherv.c.html#PetscSFCreate_Allgatherv">PetscSFCreate_Allgatherv in src/vec/is/sf/impls/basic/allgatherv/sfallgatherv.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/alltoall/sfalltoall.c.html#PetscSFCreate_Alltoall">PetscSFCreate_Alltoall in src/vec/is/sf/impls/basic/alltoall/sfalltoall.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/gather/sfgather.c.html#PetscSFCreate_Gather">PetscSFCreate_Gather in src/vec/is/sf/impls/basic/gather/sfgather.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/gatherv/sfgatherv.c.html#PetscSFCreate_Gatherv">PetscSFCreate_Gatherv in src/vec/is/sf/impls/basic/gatherv/sfgatherv.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/neighbor/sfneighbor.c.html#PetscSFCreate_Neighbor">PetscSFCreate_Neighbor in src/vec/is/sf/impls/basic/neighbor/sfneighbor.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/basic/sfbasic.c.html#PetscSFCreate_Basic">PetscSFCreate_Basic in src/vec/is/sf/impls/basic/sfbasic.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/impls/window/sfwindow.c.html#PetscSFCreate_Window">PetscSFCreate_Window in src/vec/is/sf/impls/window/sfwindow.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/is/sf/interface/sf.c)


[Index of all PetscSF routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
