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 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)); 19 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)); 23 24 /* create the application ordering */ 25 PetscCall(AOCreateBasicIS(isapp,ispetsc,&ao)); 26 27 PetscCall(AOView(ao,PETSC_VIEWER_STDOUT_WORLD)); 28 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)); 34 35 PetscCall(ISDestroy(&ispetsc)); 36 PetscCall(ISDestroy(&isapp)); 37 38 PetscCall(AODestroy(&ao)); 39 PetscCall(PetscFinalize()); 40 return 0; 41 } 42 43 /*TEST 44 45 test: 46 nsize: 2 47 48 TEST*/ 49