From dbbf198edb4edf36a06550ea20a1a3bf02784864 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 4 Apr 2019 17:10:27 -0400 Subject: [PATCH] more accurate matching of styles using utils::strmatch() --- src/info.cpp | 3 ++- src/respa.cpp | 3 ++- src/velocity.cpp | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/info.cpp b/src/info.cpp index 3d8a8d7b9e..ac2ee4a96d 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -42,6 +42,7 @@ #include "variable.h" #include "update.h" #include "error.h" +#include "utils.h" #include #include @@ -397,7 +398,7 @@ void Info::command(int narg, char **arg) fprintf(out,"Atoms = " BIGINT_FORMAT ", types = %d, style = %s\n", atom->natoms, atom->ntypes, force->pair_style); - if (force->pair && strstr(force->pair_style,"hybrid")) { + if (force->pair && utils::strmatch(force->pair_style,"^hybrid")) { PairHybrid *hybrid = (PairHybrid *)force->pair; fprintf(out,"Hybrid sub-styles:"); for (int i=0; i < hybrid->nstyles; ++i) diff --git a/src/respa.cpp b/src/respa.cpp index 26bae5a1cb..6fa9959d78 100644 --- a/src/respa.cpp +++ b/src/respa.cpp @@ -38,6 +38,7 @@ #include "timer.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "pair_hybrid.h" using namespace LAMMPS_NS; @@ -120,7 +121,7 @@ Respa::Respa(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"hybrid") == 0) { // the hybrid keyword requires a hybrid pair style - if (!strstr(force->pair_style,"hybrid")) + if (!utils::strmatch(force->pair_style,"^hybrid")) error->all(FLERR,"Illegal run_style respa command"); PairHybrid *hybrid = (PairHybrid *) force->pair; nhybrid_styles = hybrid->nstyles; diff --git a/src/velocity.cpp b/src/velocity.cpp index 6d6027cc3c..32b08708cf 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -33,6 +33,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -709,19 +710,19 @@ void Velocity::zero(int /*narg*/, char **arg) { if (strcmp(arg[0],"linear") == 0) { if (rfix < 0) zero_momentum(); - else if (strcmp(modify->fix[rfix]->style,"rigid/small") == 0) { + else if (utils::strmatch(modify->fix[rfix]->style,"^rigid/small")) { modify->fix[rfix]->setup_pre_neighbor(); modify->fix[rfix]->zero_momentum(); - } else if (strstr(modify->fix[rfix]->style,"rigid")) { + } else if (utils::strmatch(modify->fix[rfix]->style,"^rigid")) { modify->fix[rfix]->zero_momentum(); } else error->all(FLERR,"Velocity rigid used with non-rigid fix-ID"); } else if (strcmp(arg[0],"angular") == 0) { if (rfix < 0) zero_rotation(); - else if (strcmp(modify->fix[rfix]->style,"rigid/small") == 0) { + else if (utils::strmatch(modify->fix[rfix]->style,"^rigid/small")) { modify->fix[rfix]->setup_pre_neighbor(); modify->fix[rfix]->zero_rotation(); - } else if (strstr(modify->fix[rfix]->style,"rigid")) { + } else if (utils::strmatch(modify->fix[rfix]->style,"^rigid")) { modify->fix[rfix]->zero_rotation(); } else error->all(FLERR,"Velocity rigid used with non-rigid fix-ID");