revise logic and documentation of communication cutoff selection one more time

This commit is contained in:
Axel Kohlmeyer
2019-07-25 16:00:01 -04:00
parent 183d92cad7
commit fe83e4de2e
2 changed files with 50 additions and 30 deletions

View File

@ -69,18 +69,15 @@ processors. By default the ghost cutoff = neighbor cutoff = pairwise
force cutoff + neighbor skin. See the "neighbor"_neighbor.html command
for more information about the skin distance. If the specified Rcut is
greater than the neighbor cutoff, then extra ghost atoms will be acquired.
If the provided cutoff is smaller, the provided value will be ignored
and the ghost cutoff is set to the neighbor cutoff. Specifying a
cutoff value of 0.0 will reset any previous value to the default.
If bonded interactions exist and equilibrium bond length information is
available, then also a heuristic based on that bond length (2.0x {r_eq}
for systems with dihedrals or improper, 1.5x {r_eq} without) plus
neighbor skin is applied if the communication cutoff is set to its
default value of 0.0. This avoids problems for systems without a pair
style or where the non-bonded cutoff is (much) shorter than the largest
bond lengths. A warning message is printed, if a specified
communication cutoff > 0.0 is overridden or the bond length heuristics
lead to a larger communication cutoff.
If the provided cutoff is smaller, the provided value will be ignored,
the ghost cutoff is set to the neighbor cutoff and a warning will be
printed. Specifying a cutoff value of 0.0 will reset any previous value
to the default. If bonded interactions exist and equilibrium bond length
information is available, then also a heuristic based on that bond length
is computed. It is used as communication cutoff, if there is no pair
style present and no {comm_modify cutoff} command used. Otherwise a
warning is printed, if this bond based estimate is larger than the
communication cutoff used. A
The {cutoff/multi} option is equivalent to {cutoff}, but applies to
communication mode {multi} instead. Since in this case the communication

View File

@ -588,30 +588,42 @@ void Comm::set_proc_grid(int outflag)
/* ----------------------------------------------------------------------
determine suitable communication cutoff.
use the larger of the user specified value and the cutoff required
by the neighborlist build for pair styles.
if bonded interactions exist, apply a heuristic based on the equilibrium
bond length (use 1.5x r_bond if no dihedral or improper style exists
otherwise 2x r_bond) plus neighbor list skin.
if no user specified communication cutoff is given include this
heuristic, otherwise ignore it.
this uses three inputs: 1) maximum neighborlist cutoff, 2) an estimate
based on bond lengths and bonded interaction styles present, and 3) a
user supplied communication cutoff.
the neighbor list cutoff (1) is *always* used, since it is a requirement
for neighborlists working correctly. the bond length based cutoff is
*only* used, if no pair style is defined and no user cutoff is provided.
otherwise, a warning is printed. if the bond length based estimate is
larger than what is used.
print a warning, if a user specified communication cutoff is overridden.
------------------------------------------------------------------------- */
double Comm::get_comm_cutoff()
{
double maxcommcutoff = 0.0;
double maxbondcutoff = 0.0;
double maxcommcutoff, maxbondcutoff = 0.0;
if (force->bond) {
int n = atom->nbondtypes;
for (int i = 1; i <= n; ++i)
maxbondcutoff = MAX(maxbondcutoff,force->bond->equilibrium_distance(i));
if (force->dihedral || force->improper) {
maxbondcutoff *= 2.0;
// apply bond length based heuristics.
if (force->newton_bond) {
if (force->dihedral || force->improper) {
maxbondcutoff *= 2.25;
} else {
maxbondcutoff *=1.5;
}
} else {
maxbondcutoff *=1.5;
if (force->dihedral || force->improper) {
maxbondcutoff *= 3.125;
} else if (force->angle) {
maxbondcutoff *= 2.25;
} else {
maxbondcutoff *=1.5;
}
}
maxbondcutoff += neighbor->skin;
}
@ -620,16 +632,27 @@ double Comm::get_comm_cutoff()
maxcommcutoff = MAX(cutghostuser,neighbor->cutneighmax);
// consider cutoff estimate from bond length only if no user specified cutoff
// use cutoff estimate from bond length only if no user specified
// cutoff was given and no pair style present. Otherwise print a
// warning, if the estimated bond based cutoff is larger than what
// is currently used.
if (cutghostuser == 0.0) maxcommcutoff = MAX(maxcommcutoff,maxbondcutoff);
if (!force->pair && (cutghostuser == 0.0)) {
maxcommcutoff = MAX(maxcommcutoff,maxbondcutoff);
} else {
if ((me == 0) && (maxbondcutoff > maxcommcutoff)) {
char mesg[256];
snprintf(mesg,256,"Communication cutoff %g is shorter than a bond "
"length based estimate of %g. This may lead to errors.",
maxcommcutoff,maxbondcutoff);
error->warning(FLERR,mesg);
}
}
// print warning if neighborlist cutoff overrides user cutoff or
// applied bond based cutoff is larger than neighbor cutoff.
// print warning if neighborlist cutoff overrides user cutoff
if (me == 0) {
if ( ((cutghostuser > 0.0) && (maxcommcutoff > cutghostuser))
|| ((cutghostuser == 0.0) && (maxcommcutoff == maxbondcutoff)) ) {
if ((cutghostuser > 0.0) && (maxcommcutoff > cutghostuser)) {
char mesg[128];
snprintf(mesg,128,"Communication cutoff adjusted to %g",maxcommcutoff);
error->warning(FLERR,mesg);