1 static char help[] = "Test MatNullSpaceTest() with options prefixes.\n\n"; 2 3 #include <petscmat.h> 4 5 int main(int argc, char **argv) 6 { 7 Mat mat; 8 MatNullSpace nsp; 9 PetscBool prefix = PETSC_FALSE, flg; 10 PetscInt zero = 0; 11 PetscScalar value = 0; 12 CHKERRQ(PetscInitialize(&argc, &argv, NULL, help)); 13 14 CHKERRQ(PetscOptionsGetBool(NULL, NULL, "-with_prefix",&prefix,NULL)); 15 CHKERRQ(MatCreateDense(PETSC_COMM_WORLD, 1, 1, 1, 1, NULL, &mat)); 16 CHKERRQ(MatSetOptionsPrefix(mat, prefix ? "prefix_" : NULL)); 17 CHKERRQ(MatSetUp(mat)); 18 CHKERRQ(MatSetValues(mat, 1, &zero, 1, &zero, &value, INSERT_VALUES)); 19 CHKERRQ(MatAssemblyBegin(mat, MAT_FINAL_ASSEMBLY)); 20 CHKERRQ(MatAssemblyEnd(mat, MAT_FINAL_ASSEMBLY)); 21 CHKERRQ(MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_TRUE, 0, NULL, &nsp)); 22 CHKERRQ(MatNullSpaceTest(nsp, mat, &flg)); 23 PetscCheck(flg,PETSC_COMM_WORLD,PETSC_ERR_PLIB,"Null space test failed!"); 24 CHKERRQ(MatNullSpaceDestroy(&nsp)); 25 CHKERRQ(MatDestroy(&mat)); 26 CHKERRQ(PetscFinalize()); 27 return 0; 28 } 29 30 /*TEST 31 32 test: 33 suffix: no_prefix 34 output_file: output/ex227_no_prefix.out 35 args: -mat_null_space_test_view -mat_view 36 37 test: 38 suffix: prefix 39 output_file: output/ex227_prefix.out 40 args: -prefix_mat_null_space_test_view -with_prefix -prefix_mat_view 41 42 TEST*/ 43