diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index 5c7ed73d21..4a00bc6aeb 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -25,6 +25,7 @@ AtomStyle(body,AtomVecBody); namespace LAMMPS_NS { class AtomVecBody : public AtomVec { + friend class CreateAtoms; public: class Body *bptr; @@ -77,7 +78,7 @@ class AtomVecBody : public AtomVec { int nlocal_bonus; - private: + protected: int *body; double *rmass, *radius; double **angmom; diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 5399e8aee6..25931f947c 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "atom_vec.h" +#include "atom_vec_body.h" #include "comm.h" #include "domain.h" #include "error.h" @@ -390,14 +391,13 @@ void CreateAtoms::command(int narg, char **arg) if (!input->variable->equalstyle(vvar)) error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", vstr); -#define SETUP_XYZ_VAR(str, var) \ - if (str) { \ - var = input->variable->find(str); \ - if (var < 0) var = input->variable->internal_create(str, 0.0); \ - if (!input->variable->internalstyle(var)) \ - error->all(FLERR, Error::NOLASTLINE, \ - "Variable {} for create_atoms is invalid style", str); \ - } +#define SETUP_XYZ_VAR(str, var) \ + if (str) { \ + var = input->variable->find(str); \ + if (var < 0) var = input->variable->internal_create(str, 0.0); \ + if (!input->variable->internalstyle(var)) \ + error->all(FLERR, Error::NOLASTLINE, "Variable {} for create_atoms is invalid style", str); \ + } SETUP_XYZ_VAR(xstr, xvar); SETUP_XYZ_VAR(ystr, yvar); @@ -580,6 +580,10 @@ void CreateAtoms::command(int narg, char **arg) atom->ndihedrals += nmoltotal * onemol->ndihedrals; atom->nimpropers += nmoltotal * onemol->nimpropers; + // molecule files for bodies may only contain a single body + + if (onemol->bodyflag) atom->nbodies += 1; + // if atom style template // maxmol = max molecule ID across all procs, for previous atoms // moloffset = max molecule ID for all molecules owned by previous procs @@ -662,6 +666,18 @@ void CreateAtoms::command(int narg, char **arg) if (onemol->specialflag) for (int j = 0; j < nspecial[ilocal][2]; j++) special[ilocal][j] += offset; } + + // create body particle + + if (onemol->bodyflag) { + auto *avec_body = dynamic_cast(atom->avec); + if (avec_body) + avec_body->data_body(ilocal, onemol->nibody, onemol->ndbody, onemol->ibodyparams, + onemol->dbodyparams); + else + error->all(FLERR, Error::NOLASTLINE, "Molecule template {} requires a body atom style", + onemol->id); + } ilocal++; } if (molecule_flag) {