diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 268a741032..fad74dc318 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -30,6 +30,7 @@ #include "neighbor.h" #include "citeme.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -221,12 +222,11 @@ void FixGPU::init() // hybrid cannot be used with force/neigh option if (_gpu_mode == GPU_NEIGH || _gpu_mode == GPU_HYB_NEIGH) - if (force->pair_match("hybrid",1) != NULL || - force->pair_match("hybrid/overlay",1) != NULL) + if (force->pair_match("^hybrid",0) != NULL) error->all(FLERR,"Cannot use pair hybrid with GPU neighbor list builds"); + if (_particle_split < 0) - if (force->pair_match("hybrid",1) != NULL || - force->pair_match("hybrid/overlay",1) != NULL) + if (force->pair_match("^hybrid",0) != NULL) error->all(FLERR,"GPU split param must be positive " "for hybrid pair styles"); @@ -243,21 +243,16 @@ void FixGPU::init() // 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; for (int i = 0; i < hybrid->nstyles; i++) - if (strstr(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) + if (utils::strmatch(hybrid->keywords[i],"/gpu$") == NULL) force->pair->no_virial_fdotr_compute = 1; } // rRESPA support - if (strstr(update->integrate_style,"respa")) + if (utils::strmatch(update->integrate_style,"^respa")) _nlevels_respa = ((Respa *) update->integrate)->nlevels; } diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index 7146ee9d65..5019e7711a 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -33,6 +33,8 @@ #include "update.h" #include "memory.h" #include "error.h" +#include "utils.h" + using namespace LAMMPS_NS; using namespace FixConst; @@ -121,12 +123,12 @@ void FixQEQComb::init() if (!atom->q_flag) error->all(FLERR,"Fix qeq/comb requires atom attribute q"); - comb = (PairComb *) force->pair_match("comb",1); - comb3 = (PairComb3 *) force->pair_match("comb3",1); + comb = (PairComb *) force->pair_match("^comb",0); + comb3 = (PairComb3 *) force->pair_match("^comb3",0); if (comb == NULL && comb3 == NULL) 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; if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa); } diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index ebfb17390d..f1664e3540 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -46,9 +46,8 @@ #include "thermo.h" #include "output.h" #include "neighbor.h" -#include +#include "utils.h" -using namespace std; using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; @@ -478,8 +477,8 @@ void FixGCMC::init() if ((force->kspace) || (force->pair == NULL) || (force->pair->single_enable == 0) || - (force->pair_match("hybrid",0)) || - (force->pair_match("eam",0)) || + (force->pair_match("^hybrid",0)) || + (force->pair_match("^eam",0)) || (force->pair->tail_flag) ) { full_flag = true; diff --git a/src/compute_group_group.cpp b/src/compute_group_group.cpp index 51f84b020d..e55f679b2e 100644 --- a/src/compute_group_group.cpp +++ b/src/compute_group_group.cpp @@ -33,6 +33,7 @@ #include "comm.h" #include "domain.h" #include "math_const.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -124,7 +125,8 @@ void ComputeGroupGroup::init() if (pairflag && force->pair == NULL) 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 if Kspace style does not compute group/group interactions diff --git a/src/force.cpp b/src/force.cpp index 567cf2c9c5..7ff5096ee4 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -35,6 +35,7 @@ #include "group.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -287,26 +288,13 @@ Pair *Force::pair_match(const char *word, int exact, int nsub) int iwhich,count; if (exact && strcmp(pair_style,word) == 0) return pair; - else if (!exact && strstr(pair_style,word)) return pair; - - 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")) { + else if (!exact && utils::strmatch(pair_style,word)) return pair; + else if (utils::strmatch(pair_style,"^hybrid")) { PairHybrid *hybrid = (PairHybrid *) 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))) { + (!exact && utils::strmatch(hybrid->keywords[i],word))) { iwhich = i; count++; 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 (strstr(pair_style,"hybrid")) { + if (utils::strmatch(pair_style,"^hybrid")) { PairHybrid *hybrid = (PairHybrid *) pair; for (int i = 0; i < hybrid->nstyles; 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) { 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; } diff --git a/src/pair.cpp b/src/pair.cpp index cc066713c9..6841b7dd8a 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -1619,7 +1619,7 @@ void Pair::write_file(int narg, char **arg) eamfp[0] = eamfp[1] = 0.0; 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 atom style defines charge, swap in dummy q vec