more accurate matching of styles using utils::strmatch()

This commit is contained in:
Axel Kohlmeyer 2019-04-04 17:10:27 -04:00
parent df94e80bb1
commit dbbf198edb
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
3 changed files with 9 additions and 6 deletions

View File

@ -42,6 +42,7 @@
#include "variable.h"
#include "update.h"
#include "error.h"
#include "utils.h"
#include <ctime>
#include <map>
@ -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)

View File

@ -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;

View File

@ -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");