<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 21, 2013 at 1:57 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="h5">On Wed, Aug 21, 2013 at 4:59 AM, Bishesh Khanal <span dir="ltr"><<a href="mailto:bisheshkh@gmail.com" target="_blank">bisheshkh@gmail.com</a>></span> wrote:<br>
</div></div><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Aug 20, 2013 at 3:06 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>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></div><div class="gmail_extra"><div class="gmail_quote"><div><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><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></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></div></div></blockquote><div><br></div><div>Now I understand the concept, thanks! So how do I efficiently do this with petsc functions when I am using DMDA which contains the boundary points too? Conceptually the steps would be the following, I think, but which petsc functions would enable me to do this efficiently, for example, without explicitly creating the new matrix A1 in the following and instead informing KSP about it ?<br>
</div><div>1) First create the big system matrix (from DM da) including the identity rows for Dirichlet points and corresponding rhs, Lets say Ax = b. <br></div><div>2) Initialize x with zero, then set the desired Dirichlet values on corresponding boundary points of x.<br>
</div><div>3) Create a new matrix, A1 with zeros everywhere except the row,col positions corresponding to Dirchlet points where put -1.<br></div><div>4) Get b1 by multiplying A1 with x. <br></div><div>5) Update rhs with b = b + b1.<br>
</div><div>6) Now update A by removing its rows and columns that correspond to the Dirichlet points, and remove corresponding rows of b and x. <br></div><div>7) Solve Ax=b<br></div></div></div></div></blockquote><div><br>
</div></div></div><div>This is generally not a good thing to do with FD.</div></div></div></div></blockquote><div><br></div><div>Do you mean that with FD, it is better to solve the bigger matrix with the identity row for Dirichlet points instead of excluding them (That is the way I illustrated in the pseudocode in the very first email above)?<br>
</div><div>And why is it not a good thing ? (I thought by excluding the rows-cols of Dirichlet points would enable us to preserve the symmetry for symmetrical problems ?<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div> Matt </div><div class="im"><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 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 class="gmail_extra"><div class="gmail_quote">
<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<span><font color="#888888"><br>
</font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><span><font color="#888888"><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
</font></span></font></span></div></div>
</blockquote></div><br></div></div>
</blockquote></div></div><div class="im"><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></div>
</blockquote></div><br></div></div>