<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi,</div><div><br></div><div>Our unstructured finite element code does a fairly standard overlapping decomposition that allows it to calculate all the non-zero column entries for the rows owned by the processor (rows 0...ldim-1 in the local numbering).  We assemble them into a local CSR matrix and then copy them into a PETSc matrix like this:</div><div><br></div><div>for (int i=0;i<ldim;i++)</div><div>{</div><div>  irow[0] = i;</div><div>  MatSetValuesLocal(PETSCMAT(par_L),1,irow,rowptr[i+1]-rowptr[i],&colind[rowptr[i]],&a[rowptr[i]],INSERT_VALUES);</div><div>}</div><div><br></div><div>where rowptr and colind are the CSR indexing arrays in the local numbering.  </div><div><br></div><div>I would like to eliminate the duplicate memory (and the copy above). Is there a recommended way to let PETSc reference array 'a' directly or a way to get rid of 'a' and translate our CSR assembly routines to use low level PETSc data structures? </div><div><br></div><div>So far I've added <span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">MatMPIAIJSetPreallocationCSR to try to speed up the first solve, but the documentation is clear that 'a' is not a pointer to the AIJ storage so I still need the copy. I tried using MatCreateMPIAIJWithSplitArrays with the 'o' arrays set to zero but I got indexing errors, and the documentation really seems to imply that the local matrix is really not a standard CSR anyway. If that's true then it seems like the options I have are to write a shell matrix for parallel CSR storage or write some new assembly routines that use MatSetValuesLocal. I'm more concerned about the memory than the overhead of MatSetValuesLocal, but it would certainly be easier on me to use the CSR-based assembly routines we already have.</span></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre;"><br></span></font></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre;">Thanks,</span></font></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre;">Chris</span></font></div><div><br></div><br><br></body></html>