Actual source code: ex1.c
2: static char help[] = "Tests the creation of a PC context.\n\n";
4: #include <petscpc.h>
6: int main(int argc, char **args)
7: {
8: PC pc;
9: PetscInt n = 5;
10: Mat mat;
12: PetscFunctionBeginUser;
13: PetscCall(PetscInitialize(&argc, &args, (char *)0, help));
14: PetscCall(PCCreate(PETSC_COMM_WORLD, &pc));
15: PetscCall(PCSetType(pc, PCNONE));
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: }
29: /*TEST
31: test:
33: TEST*/