Actual source code: ex1.c

  1: static char help[] = "Tests the creation of a PC context.\n\n";

  3: #include <petscpc.h>

  5: int main(int argc, char **args)
  6: {
  7:   PC       pc;
  8:   PetscInt n = 5;
  9:   Mat      mat;

 11:   PetscFunctionBeginUser;
 12:   PetscCall(PetscInitialize(&argc, &args, NULL, help));
 13:   PetscCall(PCCreate(PETSC_COMM_WORLD, &pc));
 14:   PetscCall(PCSetType(pc, PCNONE));

 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: }

 28: /*TEST

 30:    test:

 32: TEST*/