implement some examples for using the utils::strmatch() function and use it for inexact Force::pair_match()
This commit is contained in:
@ -30,6 +30,7 @@
|
|||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
#include "citeme.h"
|
#include "citeme.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
@ -221,12 +222,11 @@ void FixGPU::init()
|
|||||||
// hybrid cannot be used with force/neigh option
|
// hybrid cannot be used with force/neigh option
|
||||||
|
|
||||||
if (_gpu_mode == GPU_NEIGH || _gpu_mode == GPU_HYB_NEIGH)
|
if (_gpu_mode == GPU_NEIGH || _gpu_mode == GPU_HYB_NEIGH)
|
||||||
if (force->pair_match("hybrid",1) != NULL ||
|
if (force->pair_match("^hybrid",0) != NULL)
|
||||||
force->pair_match("hybrid/overlay",1) != NULL)
|
|
||||||
error->all(FLERR,"Cannot use pair hybrid with GPU neighbor list builds");
|
error->all(FLERR,"Cannot use pair hybrid with GPU neighbor list builds");
|
||||||
|
|
||||||
if (_particle_split < 0)
|
if (_particle_split < 0)
|
||||||
if (force->pair_match("hybrid",1) != NULL ||
|
if (force->pair_match("^hybrid",0) != NULL)
|
||||||
force->pair_match("hybrid/overlay",1) != NULL)
|
|
||||||
error->all(FLERR,"GPU split param must be positive "
|
error->all(FLERR,"GPU split param must be positive "
|
||||||
"for hybrid pair styles");
|
"for hybrid pair styles");
|
||||||
|
|
||||||
@ -243,21 +243,16 @@ void FixGPU::init()
|
|||||||
|
|
||||||
// make sure fdotr virial is not accumulated multiple times
|
// make sure fdotr virial is not accumulated multiple times
|
||||||
|
|
||||||
if (force->pair_match("hybrid",1) != NULL) {
|
if (force->pair_match("^hybrid",0) != NULL) {
|
||||||
PairHybrid *hybrid = (PairHybrid *) force->pair;
|
PairHybrid *hybrid = (PairHybrid *) force->pair;
|
||||||
for (int i = 0; i < hybrid->nstyles; i++)
|
for (int i = 0; i < hybrid->nstyles; i++)
|
||||||
if (strstr(hybrid->keywords[i],"/gpu")==NULL)
|
if (utils::strmatch(hybrid->keywords[i],"/gpu$") == NULL)
|
||||||
force->pair->no_virial_fdotr_compute = 1;
|
|
||||||
} else if (force->pair_match("hybrid/overlay",1) != NULL) {
|
|
||||||
PairHybridOverlay *hybrid = (PairHybridOverlay *) force->pair;
|
|
||||||
for (int i = 0; i < hybrid->nstyles; i++)
|
|
||||||
if (strstr(hybrid->keywords[i],"/gpu")==NULL)
|
|
||||||
force->pair->no_virial_fdotr_compute = 1;
|
force->pair->no_virial_fdotr_compute = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rRESPA support
|
// rRESPA support
|
||||||
|
|
||||||
if (strstr(update->integrate_style,"respa"))
|
if (utils::strmatch(update->integrate_style,"^respa"))
|
||||||
_nlevels_respa = ((Respa *) update->integrate)->nlevels;
|
_nlevels_respa = ((Respa *) update->integrate)->nlevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,8 @@
|
|||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
|
||||||
@ -121,12 +123,12 @@ void FixQEQComb::init()
|
|||||||
if (!atom->q_flag)
|
if (!atom->q_flag)
|
||||||
error->all(FLERR,"Fix qeq/comb requires atom attribute q");
|
error->all(FLERR,"Fix qeq/comb requires atom attribute q");
|
||||||
|
|
||||||
comb = (PairComb *) force->pair_match("comb",1);
|
comb = (PairComb *) force->pair_match("^comb",0);
|
||||||
comb3 = (PairComb3 *) force->pair_match("comb3",1);
|
comb3 = (PairComb3 *) force->pair_match("^comb3",0);
|
||||||
if (comb == NULL && comb3 == NULL)
|
if (comb == NULL && comb3 == NULL)
|
||||||
error->all(FLERR,"Must use pair_style comb or comb3 with fix qeq/comb");
|
error->all(FLERR,"Must use pair_style comb or comb3 with fix qeq/comb");
|
||||||
|
|
||||||
if (strstr(update->integrate_style,"respa")) {
|
if (utils::strmatch(update->integrate_style,"^respa")) {
|
||||||
ilevel_respa = ((Respa *) update->integrate)->nlevels-1;
|
ilevel_respa = ((Respa *) update->integrate)->nlevels-1;
|
||||||
if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa);
|
if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,9 +46,8 @@
|
|||||||
#include "thermo.h"
|
#include "thermo.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
#include <iostream>
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
@ -478,8 +477,8 @@ void FixGCMC::init()
|
|||||||
if ((force->kspace) ||
|
if ((force->kspace) ||
|
||||||
(force->pair == NULL) ||
|
(force->pair == NULL) ||
|
||||||
(force->pair->single_enable == 0) ||
|
(force->pair->single_enable == 0) ||
|
||||||
(force->pair_match("hybrid",0)) ||
|
(force->pair_match("^hybrid",0)) ||
|
||||||
(force->pair_match("eam",0)) ||
|
(force->pair_match("^eam",0)) ||
|
||||||
(force->pair->tail_flag)
|
(force->pair->tail_flag)
|
||||||
) {
|
) {
|
||||||
full_flag = true;
|
full_flag = true;
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
#include "math_const.h"
|
#include "math_const.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
@ -124,7 +125,8 @@ void ComputeGroupGroup::init()
|
|||||||
|
|
||||||
if (pairflag && force->pair == NULL)
|
if (pairflag && force->pair == NULL)
|
||||||
error->all(FLERR,"No pair style defined for compute group/group");
|
error->all(FLERR,"No pair style defined for compute group/group");
|
||||||
if (force->pair_match("hybrid",0) == NULL && force->pair->single_enable == 0)
|
if (force->pair_match("^hybrid",0) == NULL
|
||||||
|
&& force->pair->single_enable == 0)
|
||||||
error->all(FLERR,"Pair style does not support compute group/group");
|
error->all(FLERR,"Pair style does not support compute group/group");
|
||||||
|
|
||||||
// error if Kspace style does not compute group/group interactions
|
// error if Kspace style does not compute group/group interactions
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -287,26 +288,13 @@ Pair *Force::pair_match(const char *word, int exact, int nsub)
|
|||||||
int iwhich,count;
|
int iwhich,count;
|
||||||
|
|
||||||
if (exact && strcmp(pair_style,word) == 0) return pair;
|
if (exact && strcmp(pair_style,word) == 0) return pair;
|
||||||
else if (!exact && strstr(pair_style,word)) return pair;
|
else if (!exact && utils::strmatch(pair_style,word)) return pair;
|
||||||
|
else if (utils::strmatch(pair_style,"^hybrid")) {
|
||||||
else if (strstr(pair_style,"hybrid/overlay")) {
|
|
||||||
PairHybridOverlay *hybrid = (PairHybridOverlay *) pair;
|
|
||||||
count = 0;
|
|
||||||
for (int i = 0; i < hybrid->nstyles; i++)
|
|
||||||
if ((exact && strcmp(hybrid->keywords[i],word) == 0) ||
|
|
||||||
(!exact && strstr(hybrid->keywords[i],word))) {
|
|
||||||
iwhich = i;
|
|
||||||
count++;
|
|
||||||
if (nsub == count) return hybrid->styles[iwhich];
|
|
||||||
}
|
|
||||||
if (count == 1) return hybrid->styles[iwhich];
|
|
||||||
|
|
||||||
} else if (strstr(pair_style,"hybrid")) {
|
|
||||||
PairHybrid *hybrid = (PairHybrid *) pair;
|
PairHybrid *hybrid = (PairHybrid *) pair;
|
||||||
count = 0;
|
count = 0;
|
||||||
for (int i = 0; i < hybrid->nstyles; i++)
|
for (int i = 0; i < hybrid->nstyles; i++)
|
||||||
if ((exact && strcmp(hybrid->keywords[i],word) == 0) ||
|
if ((exact && strcmp(hybrid->keywords[i],word) == 0) ||
|
||||||
(!exact && strstr(hybrid->keywords[i],word))) {
|
(!exact && utils::strmatch(hybrid->keywords[i],word))) {
|
||||||
iwhich = i;
|
iwhich = i;
|
||||||
count++;
|
count++;
|
||||||
if (nsub == count) return hybrid->styles[iwhich];
|
if (nsub == count) return hybrid->styles[iwhich];
|
||||||
@ -327,7 +315,7 @@ char *Force::pair_match_ptr(Pair *ptr)
|
|||||||
{
|
{
|
||||||
if (ptr == pair) return pair_style;
|
if (ptr == pair) return pair_style;
|
||||||
|
|
||||||
if (strstr(pair_style,"hybrid")) {
|
if (utils::strmatch(pair_style,"^hybrid")) {
|
||||||
PairHybrid *hybrid = (PairHybrid *) pair;
|
PairHybrid *hybrid = (PairHybrid *) pair;
|
||||||
for (int i = 0; i < hybrid->nstyles; i++)
|
for (int i = 0; i < hybrid->nstyles; i++)
|
||||||
if (ptr == hybrid->styles[i]) return hybrid->keywords[i];
|
if (ptr == hybrid->styles[i]) return hybrid->keywords[i];
|
||||||
@ -741,7 +729,7 @@ KSpace *Force::kspace_creator(LAMMPS *lmp)
|
|||||||
KSpace *Force::kspace_match(const char *word, int exact)
|
KSpace *Force::kspace_match(const char *word, int exact)
|
||||||
{
|
{
|
||||||
if (exact && strcmp(kspace_style,word) == 0) return kspace;
|
if (exact && strcmp(kspace_style,word) == 0) return kspace;
|
||||||
else if (!exact && strstr(kspace_style,word)) return kspace;
|
else if (!exact && utils::strmatch(kspace_style,word)) return kspace;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1619,7 +1619,7 @@ void Pair::write_file(int narg, char **arg)
|
|||||||
eamfp[0] = eamfp[1] = 0.0;
|
eamfp[0] = eamfp[1] = 0.0;
|
||||||
double *eamfp_hold;
|
double *eamfp_hold;
|
||||||
|
|
||||||
Pair *epair = force->pair_match("eam",0);
|
Pair *epair = force->pair_match("^eam",0);
|
||||||
if (epair) epair->swap_eam(eamfp,&eamfp_hold);
|
if (epair) epair->swap_eam(eamfp,&eamfp_hold);
|
||||||
|
|
||||||
// if atom style defines charge, swap in dummy q vec
|
// if atom style defines charge, swap in dummy q vec
|
||||||
|
|||||||
Reference in New Issue
Block a user