result of reverse communication

Dear LAMMPS - users!

I try to write compute, that calculates clusters and there sizes (like compute/cluster/atom, but with the cluster sizes). One moment is not clear for me.

When an atom has several ghost atoms in others nodes (for example atom in a corner of the box), what will be the result of reverse/communicate command?

Are the data from different ghost atoms summarize?
Or the data of ghost atoms write to the local atom in arbitrary order?

Is there any way to control the result?

Regards, Alexander Vorontsov

Dear Alexander,

From looking at the unpack_reverse functions in the atom_vec_*.cpp files, it looks like the forces from all of the ghosts are accumulated on the atom in the order that they're received. For example, if your atom starts with a force f, and its ghosts have forces f1, f2, f3, ..., the final force on the atom will be f + f1 + f2 + f3 + ...

What do you mean by 'control the result'? You can use the newton command ( http://lammps.sandia.gov/doc/newton.html) to have each processor do the full force calculation for each of its atoms, rather than communicate the forces, if you prefer.

When an atom has several ghost atoms in others nodes (for example atom in a corner of the box), what will be the result of >reverse/communicate command?

It will be the sum of all the ghost values plus the original value.

Steve

My question was about REVERSE_COMM_COMPUTE command, maybe there is any difference?

I wrote a simple code (see below) and expected to see in “color” 0 for atoms with no ghost image, and n=1,2,3,… for atoms with n ghost images. But the result is only 0 and 1. What is happend?:

Regards, Alexander Vorontsov.

for (i = 0; i < nmax; i++) color[i] = 0;

int ComputeClusterAtom::pack_reverse_comm(int n, int first, double *buf) {

int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) buf[m++] = 1.;
return 1;
}

void ComputeClusterAtom::unpack_reverse_comm(int n, int *list, double *buf) {
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
color[j] = buf[m++];
}
}

Sorry for many letters.

I found that "list" in "unpack_reverse_comm" has repeated numbers, so all the information from ghost atoms contains there.
And I should do any operation with it myself.

Is it correct?
Regards, Alexander Vorontsov.

My question was about REVERSE_COMM_COMPUTE command, maybe there is any difference?

I wrote a simple code (see below) and expected to see in "color" 0 for atoms with no ghost image, and n=1,2,3,... for atoms with n ghost images. But the result is only 0 and 1. What is happend? :

Regards, Alexander Vorontsov.

for (i = 0; i < nmax; i++) color[i] = 0;

int ComputeClusterAtom::pack_reverse_comm(int n, int first, double *buf) {
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) buf[m++] = 1.;
return 1;
}

void ComputeClusterAtom::unpack_reverse_comm(int n, int *list, double *buf) {
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
color[j] = buf[m++];
}
}

You’re providing the unpack function, not LAMMPS. If you
sum the values in your unpack function, they will be summed.
If you don’t, they won’t be. Just about every unpack function
in LAMMPS does a sum, so that’s what I assumed you were
asking.

Steve