Setting the comm sizes of a pair style dynamically (patch)

During the development of a new pair style, we came across the following issue, which requires a patch to the LAMMPS code:

We are currently working on a new pair style that doesnt have a fixed comm_forward/comm_reverse size. The number of values per atom to be communicated rather depends on the parameters set by the "pair_coeff" command. That's why our pair style class sets the "comm_forward" and "comm_reverse" fields in the Pair::coeff() routine, and not in the class constructor like other pair styles.

However, this leads to a problem when our new pair style is used as a sub-style of "pair_style hybrid". The hybrid style reads out the "comm_forward" field of its substyles immediately after constructing them, i.e. at a time when the comm size of our pair style is not known yet.

The problem can easily be fixed by letting the hybrid pair_style determine the maximum required comm size at a later stage, for instance, at the end of PairHybrid::coeff().

As a suggestion to the LAMMPS developers, I'm posting a corresponding patch to the source file "pair_style.cpp". It would be great if you would consider/incorporate this change.

Best regards,
Alex

dynamic_comm_size_patch.diff (772 Bytes)