<p dir="ltr">You should really use MatSetValuesLocal with ADD_VALUES *before* assembling.</p>
<div class="gmail_quote">On Feb 23, 2013 7:28 AM, "Hui Zhang" <<a href="mailto:mike.hui.zhang@hotmail.com">mike.hui.zhang@hotmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On Feb 23, 2013, at 1:37 PM, Matthew Knepley wrote:<br>
<br>
> On Sat, Feb 23, 2013 at 7:35 AM, Hui Zhang <<a href="mailto:mike.hui.zhang@hotmail.com">mike.hui.zhang@hotmail.com</a>> wrote:<br>
><br>
> On Feb 23, 2013, at 1:32 PM, Matthew Knepley wrote:<br>
><br>
> > On Sat, Feb 23, 2013 at 7:29 AM, Hui Zhang <<a href="mailto:mike.hui.zhang@hotmail.com">mike.hui.zhang@hotmail.com</a>> wrote:<br>
> > 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.<br>
> ><br>
> > What is the easiest way to do this? Thanks!<br>
> ><br>
> > <a href="http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatDiagonalScale.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatDiagonalScale.html</a><br>
><br>
> But it seems not what I want. That routine scales all the entries of a mat. I want to scale only the diagonal entries.<br>
><br>
> Then use <a href="http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatDiagonalSet.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatDiagonalSet.html</a><br>
<br>
I want to do the following on an already assembled matrix (FINAL_ASSEMBLY).<br>
<br>
MatGetLocalSubMatrix .. to get 'submat',<br>
MatGetDiagonal .. to get diagonal vector 'diag',<br>
VecScale .. to scale 'diag'<br>
MatDiagonalSet .. to set scaled 'diag' to 'submat'<br>
MatRestoreLocalSubMatrix .. to restore 'submat'<br>
<br>
After the above process, do I need MatAssemblyBegin/End again? I do not know why the penalty method is bad. Maybe because the bad conditioning? I just want to try out and compare with MatZeroRowsColumns (lift and remove) method.<br>
<br>
><br>
> As Jed says, you really really do not want to do this.<br>
><br>
> Matt<br>
><br>
> ><br>
> > Matt<br>
> ><br>
> > --<br>
> > What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
> > -- Norbert Wiener<br>
><br>
><br>
><br>
><br>
> --<br>
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
> -- Norbert Wiener<br>
<br>
</blockquote></div>