1 static char help[] = "Tests using MatShift() to create a constant diagonal matrix\n\n";
2
3 #include <petscmat.h>
4
main(int argc,char ** argv)5 int main(int argc, char **argv)
6 {
7 Mat A, F;
8 MatFactorInfo info;
9 PetscInt m = 10;
10 IS perm;
11 PetscMPIInt size;
12 PetscBool issbaij;
13
14 PetscFunctionBeginUser;
15 PetscCall(PetscInitialize(&argc, &argv, NULL, help));
16 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
17
18 PetscCall(MatCreate(PETSC_COMM_WORLD, &A));
19 PetscCall(MatSetSizes(A, PETSC_DECIDE, PETSC_DECIDE, m, m));
20 PetscCall(MatSetFromOptions(A));
21 PetscCall(MatSetUp(A));
22 PetscCall(MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY));
23 PetscCall(MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY));
24
25 PetscCall(MatShift(A, 1.0));
26
27 PetscCall(PetscObjectTypeCompare((PetscObject)A, MATSEQSBAIJ, &issbaij));
28 if (size == 1 && !issbaij) {
29 PetscCall(MatGetFactor(A, MATSOLVERPETSC, MAT_FACTOR_LU, &F));
30 PetscCall(MatFactorInfoInitialize(&info));
31 PetscCall(ISCreateStride(PETSC_COMM_SELF, m, 0, 1, &perm));
32 PetscCall(MatLUFactorSymbolic(F, A, perm, perm, &info));
33 PetscCall(MatLUFactorNumeric(F, A, &info));
34 PetscCall(MatDestroy(&F));
35 PetscCall(ISDestroy(&perm));
36 }
37 PetscCall(MatDestroy(&A));
38 PetscCall(PetscFinalize());
39 return 0;
40 }
41
42 /*TEST
43
44 test:
45 requires: defined(PETSC_USE_INFO)
46 args: -info
47 filter: grep malloc | sort -b
48
49 test:
50 suffix: 2
51 nsize: 2
52 requires: defined(PETSC_USE_INFO)
53 args: -info ex182info
54 filter: grep -h malloc "ex182info.0" | sort -b
55
56 test:
57 suffix: 3
58 requires: defined(PETSC_USE_INFO)
59 args: -info -mat_type baij
60 filter: grep malloc | sort -b
61
62 test:
63 suffix: 4
64 nsize: 2
65 requires: defined(PETSC_USE_INFO)
66 args: -info ex182info -mat_type baij
67 filter: grep -h malloc "ex182info.1" | sort -b
68
69 test:
70 suffix: 5
71 requires: defined(PETSC_USE_INFO)
72 args: -info -mat_type sbaij
73 filter: grep malloc | sort -b
74
75 test:
76 suffix: 6
77 nsize: 2
78 requires: defined(PETSC_USE_INFO)
79 args: -info ex182info -mat_type sbaij
80 filter: grep -h malloc "ex182info.0" | sort -b
81
82 test:
83 suffix: 7
84 nsize: 1
85 requires: defined(PETSC_USE_INFO)
86 args: -info ex182info
87 filter: grep -h malloc "ex182info.0" | grep -v Running | sort -b
88
89 test:
90 suffix: 8
91 nsize: 2
92 requires: defined(PETSC_USE_INFO)
93 args: -info ex182info:mat
94 filter: grep -h malloc "ex182info.1" | sort -b
95
96 test:
97 suffix: 9
98 nsize: 1
99 requires: defined(PETSC_USE_INFO) !defined(PETSC_HAVE_THREADSAFETY)
100 args: -info ex182info:sys
101 filter: grep -h -ve Running -ve MPI_Comm -ve Initialize -ve communicator -ve HostName -ve PetscSetFPTrap -ve PetscDetermineInitialFPTrap -ve libpetscbamg -ve libpetscpflare "ex182info.0" | grep -v PetscBLASSetNumThreads | sort -b
102
103 test:
104 suffix: 10
105 nsize: 1
106 requires: defined(PETSC_USE_INFO)
107 args: -info :~sys
108 filter: grep -h malloc | sort -b
109
110 test:
111 suffix: 11
112 nsize: 2
113 requires: defined(PETSC_USE_INFO)
114 args: -info :~sys,mat
115 filter: sort -b
116 output_file: output/empty.out
117
118 test:
119 suffix: 12
120 nsize: 2
121 requires: defined(PETSC_USE_INFO) !defined(PETSC_HAVE_THREADSAFETY)
122 args: -info ex182info:sys,mat
123 filter: grep -h -ve Running -ve MPI_Comm -ve Initialize -ve communicator -ve HostName -ve PetscSetFPTrap -ve PetscDetermineInitialFPTrap -ve libpetscbamg -ve libpetscpflare "ex182info.1" | grep -v PetscBLASSetNumThreads | sort -b
124
125 test:
126 suffix: 13
127 nsize: 2
128 requires: defined(PETSC_USE_INFO)
129 args: -info ex182info:mat:~self
130 filter: grep -h "ex182info.1" | sort -b
131 output_file: output/empty.out
132
133 test:
134 suffix: 14
135 nsize: 2
136 requires: defined(PETSC_USE_INFO)
137 args: -info ex182info::~self
138 filter: grep -h -ve Running -ve MPI_Comm -ve Initialize -ve communicator -ve HostName -ve PetscSetFPTrap -ve PetscDetermineInitialFPTrap "ex182info.1" | sort -b
139
140 test:
141 suffix: 15
142 nsize: 2
143 requires: defined(PETSC_USE_INFO) !defined(PETSC_HAVE_THREADSAFETY)
144 args: -info ex182info::self
145 filter: grep -h -ve Running -ve MPI_Comm -ve Initialize -ve communicator -ve HostName -ve PetscSetFPTrap -ve PetscDetermineInitialFPTrap -ve libpetscbamg -ve libpetscpflare "ex182info.1" | grep -v PetscBLASSetNumThreads | sort -b
146
147 TEST*/
148