<div dir="ltr">On Tue, Aug 20, 2013 at 7:19 AM, Bishesh Khanal <span dir="ltr"><<a href="mailto:bisheshkh@gmail.com" target="_blank">bisheshkh@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi all,<br></div>In solving problems such as laplacian/poisson equations with dirichlet boundary conditions with finite difference methods, I set explicity the required values to the diagonal of the boundary rows of the system matrix, and the corresponding rhs vector.<br>

</div>i.e.  typically my matrix building loop would be like:<br></div><br>e.g. in 2d problems, using DMDA:<br><br>FOR (i=0 to xn-1, j = 0 to yn-1)<br></div><div>     set row.i = i, row. j = j<br></div><div>     IF (i = 0 or xn-1) or (j = 0 or yn-1)  <br>

            set diagonal value of matrix A to 1 in current row. <br></div><div>     ELSE<br></div><div>            normal interior points: set the values accordingly<br></div><div>     ENDIF<br></div><div>ENDFOR<br><br></div>

<div>Is there another preferred method instead of doing this ? I saw functions such as MatZeroRows()<br></div><div>when following the answer in the FAQ regarding this at:<br><a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#redistribute" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html#redistribute</a><br>

</div><div><br></div><div>but I did not understand what it is trying to say in the last sentence of the answer "An alternative approach is ... into the load"  <br></div></div></blockquote><div><br></div><div>Since those values are fixed, you do not really have to solve for them. You can eliminate them from your</div>
<div>system entirely. Imagine you take the matrix you produce, plug in the values to X, act with the part of the</div><div>matrix  that hits them A_ID X, and move that to the RHS, then eliminate the row for Dirichlet values.</div>
<div><br></div><div>   Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div>Thanks,<br></div><div>Bishesh<br>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <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
</div></div>