simplify hybrid coeff parsing. check for number is already done with conversion

This commit is contained in:
Axel Kohlmeyer
2021-04-08 17:44:13 -04:00
parent 2d19282961
commit a441c7b379
2 changed files with 4 additions and 11 deletions

View File

@ -468,10 +468,7 @@ void PairHybrid::coeff(int narg, char **arg)
if (multiple[m]) { if (multiple[m]) {
multflag = 1; multflag = 1;
if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients");
if (!isdigit(arg[3][0])) if (multiple[m] == utils::inumeric(FLERR,arg[3],false,lmp)) break;
error->all(FLERR,"Incorrect args for pair coefficients");
int index = utils::inumeric(FLERR,arg[3],false,lmp);
if (index == multiple[m]) break;
else continue; else continue;
} else break; } else break;
} }
@ -492,7 +489,7 @@ void PairHybrid::coeff(int narg, char **arg)
// invoke sub-style coeff() starting with 1st remaining arg // invoke sub-style coeff() starting with 1st remaining arg
if (!none) styles[m]->coeff(narg-1-multflag,&arg[1+multflag]); if (!none) styles[m]->coeff(narg-1-multflag,arg+1+multflag);
// if sub-style only allows one pair coeff call (with * * and type mapping) // if sub-style only allows one pair coeff call (with * * and type mapping)
// then unset setflag/map assigned to that style before setting it below // then unset setflag/map assigned to that style before setting it below

View File

@ -17,7 +17,6 @@
#include "error.h" #include "error.h"
#include <cstring> #include <cstring>
#include <cctype>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -51,10 +50,7 @@ void PairHybridOverlay::coeff(int narg, char **arg)
if (multiple[m]) { if (multiple[m]) {
multflag = 1; multflag = 1;
if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients");
if (!isdigit(arg[3][0])) if (multiple[m] == utils::inumeric(FLERR,arg[3],false,lmp)) break;
error->all(FLERR,"Incorrect args for pair coefficients");
int index = utils::inumeric(FLERR,arg[3],false,lmp);
if (index == multiple[m]) break;
else continue; else continue;
} else break; } else break;
} }
@ -75,7 +71,7 @@ void PairHybridOverlay::coeff(int narg, char **arg)
// invoke sub-style coeff() starting with 1st remaining arg // invoke sub-style coeff() starting with 1st remaining arg
if (!none) styles[m]->coeff(narg-1-multflag,&arg[1+multflag]); if (!none) styles[m]->coeff(narg-1-multflag,arg+1+multflag);
// set setflag and which type pairs map to which sub-style // set setflag and which type pairs map to which sub-style
// if sub-style is none: set hybrid subflag, wipe out map // if sub-style is none: set hybrid subflag, wipe out map