# PetscSFConcatenate
concatenate multiple `PetscSF` into one 
## Synopsis
```
#include "petscsf.h" 
PetscErrorCode PetscSFConcatenate(MPI_Comm comm, PetscInt nsfs, PetscSF sfs[], PetscBool shareRoots, PetscInt leafOffsets[], PetscSF *newsf)
```

## Input Parameters

- ***comm -*** the communicator
- ***nsfs -*** the number of input `PetscSF`
- ***sfs  -*** the array of input `PetscSF`
- ***shareRoots -*** the flag whether roots of input `PetscSF` are taken as shared (`PETSC_TRUE`), or separate and concatenated (`PETSC_FALSE`)
- ***leafOffsets -*** the array of local leaf offsets, one for each input `PetscSF`, or NULL for contiguous storage



## Output Parameters

- ***newsf -*** The resulting `PetscSF`





## Notes
The communicator of all SFs in sfs must be comm.

The offsets in leafOffsets are added to the original leaf indices.

If all input SFs use contiguous leaf storage (ilocal = NULL), leafOffsets can be passed as NULL as well.
In this case, NULL is also passed as ilocal to the resulting SF.

If any input SF has non-null ilocal, leafOffsets is needed to distinguish leaves from different input SFs.
In this case, user is responsible to provide correct offsets so that the resulting leaves are unique (otherwise an error occurs).


## See Also
 `PetscSF`, `PetscSFCompose()`, `PetscSFGetGraph()`, `PetscSFSetGraph()`

## Level
developer

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


---
[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)  
