Actual source code: ex1.c

petsc-3.5.4 2015-05-23
Report Typos and Errors
  2: static char help[] = "Tests the creation of a PC context.\n\n";

  4: #include <petscpc.h>

  8: int main(int argc,char **args)
  9: {
 10:   PC             pc;
 12:   PetscInt       n = 5;
 13:   Mat            mat;

 15:   PetscInitialize(&argc,&args,(char*)0,help);
 16:   PCCreate(PETSC_COMM_WORLD,&pc);
 17:   PCSetType(pc,PCNONE);

 19:   /* Vector and matrix must be set before calling PCSetUp */
 20:   MatCreateSeqAIJ(PETSC_COMM_SELF,n,n,3,NULL,&mat);
 21:   MatAssemblyBegin(mat,MAT_FINAL_ASSEMBLY);
 22:   MatAssemblyEnd(mat,MAT_FINAL_ASSEMBLY);
 23:   PCSetOperators(pc,mat,mat);
 24:   PCSetUp(pc);
 25:   MatDestroy(&mat);
 26:   PCDestroy(&pc);
 27:   PetscFinalize();
 28:   return 0;
 29: }