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