Actual source code: ex227.c

petsc-3.10.5 2019-03-28
Report Typos and Errors
  1: static char help[] = "Test MatNullSpaceTest() with options prefixes.\n\n";

  3:  #include <petscmat.h>

  5: int main(int argc, char **argv)
  6: {
  7:   Mat mat;
  8:   MatNullSpace nsp;
  9:   PetscBool prefix = PETSC_FALSE, flg;
 11:   PetscInt zero = 0;
 12:   PetscScalar value = 0;
 13:   PetscInitialize(&argc, &argv, NULL, help); if (ierr) return ierr;

 15:   PetscOptionsGetBool(NULL, NULL, "-with_prefix",&prefix,NULL);
 16:   MatCreateDense(PETSC_COMM_WORLD, 1, 1, 1, 1, NULL, &mat);
 17:   MatSetOptionsPrefix(mat, prefix ? "prefix_" : NULL);
 18:   MatSetUp(mat);
 19:   MatSetValues(mat, 1, &zero, 1, &zero, &value, INSERT_VALUES);
 20:   MatAssemblyBegin(mat, MAT_FINAL_ASSEMBLY);
 21:   MatAssemblyEnd(mat, MAT_FINAL_ASSEMBLY);
 22:   MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_TRUE, 0, NULL, &nsp);
 23:   MatNullSpaceTest(nsp, mat, &flg);
 24:   if (!flg) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_PLIB,"Null space test failed!");
 25:   MatNullSpaceDestroy(&nsp);
 26:   MatDestroy(&mat);
 27:   PetscFinalize();
 28:   return ierr;
 29: }

 31: /*TEST

 33:    test:
 34:        suffix: no_prefix
 35:        output_file: output/ex227_no_prefix.out
 36:        args: -mat_null_space_test_view -mat_view

 38:    test:
 39:        suffix: prefix
 40:        output_file: output/ex227_prefix.out
 41:        args: -prefix_mat_null_space_test_view -with_prefix -prefix_mat_view

 43: TEST*/