How can I pass multiple quantities in forward/reverse communication


I am wondering how I can pass multiple quantities in forward communication. For example, in Pair_EAM, rho info is passed to ghost atoms. I would like to pass two quantities to ghost atoms but I am unsure how I can modify the pack/unpack commands.

The docs says this so I know it is possible but don’t know what must be altered

The Pair class also must set the comm_forward and comm_reverse variables, which store the number of values stored in the communication buffers for each operation. This means, if desired, it can choose to store multiple per-atom values in the buffer, and they will be communicated together to minimize communication overhead.

The reason being I am calling for the Voronoi volume in my pair potential via a compute and I realized that the voronoi volume is correct if its a local atom but ghost atoms get a volume of 0. So I’m guessing I must pass the voronoi volume using a forward communication. However, my pack/unpack_forward_communication functions already pass another variable.

Are there any codes that already do this so that I can use it as a template?

Any help is much appreciated!

You should be able to grep 'pack_forward_comm' $LAMMPS_DIR/src/*/fix*.cpp and find out for yourself.

(I know you were hoping for a straight answer, but as the old proverb begins, “give a man a fish …”)

The paragraph you quoted does exactly state what has to be done. Well, obviously not with the “do this, not that” level of details you seem to be expecting, but for any decent programmer the information in that paragraph is enough to identify which source files in LAMMPS do communicate multiple properties in a single forward/reverse communication.

Mind you, this section of the manual was written by @sjplimp with the expressed purpose to guide developers (like you) to implement such communication patterns in their contributed code. I remember to have specifically asked for those notes. So if you feel that that part of the manual should be improved, you should discuss with him.

In one sentence: use a 1D buffer and unpack it exactly the same way you packed it, can transfer as many values as you want.

Got it, thanks works now!