Date: 2013-07-02T14:47:43+00:00

Actual source code: ex7.c
petsc-3.4.2 2013-07-02

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

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

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

     18:   PetscInitialize(&argc,&args,(char*)0,help);

     20:   MatCreate(PETSC_COMM_WORLD,&C);
     21:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,3,3);
     22:   MatSetFromOptions(C);
     23:   MatSetUp(C);
     24:   VecCreateSeq(PETSC_COMM_WORLD,3,&xtmp);
     25:   i    = 0; j = 0; v = 4;
     26:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);
     27:   i    = 0; j = 2; v = 1;
     28:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);
     29:   i    = 1; j = 0; v = 1;
     30:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);
     31:   i    = 1; j = 1; v = 4;
     32:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);
     33:   i    = 2; j = 1; v = 1;
     34:   MatSetValues(C,1,&i,1,&j,&v,INSERT_VALUES);

     36:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
     37:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);

     39:   MatView(C,PETSC_VIEWER_STDOUT_WORLD);
     40:   PCCreate(PETSC_COMM_WORLD,&pc);
     41:   PCSetFromOptions(pc);
     42:   PCSetOperators(pc,C,C,DIFFERENT_NONZERO_PATTERN);
     43:   PCSetUp(pc);
     44:   PCFactorGetMatrix(pc,&A);
     45:   MatView(A,PETSC_VIEWER_STDOUT_WORLD);

     47:   PCDestroy(&pc);
     48:   VecDestroy(&xtmp);
     49:   MatDestroy(&C);

     51:   PetscFinalize();
     52:   return 0;
     53: }