Actual source code: ex7.c

  1: static char help[] = "Demonstrates constructing an application ordering.\n\n";

  3: #include <petscao.h>

  5: int main(int argc, char **argv)
  6: {
  7:   PetscInt    n = 5;
  8:   PetscMPIInt rank, size;
  9:   IS          ispetsc, isapp;
 10:   AO          ao;

 12:   PetscFunctionBeginUser;
 13:   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
 14:   PetscCall(PetscOptionsGetInt(NULL, NULL, "-n", &n, NULL));
 15:   PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
 16:   PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));

 18:   /* create the index sets */
 19:   PetscCall(ISCreateStride(PETSC_COMM_WORLD, n, rank, size, &ispetsc));
 20:   PetscCall(ISCreateStride(PETSC_COMM_WORLD, n, n * rank, 1, &isapp));

 22:   /* create the application ordering */
 23:   PetscCall(AOCreateBasicIS(isapp, ispetsc, &ao));

 25:   PetscCall(AOView(ao, PETSC_VIEWER_STDOUT_WORLD));

 27:   PetscCall(ISView(ispetsc, PETSC_VIEWER_STDOUT_WORLD));
 28:   PetscCall(ISView(isapp, PETSC_VIEWER_STDOUT_WORLD));
 29:   PetscCall(AOPetscToApplicationIS(ao, ispetsc));
 30:   PetscCall(ISView(isapp, PETSC_VIEWER_STDOUT_WORLD));
 31:   PetscCall(ISView(ispetsc, PETSC_VIEWER_STDOUT_WORLD));

 33:   PetscCall(ISDestroy(&ispetsc));
 34:   PetscCall(ISDestroy(&isapp));

 36:   PetscCall(AODestroy(&ao));
 37:   PetscCall(PetscFinalize());
 38:   return 0;
 39: }

 41: /*TEST

 43:    test:
 44:       nsize: 2

 46: TEST*/