a question in neigh_gran cpp

Dear all,
I saw in the file neigh_gran.cpp, in the ´void
Neighbor::granular_bin_no_newton_ghost(NeighList *list)´ part, there
is

if (fix_history) {
   if (rsq < radsum*radsum)
   {
      for (m = 0; m < npartner[i]; m++)
          if (partner[i][m] == tag[j]) break;
            if (m < npartner[i]) {
              touchptr[n] = 1;
              for (d = 0; d < dnum; d++) {
              shearptr[nn++] = contacthistory[i][m*dnum+d];
              }
? } else {
? touchptr[n] = 0;
? for (d = 0; d < dnum; d++) {
? shearptr[nn++] = 0.0;
            }
    }
    } else {
          touchptr[n] = 0;
          for (d = 0; d < dnum; d++) {
          shearptr[nn++] = 0.0;
    }
  }
}

My question is when ¨rsq < radsum*radsum¨ is met, then the two
particles should be seen as in touch with each other, right? They may
have already been registered as partners ( if (m < npartner[i]) ) , or
they have not been registered as partners yet (else). BUT touchptr in
both cases should be set to 1, right?
That´s why I have question about the codes starting with question mark
where rouchptr is set to 0. I don´t really understand it.

Another question is, I saw in many places of the code the variable
¨firstdouble¨, but I´ve never seen where this ¨firstdouble¨ variable
got its value. I often see that the ¨firstshear¨ variable gets the
value from firstdouble, okay. BUT where does firstdouble got his own
value??

Can someone help me a bit with these quesions?
Thank you so much~

The lines with question marks are simply clearing
the variables. They are set by pair gran/hooke/history

(or other granular pair styles). If the pairs are touching
for the first time on this step, then touchptr, etc will
be set later in the timestep when the pair style detects it.

You should also look at fix gran/history, which is where
the touch/shearhistory info is stored when atoms migrate

(right before the neigh list build) so that the info
persists through the migration/reneighbor.

Steve

Thanks for your email Steve. Could you please tell a bit about how
listgranhistory is generated. I checked the code and it´s really
ambiguous and confusing. In most places listgranhistory is used but
not given value to. Only in neighbor.cpp I saw
¨lists[i-1]->listgranhistory = lists[i];¨ And I have no clue what it
is.....

Thanks

Matthew

I can;t answer that in the abstract. You’d
have to ask a specific Q.

The neighbor list for granular pair styles
with history has room to store extra info
about an I,J interaction. So the pair style
accesses and updates that info in its
compute() function.

On steps when neighbor lists are re-created
and atoms migrate to new procs, that info
needs to persist and move with the atoms
and be put into the new neighbor list.

That is what fix_shear_history.cpp does.
And the neighbor list rouitnes access its data.

Steve