1 static char help[] = "Demonstrates constructing an application ordering.\n\n"; 2 3 #include <petscao.h> 4 #include <petscviewer.h> 5 6 int main(int argc, char **argv) 7 { 8 PetscInt n = 5; 9 PetscMPIInt rank, size; 10 IS ispetsc, isapp; 11 AO ao; 12 13 PetscFunctionBeginUser; 14 PetscCall(PetscInitialize(&argc, &argv, (char *)0, 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)); 18 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)); 22 23 /* create the application ordering */ 24 PetscCall(AOCreateBasicIS(isapp, ispetsc, &ao)); 25 26 PetscCall(AOView(ao, PETSC_VIEWER_STDOUT_WORLD)); 27 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)); 33 34 PetscCall(ISDestroy(&ispetsc)); 35 PetscCall(ISDestroy(&isapp)); 36 37 PetscCall(AODestroy(&ao)); 38 PetscCall(PetscFinalize()); 39 return 0; 40 } 41 42 /*TEST 43 44 test: 45 nsize: 2 46 47 TEST*/ 48