allow regexp matches for Modify::find_fix_by_style() and consolidate usage of searching for fixes
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user