diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp index b62b630be5..282f055ce7 100644 --- a/src/GRANULAR/fix_pour.cpp +++ b/src/GRANULAR/fix_pour.cpp @@ -180,11 +180,8 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) : // grav = gravity in distance/time^2 units // assume grav = -magnitude at this point, enforce in init() - int ifix; - for (ifix = 0; ifix < modify->nfix; ifix++) - if (utils::strmatch(modify->fix[ifix]->style,"^gravity")) break; - - if (ifix == modify->nfix) + int ifix = modify->find_fix_by_style("^gravity"); + if (ifix == -1) error->all(FLERR,"No fix gravity defined for fix pour"); grav = - ((FixGravity *) modify->fix[ifix])->magnitude * force->ftm2v; @@ -309,17 +306,12 @@ void FixPour::init() if (domain->triclinic) error->all(FLERR,"Cannot use fix pour with triclinic box"); - // insure gravity fix exists + // insure gravity fix (still) exists // for 3d must point in -z, for 2d must point in -y // else insertion cannot work - int ifix; - for (ifix = 0; ifix < modify->nfix; ifix++) { - if (strcmp(modify->fix[ifix]->style,"gravity") == 0) break; - if (strcmp(modify->fix[ifix]->style,"gravity/omp") == 0) break; - if (strstr(modify->fix[ifix]->style,"gravity/kk") != NULL) break; - } - if (ifix == modify->nfix) + int ifix = modify->find_fix_by_style("^gravity"); + if (ifix == -1) error->all(FLERR,"No fix gravity defined for fix pour"); double xgrav = ((FixGravity *) modify->fix[ifix])->xgrav; diff --git a/src/PERI/compute_damage_atom.cpp b/src/PERI/compute_damage_atom.cpp index 230b766725..8bea52f1cf 100644 --- a/src/PERI/compute_damage_atom.cpp +++ b/src/PERI/compute_damage_atom.cpp @@ -59,11 +59,9 @@ void ComputeDamageAtom::init() // find associated PERI_NEIGH fix that must exist - ifix_peri = -1; - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i; + ifix_peri = modify->find_fix_by_style("PERI_NEIGH"); if (ifix_peri == -1) - error->all(FLERR,"Compute damage/atom requires peridynamic potential"); + error->all(FLERR,"Compute damage/atom requires a peridynamic potential"); } /* ---------------------------------------------------------------------- */ diff --git a/src/PERI/compute_dilatation_atom.cpp b/src/PERI/compute_dilatation_atom.cpp index 095f619838..65a25cda03 100644 --- a/src/PERI/compute_dilatation_atom.cpp +++ b/src/PERI/compute_dilatation_atom.cpp @@ -66,10 +66,10 @@ void ComputeDilatationAtom::init() // check PD pair style isPMB = isLPS = isVES = isEPS = 0; - if (force->pair_match("peri/pmb",1)) isPMB = 1; - if (force->pair_match("peri/lps",1)) isLPS = 1; - if (force->pair_match("peri/ves",1)) isVES = 1; - if (force->pair_match("peri/eps",1)) isEPS = 1; + if (force->pair_match("^peri/pmb",0)) isPMB = 1; + if (force->pair_match("^peri/lps",0)) isLPS = 1; + if (force->pair_match("^peri/ves",0)) isVES = 1; + if (force->pair_match("^peri/eps",0)) isEPS = 1; if (isPMB) error->all(FLERR,"Compute dilatation/atom cannot be used " @@ -77,10 +77,7 @@ void ComputeDilatationAtom::init() // find associated PERI_NEIGH fix that must exist - int ifix_peri = -1; - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i; - if (ifix_peri == -1) + if (modify->find_fix_by_style("^PERI_NEIGH") == -1) error->all(FLERR,"Compute dilatation/atom requires Peridynamic pair style"); } diff --git a/src/PERI/compute_plasticity_atom.cpp b/src/PERI/compute_plasticity_atom.cpp index e312630b62..d90e211506 100644 --- a/src/PERI/compute_plasticity_atom.cpp +++ b/src/PERI/compute_plasticity_atom.cpp @@ -66,11 +66,9 @@ void ComputePlasticityAtom::init() // find associated PERI_NEIGH fix that must exist - ifix_peri = -1; - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i; + ifix_peri = modify->find_fix_by_style("^PERI_NEIGH"); if (ifix_peri == -1) - error->all(FLERR,"Compute plasticity/atom requires Peridynamic pair style"); + error->all(FLERR,"Compute plasticity/atom requires a Peridynamics pair style"); } /* ---------------------------------------------------------------------- */ diff --git a/src/PERI/pair_peri_eps.cpp b/src/PERI/pair_peri_eps.cpp index 2579a9b75a..51ffea9f86 100644 --- a/src/PERI/pair_peri_eps.cpp +++ b/src/PERI/pair_peri_eps.cpp @@ -524,9 +524,9 @@ void PairPeriEPS::init_style() // find associated PERI_NEIGH fix that must exist // could have changed locations in fix list since created - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i; - if (ifix_peri == -1) error->all(FLERR,"Fix peri neigh does not exist"); + ifix_peri = modify->find_fix_by_style("^PERI_NEIGH"); + if (ifix_peri == -1) + error->all(FLERR,"Fix peri neigh does not exist"); neighbor->request(this,instance_me); } diff --git a/src/PERI/pair_peri_lps.cpp b/src/PERI/pair_peri_lps.cpp index f32ce5fb1c..79f8df7c90 100644 --- a/src/PERI/pair_peri_lps.cpp +++ b/src/PERI/pair_peri_lps.cpp @@ -450,9 +450,9 @@ void PairPeriLPS::init_style() // find associated PERI_NEIGH fix that must exist // could have changed locations in fix list since created - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i; - if (ifix_peri == -1) error->all(FLERR,"Fix peri neigh does not exist"); + ifix_peri = modify->find_fix_by_style("^PERI_NEIGH"); + if (ifix_peri == -1) + error->all(FLERR,"Fix peri neigh does not exist"); neighbor->request(this,instance_me); } diff --git a/src/PERI/pair_peri_pmb.cpp b/src/PERI/pair_peri_pmb.cpp index ceab40d88d..bdd421cc7b 100644 --- a/src/PERI/pair_peri_pmb.cpp +++ b/src/PERI/pair_peri_pmb.cpp @@ -380,9 +380,9 @@ void PairPeriPMB::init_style() // find associated PERI_NEIGH fix that must exist // could have changed locations in fix list since created - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i; - if (ifix_peri == -1) error->all(FLERR,"Fix peri neigh does not exist"); + ifix_peri = modify->find_fix_by_style("^PERI_NEIGH"); + if (ifix_peri == -1) + error->all(FLERR,"Fix peri neigh does not exist"); neighbor->request(this,instance_me); } diff --git a/src/PERI/pair_peri_ves.cpp b/src/PERI/pair_peri_ves.cpp index bd1eaa5fd2..1286f88faf 100644 --- a/src/PERI/pair_peri_ves.cpp +++ b/src/PERI/pair_peri_ves.cpp @@ -506,9 +506,9 @@ void PairPeriVES::init_style() // find associated PERI_NEIGH fix that must exist // could have changed locations in fix list since created - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i; - if (ifix_peri == -1) error->all(FLERR,"Fix peri neigh does not exist"); + ifix_peri = modify->find_fix_by_style("^PERI_NEIGH"); + if (ifix_peri == -1) + error->all(FLERR,"Fix peri neigh does not exist"); neighbor->request(this,instance_me); } diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 48a08118c5..054985ba72 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -32,6 +32,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -360,9 +361,8 @@ void FixShake::init() // could have changed locations in fix list since created // set ptrs to rRESPA variables - if (strstr(update->integrate_style,"respa")) { - for (i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"RESPA") == 0) ifix_respa = i; + if (utils::strmatch(update->integrate_style,"^respa")) { + ifix_respa = modify->find_fix_by_style("^RESPA"); nlevels_respa = ((Respa *) update->integrate)->nlevels; loop_respa = ((Respa *) update->integrate)->loop; step_respa = ((Respa *) update->integrate)->step; diff --git a/src/USER-MISC/fix_bond_react.cpp b/src/USER-MISC/fix_bond_react.cpp index a3d7979a56..e4acbf1700 100644 --- a/src/USER-MISC/fix_bond_react.cpp +++ b/src/USER-MISC/fix_bond_react.cpp @@ -113,7 +113,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : master_group = (char *) "bond_react_MASTER_group"; // by using fixed group names, only one instance of fix bond/react is allowed. - if (modify->find_fix_by_style("bond/react") != -1) + if (modify->find_fix_by_style("^bond/react") != -1) error->all(FLERR,"Only one instance of fix bond/react allowed at a time"); // let's find number of reactions specified diff --git a/src/USER-OMP/pair_reaxc_omp.cpp b/src/USER-OMP/pair_reaxc_omp.cpp index aedd438066..fa6e8f54e5 100644 --- a/src/USER-OMP/pair_reaxc_omp.cpp +++ b/src/USER-OMP/pair_reaxc_omp.cpp @@ -325,9 +325,10 @@ void PairReaxCOMP::init_style( ) // firstwarn = 1; - int iqeq = modify->find_fix_by_style("qeq/reax/omp"); - if (iqeq < 0 && qeqflag == 1) - error->all(FLERR,"Pair reax/c/omp requires use of fix qeq/reax/omp"); + bool have_qeq = ((modify->find_fix_by_style("^qeq/reax") != -1) + || (modify->find_fix_by_style("^qeq/shielded") != -1)); + if (!have_qeq && qeqflag == 1) + error->all(FLERR,"Pair reax/c requires use of fix qeq/reax or qeq/shielded"); system->n = atom->nlocal; // my atoms system->N = atom->nlocal + atom->nghost; // mine + ghosts diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index 959405576e..28f9a193c4 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -39,6 +39,7 @@ #include "citeme.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "reaxc_defs.h" #include "reaxc_types.h" @@ -372,12 +373,10 @@ void PairReaxC::init_style( ) // firstwarn = 1; - int iqeq; - for (iqeq = 0; iqeq < modify->nfix; iqeq++) - if (strstr(modify->fix[iqeq]->style,"qeq/reax") - || strstr(modify->fix[iqeq]->style,"qeq/shielded")) break; - if (iqeq == modify->nfix && qeqflag == 1) - error->all(FLERR,"Pair reax/c requires use of fix qeq/reax"); + bool have_qeq = ((modify->find_fix_by_style("^qeq/reax") != -1) + || (modify->find_fix_by_style("^qeq/shielded") != -1)); + if (!have_qeq && qeqflag == 1) + error->all(FLERR,"Pair reax/c requires use of fix qeq/reax or qeq/shielded"); system->n = atom->nlocal; // my atoms system->N = atom->nlocal + atom->nghost; // mine + ghosts diff --git a/src/modify.cpp b/src/modify.cpp index 109571d531..0e976b1d97 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -1029,7 +1029,7 @@ int Modify::find_fix_by_style(const char *style) { int ifix; for (ifix = 0; ifix < nfix; ifix++) - if (strcmp(style,fix[ifix]->style) == 0) break; + if (utils::strmatch(fix[ifix]->style,style)) break; if (ifix == nfix) return -1; return ifix; }