LAMMPS get stuck when communicating information between local atoms and ghost atoms

Hi Diaz,
I checked my codes again and didn’t find the problem.

Below are the codes for forward_communication.
aaa[ ][ ], bbb[ ][ ][ ] and ccc[ ][ ][ ][ ] are arrays stored for each local atom.

The size of comm_forward is 66. Maybe this is too big to communicate?
I used for loops inside the loop of forward_comm, will this cause the problem?

What confused me is that the codes work fine with 1 or 2 CPUs but got stuck with 4 or more CPUs.
Does anyone know what’s the possible reason for this?

int PairABC::pack_forward_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m,id,ip,l;

m = 0;
for (i = 0; i < n; i++) {
j = list[i];
for (id = 0; id < 3; id++){
buf[m++] = aaa[j][id];
}
for (id = 0; id < 3; id++){
for (ip = 0; ip < 3; ip++){
buf[m++] = bbb[j][id][ip];
}
}
for (id = 0; id < 3; id++){
for (ip = 0; ip < 3; ip++){
for (l = 0; l < 6; l++){
buf[m++] = ccc[j][id][l][ip];
}
}
}
}
return m;
}

void PairABC::unpack_forward_comm(int n, int first, double *buf)
{
int i,m,last,id,ip,l;

m = 0;
last = first + n;
for (i = first; i < last; i++) {
for (id = 0; id < 3; id++){
aaa[i][id] = buf[m++];
}
for (id = 0; id < 3; id++){
for (ip = 0; ip < 3; ip++){
bbb[i][id][ip] = buf[m++];
}
}
for (id = 0; id < 3; id++){
for (ip = 0; ip < 3; ip++){
for (l = 0; l < 6; l++){
ccc[i][id][l][ip] = buf[m++];
}
}
}
}
}

Best,
Huang

Did you allocate your new per atom arrays with memory->create or memory->grow?

Sincerely,
Adrian Diaz
Graduate Research Fellow – Mechanical and Aerospace Engineering
Herbert Wertheim College of Engineering
University of Florida

Contact – 786-863-2326

Please check the size of your arrays. You must have indexes larger than the array you allocated which is the usual problem. Hope this helps! Hao

Hi Hao,
Thanks for your information. I checked the size of arrays carefully and I didn’t find the problem what you said. If I manually changed the size to make the indexes larger than the array, LAMMPS gives an error message instead of getting stuck. What’s more, please note that the codes work fine for 1 or 2 CPUs but got stuck for 4 or more CPUs. This is the reason why I guess it is a communication problem.

Hi Diaz,
I used memory->create to allocate the new per atom arrays. The related codes read as:

if (atom->nmax > nmax) {
memory->destroy(aaa);
memory->destroy(bbb);
memory->destroy(ccc);
nmax = atom->nmax;
memory->create(aaa,nmax,3,“ABC:aaa”);
memory->create(bbb,nmax,3,3,“ABC:bbb”);
memory->create(ccc,nmax,3,6,3,“ABC:ccc”);
}

Do you think this will cause the problem?

Best,
Huang