1)
MatSetType(A,MATAIJ);
This causes the matrix A to used the compressed sparse row storage format to store the matrix entries. See
MatType for a list of all matrix types.
2)
DMSetSetFromOptions(DM dm)
and the options database option -dm_mat_type <aij or baij or aijcusparse etc> Matrices can
be created for CPU usage, for GPU usage and for usage on both the CPUs and GPUs.
3)
2.3.7 Using External Linear Solvers
PETSc interfaces to several external linear solvers (also see Acknowledgments). To use these solvers, one
may:
1. Run configure with the additional options --download-packagename e.g.
--download-superlu_dist --download-parmetis (SuperLU_DIST needs ParMetis) or
--download-mumps --download-scalapack (MUMPS requires ScaLAPACK).
2. Build the PETSc libraries.
3. Use the runtime option: -ksp_type preonly (or equivalently -ksp_type none) -pc_type
<pctype> -pc_factor_mat_solver_type <packagename>. For eg: -ksp_type preonly
-pc_type lu -pc_factor_mat_solver_type superlu_dist
4)
2.2 Matrices
PETSc provides a variety of matrix implementations because no single matrix format is appropriate for all
problems. Currently, we support dense storage and compressed sparse row storage (both sequential and
parallel versions) for CPU and GPU based matrices, as well as several specialized formats. Additional
specialized formats can be easily added
支持稠密、CSR和一些特别的格式。
5)When using the block compressed sparse row matrix format (MATSEQBAIJ or MATMPIBAIJ), one can
insert elements more efficiently using the block variant, MatSetValuesBlocked() or MatSetValues-
BlockedLocal().
6)
The default matrix representation within PETSc is the general sparse AIJ format (also called the compressed sparse row format, CSR). Additional formats (such as block compressed row and block symmetric storage, which are
generally much more efficient for problems with multiple degrees of freedom per node) are discussed below.
Beginning users need not concern themselves initially with such details and may wish to proceed directly to
Basic Matrix Operations. However, when an application code progresses to the point of tuning for efficiency
and/or generating timing results, it is crucial to read this information.
默认是CSR格式。
7)
./ex1 -n 1000 -pc_type ilu -ksp_type gmres -ksp_rtol 1.e-7 -log_view
8)使用了CG方法,可以调试。可以调大小,但是还没有搞清楚怎么并行
./ex24 -pc_type icc -mat_type seqsbaij -mat_ignore_lower_triangular -m 400 -n 400
9)真正用到CG方法的并不多。
tests/ex24.c:78: PetscCall(KSPSetType(ksp, KSPCG));
tests/ex25.c:53: PetscCall(KSPSetType(ksp, KSPCG));
tutorials/ex78.c:13: const char *common[] = {KSPGMRES, KSPCG, KSPPREONLY};
tutorials/ex71.c:420: PetscCall(KSPSetType(ksp, KSPCG));
tutorials/ex59.c:780: PetscCall(KSPSetType(temp_ksp, KSPCG));
tutorials/ex59.c:816: PetscCall(KSPSetType(temp_ksp, KSPCG));
10)GMRES稍微多一点
tests/ex53.c:77: PetscCall(KSPSetType(ksp, KSPGMRES));
Binary file tests/ex1 matches
tests/ex43.c:51: PetscCall(KSPSetType(ksp, KSPGMRES));
tests/ex82.c:33: PetscCall(KSPSetType(ksp, KSPGMRES));
tests/ex22.c:89: PetscCall(KSPSetType(ksp, KSPGMRES));
Binary file tests/ex24 matches
tutorials/ex7f.F90:193: PetscCallA(KSPSetType(subksp(i+1),KSPGMRES,ierr))
tutorials/ex7.c:117: iterative methods (such as KSPGMRES) the outer Krylov method should
tutorials/ex7.c:207: PetscCall(KSPSetType(subksp[i], KSPGMRES));
tutorials/ex5f.F90:193: PetscCallA(KSPGMRESSetOrthogonalization(ksp,KSPGMRESModifiedGramSchmidtOrthogonalization,ierr))
tutorials/ex5f.F90:195: PetscCallA(KSPGMRESSetOrthogonalization(ksp,KSPGMRESClassicalGramSchmidtOrthogonalization,ierr))
tutorials/ex78.c:13: const char *common[] = {KSPGMRES, KSPCG, KSPPREONLY};
tutorials/ex62.c:242: PetscCall(KSPSetType(subksp[i], KSPGMRES));
tutorials/ex71.c:456: PetscCall(KSPGMRESSetRestart(ksp, 100));
Binary file tutorials/ex4 matches
Binary file tutorials/ex9 matches
tutorials/ex8.c:250: PetscCall(KSPSetType(subksp[i], KSPGMRES));