<div dir="ltr">I would just get in the debugger, break at the MatSetValuesBlocked() line, and step through until its about to insert a value and<div>see what goes wrong. That would only take about 5 minutes.</div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 8, 2020 at 6:17 PM Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com">jacob.fai@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">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><br><div>
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;word-wrap:break-word"><div>Best regards,<br><br>Jacob Faibussowitsch<br>(Jacob Fai - booss - oh - vitch)<br>Cell: (312) 694-3391</div></div>

</div>
<div><br><blockquote type="cite"><div>On Apr 8, 2020, at 5:14 PM, Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:</div><br><div><div>Sure, but could you have computed them as a negative number here?<br><br>Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com" target="_blank">jacob.fai@gmail.com</a>> writes:<br><br><blockquote type="cite">Supposed to be the block row and column indices. So they are the atom global IDs. <br><br>Best regards,<br><br>Jacob Faibussowitsch<br>(Jacob Fai - booss - oh - vitch)<br>Cell: (312) 694-3391<br><br><blockquote type="cite">On Apr 8, 2020, at 4:29 PM, Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:<br><br>What are idxm[0] and idxn[0] in this code?<br><br>Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com" target="_blank">jacob.fai@gmail.com</a>> writes:<br><br><blockquote type="cite">Hello All,<br><br>I am using MATSBAIJ to make a symmetric hamiltonian matrix, but for some reason MatSetValuesBlocked isn’t inserting anything. <br><br>Setup:<br><br>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><br>My non-working implementation:<br><br>PetscInt bs = 4;<br><br>ierr = MatCreateSBAIJ(comm, bs, bs*nLocalAtoms, bs*nLocalAtoms, PETSC_DETERMINE, PETSC_DETERMINE, 1, NULL, 1, NULL, H);CHKERRQ(ierr);<br>ierr = MatSetOption(*H, MAT_SYMMETRIC, PETSC_TRUE);CHKERRQ(ierr);<br>ierr = MatSetUp(*H);CHKERRQ(ierr);                                    <br>.<br>.<br>.<br>START LOOP {<br><br>Calculations...<br><br>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>PetscInt                  idxm[1], idxn[1];<br>PetscInt                  m = 1, n = 1;<br><br>if (globalIDs[i] < globalIDs[neighidx[0]]-1) {<br><span style="white-space:pre-wrap">        </span>// Insert in upper triangular<br>       idxm[0] = globalIDs[i]-1;<br>       idxn[0] = globalIDs[neighidx[0]]-1;<br>} else {<br>       // swap so we insert on upper triangular                                                    <br>       idxn[0] = globalIDs[i]-1;<br>       idxm[0] = globalIDs[neighidx[0]]-1;<br>}<br>ierr = MatSetValuesBlocked(*H, m, (const PetscInt *) idxm, n, (const PetscInt *) idxn, valmat, INSERT_VALUES);CHKERRQ(ierr);<br>} END LOOP<br><br>ierr = MatAssemblyBegin(*H, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br>ierr = MatAssemblyEnd(*H, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br><br>RETURN H<br><br>Output from -mat_view:<br><br>Mat Object: 2 MPI processes<br> type: mpisbaij<br>row 0:<br>row 1:<br>row 2:<br>row 3:<br>row 4:<br>row 5:<br>row 6:<br>row 7:<br>row 8:<br>row 9:<br>row 10:<br>row 11:<br>row 12:<br>row 13:<br>row 14:<br>row 15:<br><br>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><br>Best regards,<br><br>Jacob Faibussowitsch<br>(Jacob Fai - booss - oh - vitch)<br>Cell: (312) 694-3391<br></blockquote></blockquote></blockquote></div></div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div>