xref: /petsc/src/ksp/pc/tests/ex1.c (revision 503c0ea9b45bcfbcebbb1ea5341243bbc69f0bea)
1 
2 static char help[] = "Tests the creation of a PC context.\n\n";
3 
4 #include <petscpc.h>
5 
6 int main(int argc,char **args)
7 {
8   PC             pc;
9   PetscInt       n = 5;
10   Mat            mat;
11 
12   PetscCall(PetscInitialize(&argc,&args,(char*)0,help));
13   PetscCall(PCCreate(PETSC_COMM_WORLD,&pc));
14   PetscCall(PCSetType(pc,PCNONE));
15 
16   /* Vector and matrix must be set before calling PCSetUp */
17   PetscCall(MatCreateSeqAIJ(PETSC_COMM_SELF,n,n,3,NULL,&mat));
18   PetscCall(MatAssemblyBegin(mat,MAT_FINAL_ASSEMBLY));
19   PetscCall(MatAssemblyEnd(mat,MAT_FINAL_ASSEMBLY));
20   PetscCall(PCSetOperators(pc,mat,mat));
21   PetscCall(PCSetUp(pc));
22   PetscCall(MatDestroy(&mat));
23   PetscCall(PCDestroy(&pc));
24   PetscCall(PetscFinalize());
25   return 0;
26 }
27 
28 /*TEST
29 
30    test:
31 
32 TEST*/
33