<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello All,<div class=""><br class=""></div><div class="">I am using MATSBAIJ to make a symmetric hamiltonian matrix, but for some reason MatSetValuesBlocked isn’t inserting anything. </div><div class=""><br class=""></div><div class=""><u class="">Setup:</u></div><div class=""><br class=""></div><div class="">I want a 4n x 4n symmetric matrix, where each MatSetValuesBlocked inserts a 4x4 sub-matrix of values into the global matrix, positioned by the global ID of two atoms that I am extracting. So the 4x4 interaction sub matrix between atom 1 and atom 4 will be in rows 0-4 and cols 16-20.</div><div class=""><br class=""></div><div class=""><u class="">My non-working implementation:</u></div><div class=""><br class=""></div><div class="">PetscInt bs = 4;</div><div class=""><br class=""></div><div class="">ierr = MatCreateSBAIJ(comm, bs, bs*nLocalAtoms, bs*nLocalAtoms, PETSC_DETERMINE, PETSC_DETERMINE, 1, NULL, 1, NULL, H);CHKERRQ(ierr);<br class="">ierr = MatSetOption(*H, MAT_SYMMETRIC, PETSC_TRUE);CHKERRQ(ierr);<br class="">ierr = MatSetUp(*H);CHKERRQ(ierr);                                    </div><div class="">.</div><div class="">.</div><div class="">.</div><div class="">START LOOP {</div><div class=""><br class=""></div><div class="">Calculations...</div><div class=""><br class=""></div><div class="">const PetscScalar  valmat[16] = {Es[0], Es[1], Es[2], Es[3], Ex[0], Ex[1], Ex[2], Ex[3], Ey[0], Ey[1], Ey[2], Ey[3], Ez[0], Ez[1], Ez[2], Ez[3]};</div><div class="">PetscInt                  idxm[1], idxn[1];</div><div class="">PetscInt                  m = 1, n = 1;</div><div class=""><br class=""></div><div class="">if (globalIDs[i] < globalIDs[neighidx[0]]-1) {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">   </span>// Insert in upper triangular<br class="">        idxm[0] = globalIDs[i]-1;<br class="">        idxn[0] = globalIDs[neighidx[0]]-1;</div><div class="">} else {<br class="">        // swap so we insert on upper triangular                                                    <br class="">        idxn[0] = globalIDs[i]-1;<br class="">        idxm[0] = globalIDs[neighidx[0]]-1;<br class="">}</div><div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">ierr = MatSetValuesBlocked(*H, m, (const</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""> </span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">PetscInt</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""> *) idxm, n, (</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">const</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""> </span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">PetscInt</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""> *) idxn, valmat</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">, INSERT_VALUES);CHKERRQ(ierr);</span><br class="">} END LOOP</div><div class=""><br class=""></div><div class="">ierr = MatAssemblyBegin(*H, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div><div class="">ierr = MatAssemblyEnd(*H, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);</div><div class=""><br class=""></div><div class="">RETURN H</div><div class=""><br class=""></div><div class=""><u class="">Output from -mat_view:</u></div><div class=""><br class=""></div><div class="">Mat Object: 2 MPI processes<br class="">  type: mpisbaij<br class="">row 0:<br class="">row 1:<br class="">row 2:<br class="">row 3:<br class="">row 4:<br class="">row 5:<br class="">row 6:<br class="">row 7:<br class="">row 8:<br class="">row 9:<br class="">row 10:<br class="">row 11:<br class="">row 12:<br class="">row 13:<br class="">row 14:<br class="">row 15:</div><div class=""><br class=""></div><div class="">I also checked -info :mat: and it also reports X unneeded storage space but more importantly, 0 used. I am not sure what is going wrong here. <br class=""><br class=""></div><div class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391</div></div>

</div>

<br class=""></div></body></html>