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 PetscFunctionBeginUser; 13 PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 14 15 PetscCall(PetscOptionsGetBool(NULL, NULL, "-with_prefix", &prefix, NULL)); 16 PetscCall(MatCreateDense(PETSC_COMM_WORLD, 1, 1, 1, 1, NULL, &mat)); 17 PetscCall(MatSetOptionsPrefix(mat, prefix ? "prefix_" : NULL)); 18 PetscCall(MatSetUp(mat)); 19 PetscCall(MatSetValues(mat, 1, &zero, 1, &zero, &value, INSERT_VALUES)); 20 PetscCall(MatAssemblyBegin(mat, MAT_FINAL_ASSEMBLY)); 21 PetscCall(MatAssemblyEnd(mat, MAT_FINAL_ASSEMBLY)); 22 PetscCall(MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_TRUE, 0, NULL, &nsp)); 23 PetscCall(MatNullSpaceTest(nsp, mat, &flg)); 24 PetscCheck(flg, PETSC_COMM_WORLD, PETSC_ERR_PLIB, "Null space test failed!"); 25 PetscCall(MatNullSpaceDestroy(&nsp)); 26 PetscCall(MatDestroy(&mat)); 27 PetscCall(PetscFinalize()); 28 return 0; 29 } 30 31 /*TEST 32 33 test: 34 suffix: no_prefix 35 output_file: output/ex227_no_prefix.out 36 args: -mat_null_space_test_view -mat_view 37 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 42 43 TEST*/ 44