Actual source code: ex7.c
2: static char help[] = "Demonstrates constructing an application ordering.\n\n";
4: #include <petscao.h>
5: #include <petscviewer.h>
7: int main(int argc, char **argv)
8: {
9: PetscInt n = 5;
10: PetscMPIInt rank, size;
11: IS ispetsc, isapp;
12: AO ao;
14: PetscFunctionBeginUser;
15: PetscCall(PetscInitialize(&argc, &argv, (char *)0, help));
16: PetscCall(PetscOptionsGetInt(NULL, NULL, "-n", &n, NULL));
17: PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
18: PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
20: /* create the index sets */
21: PetscCall(ISCreateStride(PETSC_COMM_WORLD, n, rank, size, &ispetsc));
22: PetscCall(ISCreateStride(PETSC_COMM_WORLD, n, n * rank, 1, &isapp));
24: /* create the application ordering */
25: PetscCall(AOCreateBasicIS(isapp, ispetsc, &ao));
27: PetscCall(AOView(ao, PETSC_VIEWER_STDOUT_WORLD));
29: PetscCall(ISView(ispetsc, PETSC_VIEWER_STDOUT_WORLD));
30: PetscCall(ISView(isapp, PETSC_VIEWER_STDOUT_WORLD));
31: PetscCall(AOPetscToApplicationIS(ao, ispetsc));
32: PetscCall(ISView(isapp, PETSC_VIEWER_STDOUT_WORLD));
33: PetscCall(ISView(ispetsc, PETSC_VIEWER_STDOUT_WORLD));
35: PetscCall(ISDestroy(&ispetsc));
36: PetscCall(ISDestroy(&isapp));
38: PetscCall(AODestroy(&ao));
39: PetscCall(PetscFinalize());
40: return 0;
41: }
43: /*TEST
45: test:
46: nsize: 2
48: TEST*/