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.nn";

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

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

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

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

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

 27:   ISDestroy(ispetsc);
 28:   ISDestroy(isapp);

 30:   AOView(ao,PETSC_VIEWER_STDOUT_WORLD);

 32:   AOPetscToApplication(ao,4,getapp);
 33:   AOApplicationToPetsc(ao,3,getpetsc);
 34:   PetscSynchronizedPrintf(PETSC_COMM_WORLD,"[%d] 2,1,3,4 PetscToApplication %d %d %d %dn",
 35:           rank,getapp[0],getapp[1],getapp[2],getapp[3]);
 36:   PetscSynchronizedPrintf(PETSC_COMM_WORLD,"[%d] 0,3,4 ApplicationToPetsc %d %d %dn",
 37:           rank,getpetsc[0],getpetsc[1],getpetsc[2]);
 38:   PetscSynchronizedFlush(PETSC_COMM_WORLD);

 40:   AODestroy(ao);
 41:   PetscFinalize();
 42:   return 0;
 43: }
 44: