Actual source code: ex7.c

petsc-3.13.6 2020-09-29
Report Typos and Errors

  2: static char help[] = "Tests MatILUFactorSymbolic() on matrix with missing diagonal.\n\n";

  4:  #include <petscmat.h>
  5:  #include <petscpc.h>

  7: int main(int argc,char **args)
  8: {
  9:   Mat            C,A;
 10:   PetscInt       i,j;
 12:   PetscScalar    v;
 13:   PC             pc;
 14:   Vec            xtmp;

 16:   PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
 17:   MatCreate(PETSC_COMM_WORLD,&C);
 18:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,3,3);
 19:   MatSetFromOptions(C);
 20:   MatSetUp(C);
 21:   VecCreateSeq(PETSC_COMM_WORLD,3,&xtmp);
 22:   i    = 0; j = 0; v = 4;
 23:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);
 24:   i    = 0; j = 2; v = 1;
 25:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);
 26:   i    = 1; j = 0; v = 1;
 27:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);
 28:   i    = 1; j = 1; v = 4;
 29:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);
 30:   i    = 2; j = 1; v = 1;
 31:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);

 33:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
 34:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);

 36:   MatView(C,PETSC_VIEWER_STDOUT_WORLD);
 37:   PCCreate(PETSC_COMM_WORLD,&pc);
 38:   PCSetFromOptions(pc);
 39:   PCSetOperators(pc,C,C);
 40:   PCSetUp(pc);
 41:   PCFactorGetMatrix(pc,&A);
 42:   MatView(A,PETSC_VIEWER_STDOUT_WORLD);

 44:   PCDestroy(&pc);
 45:   VecDestroy(&xtmp);
 46:   MatDestroy(&C);

 48:   PetscFinalize();
 49:   return ierr;
 50: }