Use MatSetValues with ADD_VALUES. The method is used for toy examples because it is the most brain-dead simple thing to implement, not because it is a good method. Much better to lift and remove or to eliminate in-place. Any good book discusses this and there are useful answers on scicomp.stackexchange.com. On Feb 23, 2013 6:36 AM, "Hui Zhang" <mike.hui.zhang at hotmail.com> wrote:
> > On Feb 23, 2013, at 1:32 PM, Jed Brown wrote: > > > Add big values to diagonal entries and scale the right hand side > appropriately, as per the definition. It is a terrible method. > > Why? That is what I was taught by textbooks and used by some FEM library > like FreeFem++. > > > > > On Feb 23, 2013 6:29 AM, "Hui Zhang" <mike.hui.zhang at hotmail.com> wrote: > > I want to implement diagonal penalty method for enforcing the Dirichlet > boundary conditions. That is, the diagonal entries corresponding to > Dirichlet boundary are going to be scaled by a large number. > > > > What is the easiest way to do this? Thanks! > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130223/f0324831/attachment-0001.html>
