xref: /petsc/src/ksp/pc/tests/ex1.c (revision 517f4e3460cd8c7e73c19b8bf533f1efe47f30a7)
1 static char help[] = "Tests the creation of a PC context.\n\n";
2 
3 #include <petscpc.h>
4 
5 int main(int argc, char **args)
6 {
7   PC       pc;
8   PetscInt n = 5;
9   Mat      mat;
10 
11   PetscFunctionBeginUser;
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