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, NULL, 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 output_file: output/empty.out 32 33 TEST*/ 34