xref: /petsc/include/petscsftypes.h (revision 38ab3f8ade3d9d5a6e753c5c879a9fe9edd01cb0)
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.
120c312b8eSJed Brown   A star  http://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 
150c312b8eSJed Brown .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 
26*38ab3f8aSBarry Smith   Sample Usage:
27*38ab3f8aSBarry Smith $      PetscSFNode    *remote;
28*38ab3f8aSBarry Smith $    ierr = PetscMalloc1(nleaves,&remote);CHKERRQ(ierr);
29*38ab3f8aSBarry Smith $    for (i=0; i<size; i++) {
30*38ab3f8aSBarry Smith $      remote[i].rank = i;
31*38ab3f8aSBarry Smith $      remote[i].index = rank;
32*38ab3f8aSBarry Smith $    }
33*38ab3f8aSBarry Smith 
34*38ab3f8aSBarry Smith   Sample Fortran Usage:
35*38ab3f8aSBarry Smith $     type(PetscSFNode) remote(6)
36*38ab3f8aSBarry Smith $      remote(1)%rank  = modulo(rank+size-1,size)
37*38ab3f8aSBarry Smith $      remote(1)%index = 1 * stride
38*38ab3f8aSBarry 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