"stringify" and "vectorize" processing of per-atom attributs in AtomVec classes
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
|
||||
@ -21,8 +20,6 @@
|
||||
#include "math_const.h"
|
||||
#include "modify.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
@ -34,26 +31,25 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
|
||||
molecular = Atom::ATOMIC;
|
||||
|
||||
atom->sphere_flag = 1;
|
||||
atom->radius_flag = atom->rmass_flag = atom->omega_flag =
|
||||
atom->torque_flag = 1;
|
||||
atom->radius_flag = atom->rmass_flag = atom->omega_flag = atom->torque_flag = 1;
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "radius rmass omega torque";
|
||||
fields_copy = (char *) "radius rmass omega";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "omega";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "radius rmass";
|
||||
fields_border_vel = (char *) "radius rmass omega";
|
||||
fields_exchange = (char *) "radius rmass omega";
|
||||
fields_restart = (char *) "radius rmass omega";
|
||||
fields_create = (char *) "radius rmass omega";
|
||||
fields_data_atom = (char *) "id type radius rmass x";
|
||||
fields_data_vel = (char *) "id v omega";
|
||||
fields_grow = {"radius", "rmass", "omega", "torque"};
|
||||
fields_copy = {"radius", "rmass", "omega"};
|
||||
fields_comm = {};
|
||||
fields_comm_vel = {"omega"};
|
||||
fields_reverse = {"torque"};
|
||||
fields_border = {"radius", "rmass"};
|
||||
fields_border_vel = {"radius", "rmass", "omega"};
|
||||
fields_exchange = {"radius", "rmass", "omega"};
|
||||
fields_restart = {"radius", "rmass", "omega"};
|
||||
fields_create = {"radius", "rmass", "omega"};
|
||||
fields_data_atom = {"id", "type", "radius", "rmass", "x"};
|
||||
fields_data_vel = {"id", "v", "omega"};
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -63,21 +59,19 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
void AtomVecSphere::process_args(int narg, char **arg)
|
||||
{
|
||||
if (narg != 0 && narg != 1)
|
||||
error->all(FLERR,"Illegal atom_style sphere command");
|
||||
if (narg != 0 && narg != 1) error->all(FLERR, "Illegal atom_style sphere command");
|
||||
|
||||
radvary = 0;
|
||||
if (narg == 1) {
|
||||
radvary = utils::numeric(FLERR,arg[0],true,lmp);
|
||||
if (radvary < 0 || radvary > 1)
|
||||
error->all(FLERR,"Illegal atom_style sphere command");
|
||||
radvary = utils::numeric(FLERR, arg[0], true, lmp);
|
||||
if (radvary < 0 || radvary > 1) error->all(FLERR, "Illegal atom_style sphere command");
|
||||
}
|
||||
|
||||
// dynamic particle radius and mass must be communicated every step
|
||||
|
||||
if (radvary) {
|
||||
fields_comm = (char *) "radius rmass";
|
||||
fields_comm_vel = (char *) "radius rmass omega";
|
||||
fields_comm = {"radius", "rmass"};
|
||||
fields_comm_vel = {"radius", "rmass", "omega"};
|
||||
}
|
||||
|
||||
// delay setting up of fields until now
|
||||
@ -94,11 +88,10 @@ void AtomVecSphere::init()
|
||||
// check if optional radvary setting should have been set to 1
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (strcmp(modify->fix[i]->style,"adapt") == 0) {
|
||||
auto fix = dynamic_cast<FixAdapt *>( modify->fix[i]);
|
||||
if (strcmp(modify->fix[i]->style, "adapt") == 0) {
|
||||
auto fix = dynamic_cast<FixAdapt *>(modify->fix[i]);
|
||||
if (fix->diamflag && radvary == 0)
|
||||
error->all(FLERR,"Fix adapt changes particle radii "
|
||||
"but atom_style sphere is not dynamic");
|
||||
error->all(FLERR, "Fix adapt changes particle radii but atom_style sphere is not dynamic");
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +114,7 @@ void AtomVecSphere::grow_pointers()
|
||||
void AtomVecSphere::create_atom_post(int ilocal)
|
||||
{
|
||||
radius[ilocal] = 0.5;
|
||||
rmass[ilocal] = 4.0*MY_PI/3.0 * 0.5*0.5*0.5;
|
||||
rmass[ilocal] = 4.0 * MY_PI / 3.0 * 0.5 * 0.5 * 0.5;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -133,11 +126,9 @@ void AtomVecSphere::data_atom_post(int ilocal)
|
||||
{
|
||||
radius_one = 0.5 * atom->radius[ilocal];
|
||||
radius[ilocal] = radius_one;
|
||||
if (radius_one > 0.0)
|
||||
rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one;
|
||||
if (radius_one > 0.0) rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
|
||||
|
||||
if (rmass[ilocal] <= 0.0)
|
||||
error->one(FLERR,"Invalid density in Atoms section of data file");
|
||||
if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
|
||||
|
||||
omega[ilocal][0] = 0.0;
|
||||
omega[ilocal][1] = 0.0;
|
||||
@ -154,9 +145,8 @@ void AtomVecSphere::pack_data_pre(int ilocal)
|
||||
rmass_one = rmass[ilocal];
|
||||
|
||||
radius[ilocal] *= 2.0;
|
||||
if (radius_one!= 0.0)
|
||||
rmass[ilocal] =
|
||||
rmass_one / (4.0*MY_PI/3.0 * radius_one*radius_one*radius_one);
|
||||
if (radius_one != 0.0)
|
||||
rmass[ilocal] = rmass_one / (4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user