xref: /petsc/include/petscsftypes.h (revision a8d69d7b0124b1e6ce75950a93e6ff079980e86f)
10c312b8eSJed Brown #if !defined(_PETSCSFTYPES_H)
20c312b8eSJed Brown #define _PETSCSFTYPES_H
30c312b8eSJed Brown 
40c312b8eSJed Brown /*S
50c312b8eSJed Brown    PetscSF - PETSc object for setting up and managing the communication of certain entries of arrays and Vecs between MPI processes.
60c312b8eSJed Brown 
70c312b8eSJed Brown    Level: intermediate
80c312b8eSJed Brown 
90c312b8eSJed Brown   Concepts: star forest
100c312b8eSJed Brown 
110c312b8eSJed Brown        PetscSF uses the concept of star forests to indicate and determine the communication patterns concisely and efficiently.
12*a8d69d7bSBarry Smith   A star  https://en.wikipedia.org/wiki/Star_(graph_theory) forest is simply a collection of trees of height 1. The leave nodes represent
130c312b8eSJed Brown   "ghost locations" for the root nodes.
140c312b8eSJed Brown 
159448b7f1SJunchao Zhang .seealso: PetscSFCreate(), VecScatter, VecScatterCreate()
160c312b8eSJed Brown S*/
170c312b8eSJed Brown typedef struct _p_PetscSF* PetscSF;
180c312b8eSJed Brown 
19799f573fSMatthew G. Knepley /*S
20799f573fSMatthew G. Knepley    PetscSFNode - specifier of owner and index
21799f573fSMatthew G. Knepley 
22799f573fSMatthew G. Knepley    Level: beginner
23799f573fSMatthew G. Knepley 
24799f573fSMatthew G. Knepley   Concepts: indexing, stride, distribution
25799f573fSMatthew G. Knepley 
2638ab3f8aSBarry Smith   Sample Usage:
2738ab3f8aSBarry Smith $      PetscSFNode    *remote;
2838ab3f8aSBarry Smith $    ierr = PetscMalloc1(nleaves,&remote);CHKERRQ(ierr);
2938ab3f8aSBarry Smith $    for (i=0; i<size; i++) {
3038ab3f8aSBarry Smith $      remote[i].rank = i;
3138ab3f8aSBarry Smith $      remote[i].index = rank;
3238ab3f8aSBarry Smith $    }
3338ab3f8aSBarry Smith 
3438ab3f8aSBarry Smith   Sample Fortran Usage:
3538ab3f8aSBarry Smith $     type(PetscSFNode) remote(6)
3638ab3f8aSBarry Smith $      remote(1)%rank  = modulo(rank+size-1,size)
3738ab3f8aSBarry Smith $      remote(1)%index = 1 * stride
3838ab3f8aSBarry Smith 
39799f573fSMatthew G. Knepley .seealso: PetscSFSetGraph()
40799f573fSMatthew G. Knepley S*/
41799f573fSMatthew G. Knepley typedef struct {
42799f573fSMatthew G. Knepley   PetscInt rank;                /* Rank of owner */
43799f573fSMatthew G. Knepley   PetscInt index;               /* Index of node on rank */
44799f573fSMatthew G. Knepley } PetscSFNode;
45799f573fSMatthew G. Knepley 
460c312b8eSJed Brown #endif
47