Actual source code: ex1.c

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

 4:  #include petscsys.h
 5:  #include petscao.h

  9: int main(int argc,char **argv)
 10: {
 12:   PetscInt       n = 5,getpetsc[] = {0,3,4},getapp[] = {2,1,3,4};
 13:   PetscMPIInt    rank,size;
 14:   IS             ispetsc,isapp;
 15:   AO             ao;

 17:   PetscInitialize(&argc,&argv,(char*)0,help);
 18:   PetscOptionsGetInt(PETSC_NULL,"-n",&n,PETSC_NULL);
 19:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
 20:   MPI_Comm_size(PETSC_COMM_WORLD,&size);

 22:   /* create the index sets */
 23:   ISCreateStride(PETSC_COMM_WORLD,n,rank,size,&ispetsc);
 24:   ISCreateStride(PETSC_COMM_WORLD,n,n*rank,1,&isapp);

 26:   /* create the application ordering */
 27:   AOCreateBasicIS(isapp,ispetsc,&ao);

 29:   ISDestroy(ispetsc);
 30:   ISDestroy(isapp);

 32:   AOView(ao,PETSC_VIEWER_STDOUT_WORLD);

 34:   AOPetscToApplication(ao,4,getapp);
 35:   AOApplicationToPetsc(ao,3,getpetsc);
 36:   PetscSynchronizedPrintf(PETSC_COMM_WORLD,"[%d] 2,1,3,4 PetscToApplication %D %D %D %D\n",
 37:           rank,getapp[0],getapp[1],getapp[2],getapp[3]);
 38:   PetscSynchronizedPrintf(PETSC_COMM_WORLD,"[%d] 0,3,4 ApplicationToPetsc %D %D %D\n",
 39:           rank,getpetsc[0],getpetsc[1],getpetsc[2]);
 40:   PetscSynchronizedFlush(PETSC_COMM_WORLD);

 42:   AODestroy(ao);
 43:   PetscFinalize();
 44:   return 0;
 45: }
 46: