Unverified Commit d6886243 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1581 from akohlmey/comm-cutoff-with-bond

Include bonds in communication cutoff estimate when no pair style is present or print warning, if cutoff may be too small.
parents 191044ab fe83e4de
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -129,6 +129,16 @@ Self-explanatory. :dd

Self-explanatory. :dd

{Communication cutoff is 0.0. No ghost atoms will be generated. Atoms may get lost} :dt

The communication cutoff defaults to the maximum of what is inferred from
pair and bond styles (will be zero, if none are defined) and what is specified
via "comm_modify cutoff"_comm_modify.html (defaults to 0.0).  If this results
to 0.0, no ghost atoms will be generated and LAMMPS may lose atoms or use
incorrect periodic images of atoms in interaction lists.  To avoid, either use
"pair style zero"_pair_zero.html with a suitable cutoff or use "comm_modify
cutoff"_comm_modify.html. :dd

{Communication cutoff is too small for SNAP micro load balancing, increased to %lf} :dt

Self-explanatory. :dd
+9 −3
Original line number Diff line number Diff line
@@ -69,9 +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 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
+77 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include "atom_vec.h"
#include "force.h"
#include "pair.h"
#include "bond.h"
#include "modify.h"
#include "fix.h"
#include "compute.h"
@@ -585,6 +586,82 @@ void Comm::set_proc_grid(int outflag)
  }
}

/* ----------------------------------------------------------------------
   determine suitable communication cutoff.
   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, 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));

    // apply bond length based heuristics.

    if (force->newton_bond) {
      if (force->dihedral || force->improper) {
        maxbondcutoff *= 2.25;
      } else {
        maxbondcutoff *=1.5;
      }
    } else {
      if (force->dihedral || force->improper) {
        maxbondcutoff *= 3.125;
      } else if (force->angle) {
        maxbondcutoff *= 2.25;
      } else {
        maxbondcutoff *=1.5;
      }
    }
    maxbondcutoff += neighbor->skin;
  }

  // always take the larger of max neighbor list and user specified cutoff

  maxcommcutoff = MAX(cutghostuser,neighbor->cutneighmax);

  // 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 (!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

  if (me == 0) {
    if ((cutghostuser > 0.0) && (maxcommcutoff > cutghostuser)) {
      char mesg[128];
      snprintf(mesg,128,"Communication cutoff adjusted to %g",maxcommcutoff);
      error->warning(FLERR,mesg);
    }
  }

  return maxcommcutoff;
}

/* ----------------------------------------------------------------------
   determine which proc owns atom with coord x[3] based on current decomp
   x will be in box (orthogonal) or lamda coords (triclinic)
@@ -963,11 +1040,6 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs,
    return 0;    // all nout_rvous are 0, no 2nd irregular
  }






  // create procs and outbuf for All2all if necesary

  if (!outorder) {
+11 −0
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ class Comm : protected Pointers {
  void set_processors(int, char **);      // set 3d processor grid attributes
  virtual void set_proc_grid(int outflag = 1); // setup 3d grid of procs

  double get_comm_cutoff();     // determine communication cutoff

  virtual void setup() = 0;                      // setup 3d comm pattern
  virtual void forward_comm(int dummy = 0) = 0;  // forward comm of atom coords
  virtual void reverse_comm() = 0;               // reverse comm of forces
@@ -237,6 +239,15 @@ Self-explanatory.

E: Cannot put data on ring from NULL pointer

W: Communication cutoff is 0.0. No ghost atoms will be generated. Atoms may get lost.

The communication cutoff defaults to the maximum of what is inferred from pair and
bond styles (will be zero, if none are defined) and what is specified via
"comm_modify cutoff" (defaults to 0.0).  If this results to 0.0, no ghost atoms will
be generated and LAMMPS may lose atoms or use incorrect periodic images of atoms in
interaction lists.  To avoid, either define pair style zero with a suitable cutoff
or use comm_modify cutoff.

UNDOCUMENTED

U: OMP_NUM_THREADS environment is not set.
+4 −1
Original line number Diff line number Diff line
@@ -175,7 +175,10 @@ void CommBrick::setup()
  int ntypes = atom->ntypes;
  double *prd,*sublo,*subhi;

  double cut = MAX(neighbor->cutneighmax,cutghostuser);
  double cut = get_comm_cutoff();
  if ((cut == 0.0) && (me == 0))
    error->warning(FLERR,"Communication cutoff is 0.0. No ghost atoms "
                   "will be generated. Atoms may get lost.");

  if (triclinic == 0) {
    prd = domain->prd;
Loading