add support to pair_modify to selectively disable compute/tally callbacks in sub-styles for pair hybrid and hybrid/overlay

This commit is contained in:
Axel Kohlmeyer
2017-04-21 14:01:38 -04:00
parent f0681f7e12
commit 4e411364ff
4 changed files with 50 additions and 10 deletions

View File

@ -33,7 +33,7 @@ using namespace LAMMPS_NS;
PairHybrid::PairHybrid(LAMMPS *lmp) : Pair(lmp),
styles(NULL), keywords(NULL), multiple(NULL), nmap(NULL),
map(NULL), special_lj(NULL), special_coul(NULL)
map(NULL), special_lj(NULL), special_coul(NULL), compute_tally(NULL)
{
nstyles = 0;
@ -62,6 +62,7 @@ PairHybrid::~PairHybrid()
delete [] special_lj;
delete [] special_coul;
delete [] compute_tally;
delete [] svector;
@ -175,7 +176,7 @@ void PairHybrid::compute(int eflag, int vflag)
void PairHybrid::add_tally_callback(Compute *ptr)
{
for (int m = 0; m < nstyles; m++)
styles[m]->add_tally_callback(ptr);
if (compute_tally[m]) styles[m]->add_tally_callback(ptr);
}
/* ---------------------------------------------------------------------- */
@ -183,7 +184,7 @@ void PairHybrid::add_tally_callback(Compute *ptr)
void PairHybrid::del_tally_callback(Compute *ptr)
{
for (int m = 0; m < nstyles; m++)
styles[m]->del_tally_callback(ptr);
if (compute_tally[m]) styles[m]->del_tally_callback(ptr);
}
/* ---------------------------------------------------------------------- */
@ -270,6 +271,8 @@ void PairHybrid::settings(int narg, char **arg)
special_lj = new double*[narg];
special_coul = new double*[narg];
compute_tally = new int[narg];
// allocate each sub-style
// allocate uses suffix, but don't store suffix version in keywords,
// else syntax in coeff() will not match
@ -289,6 +292,7 @@ void PairHybrid::settings(int narg, char **arg)
styles[nstyles] = force->new_pair(arg[iarg],1,dummy);
force->store_style(keywords[nstyles],arg[iarg],0);
special_lj[nstyles] = special_coul[nstyles] = NULL;
compute_tally[nstyles] = 1;
jarg = iarg + 1;
while (jarg < narg && !force->pair_map->count(arg[jarg])) jarg++;
@ -799,6 +803,20 @@ void PairHybrid::modify_params(int narg, char **arg)
iarg += 5;
}
// if 2nd keyword (after pair) is compute/tally:
// set flag to register USER-TALLY computes accordingly
if (iarg < narg && strcmp(arg[iarg],"compute/tally") == 0) {
if (narg < iarg+2)
error->all(FLERR,"Illegal pair_modify compute/tally command");
if (strcmp(arg[iarg+1],"yes") == 0) {
compute_tally[m] = 1;
} else if (strcmp(arg[iarg+1],"no") == 0) {
compute_tally[m] = 0;
} else error->all(FLERR,"Illegal pair_modify compute/tally command");
iarg += 2;
}
// apply the remaining keywords to the base pair style itself and the
// sub-style except for "pair" and "special".
// the former is important for some keywords like "tail" or "compute"