<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="">No I also printed those out and checked them. They return 0->nGlobalAtoms. The globalID-1 is because the other library which is assigning these ID's (LAMMPS) doesn’t use 0-based indexing for the global indices for whatever reason.<div class=""><br 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>
<div><br class=""><blockquote type="cite" class=""><div class="">On Apr 8, 2020, at 5:14 PM, Jed Brown <<a href="mailto:jed@jedbrown.org" class="">jed@jedbrown.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Sure, but could you have computed them as a negative number here?<br class=""><br class="">Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com" class="">jacob.fai@gmail.com</a>> writes:<br class=""><br class=""><blockquote type="cite" class="">Supposed to be the block row and column indices. So they are the atom global IDs. <br class=""><br class="">Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391<br class=""><br class=""><blockquote type="cite" class="">On Apr 8, 2020, at 4:29 PM, Jed Brown <<a href="mailto:jed@jedbrown.org" class="">jed@jedbrown.org</a>> wrote:<br class=""><br class="">What are idxm[0] and idxn[0] in this code?<br class=""><br class="">Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com" class="">jacob.fai@gmail.com</a>> writes:<br class=""><br class=""><blockquote type="cite" class="">Hello All,<br class=""><br class="">I am using MATSBAIJ to make a symmetric hamiltonian matrix, but for some reason MatSetValuesBlocked isn’t inserting anything. <br class=""><br class="">Setup:<br class=""><br 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.<br class=""><br class="">My non-working implementation:<br class=""><br class="">PetscInt bs = 4;<br class=""><br 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);                                    <br class="">.<br class="">.<br class="">.<br class="">START LOOP {<br class=""><br class="">Calculations...<br class=""><br 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]};<br class="">PetscInt                  idxm[1], idxn[1];<br class="">PetscInt                  m = 1, n = 1;<br class=""><br class="">if (globalIDs[i] < globalIDs[neighidx[0]]-1) {<br 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;<br 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="">}<br class="">ierr = MatSetValuesBlocked(*H, m, (const PetscInt *) idxm, n, (const PetscInt *) idxn, valmat, INSERT_VALUES);CHKERRQ(ierr);<br class="">} END LOOP<br class=""><br class="">ierr = MatAssemblyBegin(*H, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br class="">ierr = MatAssemblyEnd(*H, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br class=""><br class="">RETURN H<br class=""><br class="">Output from -mat_view:<br class=""><br 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:<br class=""><br 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="">Best regards,<br class=""><br class="">Jacob Faibussowitsch<br class="">(Jacob Fai - booss - oh - vitch)<br class="">Cell: (312) 694-3391<br class=""></blockquote></blockquote></blockquote></div></div></blockquote></div><br class=""></div></body></html>