<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div> You need to call MatZeroRows() once; passing all the rows you want zeroed, instead of once for each row.<div><br></div><div> If you are running in parallel each MPI process should call MatZeroRows() once passing in a list of rows to be zeroed. Each process can pass in different</div><div> rows than the other processes.<br><div><br></div><div> BTW: You do not need to call MatAssemblyBegin/End() after MatZeroRows()</div><div><br></div><div> Barry</div><div><br><div><br><blockquote type="cite"><div>On Nov 29, 2024, at 9:56 PM, Qiyue Lu <qiyuelu1@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr">Hello, <div>In the MPI context, after assembling the distributed matrix A (matmpiaij) and the right-hand-side b, I am trying to apply the 1st kind boundary condition using MatZeroRows() and VecSetValues(), for A and b respectively. </div><div>The pseudo-code is:</div><div>=========</div><div><font face="arial, sans-serif">for (<span style="background-color:rgb(255,255,255)">int key = 0; key < BCNodes_Length; key++){</span></font></div><div><span style="background-color:rgb(255,255,255)"> // retrieving the global row position</span></div> pos = BCNodes[key]; <div><span style="background-color:rgb(255,255,255)"> // Set all elements in that row 0 except the one on the diagonal to be 1.0</span></div><div> MatZeroRows(A, 1, &pos, 1.0, NULL, NULL); </div><div><span style="background-color:rgb(255,255,255)">}</span></div><div><div style="line-height:19px">MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);</div><div style="line-height:19px">MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);</div><div style="line-height:19px">=========</div><div><br></div>For BCNodes_Length = 10^4, the FOR loop timing is 8 seconds.<br>For BCNodes_Length = 15*10^4, the FOR loop timing is 3000 seconds.<br>I am using two computational nodes and each having 12 cores.<br><br>My questions are:<br>1) Is the timing plausible? Is the MatZeroRows() function so costly?<br>2) Any suggestions to apply the 1st kind boundary conditions for a better performance?<br><br>Thanks,<br>Qiyue Lu</div></div>
</div></blockquote></div><br></div></div></body></html>