1 2 static char help[] = "Demonstrates constructing an application ordering.\n\n"; 3 4 #include <petscao.h> 5 #include <petscviewer.h> 6 7 int main(int argc,char **argv) 8 { 9 PetscInt n = 5; 10 PetscMPIInt rank,size; 11 IS ispetsc,isapp; 12 AO ao; 13 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