MatZeroRows and MatAssembly

Barry Smith bsmith at
Wed May 28 10:06:04 CDT 2008

On May 28, 2008, at 9:48 AM, Gong Ding wrote:

> Hi,
> I meet some trouble about my code.
> I'd like to use MatZeroRows to perform  Dirichlet boundary condition.
> However, it requires MatAssembly, which packs the sparse matrix.
> Then the none zero pattern seems to be freezed.

    Not froozen, but yes adding more nonzeros later will be inefficient.

> The continued MatSetValues
> may be very low efficient if the item not in the previous none zero  
> pattern..

> Is there any way to use MatZeroRows without freeze the none zero  
> pattern?


> Or I have to redesign my code....

    Generally you can apply the Dirichlet boundary conditions after  
you have
completely constructed the matrix.


> Regards
> Gong Ding

More information about the petsc-users mailing list