Actual source code: ex182.c

petsc-3.10.5 2019-03-28
Report Typos and Errors

  2: static char help[] = "Tests using MatShift() to create a constant diagonal matrix\n\n";

  4:  #include <petscmat.h>

  6: int main(int argc,char **argv)
  7: {
  8:   Mat            A,F;
  9:   MatFactorInfo  info;
 11:   PetscInt       m = 10;
 12:   IS             perm;
 13:   PetscMPIInt    size;
 14:   PetscBool      issbaij;

 16:   PetscInitialize(&argc,&argv,(char*) 0,help);if (ierr) return ierr;
 17:   MPI_Comm_size(PETSC_COMM_WORLD,&size);

 19:   MatCreate(PETSC_COMM_WORLD,&A);
 20:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,m,m);
 21:   MatSetFromOptions(A);
 22:   MatSetUp(A);
 23:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 24:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 26:   MatShift(A,1.0);

 28:   PetscObjectTypeCompare((PetscObject)A,MATSEQSBAIJ,&issbaij);
 29:   if (size == 1 && !issbaij) {
 30:     MatGetFactor(A,MATSOLVERPETSC,MAT_FACTOR_LU,&F);
 31:     MatFactorInfoInitialize(&info);
 32:     ISCreateStride(PETSC_COMM_SELF,m,0,1,&perm);
 33:     MatLUFactorSymbolic(F,A,perm,perm,&info);
 34:     MatLUFactorNumeric(F,A,&info);
 35:     MatDestroy(&F);
 36:     ISDestroy(&perm);
 37:   }
 38:   MatDestroy(&A);
 39:   PetscFinalize();
 40:   return ierr;
 41: }

 43: /*TEST

 45:    test:
 46:       requires: define(PETSC_USE_INFO)
 47:       args: -info
 48:       filter: grep malloc | sort -b

 50:    test:
 51:       suffix: 2
 52:       nsize: 2
 53:       requires: define(PETSC_USE_INFO)
 54:       args: -info ex182info
 55:       filter: grep -h malloc "ex182info.*" | sort -b
 56:       TODO: get ex182info.* to work correctly inside harness

 58:    test:
 59:       suffix: 3
 60:       requires: define(PETSC_USE_INFO)
 61:       args: -info -mat_type baij
 62:       filter: grep malloc | sort -b

 64:    test:
 65:       suffix: 4
 66:       nsize: 2
 67:       requires: define(PETSC_USE_INFO)
 68:       args: -info ex182info -mat_type baij
 69:       filter: grep -h malloc "ex182info.*" | sort -b
 70:       TODO: get ex182info.* to work correctly inside harness

 72:    test:
 73:       suffix: 5
 74:       requires: define(PETSC_USE_INFO)
 75:       args: -info -mat_type sbaij
 76:       filter: grep malloc | sort  -b

 78:    test:
 79:       suffix: 6
 80:       nsize: 2
 81:       requires: define(PETSC_USE_INFO)
 82:       args: -info ex182info -mat_type sbaij
 83:       filter: grep -h malloc "ex182info.*" | sort -b
 84:       TODO: get ex182info.* to work correctly inside harness

 86: TEST*/