[petsc-users] How to zeros all entries of a set of columns of a matrix

Barry Smith bsmith at mcs.anl.gov
Thu Feb 25 12:54:13 CST 2010

   We get this question a lot so it has its own FAQ.

solving a symmetric system with Dirichlet boundary conditions I can use
MatZeroRows() to eliminate the Dirichlet rows but this results in a
non-symmetric system. How come there is no MatZeroColumns() to keep the
matrix symmetric?<br>
             </span>For the default PETSc sparse matrix data  
structures (parallel and sequential) which are row based, zeroing  
certain columns is very expensive (it would require either searches or  
additional data structures). Hence we don't provide this  
functionality. One can solve Dirichilet boundary condition problems  
using symmetric methods two ways. (1) Manually call MatGetSubMatrix()  
to extract your symmetric subproblem or (2) call MatZeroRows() then  
use the PCREDISTRIBUTE preconditioner to solve the reduced system using
symmetric methods. See its manual page.
             <hr> </td>

Does this help you understand the situation? Or are you dealing with a  
very different situation?


On Feb 25, 2010, at 11:08 AM, rlchen2008 wrote:

> Dear all,
>   Who can tell me how to zero all entries of a set of COLUMNS of a  
> matrix and let all diagonals of eliminated COLUMNS be 1.0?
>   Thanks!
> Rongliang

More information about the petsc-users mailing list