Actual source code: ex1.c

  1: /* $Id: ex1.c,v 1.22 2001/04/10 19:37:18 bsmith Exp $ */

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

 5:  #include petsc.h
 6:  #include petscao.h

 10: int main(int argc,char **argv)
 11: {
 12:   int      n = 5,ierr,rank,size,getpetsc[] = {0,3,4};
 13:   int      getapp[] = {2,1,3,4};
 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: