将用户定义的矩阵替换为PETSc矩阵

时间:2014-04-24 16:56:54

标签: c++ mpi sparse-matrix petsc

我有顺序块AIJ矩阵,用c ++编写,我将使用PETSc创建MPI矩阵。因此,我必须将我的稀疏块AIJ矩阵替换为MPI块AIJ PETSc矩阵。有没有人有关于如何做到这一点的任何例子? 我很感激有关我想要完成的任务的任何建议。

1 个答案:

答案 0 :(得分:0)

一个好的起点可能是http://www.mcs.anl.gov/petsc/petsc-current/src/mat/examples/tutorials/ex5.c.html

Opens a separate file for each process and reads in ITS portion
of a large parallel matrix. Only requires enough memory to store
the processes portion of the matrix ONCE.

它使用MatSetValues()来设置值。仔细阅读文档以了解您应该做什么:http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValues.html。 PETSC手册上的章节也将为您提供帮助。

如果您想使用阻止矩阵(BAIJ),可以使用MatSetValuesBlocked() http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesBlocked.html#MatSetValuesBlocked (和MatSetBlockSize()

再见,