Jinquan:<div><br><div>You need understand some basic concepts in numerical computations, for example:</div><div>- dense matrix vs. sparse matrix and their data structures</div><div>- algorithms for solve Ax=b</div><div>- available software packages, their targeted applications</div>
<div><br></div><div>See <span class="Apple-style-span" style="font-family:Times;font-size:medium"><a href="http://www.mcs.anl.gov/~hzhang/teach/cs595">www.mcs.anl.gov/~hzhang/teach/cs595</a> for a list of references.</span></div>
<div><span class="Apple-style-span" style="font-family:Times;font-size:medium"><br></span></div><div><span class="Apple-style-span" style="font-family:Times;font-size:medium">Hong</span></div><div><br><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">What I am trying to say is that
<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:Symbol;color:#1f497d"><span>·<span style="font:7.0pt "Times New Roman"">
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">allocated 1D array A in PETSc<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:Symbol;color:#1f497d"><span>·<span style="font:7.0pt "Times New Roman"">
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">passed 1D A into ScaLAPACK<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:Symbol;color:#1f497d"><span>·<span style="font:7.0pt "Times New Roman"">
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">obtained the indices of A^-1 computed from ScaLAPACK and stored them in a 1D array<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:Symbol;color:#1f497d"><span>·<span style="font:7.0pt "Times New Roman"">
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">indexed A^-1 as a 1D array in PETSc using the indices obtained from ScaLAPACK<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:Symbol;color:#1f497d"><span>·<span style="font:7.0pt "Times New Roman"">
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">constructed a sparse matrix, including A^-1 and others, using a new set of indices for A^-1.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I can have the last step done in using
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.5pt;font-family:Consolas"> ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.5pt;font-family:Consolas"> ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr);<u></u><u></u></span></p><div class="im">
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.5pt;font-family:Consolas"> ierr = MatSetFromOptions(A);CHKERRQ(ierr);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.5pt;font-family:Consolas"> ierr = MatSetUp(A);CHKERRQ(ierr);<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:1.5in;text-indent:.5in;text-autospace:none">
<span style="font-size:12.5pt;font-family:Consolas"> <u></u><u></u></span></p>
</div><p class="MsoNormal" style="margin-left:1.5in;text-indent:.5in;text-autospace:none">
<span style="font-size:12.5pt;font-family:Consolas"> ierr = MatSetValues(A,1,&Ii,1,&J,&v,INSERT_VALUES);CHKERRQ(ierr);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:12.5pt;font-family:Consolas"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">It just took too long. This is the performance issue I am having.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">To improve the performance, it is necessary for preallocation. The dilemma is:
<b>MatCreateAIJ</b> and <b>MatXCreateAIJ</b> complained the setting of </span><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">d_nz, d_nnz,o_nz, o_nnz</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">
since there are no diagonal and off-diagonal parts defined in A^-1.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Jinquan<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:petsc-users-bounces@mcs.anl.gov" target="_blank">petsc-users-bounces@mcs.anl.gov</a> [mailto:<a href="mailto:petsc-users-bounces@mcs.anl.gov" target="_blank">petsc-users-bounces@mcs.anl.gov</a>]
<b>On Behalf Of </b>Jed Brown<br>
<b>Sent:</b> Wednesday, August 08, 2012 3:04 PM</span></p><div class="im"><br>
<b>To:</b> PETSc users list<br>
<b>Subject:</b> Re: [petsc-users] Customizeing MatSetValuesBlocked(...)<u></u><u></u></div><p></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, Aug 8, 2012 at 3:45 PM, Jinquan Zhong <<a href="mailto:jzhong@scsolutions.com" target="_blank">jzhong@scsolutions.com</a>> wrote:<u></u><u></u></p><div class="im">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">It is a 1D matrix in PETSc. I just passed it as a 2D matrix in ScaLAPACK. It is still a 1D matrix
when get back into PETSc.</span><u></u><u></u></p>
</div></div><div class="im">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">What are you trying to say?<u></u><u></u></p>
</div>
</div></div>
</div>
</blockquote></div><br></div></div>