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
|
// grav = gravity in distance/time^2 units
|
||||||
// assume grav = -magnitude at this point, enforce in init()
|
// assume grav = -magnitude at this point, enforce in init()
|
||||||
|
|
||||||
int ifix;
|
int ifix = modify->find_fix_by_style("^gravity");
|
||||||
for (ifix = 0; ifix < modify->nfix; ifix++)
|
if (ifix == -1)
|
||||||
if (utils::strmatch(modify->fix[ifix]->style,"^gravity")) break;
|
|
||||||
|
|
||||||
if (ifix == modify->nfix)
|
|
||||||
error->all(FLERR,"No fix gravity defined for fix pour");
|
error->all(FLERR,"No fix gravity defined for fix pour");
|
||||||
grav = - ((FixGravity *) modify->fix[ifix])->magnitude * force->ftm2v;
|
grav = - ((FixGravity *) modify->fix[ifix])->magnitude * force->ftm2v;
|
||||||
|
|
||||||
@ -309,17 +306,12 @@ void FixPour::init()
|
|||||||
if (domain->triclinic)
|
if (domain->triclinic)
|
||||||
error->all(FLERR,"Cannot use fix pour with triclinic box");
|
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
|
// for 3d must point in -z, for 2d must point in -y
|
||||||
// else insertion cannot work
|
// else insertion cannot work
|
||||||
|
|
||||||
int ifix;
|
int ifix = modify->find_fix_by_style("^gravity");
|
||||||
for (ifix = 0; ifix < modify->nfix; ifix++) {
|
if (ifix == -1)
|
||||||
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)
|
|
||||||
error->all(FLERR,"No fix gravity defined for fix pour");
|
error->all(FLERR,"No fix gravity defined for fix pour");
|
||||||
|
|
||||||
double xgrav = ((FixGravity *) modify->fix[ifix])->xgrav;
|
double xgrav = ((FixGravity *) modify->fix[ifix])->xgrav;
|
||||||
|
|||||||
@ -59,11 +59,9 @@ void ComputeDamageAtom::init()
|
|||||||
|
|
||||||
// find associated PERI_NEIGH fix that must exist
|
// find associated PERI_NEIGH fix that must exist
|
||||||
|
|
||||||
ifix_peri = -1;
|
ifix_peri = modify->find_fix_by_style("PERI_NEIGH");
|
||||||
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 (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
|
// check PD pair style
|
||||||
|
|
||||||
isPMB = isLPS = isVES = isEPS = 0;
|
isPMB = isLPS = isVES = isEPS = 0;
|
||||||
if (force->pair_match("peri/pmb",1)) isPMB = 1;
|
if (force->pair_match("^peri/pmb",0)) isPMB = 1;
|
||||||
if (force->pair_match("peri/lps",1)) isLPS = 1;
|
if (force->pair_match("^peri/lps",0)) isLPS = 1;
|
||||||
if (force->pair_match("peri/ves",1)) isVES = 1;
|
if (force->pair_match("^peri/ves",0)) isVES = 1;
|
||||||
if (force->pair_match("peri/eps",1)) isEPS = 1;
|
if (force->pair_match("^peri/eps",0)) isEPS = 1;
|
||||||
|
|
||||||
if (isPMB)
|
if (isPMB)
|
||||||
error->all(FLERR,"Compute dilatation/atom cannot be used "
|
error->all(FLERR,"Compute dilatation/atom cannot be used "
|
||||||
@ -77,10 +77,7 @@ void ComputeDilatationAtom::init()
|
|||||||
|
|
||||||
// find associated PERI_NEIGH fix that must exist
|
// find associated PERI_NEIGH fix that must exist
|
||||||
|
|
||||||
int ifix_peri = -1;
|
if (modify->find_fix_by_style("^PERI_NEIGH") == -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)
|
|
||||||
error->all(FLERR,"Compute dilatation/atom requires Peridynamic pair style");
|
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
|
// find associated PERI_NEIGH fix that must exist
|
||||||
|
|
||||||
ifix_peri = -1;
|
ifix_peri = modify->find_fix_by_style("^PERI_NEIGH");
|
||||||
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 (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
|
// find associated PERI_NEIGH fix that must exist
|
||||||
// could have changed locations in fix list since created
|
// could have changed locations in fix list since created
|
||||||
|
|
||||||
for (int i = 0; i < modify->nfix; i++)
|
ifix_peri = modify->find_fix_by_style("^PERI_NEIGH");
|
||||||
if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i;
|
if (ifix_peri == -1)
|
||||||
if (ifix_peri == -1) error->all(FLERR,"Fix peri neigh does not exist");
|
error->all(FLERR,"Fix peri neigh does not exist");
|
||||||
|
|
||||||
neighbor->request(this,instance_me);
|
neighbor->request(this,instance_me);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -450,9 +450,9 @@ void PairPeriLPS::init_style()
|
|||||||
// find associated PERI_NEIGH fix that must exist
|
// find associated PERI_NEIGH fix that must exist
|
||||||
// could have changed locations in fix list since created
|
// could have changed locations in fix list since created
|
||||||
|
|
||||||
for (int i = 0; i < modify->nfix; i++)
|
ifix_peri = modify->find_fix_by_style("^PERI_NEIGH");
|
||||||
if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i;
|
if (ifix_peri == -1)
|
||||||
if (ifix_peri == -1) error->all(FLERR,"Fix peri neigh does not exist");
|
error->all(FLERR,"Fix peri neigh does not exist");
|
||||||
|
|
||||||
neighbor->request(this,instance_me);
|
neighbor->request(this,instance_me);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -380,9 +380,9 @@ void PairPeriPMB::init_style()
|
|||||||
// find associated PERI_NEIGH fix that must exist
|
// find associated PERI_NEIGH fix that must exist
|
||||||
// could have changed locations in fix list since created
|
// could have changed locations in fix list since created
|
||||||
|
|
||||||
for (int i = 0; i < modify->nfix; i++)
|
ifix_peri = modify->find_fix_by_style("^PERI_NEIGH");
|
||||||
if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i;
|
if (ifix_peri == -1)
|
||||||
if (ifix_peri == -1) error->all(FLERR,"Fix peri neigh does not exist");
|
error->all(FLERR,"Fix peri neigh does not exist");
|
||||||
|
|
||||||
neighbor->request(this,instance_me);
|
neighbor->request(this,instance_me);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -506,9 +506,9 @@ void PairPeriVES::init_style()
|
|||||||
// find associated PERI_NEIGH fix that must exist
|
// find associated PERI_NEIGH fix that must exist
|
||||||
// could have changed locations in fix list since created
|
// could have changed locations in fix list since created
|
||||||
|
|
||||||
for (int i = 0; i < modify->nfix; i++)
|
ifix_peri = modify->find_fix_by_style("^PERI_NEIGH");
|
||||||
if (strcmp(modify->fix[i]->style,"PERI_NEIGH") == 0) ifix_peri = i;
|
if (ifix_peri == -1)
|
||||||
if (ifix_peri == -1) error->all(FLERR,"Fix peri neigh does not exist");
|
error->all(FLERR,"Fix peri neigh does not exist");
|
||||||
|
|
||||||
neighbor->request(this,instance_me);
|
neighbor->request(this,instance_me);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#include "math_const.h"
|
#include "math_const.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
@ -360,9 +361,8 @@ void FixShake::init()
|
|||||||
// could have changed locations in fix list since created
|
// could have changed locations in fix list since created
|
||||||
// set ptrs to rRESPA variables
|
// set ptrs to rRESPA variables
|
||||||
|
|
||||||
if (strstr(update->integrate_style,"respa")) {
|
if (utils::strmatch(update->integrate_style,"^respa")) {
|
||||||
for (i = 0; i < modify->nfix; i++)
|
ifix_respa = modify->find_fix_by_style("^RESPA");
|
||||||
if (strcmp(modify->fix[i]->style,"RESPA") == 0) ifix_respa = i;
|
|
||||||
nlevels_respa = ((Respa *) update->integrate)->nlevels;
|
nlevels_respa = ((Respa *) update->integrate)->nlevels;
|
||||||
loop_respa = ((Respa *) update->integrate)->loop;
|
loop_respa = ((Respa *) update->integrate)->loop;
|
||||||
step_respa = ((Respa *) update->integrate)->step;
|
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";
|
master_group = (char *) "bond_react_MASTER_group";
|
||||||
|
|
||||||
// by using fixed group names, only one instance of fix bond/react is allowed.
|
// 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");
|
error->all(FLERR,"Only one instance of fix bond/react allowed at a time");
|
||||||
|
|
||||||
// let's find number of reactions specified
|
// let's find number of reactions specified
|
||||||
|
|||||||
@ -325,9 +325,10 @@ void PairReaxCOMP::init_style( )
|
|||||||
|
|
||||||
// firstwarn = 1;
|
// firstwarn = 1;
|
||||||
|
|
||||||
int iqeq = modify->find_fix_by_style("qeq/reax/omp");
|
bool have_qeq = ((modify->find_fix_by_style("^qeq/reax") != -1)
|
||||||
if (iqeq < 0 && qeqflag == 1)
|
|| (modify->find_fix_by_style("^qeq/shielded") != -1));
|
||||||
error->all(FLERR,"Pair reax/c/omp requires use of fix qeq/reax/omp");
|
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; // my atoms
|
||||||
system->N = atom->nlocal + atom->nghost; // mine + ghosts
|
system->N = atom->nlocal + atom->nghost; // mine + ghosts
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
#include "citeme.h"
|
#include "citeme.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include "reaxc_defs.h"
|
#include "reaxc_defs.h"
|
||||||
#include "reaxc_types.h"
|
#include "reaxc_types.h"
|
||||||
@ -372,12 +373,10 @@ void PairReaxC::init_style( )
|
|||||||
|
|
||||||
// firstwarn = 1;
|
// firstwarn = 1;
|
||||||
|
|
||||||
int iqeq;
|
bool have_qeq = ((modify->find_fix_by_style("^qeq/reax") != -1)
|
||||||
for (iqeq = 0; iqeq < modify->nfix; iqeq++)
|
|| (modify->find_fix_by_style("^qeq/shielded") != -1));
|
||||||
if (strstr(modify->fix[iqeq]->style,"qeq/reax")
|
if (!have_qeq && qeqflag == 1)
|
||||||
|| strstr(modify->fix[iqeq]->style,"qeq/shielded")) break;
|
error->all(FLERR,"Pair reax/c requires use of fix qeq/reax or qeq/shielded");
|
||||||
if (iqeq == modify->nfix && qeqflag == 1)
|
|
||||||
error->all(FLERR,"Pair reax/c requires use of fix qeq/reax");
|
|
||||||
|
|
||||||
system->n = atom->nlocal; // my atoms
|
system->n = atom->nlocal; // my atoms
|
||||||
system->N = atom->nlocal + atom->nghost; // mine + ghosts
|
system->N = atom->nlocal + atom->nghost; // mine + ghosts
|
||||||
|
|||||||
@ -1029,7 +1029,7 @@ int Modify::find_fix_by_style(const char *style)
|
|||||||
{
|
{
|
||||||
int ifix;
|
int ifix;
|
||||||
for (ifix = 0; ifix < nfix; 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;
|
if (ifix == nfix) return -1;
|
||||||
return ifix;
|
return ifix;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user