xref: /petsc/src/ksp/pc/tests/ex1.c (revision 73fdd05bb67e49f40fd8fd311695ff6fdf0b9b8a)
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   PetscFunctionBeginUser;
13   PetscCall(PetscInitialize(&argc, &args, (char *)0, help));
14   PetscCall(PCCreate(PETSC_COMM_WORLD, &pc));
15   PetscCall(PCSetType(pc, PCNONE));
16 
17   /* Vector and matrix must be set before calling PCSetUp */
18   PetscCall(MatCreateSeqAIJ(PETSC_COMM_SELF, n, n, 3, NULL, &mat));
19   PetscCall(MatAssemblyBegin(mat, MAT_FINAL_ASSEMBLY));
20   PetscCall(MatAssemblyEnd(mat, MAT_FINAL_ASSEMBLY));
21   PetscCall(PCSetOperators(pc, mat, mat));
22   PetscCall(PCSetUp(pc));
23   PetscCall(MatDestroy(&mat));
24   PetscCall(PCDestroy(&pc));
25   PetscCall(PetscFinalize());
26   return 0;
27 }
28 
29 /*TEST
30 
31    test:
32 
33 TEST*/
34