Unverified Commit dbbf198e authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

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

parent df94e80b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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)
+2 −1
Original line number Diff line number Diff line
@@ -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;
+5 −4
Original line number Diff line number Diff line
@@ -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");