enable and apply clang-format, revert to some older code constructs where equivalent
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -35,14 +34,13 @@
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum{NONE, SPHERE, CYLINDER, PLANE, CONE};
|
||||
enum{INSIDE, OUTSIDE};
|
||||
enum { NONE, SPHERE, CYLINDER, PLANE, CONE };
|
||||
enum { INSIDE, OUTSIDE };
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg),
|
||||
xstr(nullptr), ystr(nullptr), zstr(nullptr), rstr(nullptr), pstr(nullptr),
|
||||
Fix(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr), rstr(nullptr), pstr(nullptr),
|
||||
rlostr(nullptr), rhistr(nullptr), lostr(nullptr), histr(nullptr)
|
||||
{
|
||||
if (narg < 4) utils::missing_cmd_args(FLERR, "fix indent", error);
|
||||
@ -57,20 +55,20 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) :
|
||||
respa_level_support = 1;
|
||||
ilevel_respa = 0;
|
||||
|
||||
k = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
k = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
if (k < 0.0) error->all(FLERR, "Illegal fix indent force constant: {}", k);
|
||||
k3 = k/3.0;
|
||||
k3 = k / 3.0;
|
||||
|
||||
// read geometry of indenter and optional args
|
||||
|
||||
int iarg = geometry(narg-4,&arg[4]) + 4;
|
||||
options(narg-iarg,&arg[iarg]);
|
||||
int iarg = geometry(narg - 4, &arg[4]) + 4;
|
||||
options(narg - iarg, &arg[iarg]);
|
||||
|
||||
// setup scaling
|
||||
|
||||
const double xscale { scaleflag ? domain->lattice->xlattice : 1.0};
|
||||
const double yscale { scaleflag ? domain->lattice->ylattice : 1.0};
|
||||
const double zscale { scaleflag ? domain->lattice->zlattice : 1.0};
|
||||
const double xscale{scaleflag ? domain->lattice->xlattice : 1.0};
|
||||
const double yscale{scaleflag ? domain->lattice->ylattice : 1.0};
|
||||
const double zscale{scaleflag ? domain->lattice->zlattice : 1.0};
|
||||
|
||||
// apply scaling factors to geometry
|
||||
|
||||
@ -104,11 +102,15 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (!histr) hivalue *= scaling_factor;
|
||||
|
||||
} else if (istyle == PLANE) {
|
||||
if (cdim == 0 && !pstr) pvalue *= xscale;
|
||||
else if (cdim == 1 && !pstr) pvalue *= yscale;
|
||||
else if (cdim == 2 && !pstr) pvalue *= zscale;
|
||||
if (cdim == 0 && !pstr)
|
||||
pvalue *= xscale;
|
||||
else if (cdim == 1 && !pstr)
|
||||
pvalue *= yscale;
|
||||
else if (cdim == 2 && !pstr)
|
||||
pvalue *= zscale;
|
||||
|
||||
} else error->all(FLERR,"Unknown fix indent keyword: {}", istyle);
|
||||
} else
|
||||
error->all(FLERR, "Unknown fix indent keyword: {}", istyle);
|
||||
|
||||
varflag = 0;
|
||||
if (xstr || ystr || zstr || rstr || pstr || rlostr || rhistr || lostr || histr) varflag = 1;
|
||||
@ -121,15 +123,15 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
FixIndent::~FixIndent()
|
||||
{
|
||||
delete [] xstr;
|
||||
delete [] ystr;
|
||||
delete [] zstr;
|
||||
delete [] rstr;
|
||||
delete [] pstr;
|
||||
delete [] rlostr;
|
||||
delete [] rhistr;
|
||||
delete [] lostr;
|
||||
delete [] histr;
|
||||
delete[] xstr;
|
||||
delete[] ystr;
|
||||
delete[] zstr;
|
||||
delete[] rstr;
|
||||
delete[] pstr;
|
||||
delete[] rlostr;
|
||||
delete[] rhistr;
|
||||
delete[] lostr;
|
||||
delete[] histr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -149,71 +151,62 @@ void FixIndent::init()
|
||||
{
|
||||
if (xstr) {
|
||||
xvar = input->variable->find(xstr);
|
||||
if (xvar < 0)
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", xstr);
|
||||
if (xvar < 0) error->all(FLERR, "Variable {} for fix indent does not exist", xstr);
|
||||
if (!input->variable->equalstyle(xvar))
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", xstr);
|
||||
error->all(FLERR, "Variable {} for fix indent is invalid style", xstr);
|
||||
}
|
||||
if (ystr) {
|
||||
yvar = input->variable->find(ystr);
|
||||
if (yvar < 0)
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", ystr);
|
||||
if (yvar < 0) error->all(FLERR, "Variable {} for fix indent does not exist", ystr);
|
||||
if (!input->variable->equalstyle(yvar))
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", ystr);
|
||||
error->all(FLERR, "Variable {} for fix indent is invalid style", ystr);
|
||||
}
|
||||
if (zstr) {
|
||||
zvar = input->variable->find(zstr);
|
||||
if (zvar < 0)
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", zstr);
|
||||
if (zvar < 0) error->all(FLERR, "Variable {} for fix indent does not exist", zstr);
|
||||
if (!input->variable->equalstyle(zvar))
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", zstr);
|
||||
error->all(FLERR, "Variable {} for fix indent is invalid style", zstr);
|
||||
}
|
||||
if (rstr) {
|
||||
rvar = input->variable->find(rstr);
|
||||
if (rvar < 0)
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", rstr);
|
||||
if (rvar < 0) error->all(FLERR, "Variable {} for fix indent does not exist", rstr);
|
||||
if (!input->variable->equalstyle(rvar))
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", rstr);
|
||||
error->all(FLERR, "Variable {} for fix indent is invalid style", rstr);
|
||||
}
|
||||
if (pstr) {
|
||||
pvar = input->variable->find(pstr);
|
||||
if (pvar < 0)
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", pstr);
|
||||
if (pvar < 0) error->all(FLERR, "Variable {} for fix indent does not exist", pstr);
|
||||
if (!input->variable->equalstyle(pvar))
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", pstr);
|
||||
error->all(FLERR, "Variable {} for fix indent is invalid style", pstr);
|
||||
}
|
||||
if (rlostr) {
|
||||
rlovar = input->variable->find(rlostr);
|
||||
if (rlovar < 0)
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", rlostr);
|
||||
if (rlovar < 0) error->all(FLERR, "Variable {} for fix indent does not exist", rlostr);
|
||||
if (!input->variable->equalstyle(rlovar))
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", rlostr);
|
||||
error->all(FLERR, "Variable {} for fix indent is invalid style", rlostr);
|
||||
}
|
||||
if (rhistr) {
|
||||
rhivar = input->variable->find(rhistr);
|
||||
if (rhivar < 0)
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", rhistr);
|
||||
if (rhivar < 0) error->all(FLERR, "Variable {} for fix indent does not exist", rhistr);
|
||||
if (!input->variable->equalstyle(rhivar))
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", rhistr);
|
||||
error->all(FLERR, "Variable {} for fix indent is invalid style", rhistr);
|
||||
}
|
||||
if (lostr) {
|
||||
lovar = input->variable->find(lostr);
|
||||
if (lovar < 0)
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", lostr);
|
||||
if (lovar < 0) error->all(FLERR, "Variable {} for fix indent does not exist", lostr);
|
||||
if (!input->variable->equalstyle(lovar))
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", lostr);
|
||||
error->all(FLERR, "Variable {} for fix indent is invalid style", lostr);
|
||||
}
|
||||
if (histr) {
|
||||
hivar = input->variable->find(histr);
|
||||
if (hivar < 0)
|
||||
error->all(FLERR,"Variable {} for fix indent does not exist", histr);
|
||||
if (hivar < 0) error->all(FLERR, "Variable {} for fix indent does not exist", histr);
|
||||
if (!input->variable->equalstyle(hivar))
|
||||
error->all(FLERR,"Variable {} for fix indent is invalid style", histr);
|
||||
error->all(FLERR, "Variable {} for fix indent is invalid style", histr);
|
||||
}
|
||||
|
||||
if (utils::strmatch(update->integrate_style,"^respa")) {
|
||||
ilevel_respa = (dynamic_cast<Respa *>(update->integrate))->nlevels-1;
|
||||
if (respa_level >= 0) ilevel_respa = MIN(respa_level,ilevel_respa);
|
||||
if (utils::strmatch(update->integrate_style, "^respa")) {
|
||||
ilevel_respa = (dynamic_cast<Respa *>(update->integrate))->nlevels - 1;
|
||||
if (respa_level >= 0) ilevel_respa = MIN(respa_level, ilevel_respa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,11 +214,11 @@ void FixIndent::init()
|
||||
|
||||
void FixIndent::setup(int vflag)
|
||||
{
|
||||
if (utils::strmatch(update->integrate_style,"^verlet"))
|
||||
if (utils::strmatch(update->integrate_style, "^verlet"))
|
||||
post_force(vflag);
|
||||
else {
|
||||
(dynamic_cast<Respa *>(update->integrate))->copy_flevel_f(ilevel_respa);
|
||||
post_force_respa(vflag,ilevel_respa,0);
|
||||
post_force_respa(vflag, ilevel_respa, 0);
|
||||
(dynamic_cast<Respa *>(update->integrate))->copy_f_flevel(ilevel_respa);
|
||||
}
|
||||
}
|
||||
@ -251,7 +244,7 @@ void FixIndent::post_force(int /*vflag*/)
|
||||
|
||||
// ctr = current indenter centerz
|
||||
|
||||
double ctr[3] {xvalue, yvalue, zvalue};
|
||||
double ctr[3] = {xvalue, yvalue, zvalue};
|
||||
if (xstr) ctr[0] = input->variable->compute_equal(xvar);
|
||||
if (ystr) ctr[1] = input->variable->compute_equal(yvar);
|
||||
if (zstr) ctr[2] = input->variable->compute_equal(zvar);
|
||||
@ -271,7 +264,7 @@ void FixIndent::post_force(int /*vflag*/)
|
||||
|
||||
domain->remap(ctr);
|
||||
|
||||
double radius { rstr ? input->variable->compute_equal(rvar) : rvalue};
|
||||
double radius = rstr ? input->variable->compute_equal(rvar) : rvalue;
|
||||
if (radius < 0.0) error->all(FLERR, "Illegal fix indent sphere radius: {}", radius);
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
@ -279,23 +272,23 @@ void FixIndent::post_force(int /*vflag*/)
|
||||
delx = x[i][0] - ctr[0];
|
||||
dely = x[i][1] - ctr[1];
|
||||
delz = x[i][2] - ctr[2];
|
||||
domain->minimum_image(delx,dely,delz);
|
||||
r = sqrt(delx*delx + dely*dely + delz*delz);
|
||||
domain->minimum_image(delx, dely, delz);
|
||||
r = sqrt(delx * delx + dely * dely + delz * delz);
|
||||
if (side == OUTSIDE) {
|
||||
dr = r - radius;
|
||||
fmag = k*dr*dr;
|
||||
fmag = k * dr * dr;
|
||||
} else {
|
||||
dr = radius - r;
|
||||
fmag = -k*dr*dr;
|
||||
fmag = -k * dr * dr;
|
||||
}
|
||||
if (dr >= 0.0) continue;
|
||||
fx = delx*fmag/r;
|
||||
fy = dely*fmag/r;
|
||||
fz = delz*fmag/r;
|
||||
fx = delx * fmag / r;
|
||||
fy = dely * fmag / r;
|
||||
fz = delz * fmag / r;
|
||||
f[i][0] += fx;
|
||||
f[i][1] += fy;
|
||||
f[i][2] += fz;
|
||||
indenter[0] -= k3 * dr*dr*dr;
|
||||
indenter[0] -= k3 * dr * dr * dr;
|
||||
indenter[1] -= fx;
|
||||
indenter[2] -= fy;
|
||||
indenter[3] -= fz;
|
||||
@ -312,30 +305,30 @@ void FixIndent::post_force(int /*vflag*/)
|
||||
ctr[cdim] = domain->boxlo[cdim];
|
||||
domain->remap(ctr);
|
||||
|
||||
double radius { rstr ? input->variable->compute_equal(rvar) : rvalue};
|
||||
double radius{rstr ? input->variable->compute_equal(rvar) : rvalue};
|
||||
if (radius < 0.0) error->all(FLERR, "Illegal fix indent cylinder radius: {}", radius);
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
double del[3] {x[i][0] - ctr[0], x[i][1] - ctr[1], x[i][2] - ctr[2]};
|
||||
double del[3] = {x[i][0] - ctr[0], x[i][1] - ctr[1], x[i][2] - ctr[2]};
|
||||
del[cdim] = 0;
|
||||
domain->minimum_image(del[0], del[1], del[2]);
|
||||
r = sqrt(del[0]*del[0] + del[1]*del[1] + del[2]*del[2]);
|
||||
r = sqrt(del[0] * del[0] + del[1] * del[1] + del[2] * del[2]);
|
||||
if (side == OUTSIDE) {
|
||||
dr = r - radius;
|
||||
fmag = k*dr*dr;
|
||||
fmag = k * dr * dr;
|
||||
} else {
|
||||
dr = radius - r;
|
||||
fmag = -k*dr*dr;
|
||||
fmag = -k * dr * dr;
|
||||
}
|
||||
if (dr >= 0.0) continue;
|
||||
fx = del[0]*fmag/r;
|
||||
fy = del[1]*fmag/r;
|
||||
fz = del[2]*fmag/r;
|
||||
fx = del[0] * fmag / r;
|
||||
fy = del[1] * fmag / r;
|
||||
fz = del[2] * fmag / r;
|
||||
f[i][0] += fx;
|
||||
f[i][1] += fy;
|
||||
f[i][2] += fz;
|
||||
indenter[0] -= k3 * dr*dr*dr;
|
||||
indenter[0] -= k3 * dr * dr * dr;
|
||||
indenter[1] -= fx;
|
||||
indenter[2] -= fy;
|
||||
indenter[3] -= fz;
|
||||
@ -345,13 +338,13 @@ void FixIndent::post_force(int /*vflag*/)
|
||||
|
||||
} else if (istyle == CONE) {
|
||||
|
||||
double radiuslo { rlostr ? input->variable->compute_equal(rlovar) : rlovalue };
|
||||
double radiuslo{rlostr ? input->variable->compute_equal(rlovar) : rlovalue};
|
||||
if (radiuslo < 0.0) error->all(FLERR, "Illegal fix indent cone lower radius: {}", radiuslo);
|
||||
double radiushi { rhistr ? input->variable->compute_equal(rhivar) : rhivalue };
|
||||
double radiushi{rhistr ? input->variable->compute_equal(rhivar) : rhivalue};
|
||||
if (radiushi < 0.0) error->all(FLERR, "Illegal fix indent cone high radius: {}", radiushi);
|
||||
|
||||
double initial_lo { lostr ? input->variable->compute_equal(lovar) : lovalue };
|
||||
double initial_hi { histr ? input->variable->compute_equal(hivar) : hivalue };
|
||||
double initial_lo{lostr ? input->variable->compute_equal(lovar) : lovalue};
|
||||
double initial_hi{histr ? input->variable->compute_equal(hivar) : hivalue};
|
||||
|
||||
ctr[cdim] = 0.5 * (initial_hi + initial_lo);
|
||||
|
||||
@ -368,7 +361,7 @@ void FixIndent::post_force(int /*vflag*/)
|
||||
delz = x[i][2] - ctr[2];
|
||||
domain->minimum_image(delx, dely, delz);
|
||||
|
||||
double x0[3] {delx + ctr[0], dely + ctr[1], delz + ctr[2]};
|
||||
double x0[3] = {delx + ctr[0], dely + ctr[1], delz + ctr[2]};
|
||||
r = sqrt(delx * delx + dely * dely + delz * delz);
|
||||
|
||||
// check if particle is inside or outside the cone
|
||||
@ -391,12 +384,12 @@ void FixIndent::post_force(int /*vflag*/)
|
||||
|
||||
dr = sqrt(x0[0] * x0[0] + x0[1] * x0[1] + x0[2] * x0[2]);
|
||||
|
||||
int force_sign = { point_inside_cone ? 1 : -1 };
|
||||
int force_sign = {point_inside_cone ? 1 : -1};
|
||||
fmag = force_sign * k * dr * dr;
|
||||
|
||||
fx = delx*fmag/r;
|
||||
fy = dely*fmag/r;
|
||||
fz = delz*fmag/r;
|
||||
fx = delx * fmag / r;
|
||||
fy = dely * fmag / r;
|
||||
fz = delz * fmag / r;
|
||||
f[i][0] += fx;
|
||||
f[i][1] += fy;
|
||||
f[i][2] += fz;
|
||||
@ -413,7 +406,7 @@ void FixIndent::post_force(int /*vflag*/)
|
||||
|
||||
// plane = current plane position
|
||||
|
||||
double plane { pstr ? input->variable->compute_equal(pvar) : pvalue};
|
||||
double plane{pstr ? input->variable->compute_equal(pvar) : pvalue};
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
@ -422,7 +415,7 @@ void FixIndent::post_force(int /*vflag*/)
|
||||
fmag = -planeside * k * dr * dr;
|
||||
f[i][cdim] += fmag;
|
||||
indenter[0] -= k3 * dr * dr * dr;
|
||||
indenter[cdim+1] -= fmag;
|
||||
indenter[cdim + 1] -= fmag;
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,7 +445,7 @@ double FixIndent::compute_scalar()
|
||||
// only sum across procs one time
|
||||
|
||||
if (indenter_flag == 0) {
|
||||
MPI_Allreduce(indenter,indenter_all,4,MPI_DOUBLE,MPI_SUM,world);
|
||||
MPI_Allreduce(indenter, indenter_all, 4, MPI_DOUBLE, MPI_SUM, world);
|
||||
indenter_flag = 1;
|
||||
}
|
||||
return indenter_all[0];
|
||||
@ -467,10 +460,10 @@ double FixIndent::compute_vector(int n)
|
||||
// only sum across procs one time
|
||||
|
||||
if (indenter_flag == 0) {
|
||||
MPI_Allreduce(indenter,indenter_all,4,MPI_DOUBLE,MPI_SUM,world);
|
||||
MPI_Allreduce(indenter, indenter_all, 4, MPI_DOUBLE, MPI_SUM, world);
|
||||
indenter_flag = 1;
|
||||
}
|
||||
return indenter_all[n+1];
|
||||
return indenter_all[n + 1];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -487,22 +480,26 @@ int FixIndent::geometry(int narg, char **arg)
|
||||
|
||||
// sphere
|
||||
|
||||
if (strcmp(arg[0],"sphere") == 0) {
|
||||
if (strcmp(arg[0], "sphere") == 0) {
|
||||
if (istyle != NONE) error->all(FLERR, "Fix indent requires a single geometry keyword");
|
||||
if (5 > narg) utils::missing_cmd_args(FLERR, "fix indent sphere", error);
|
||||
|
||||
if (utils::strmatch(arg[1],"^v_")) {
|
||||
xstr = utils::strdup(arg[1]+2);
|
||||
} else xvalue = utils::numeric(FLERR,arg[1],false,lmp);
|
||||
if (utils::strmatch(arg[2],"^v_")) {
|
||||
ystr = utils::strdup(arg[2]+2);
|
||||
} else yvalue = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
if (utils::strmatch(arg[3],"^v_")) {
|
||||
zstr = utils::strdup(arg[3]+2);
|
||||
} else zvalue = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
if (utils::strmatch(arg[4],"^v_")) {
|
||||
rstr = utils::strdup(arg[4]+2);
|
||||
} else rvalue = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
if (utils::strmatch(arg[1], "^v_")) {
|
||||
xstr = utils::strdup(arg[1] + 2);
|
||||
} else
|
||||
xvalue = utils::numeric(FLERR, arg[1], false, lmp);
|
||||
if (utils::strmatch(arg[2], "^v_")) {
|
||||
ystr = utils::strdup(arg[2] + 2);
|
||||
} else
|
||||
yvalue = utils::numeric(FLERR, arg[2], false, lmp);
|
||||
if (utils::strmatch(arg[3], "^v_")) {
|
||||
zstr = utils::strdup(arg[3] + 2);
|
||||
} else
|
||||
zvalue = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
if (utils::strmatch(arg[4], "^v_")) {
|
||||
rstr = utils::strdup(arg[4] + 2);
|
||||
} else
|
||||
rvalue = utils::numeric(FLERR, arg[4], false, lmp);
|
||||
|
||||
istyle = SPHERE;
|
||||
return 5;
|
||||
@ -510,39 +507,47 @@ int FixIndent::geometry(int narg, char **arg)
|
||||
|
||||
// cylinder
|
||||
|
||||
if (strcmp(arg[0],"cylinder") == 0) {
|
||||
if (strcmp(arg[0], "cylinder") == 0) {
|
||||
if (istyle != NONE) error->all(FLERR, "Fix indent requires a single geometry keyword");
|
||||
if (5 > narg) utils::missing_cmd_args(FLERR, "fix indent cylinder", error);
|
||||
|
||||
if (strcmp(arg[1],"x") == 0) {
|
||||
if (strcmp(arg[1], "x") == 0) {
|
||||
cdim = 0;
|
||||
if (utils::strmatch(arg[2],"^v_")) {
|
||||
ystr = utils::strdup(arg[2]+2);
|
||||
} else yvalue = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
if (utils::strmatch(arg[3],"^v_")) {
|
||||
zstr = utils::strdup(arg[3]+2);
|
||||
} else zvalue = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
} else if (strcmp(arg[1],"y") == 0) {
|
||||
if (utils::strmatch(arg[2], "^v_")) {
|
||||
ystr = utils::strdup(arg[2] + 2);
|
||||
} else
|
||||
yvalue = utils::numeric(FLERR, arg[2], false, lmp);
|
||||
if (utils::strmatch(arg[3], "^v_")) {
|
||||
zstr = utils::strdup(arg[3] + 2);
|
||||
} else
|
||||
zvalue = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
} else if (strcmp(arg[1], "y") == 0) {
|
||||
cdim = 1;
|
||||
if (utils::strmatch(arg[2],"^v_")) {
|
||||
xstr = utils::strdup(arg[2]+2);
|
||||
} else xvalue = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
if (utils::strmatch(arg[3],"^v_")) {
|
||||
zstr = utils::strdup(arg[3]+2);
|
||||
} else zvalue = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
} else if (strcmp(arg[1],"z") == 0) {
|
||||
if (utils::strmatch(arg[2], "^v_")) {
|
||||
xstr = utils::strdup(arg[2] + 2);
|
||||
} else
|
||||
xvalue = utils::numeric(FLERR, arg[2], false, lmp);
|
||||
if (utils::strmatch(arg[3], "^v_")) {
|
||||
zstr = utils::strdup(arg[3] + 2);
|
||||
} else
|
||||
zvalue = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
} else if (strcmp(arg[1], "z") == 0) {
|
||||
cdim = 2;
|
||||
if (utils::strmatch(arg[2],"^v_")) {
|
||||
xstr = utils::strdup(arg[2]+2);
|
||||
} else xvalue = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
if (utils::strmatch(arg[3],"^v_")) {
|
||||
ystr = utils::strdup(arg[3]+2);
|
||||
} else yvalue = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
} else error->all(FLERR,"Unknown fix indent cylinder argument: {}", arg[1]);
|
||||
if (utils::strmatch(arg[2], "^v_")) {
|
||||
xstr = utils::strdup(arg[2] + 2);
|
||||
} else
|
||||
xvalue = utils::numeric(FLERR, arg[2], false, lmp);
|
||||
if (utils::strmatch(arg[3], "^v_")) {
|
||||
ystr = utils::strdup(arg[3] + 2);
|
||||
} else
|
||||
yvalue = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
} else
|
||||
error->all(FLERR, "Unknown fix indent cylinder argument: {}", arg[1]);
|
||||
|
||||
if (utils::strmatch(arg[4],"^v_")) {
|
||||
rstr = utils::strdup(arg[4]+2);
|
||||
} else rvalue = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
if (utils::strmatch(arg[4], "^v_")) {
|
||||
rstr = utils::strdup(arg[4] + 2);
|
||||
} else
|
||||
rvalue = utils::numeric(FLERR, arg[4], false, lmp);
|
||||
|
||||
istyle = CYLINDER;
|
||||
return 5;
|
||||
@ -550,51 +555,62 @@ int FixIndent::geometry(int narg, char **arg)
|
||||
|
||||
// cone
|
||||
|
||||
if (strcmp(arg[0],"cone") == 0) {
|
||||
if (strcmp(arg[0], "cone") == 0) {
|
||||
if (istyle != NONE) error->all(FLERR, "Fix indent requires a single geometry keyword");
|
||||
if (8 > narg) utils::missing_cmd_args(FLERR, "fix indent cone", error);
|
||||
|
||||
if (strcmp(arg[1],"x") == 0) {
|
||||
if (strcmp(arg[1], "x") == 0) {
|
||||
cdim = 0;
|
||||
if (utils::strmatch(arg[2],"^v_")) {
|
||||
ystr = utils::strdup(arg[2]+2);
|
||||
} else yvalue = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
if (utils::strmatch(arg[3],"^v_")) {
|
||||
zstr = utils::strdup(arg[3]+2);
|
||||
} else zvalue = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
if (utils::strmatch(arg[2], "^v_")) {
|
||||
ystr = utils::strdup(arg[2] + 2);
|
||||
} else
|
||||
yvalue = utils::numeric(FLERR, arg[2], false, lmp);
|
||||
if (utils::strmatch(arg[3], "^v_")) {
|
||||
zstr = utils::strdup(arg[3] + 2);
|
||||
} else
|
||||
zvalue = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
|
||||
} else if (strcmp(arg[1],"y") == 0) {
|
||||
} else if (strcmp(arg[1], "y") == 0) {
|
||||
cdim = 1;
|
||||
if (utils::strmatch(arg[2],"^v_")) {
|
||||
xstr = utils::strdup(arg[2]+2);
|
||||
} else xvalue = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
if (utils::strmatch(arg[3],"^v_")) {
|
||||
zstr = utils::strdup(arg[3]+2);
|
||||
} else zvalue = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
if (utils::strmatch(arg[2], "^v_")) {
|
||||
xstr = utils::strdup(arg[2] + 2);
|
||||
} else
|
||||
xvalue = utils::numeric(FLERR, arg[2], false, lmp);
|
||||
if (utils::strmatch(arg[3], "^v_")) {
|
||||
zstr = utils::strdup(arg[3] + 2);
|
||||
} else
|
||||
zvalue = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
|
||||
} else if (strcmp(arg[1],"z") == 0) {
|
||||
} else if (strcmp(arg[1], "z") == 0) {
|
||||
cdim = 2;
|
||||
if (utils::strmatch(arg[2],"^v_")) {
|
||||
xstr = utils::strdup(arg[2]+2);
|
||||
} else xvalue = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
if (utils::strmatch(arg[3],"^v_")) {
|
||||
ystr = utils::strdup(arg[3]+2);
|
||||
} else yvalue = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
if (utils::strmatch(arg[2], "^v_")) {
|
||||
xstr = utils::strdup(arg[2] + 2);
|
||||
} else
|
||||
xvalue = utils::numeric(FLERR, arg[2], false, lmp);
|
||||
if (utils::strmatch(arg[3], "^v_")) {
|
||||
ystr = utils::strdup(arg[3] + 2);
|
||||
} else
|
||||
yvalue = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
|
||||
} else error->all(FLERR,"Unknown fix indent cone argument: {}", arg[1]);
|
||||
} else
|
||||
error->all(FLERR, "Unknown fix indent cone argument: {}", arg[1]);
|
||||
|
||||
if (utils::strmatch(arg[4],"^v_")) {
|
||||
rlostr = utils::strdup(arg[4]+2);
|
||||
} else rlovalue = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
if (utils::strmatch(arg[5],"^v_")) {
|
||||
rhistr = utils::strdup(arg[5]+2);
|
||||
} else rhivalue = utils::numeric(FLERR,arg[5],false,lmp);
|
||||
if (utils::strmatch(arg[6],"^v_")) {
|
||||
lostr = utils::strdup(arg[6]+2);
|
||||
} else lovalue = utils::numeric(FLERR,arg[6],false,lmp);
|
||||
if (utils::strmatch(arg[7],"^v_")) {
|
||||
histr = utils::strdup(arg[7]+2);
|
||||
} else hivalue = utils::numeric(FLERR,arg[7],false,lmp);
|
||||
if (utils::strmatch(arg[4], "^v_")) {
|
||||
rlostr = utils::strdup(arg[4] + 2);
|
||||
} else
|
||||
rlovalue = utils::numeric(FLERR, arg[4], false, lmp);
|
||||
if (utils::strmatch(arg[5], "^v_")) {
|
||||
rhistr = utils::strdup(arg[5] + 2);
|
||||
} else
|
||||
rhivalue = utils::numeric(FLERR, arg[5], false, lmp);
|
||||
if (utils::strmatch(arg[6], "^v_")) {
|
||||
lostr = utils::strdup(arg[6] + 2);
|
||||
} else
|
||||
lovalue = utils::numeric(FLERR, arg[6], false, lmp);
|
||||
if (utils::strmatch(arg[7], "^v_")) {
|
||||
histr = utils::strdup(arg[7] + 2);
|
||||
} else
|
||||
hivalue = utils::numeric(FLERR, arg[7], false, lmp);
|
||||
|
||||
istyle = CONE;
|
||||
return 8;
|
||||
@ -602,28 +618,36 @@ int FixIndent::geometry(int narg, char **arg)
|
||||
|
||||
// plane
|
||||
|
||||
if (strcmp(arg[0],"plane") == 0) {
|
||||
if (strcmp(arg[0], "plane") == 0) {
|
||||
if (istyle != NONE) error->all(FLERR, "Fix indent requires a single geometry keyword");
|
||||
if (4 > narg) utils::missing_cmd_args(FLERR, "fix indent plane", error);
|
||||
if (strcmp(arg[1],"x") == 0) cdim = 0;
|
||||
else if (strcmp(arg[1],"y") == 0) cdim = 1;
|
||||
else if (strcmp(arg[1],"z") == 0) cdim = 2;
|
||||
else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[1]);
|
||||
if (strcmp(arg[1], "x") == 0)
|
||||
cdim = 0;
|
||||
else if (strcmp(arg[1], "y") == 0)
|
||||
cdim = 1;
|
||||
else if (strcmp(arg[1], "z") == 0)
|
||||
cdim = 2;
|
||||
else
|
||||
error->all(FLERR, "Unknown fix indent plane argument: {}", arg[1]);
|
||||
|
||||
if (utils::strmatch(arg[2],"^v_")) {
|
||||
pstr = utils::strdup(arg[2]+2);
|
||||
} else pvalue = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
if (utils::strmatch(arg[2], "^v_")) {
|
||||
pstr = utils::strdup(arg[2] + 2);
|
||||
} else
|
||||
pvalue = utils::numeric(FLERR, arg[2], false, lmp);
|
||||
|
||||
if (strcmp(arg[3],"lo") == 0) planeside = -1;
|
||||
else if (strcmp(arg[3],"hi") == 0) planeside = 1;
|
||||
else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[3]);
|
||||
if (strcmp(arg[3], "lo") == 0)
|
||||
planeside = -1;
|
||||
else if (strcmp(arg[3], "hi") == 0)
|
||||
planeside = 1;
|
||||
else
|
||||
error->all(FLERR, "Unknown fix indent plane argument: {}", arg[3]);
|
||||
istyle = PLANE;
|
||||
return 4;
|
||||
}
|
||||
|
||||
// invalid istyle arg
|
||||
|
||||
error->all(FLERR,"Unknown fix indent argument: {}", arg[0]);
|
||||
error->all(FLERR, "Unknown fix indent argument: {}", arg[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -640,21 +664,28 @@ void FixIndent::options(int narg, char **arg)
|
||||
int iarg = 0;
|
||||
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"units") == 0) {
|
||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix indent units", error);
|
||||
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
|
||||
else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
|
||||
else error->all(FLERR,"Unknown fix indent units argument: {}", arg[iarg+1]);
|
||||
if (strcmp(arg[iarg], "units") == 0) {
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix indent units", error);
|
||||
if (strcmp(arg[iarg + 1], "box") == 0)
|
||||
scaleflag = 0;
|
||||
else if (strcmp(arg[iarg + 1], "lattice") == 0)
|
||||
scaleflag = 1;
|
||||
else
|
||||
error->all(FLERR, "Unknown fix indent units argument: {}", arg[iarg + 1]);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg],"side") == 0) {
|
||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix indent side", error);
|
||||
if (strcmp(arg[iarg+1],"in") == 0) side = INSIDE;
|
||||
else if (strcmp(arg[iarg+1],"out") == 0) side = OUTSIDE;
|
||||
else error->all(FLERR,"Unknown fix indent side argument: {}", arg[iarg+1]);
|
||||
} else if (strcmp(arg[iarg], "side") == 0) {
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix indent side", error);
|
||||
if (strcmp(arg[iarg + 1], "in") == 0)
|
||||
side = INSIDE;
|
||||
else if (strcmp(arg[iarg + 1], "out") == 0)
|
||||
side = OUTSIDE;
|
||||
else
|
||||
error->all(FLERR, "Unknown fix indent side argument: {}", arg[iarg + 1]);
|
||||
iarg += 2;
|
||||
|
||||
} else error->all(FLERR,"Unknown fix indent argument: {}", arg[iarg]);
|
||||
} else
|
||||
error->all(FLERR, "Unknown fix indent argument: {}", arg[iarg]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -662,12 +693,12 @@ void FixIndent::options(int narg, char **arg)
|
||||
determines if a point is inside (true) or outside (false) of a cone
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
bool FixIndent::PointInsideCone(int dir, double *center, double lo,
|
||||
double hi, double rlo, double rhi, double *x)
|
||||
bool FixIndent::PointInsideCone(int dir, double *center, double lo, double hi, double rlo,
|
||||
double rhi, double *x)
|
||||
{
|
||||
if ((x[dir] > hi) || (x[dir] < lo)) return false;
|
||||
|
||||
double del[3] {x[0] - center[0], x[1] - center[1], x[2] - center[2]};
|
||||
double del[3] = {x[0] - center[0], x[1] - center[1], x[2] - center[2]};
|
||||
del[dir] = 0.0;
|
||||
|
||||
double dist = sqrt(del[0] * del[0] + del[1] * del[1] + del[2] * del[2]);
|
||||
@ -682,17 +713,14 @@ bool FixIndent::PointInsideCone(int dir, double *center, double lo,
|
||||
distance between an exterior point and a cone
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixIndent::DistanceExteriorPoint(int dir, double *center, double lo, double hi,
|
||||
double rlo, double rhi,
|
||||
double &x, double &y, double &z)
|
||||
void FixIndent::DistanceExteriorPoint(int dir, double *center, double lo, double hi, double rlo,
|
||||
double rhi, double &x, double &y, double &z)
|
||||
{
|
||||
double xp[3], nearest[3], corner1[3], corner2[3];
|
||||
double point[3] = {x, y, z};
|
||||
double del[3] = {x - center[0], y - center[1], z - center[2]};
|
||||
|
||||
double point[3] {x, y, z};
|
||||
|
||||
double del[3] {x - center[0], y - center[1], z - center[2]};
|
||||
del[dir] = 0.0;
|
||||
|
||||
double r = sqrt(del[0] * del[0] + del[1] * del[1] + del[2] * del[2]);
|
||||
|
||||
corner1[0] = center[0] + del[0] * rlo / r;
|
||||
@ -705,10 +733,10 @@ void FixIndent::DistanceExteriorPoint(int dir, double *center, double lo, double
|
||||
corner2[2] = center[2] + del[2] * rhi / r;
|
||||
corner2[dir] = hi;
|
||||
|
||||
double corner3[3] {center[0], center[1], center[2]};
|
||||
double corner3[3] = {center[0], center[1], center[2]};
|
||||
corner3[dir] = lo;
|
||||
|
||||
double corner4[3] {center[0], center[1], center[2]};
|
||||
double corner4[3] = {center[0], center[1], center[2]};
|
||||
corner4[dir] = hi;
|
||||
|
||||
// initialize distance to a big number
|
||||
@ -741,18 +769,17 @@ void FixIndent::DistanceExteriorPoint(int dir, double *center, double lo, double
|
||||
distance between an interior point and a cone
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixIndent::DistanceInteriorPoint(int dir, double *center,
|
||||
double lo, double hi, double rlo, double rhi, double &x,
|
||||
double &y, double &z)
|
||||
void FixIndent::DistanceInteriorPoint(int dir, double *center, double lo, double hi, double rlo,
|
||||
double rhi, double &x, double &y, double &z)
|
||||
{
|
||||
double r, dist_disk, dist_surf;
|
||||
double surflo[3], surfhi[3], xs[3];
|
||||
double initial_point[3] {x, y, z};
|
||||
double point[3] {0.0, 0.0, 0.0};
|
||||
double initial_point[3] = {x, y, z};
|
||||
double point[3] = {0.0, 0.0, 0.0};
|
||||
|
||||
// initial check with the two disks
|
||||
|
||||
if ( (initial_point[dir] - lo) < (hi - initial_point[dir]) ) {
|
||||
if ((initial_point[dir] - lo) < (hi - initial_point[dir])) {
|
||||
dist_disk = (initial_point[dir] - lo) * (initial_point[dir] - lo);
|
||||
point[dir] = initial_point[dir] - lo;
|
||||
} else {
|
||||
@ -762,7 +789,7 @@ void FixIndent::DistanceInteriorPoint(int dir, double *center,
|
||||
|
||||
// check with the points in the conical surface
|
||||
|
||||
double del[3] {x - center[0], y - center[1], z - center[2]};
|
||||
double del[3] = {x - center[0], y - center[1], z - center[2]};
|
||||
del[dir] = 0.0;
|
||||
r = sqrt(del[0] * del[0] + del[1] * del[1] + del[2] * del[2]);
|
||||
|
||||
@ -778,7 +805,7 @@ void FixIndent::DistanceInteriorPoint(int dir, double *center,
|
||||
|
||||
point_on_line_segment(surflo, surfhi, initial_point, xs);
|
||||
|
||||
double dx[3] {initial_point[0] - xs[0], initial_point[1] - xs[1], initial_point[2] - xs[2]};
|
||||
double dx[3] = {initial_point[0] - xs[0], initial_point[1] - xs[1], initial_point[2] - xs[2]};
|
||||
dist_surf = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2];
|
||||
if (dist_surf < dist_disk) {
|
||||
x = dx[0];
|
||||
|
||||
Reference in New Issue
Block a user