diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index acd35a1b9c5ee533b1dcc6e256cfd1048fde9e05..ef4f68a86c8fc1724b721dfaabeeb33d3f5bab27 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -28,8 +28,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecDipole::AtomVecDipole(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; mass_type = 1; diff --git a/src/DIPOLE/atom_vec_dipole.h b/src/DIPOLE/atom_vec_dipole.h index bdbf180a8e4e164a4bc618bc46f6b21e72f52b68..a465272e36ee3b82bf0ed28f0cea7e571a21a967 100644 --- a/src/DIPOLE/atom_vec_dipole.h +++ b/src/DIPOLE/atom_vec_dipole.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecDipole : public AtomVec { public: - AtomVecDipole(class LAMMPS *, int, char **); + AtomVecDipole(class LAMMPS *); void grow(int); void grow_reset(); void copy(int, int, int); diff --git a/src/Depend.sh b/src/Depend.sh index feb92c3e29bfcd8ea977044a305b6db01a0cf8fc..b5d6ff3d66a7643eaaa0680356ba956b9fc06c3c 100644 --- a/src/Depend.sh +++ b/src/Depend.sh @@ -46,4 +46,3 @@ elif (test $1 = 0) then fi fi - diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index 8b1d2cd2f62a7634346e62622b6c476f0202131d..9b42d6ef1b4a11b55073da77983b4d7c90b56e3d 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -27,8 +27,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecAngle::AtomVecAngle(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) { molecular = 1; bonds_allow = angles_allow = 1; diff --git a/src/MOLECULE/atom_vec_angle.h b/src/MOLECULE/atom_vec_angle.h index 7a39863f222344a19277cd856944269802108258..3300106fdf5cf40b36e9b707f9d53a521515e089 100644 --- a/src/MOLECULE/atom_vec_angle.h +++ b/src/MOLECULE/atom_vec_angle.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecAngle : public AtomVec { public: - AtomVecAngle(class LAMMPS *, int, char **); + AtomVecAngle(class LAMMPS *); virtual ~AtomVecAngle() {} void grow(int); void grow_reset(); diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 375c0dc7702792b435d451fa321b9f55777fff4b..2493533c443a259c5a86c5a1821b9ad5132fa635 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -27,8 +27,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecBond::AtomVecBond(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp) { molecular = 1; bonds_allow = 1; diff --git a/src/MOLECULE/atom_vec_bond.h b/src/MOLECULE/atom_vec_bond.h index ed437027a10551b5968961559c983794639daa97..c94aec1eb438a256f48ff343c99021c0542650f8 100644 --- a/src/MOLECULE/atom_vec_bond.h +++ b/src/MOLECULE/atom_vec_bond.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecBond : public AtomVec { public: - AtomVecBond(class LAMMPS *, int, char **); + AtomVecBond(class LAMMPS *); void grow(int); void grow_reset(); void copy(int, int, int); diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index e7f009c569eb69512acf16a565b3dd8c339d7185..d7cecabf718e524e83613e351d4dee9d1c913342 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -27,8 +27,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecFull::AtomVecFull(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) { molecular = 1; bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 1; diff --git a/src/MOLECULE/atom_vec_full.h b/src/MOLECULE/atom_vec_full.h index 14e25237dea6a2238f365168c6798b8e2f14a7fa..d14871271af6109c124a21df7e0743d28a565fb3 100644 --- a/src/MOLECULE/atom_vec_full.h +++ b/src/MOLECULE/atom_vec_full.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecFull : public AtomVec { public: - AtomVecFull(class LAMMPS *, int, char **); + AtomVecFull(class LAMMPS *); virtual ~AtomVecFull() {} void grow(int); void grow_reset(); diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index bb21e5b0f4528b87ba638bcdafa6b221db9881eb..d85cc567ba48f0f00d657697f2ef8deb1d0242be 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -27,8 +27,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) { molecular = 1; bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 1; diff --git a/src/MOLECULE/atom_vec_molecular.h b/src/MOLECULE/atom_vec_molecular.h index 3da1a5fe029334e41f8507c1eb047ed35901d9f8..9ba67449702d6a790efae7bf3bfbe0a22aab5f34 100644 --- a/src/MOLECULE/atom_vec_molecular.h +++ b/src/MOLECULE/atom_vec_molecular.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecMolecular : public AtomVec { public: - AtomVecMolecular(class LAMMPS *, int, char **); + AtomVecMolecular(class LAMMPS *); void grow(int); void grow_reset(); void copy(int, int, int); diff --git a/src/Make.sh b/src/Make.sh index e554ba6353e69004a96a0621221d1b04c9d66c1b..47d62037e209f9359c5b93090f96ee5e801b5142 100644 --- a/src/Make.sh +++ b/src/Make.sh @@ -10,7 +10,7 @@ # else Make will not recreate them style () { - list=`grep -l $1 $2*.h` + list=`grep -sl $1 $2*.h` if (test -e style_$3.tmp) then rm -f style_$3.tmp fi @@ -19,8 +19,15 @@ style () { echo "#include $qfile" >> style_$3.tmp done if (test ! -e style_$3.tmp) then - rm -f style_$3.h - touch style_$3.h + if (test "`cat style_$3.h`" != "") then + rm -f style_$3.h + touch style_$3.h + rm -f Obj_*/$4.d + if (test $5) then + rm -f Obj_*/$5.d + fi + rm -f Obj_*/lammps.d + fi elif (test ! -e style_$3.h) then mv style_$3.tmp style_$3.h rm -f Obj_*/$4.d @@ -50,7 +57,8 @@ style () { if (test $1 = "style") then style ANGLE_CLASS angle_ angle force - style ATOM_CLASS atom_vec_ atom atom + style ATOM_CLASS atom_vec_ atom atom atom_vec_hybrid + style BODY_CLASS body_ body atom_vec_body style BOND_CLASS bond_ bond force style COMMAND_CLASS "" command input style COMPUTE_CLASS compute_ compute modify diff --git a/src/Makefile b/src/Makefile index 35a3e4814f54fc99398cb6d4ff34c205b0635de9..d994ba4089b45e0da2c88badd969efcb085fc10a 100755 --- a/src/Makefile +++ b/src/Makefile @@ -13,7 +13,7 @@ OBJ = $(SRC:.cpp=.o) # Package variables -PACKAGE = asphere class2 colloid dipole fld gpu granular kim \ +PACKAGE = asphere body class2 colloid dipole fld gpu granular kim \ kspace manybody mc meam molecule opt peri poems reax replica \ rigid shock srd voronoi xtc diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 8bccaf5dee8e98b9bbeda1b9cb298b0bfadd307c..21a1717d8431079aadaa46602a5941b40ba73a4e 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -32,8 +32,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecPeri::AtomVecPeri(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; diff --git a/src/PERI/atom_vec_peri.h b/src/PERI/atom_vec_peri.h index 185eca375c46a936e2c585f8192be881e00b0b12..9633540b95c871f636c79a4e721fb78a46c0ca66 100755 --- a/src/PERI/atom_vec_peri.h +++ b/src/PERI/atom_vec_peri.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecPeri : public AtomVec { public: - AtomVecPeri(class LAMMPS *, int, char **); + AtomVecPeri(class LAMMPS *); void grow(int); void grow_reset(); void copy(int, int, int); diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index a8572f4a0498c22d2903ae77cf5ab31ef112f280..627cbe80c654b6604fcbd9731fd77b3487fbbd1e 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -2139,9 +2139,9 @@ void FixRigid::readfile(int which, double *vec, double **array, int *inbody) array[id][0] = atof(values[5]); array[id][1] = atof(values[6]); array[id][2] = atof(values[7]); - array[id][5] = atof(values[8]); - array[id][4] = atof(values[9]); array[id][3] = atof(values[10]); + array[id][4] = atof(values[9]); + array[id][5] = atof(values[8]); } buf = next + 1; diff --git a/src/USER-AWPMD/atom_vec_wavepacket.cpp b/src/USER-AWPMD/atom_vec_wavepacket.cpp index e36741e59d47cd0d695ecd52bcada5d31b32f9e3..92721e0d904fc1b60bccdbcf6b01d8267ad88eab 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.cpp +++ b/src/USER-AWPMD/atom_vec_wavepacket.cpp @@ -34,8 +34,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp) { comm_x_only = comm_f_only = 0; @@ -56,8 +55,6 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp, int narg, char **arg) : atom->ervel_flag = atom->erforce_flag = 1; atom->cs_flag = atom->csforce_flag = atom->vforce_flag = atom->ervelforce_flag = atom->etag_flag = 1; - - } /* ---------------------------------------------------------------------- diff --git a/src/USER-AWPMD/atom_vec_wavepacket.h b/src/USER-AWPMD/atom_vec_wavepacket.h index dd8b61c6fc2a28bd36af41c10dbeb45f04090753..41f9559137faf35e8107b460299ad50ac411875e 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.h +++ b/src/USER-AWPMD/atom_vec_wavepacket.h @@ -31,7 +31,7 @@ namespace LAMMPS_NS { class AtomVecWavepacket : public AtomVec { public: - AtomVecWavepacket(class LAMMPS *, int, char **); + AtomVecWavepacket(class LAMMPS *); ~AtomVecWavepacket() {} void grow(int); void grow_reset(); diff --git a/src/USER-CUDA/atom_vec_angle_cuda.cpp b/src/USER-CUDA/atom_vec_angle_cuda.cpp index f7795a3148ce1263615873d3bb801213438f8c6f..9fff3c9b6d321e4dc91f3049128abddd86e3d643 100644 --- a/src/USER-CUDA/atom_vec_angle_cuda.cpp +++ b/src/USER-CUDA/atom_vec_angle_cuda.cpp @@ -60,8 +60,7 @@ using namespace LAMMPS_NS; #define BUF_FLOAT double /* ---------------------------------------------------------------------- */ -AtomVecAngleCuda::AtomVecAngleCuda(LAMMPS *lmp, int narg, char **arg) : - AtomVecAngle(lmp, narg, arg) +AtomVecAngleCuda::AtomVecAngleCuda(LAMMPS *lmp) : AtomVecAngle(lmp) { cuda = lmp->cuda; if(cuda == NULL) diff --git a/src/USER-CUDA/atom_vec_angle_cuda.h b/src/USER-CUDA/atom_vec_angle_cuda.h index 1c2956e8377c70e8ef3a4ecdeab258dc348ae886..f89b4b4bf091f35b917a943af50368ee7ec4ac58 100644 --- a/src/USER-CUDA/atom_vec_angle_cuda.h +++ b/src/USER-CUDA/atom_vec_angle_cuda.h @@ -37,7 +37,7 @@ namespace LAMMPS_NS { class AtomVecAngleCuda : public AtomVecAngle { public: - AtomVecAngleCuda(class LAMMPS *, int, char **); + AtomVecAngleCuda(class LAMMPS *); virtual ~AtomVecAngleCuda() {} void grow_copylist(int n); void grow_send(int n,double** buf_send,int flag); diff --git a/src/USER-CUDA/atom_vec_atomic_cuda.cpp b/src/USER-CUDA/atom_vec_atomic_cuda.cpp index 51ce230b8ce5e61b5f2fc458975389951a7a16b2..a6840355d775047a1a7df50069c56209387b9612 100644 --- a/src/USER-CUDA/atom_vec_atomic_cuda.cpp +++ b/src/USER-CUDA/atom_vec_atomic_cuda.cpp @@ -60,8 +60,7 @@ using namespace LAMMPS_NS; #define BUF_FLOAT double /* ---------------------------------------------------------------------- */ -AtomVecAtomicCuda::AtomVecAtomicCuda(LAMMPS *lmp, int narg, char **arg) : - AtomVecAtomic(lmp, narg, arg) +AtomVecAtomicCuda::AtomVecAtomicCuda(LAMMPS *lmp) : AtomVecAtomic(lmp) { cuda = lmp->cuda; if(cuda == NULL) diff --git a/src/USER-CUDA/atom_vec_atomic_cuda.h b/src/USER-CUDA/atom_vec_atomic_cuda.h index 17b803d8ad383497ffcef1c2cc9b93a29614f469..1260971c431e9934925741259362454108d152bc 100644 --- a/src/USER-CUDA/atom_vec_atomic_cuda.h +++ b/src/USER-CUDA/atom_vec_atomic_cuda.h @@ -49,7 +49,7 @@ namespace LAMMPS_NS { class AtomVecAtomicCuda : public AtomVecAtomic { public: - AtomVecAtomicCuda(class LAMMPS *, int, char **); + AtomVecAtomicCuda(class LAMMPS *); virtual ~AtomVecAtomicCuda() {} void grow_copylist(int n); void grow_send(int n,double** buf_send,int flag); diff --git a/src/USER-CUDA/atom_vec_charge_cuda.cpp b/src/USER-CUDA/atom_vec_charge_cuda.cpp index 991038debb43e4d80a5cdbcb562c07dae62d6315..9e8a5ac373c934f8e25d10735c7eaa605ddfc835 100644 --- a/src/USER-CUDA/atom_vec_charge_cuda.cpp +++ b/src/USER-CUDA/atom_vec_charge_cuda.cpp @@ -59,8 +59,7 @@ using namespace LAMMPS_NS; #define BUF_FLOAT double /* ---------------------------------------------------------------------- */ -AtomVecChargeCuda::AtomVecChargeCuda(LAMMPS *lmp, int narg, char **arg) : - AtomVecCharge(lmp, narg, arg) +AtomVecChargeCuda::AtomVecChargeCuda(LAMMPS *lmp) : AtomVecCharge(lmp) { cuda = lmp->cuda; if(cuda == NULL) diff --git a/src/USER-CUDA/atom_vec_charge_cuda.h b/src/USER-CUDA/atom_vec_charge_cuda.h index ba7b57e75f0d2d40a967cde7d277597525f2856e..b1bbabb0d1c4977a4402991430d351fe21949401 100644 --- a/src/USER-CUDA/atom_vec_charge_cuda.h +++ b/src/USER-CUDA/atom_vec_charge_cuda.h @@ -37,7 +37,7 @@ namespace LAMMPS_NS { class AtomVecChargeCuda : public AtomVecCharge { public: - AtomVecChargeCuda(class LAMMPS *, int, char **); + AtomVecChargeCuda(class LAMMPS *); virtual ~AtomVecChargeCuda() {} void grow_copylist(int n); void grow_send(int n,double** buf_send,int flag); diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index c8eb874087998080a9c414676afc7be2d4e019cb..f95ed825c64c711035768cc82e361125279d9c82 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -33,8 +33,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecElectron::AtomVecElectron(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) { comm_x_only = comm_f_only = 0; diff --git a/src/USER-EFF/atom_vec_electron.h b/src/USER-EFF/atom_vec_electron.h index 73dd126a628df8e3ff0e27e092b7ab6d7f4b0232..c0cc5d5e4a3b811f9bbb8072ace085d8f7b2dc03 100644 --- a/src/USER-EFF/atom_vec_electron.h +++ b/src/USER-EFF/atom_vec_electron.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecElectron : public AtomVec { public: - AtomVecElectron(class LAMMPS *, int, char **); + AtomVecElectron(class LAMMPS *); ~AtomVecElectron() {} void grow(int); void grow_reset(); diff --git a/src/USER-SPH/atom_vec_meso.cpp b/src/USER-SPH/atom_vec_meso.cpp index 73cf49619f3440886c60f3f0b30bda55b6ec7afe..57c71e353f71506f6c410d6afd0fc51616a0fdd9 100644 --- a/src/USER-SPH/atom_vec_meso.cpp +++ b/src/USER-SPH/atom_vec_meso.cpp @@ -27,8 +27,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecMeso::AtomVecMeso(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) { +AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) +{ molecular = 0; mass_type = 1; diff --git a/src/USER-SPH/atom_vec_meso.h b/src/USER-SPH/atom_vec_meso.h index 97ea42ac5caffebcaf7a6d9edb81040ffeb95f18..f017008d465beb64de2e66dda8e08c1a54bc1699 100644 --- a/src/USER-SPH/atom_vec_meso.h +++ b/src/USER-SPH/atom_vec_meso.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecMeso : public AtomVec { public: - AtomVecMeso(class LAMMPS *, int, char **); + AtomVecMeso(class LAMMPS *); ~AtomVecMeso() {} void grow(int); void grow_reset(); diff --git a/src/atom.cpp b/src/atom.cpp index 3ee0d194fc04c66381ea0cbeef69b9384daf0fbb..993a239186a03ce0e2dcf7492ec0f5d55463d2d8 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -42,6 +42,7 @@ using namespace LAMMPS_NS; #define DELTA_MEMSTR 1024 #define EPSILON 1.0e-6 #define CUDA_CHUNK 3000 +#define MAXBODY 20 // max # of lines in one body, also in ReadData class /* ---------------------------------------------------------------------- */ @@ -190,6 +191,7 @@ Atom::~Atom() memory->destroy(ellipsoid); memory->destroy(line); memory->destroy(tri); + memory->destroy(body); memory->destroy(spin); memory->destroy(eradius); memory->destroy(ervel); @@ -271,7 +273,8 @@ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix) vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; int sflag; - avec = new_avec(style,narg,arg,suffix,sflag); + avec = new_avec(style,suffix,sflag); + avec->settings(narg,arg); if (sflag) { char estyle[256]; @@ -295,8 +298,7 @@ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix) generate an AtomVec class, first with suffix appended ------------------------------------------------------------------------- */ -AtomVec *Atom::new_avec(const char *style, int narg, char **arg, - char *suffix, int &sflag) +AtomVec *Atom::new_avec(const char *style, char *suffix, int &sflag) { if (suffix && lmp->suffix_enable) { sflag = 1; @@ -307,7 +309,7 @@ AtomVec *Atom::new_avec(const char *style, int narg, char **arg, #define ATOM_CLASS #define AtomStyle(key,Class) \ - else if (strcmp(estyle,#key) == 0) return new Class(lmp,narg,arg); + else if (strcmp(estyle,#key) == 0) return new Class(lmp); #include "style_atom.h" #undef AtomStyle #undef ATOM_CLASS @@ -320,7 +322,7 @@ AtomVec *Atom::new_avec(const char *style, int narg, char **arg, #define ATOM_CLASS #define AtomStyle(key,Class) \ - else if (strcmp(style,#key) == 0) return new Class(lmp,narg,arg); + else if (strcmp(style,#key) == 0) return new Class(lmp); #include "style_atom.h" #undef ATOM_CLASS @@ -718,6 +720,45 @@ void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus) delete [] values; } +/* ---------------------------------------------------------------------- + unpack n lines from atom-style specific section of data file + check that atom IDs are > 0 and <= map_tag_max + call style-specific routine to parse line +------------------------------------------------------------------------- */ + +void Atom::data_bodies(int n, char *buf, AtomVecBody *avec_body) +{ + int j,m,tagdata,ninteger,ndouble; + + char **ivalues = new char*[10*MAXBODY]; + char **dvalues = new char*[10*MAXBODY]; + + // loop over lines of body data + // tokenize the lines into ivalues and dvalues + // if I own atom tag, unpack its values + + for (int i = 0; i < n; i++) { + if (i == 0) tagdata = atoi(strtok(buf," \t\n\r\f")); + else tagdata = atoi(strtok(NULL," \t\n\r\f")); + ninteger = atoi(strtok(NULL," \t\n\r\f")); + ndouble = atoi(strtok(NULL," \t\n\r\f")); + + for (j = 0; j < ninteger; j++) + ivalues[j] = strtok(NULL," \t\n\r\f"); + for (j = 0; j < ndouble; j++) + dvalues[j] = strtok(NULL," \t\n\r\f"); + + if (tagdata <= 0 || tagdata > map_tag_max) + error->one(FLERR,"Invalid atom ID in Bodies section of data file"); + + if ((m = map(tagdata)) >= 0) + avec_body->data_body(m,ninteger,ndouble,ivalues,dvalues); + } + + delete [] ivalues; + delete [] dvalues; +} + /* ---------------------------------------------------------------------- check that atom IDs are > 0 and <= map_tag_max ------------------------------------------------------------------------- */ diff --git a/src/atom.h b/src/atom.h index a87b66fed5eaadbada16ef8162526947fc616ec2..03c9a4c47bbbd246c052ecd63574b000c9ebc1c7 100644 --- a/src/atom.h +++ b/src/atom.h @@ -53,7 +53,7 @@ class Atom : protected Pointers { double **omega,**angmom,**torque; double *radius,*rmass,*vfrac,*s0; double **x0; - int *ellipsoid,*line,*tri; + int *ellipsoid,*line,*tri,*body; int *spin; double *eradius,*ervel,*erforce,*ervelforce; double *cs,*csforce,*vforce; @@ -89,7 +89,8 @@ class Atom : protected Pointers { // atom style and per-atom array existence flags // customize by adding new flag - int sphere_flag,ellipsoid_flag,line_flag,tri_flag,peri_flag,electron_flag; + int sphere_flag,ellipsoid_flag,line_flag,tri_flag,body_flag; + int peri_flag,electron_flag; int ecp_flag; int wavepacket_flag,sph_flag; @@ -135,7 +136,7 @@ class Atom : protected Pointers { void settings(class Atom *); void create_avec(const char *, int, char **, char *suffix = NULL); - class AtomVec *new_avec(const char *, int, char **, char *, int &); + class AtomVec *new_avec(const char *, char *, int &); void init(); void setup(); @@ -150,6 +151,7 @@ class Atom : protected Pointers { void data_atoms(int, char *); void data_vels(int, char *); void data_bonus(int, char *, class AtomVec *); + void data_bodies(int, char *, class AtomVecBody *); void data_bonds(int, char *); void data_angles(int, char *); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index e33fb007bc43917751aa4f59651b821acaf22afb..7b0e4984031f0d67c5594ea8215555f09ea4179c 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -21,7 +21,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVec::AtomVec(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) +AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) { nmax = 0; bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 0; @@ -30,6 +30,15 @@ AtomVec::AtomVec(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) cudable = false; } +/* ---------------------------------------------------------------------- + no additional args by default +------------------------------------------------------------------------- */ + +void AtomVec::settings(int narg, char **arg) +{ + if (narg) error->all(FLERR,"Invalid atom_style command"); +} + /* ---------------------------------------------------------------------- copy of velocity remap settings from Domain ------------------------------------------------------------------------- */ diff --git a/src/atom_vec.h b/src/atom_vec.h index 75627a42ef5bde16a5417726c3bdd7ec0a50a3f6..58e215120a8bca9671264024e667d28b35cb3c2c 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -14,6 +14,7 @@ #ifndef LMP_ATOM_VEC_H #define LMP_ATOM_VEC_H +#include "stdio.h" #include "pointers.h" namespace LAMMPS_NS { @@ -41,8 +42,9 @@ class AtomVec : protected Pointers { int cudable; // 1 if atom style is CUDA-enabled int *maxsend; // CUDA-specific variable - AtomVec(class LAMMPS *, int, char **); + AtomVec(class LAMMPS *); virtual ~AtomVec() {} + virtual void settings(int, char **); virtual void init(); virtual void grow(int) = 0; @@ -76,6 +78,9 @@ class AtomVec : protected Pointers { virtual int pack_restart(int, double *) = 0; virtual int unpack_restart(double *) = 0; + virtual void write_restart_settings(FILE *) {} + virtual void read_restart_settings(FILE *) {} + virtual void create_atom(int, double *) = 0; virtual void data_atom(double *, tagint, char **) = 0; virtual void data_atom_bonus(int, char **) {} diff --git a/src/atom_vec_atomic.cpp b/src/atom_vec_atomic.cpp index b57b443cc01afe5fa033ac85b627e345cd4526d4..d3097b85568c9ad443f220cd08517bb6cbab3540 100644 --- a/src/atom_vec_atomic.cpp +++ b/src/atom_vec_atomic.cpp @@ -27,8 +27,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; mass_type = 1; diff --git a/src/atom_vec_atomic.h b/src/atom_vec_atomic.h index 97e6c66887b2d3bc24dbbc2367de7e1c30fa4cce..5166bf3d7408b1e7136df5af488272a5034af198 100644 --- a/src/atom_vec_atomic.h +++ b/src/atom_vec_atomic.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecAtomic : public AtomVec { public: - AtomVecAtomic(class LAMMPS *, int, char **); + AtomVecAtomic(class LAMMPS *); virtual ~AtomVecAtomic() {} void grow(int); void grow_reset(); diff --git a/src/atom_vec_charge.cpp b/src/atom_vec_charge.cpp index 247912d6ac22ee6eba702ed34f016c431e2416a0..66efec1952b4c903420c2c2fc88bee74ccf6920a 100644 --- a/src/atom_vec_charge.cpp +++ b/src/atom_vec_charge.cpp @@ -27,8 +27,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecCharge::AtomVecCharge(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; mass_type = 1; diff --git a/src/atom_vec_charge.h b/src/atom_vec_charge.h index 41ee4e214c9871bafb722ce58f5bd449e9f4245b..69f68cc3396d548758570d793a545b88d3d5077d 100644 --- a/src/atom_vec_charge.h +++ b/src/atom_vec_charge.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecCharge : public AtomVec { public: - AtomVecCharge(class LAMMPS *, int, char **); + AtomVecCharge(class LAMMPS *); virtual ~AtomVecCharge() {} void grow(int); void grow_reset(); diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index 0e88e3472a013e6e18800e457dc7655048b690ec..c30cbaa0b9d114d42b09b2d251b276cffdb66310 100755 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -36,8 +36,7 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; @@ -107,6 +106,7 @@ void AtomVecEllipsoid::grow_reset() mask = atom->mask; image = atom->image; x = atom->x; v = atom->v; f = atom->f; rmass = atom->rmass; angmom = atom->angmom; torque = atom->torque; + ellipsoid = atom->ellipsoid; } /* ---------------------------------------------------------------------- @@ -145,16 +145,16 @@ void AtomVecEllipsoid::copy(int i, int j, int delflag) angmom[j][1] = angmom[i][1]; angmom[j][2] = angmom[i][2]; - // if delflag and atom J has bonus data, then delete it + // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && ellipsoid[j] >= 0) { copy_bonus(nlocal_bonus-1,ellipsoid[j]); nlocal_bonus--; } - // if atom I has bonus data and not deleting I, repoint I's bonus to J + // if atom I has bonus data, reset I's bonus.ilocal to loc J - if (ellipsoid[i] >= 0 && i != j) bonus[ellipsoid[i]].ilocal = j; + if (ellipsoid[i] >= 0) bonus[ellipsoid[i]].ilocal = j; ellipsoid[j] = ellipsoid[i]; if (atom->nextra_grow) diff --git a/src/atom_vec_ellipsoid.h b/src/atom_vec_ellipsoid.h index ef13f6dbd7f970a2ee577ff87b8ba38f8b12f066..379fd36e6e0ac3b9aff2607462acf67fd0d59859 100755 --- a/src/atom_vec_ellipsoid.h +++ b/src/atom_vec_ellipsoid.h @@ -33,7 +33,7 @@ class AtomVecEllipsoid : public AtomVec { }; struct Bonus *bonus; - AtomVecEllipsoid(class LAMMPS *, int, char **); + AtomVecEllipsoid(class LAMMPS *); ~AtomVecEllipsoid(); void grow(int); void grow_reset(); diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 05351cf7650af86b2f2f048b3eeb10b4596a6895..0bda19c251d1309b6b5f79b663ec9bc845d44e8a 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -27,30 +27,62 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) {} + +/* ---------------------------------------------------------------------- */ + +AtomVecHybrid::~AtomVecHybrid() { - int i,k,dummy; + for (int k = 0; k < nstyles; k++) delete styles[k]; + delete [] styles; + for (int k = 0; k < nstyles; k++) delete [] keywords[k]; + delete [] keywords; +} - if (narg < 1) error->all(FLERR,"Illegal atom_style command"); +/* ---------------------------------------------------------------------- + process sub-style args +------------------------------------------------------------------------- */ - // create sub-styles +void AtomVecHybrid::settings(int narg, char **arg) +{ + // build list of all known atom styles - nstyles = narg; - styles = new AtomVec*[nstyles]; - keywords = new char*[nstyles]; + build_styles(); - for (i = 0; i < narg; i++) { - for (k = 0; k < i; k++) - if (strcmp(arg[i],keywords[k]) == 0) - error->all(FLERR,"Atom style hybrid cannot use same atom style twice"); - if (strcmp(arg[i],"hybrid") == 0) + // allocate list of sub-styles as big as possibly needed if no extra args + + styles = new AtomVec*[narg]; + keywords = new char*[narg]; + + // allocate each sub-style + // call settings() with set of args that are not atom style names + // use known_style() to determine which args these are + + int i,jarg,dummy; + + int iarg = 0; + nstyles = 0; + while (iarg < narg) { + if (strcmp(arg[iarg],"hybrid") == 0) error->all(FLERR,"Atom style hybrid cannot have hybrid as an argument"); - styles[i] = atom->new_avec(arg[i],0,NULL,NULL,dummy); - keywords[i] = new char[strlen(arg[i])+1]; - strcpy(keywords[i],arg[i]); + for (i = 0; i < nstyles; i++) + if (strcmp(arg[iarg],keywords[i]) == 0) + error->all(FLERR,"Atom style hybrid cannot use same atom style twice"); + styles[nstyles] = atom->new_avec(arg[iarg],NULL,dummy); + keywords[nstyles] = new char[strlen(arg[iarg])+1]; + strcpy(keywords[nstyles],arg[iarg]); + jarg = iarg + 1; + while (jarg < narg && !known_style(arg[jarg])) jarg++; + styles[nstyles]->settings(jarg-iarg-1,&arg[iarg+1]); + iarg = jarg; + nstyles++; } + // free allstyles created by build_styles() + + for (int i = 0; i < nallstyles; i++) delete [] allstyles[i]; + delete [] allstyles; + // hybrid settings are MAX or MIN of sub-style settings // hybrid sizes are minimial values plus extra values for each sub-style @@ -64,7 +96,7 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp, int narg, char **arg) : size_data_vel = 4; xcol_data = 3; - for (k = 0; k < nstyles; k++) { + for (int k = 0; k < nstyles; k++) { molecular = MAX(molecular,styles[k]->molecular); bonds_allow = MAX(bonds_allow,styles[k]->bonds_allow); angles_allow = MAX(angles_allow,styles[k]->angles_allow); @@ -89,16 +121,6 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -AtomVecHybrid::~AtomVecHybrid() -{ - for (int k = 0; k < nstyles; k++) delete styles[k]; - delete [] styles; - for (int k = 0; k < nstyles; k++) delete [] keywords[k]; - delete [] keywords; -} - -/* ---------------------------------------------------------------------- */ - void AtomVecHybrid::init() { AtomVec::init(); @@ -780,6 +802,22 @@ int AtomVecHybrid::unpack_restart(double *buf) return m; } +/* ---------------------------------------------------------------------- */ + +void AtomVecHybrid::write_restart_settings(FILE *fp) +{ + for (int k = 0; k < nstyles; k++) + styles[k]->write_restart_settings(fp); +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecHybrid::read_restart_settings(FILE *fp) +{ + for (int k = 0; k < nstyles; k++) + styles[k]->read_restart_settings(fp); +} + /* ---------------------------------------------------------------------- create one atom of itype at coord create each sub-style one after the other @@ -863,6 +901,45 @@ void AtomVecHybrid::data_vel(int m, char **values) n += styles[k]->data_vel_hybrid(m,&values[n]); } +/* ---------------------------------------------------------------------- + allstyles = list of all atom styles in this LAMMPS executable +------------------------------------------------------------------------- */ + +void AtomVecHybrid::build_styles() +{ + nallstyles = 0; +#define ATOM_CLASS +#define AtomStyle(key,Class) nallstyles++; +#include "style_atom.h" +#undef AtomStyle +#undef ATOM_CLASS + + allstyles = new char*[nallstyles]; + + int n; + nallstyles = 0; +#define ATOM_CLASS +#define AtomStyle(key,Class) \ + n = strlen(#key) + 1; \ + allstyles[nallstyles] = new char[n]; \ + strcpy(allstyles[nallstyles],#key); \ + nallstyles++; +#include "style_atom.h" +#undef AtomStyle +#undef ATOM_CLASS +} + +/* ---------------------------------------------------------------------- + allstyles = list of all known atom styles +------------------------------------------------------------------------- */ + +int AtomVecHybrid::known_style(char *str) +{ + for (int i = 0; i < nallstyles; i++) + if (strcmp(str,allstyles[i]) == 0) return 1; + return 0; +} + /* ---------------------------------------------------------------------- return # of bytes of allocated memory ------------------------------------------------------------------------- */ diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index da9956d6957e207ba0690e987d45cfed7ebfa054..df3d410efc8034484d302bcfc358195292c63846 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -20,6 +20,7 @@ AtomStyle(hybrid,AtomVecHybrid) #ifndef LMP_ATOM_VEC_HYBRID_H #define LMP_ATOM_VEC_HYBRID_H +#include "stdio.h" #include "atom_vec.h" namespace LAMMPS_NS { @@ -30,8 +31,9 @@ class AtomVecHybrid : public AtomVec { class AtomVec **styles; char **keywords; - AtomVecHybrid(class LAMMPS *, int, char **); + AtomVecHybrid(class LAMMPS *); ~AtomVecHybrid(); + void settings(int, char **); void init(); void grow(int); void grow_reset(); @@ -52,6 +54,8 @@ class AtomVecHybrid : public AtomVec { int size_restart(); int pack_restart(int, double *); int unpack_restart(double *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); void create_atom(int, double *); void data_atom(double *, tagint, char **); int data_atom_hybrid(int, char **) {return 0;} @@ -63,6 +67,12 @@ class AtomVecHybrid : public AtomVec { tagint *image; double **x,**v,**f; double **omega,**angmom; + + int nallstyles; + char **allstyles; + + void build_styles(); + int known_style(char *); }; } diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index 9da8c139dc2ede564b0eb5b24c72c63e2c0bcbdb..000f38b4af77b265a3d146fef9818ff5a81f5c21 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -32,8 +32,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecLine::AtomVecLine(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; @@ -116,6 +115,7 @@ void AtomVecLine::grow_reset() x = atom->x; v = atom->v; f = atom->f; molecule = atom->molecule; rmass = atom->rmass; omega = atom->omega; torque = atom->torque; + line = atom->line; } /* ---------------------------------------------------------------------- @@ -155,16 +155,16 @@ void AtomVecLine::copy(int i, int j, int delflag) omega[j][1] = omega[i][1]; omega[j][2] = omega[i][2]; - // if delflag and atom J has bonus data, then delete it + // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && line[j] >= 0) { copy_bonus(nlocal_bonus-1,line[j]); nlocal_bonus--; } - // if atom I has bonus data and not deleting I, repoint I's bonus to J + // if atom I has bonus data, reset I's bonus.ilocal to loc J - if (line[i] >= 0 && i != j) bonus[line[i]].ilocal = j; + if (line[i] >= 0) bonus[line[i]].ilocal = j; line[j] = line[i]; if (atom->nextra_grow) diff --git a/src/atom_vec_line.h b/src/atom_vec_line.h index b94a63ad3f10c5a2afc5db38d180df7d2c8d5612..72e871f5422292ccc1d5c7f4f149bf66c3456fd6 100644 --- a/src/atom_vec_line.h +++ b/src/atom_vec_line.h @@ -32,7 +32,7 @@ class AtomVecLine : public AtomVec { }; struct Bonus *bonus; - AtomVecLine(class LAMMPS *, int, char **); + AtomVecLine(class LAMMPS *); ~AtomVecLine(); void init(); void grow(int); diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index c8f00743bb653a7e04fb358a07bd3bd491b84a6d..7cc92d5202e18f8e9ab6e4aa1a93d09e6c932056 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -33,8 +33,7 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -AtomVecSphere::AtomVecSphere(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; diff --git a/src/atom_vec_sphere.h b/src/atom_vec_sphere.h index 02ba050b43452dc4f53bd78ccc3114da438e2a46..1501ce791f9c267b373f7015721a2b0e38cb8631 100644 --- a/src/atom_vec_sphere.h +++ b/src/atom_vec_sphere.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class AtomVecSphere : public AtomVec { public: - AtomVecSphere(class LAMMPS *, int, char **); + AtomVecSphere(class LAMMPS *); ~AtomVecSphere() {} void init(); void grow(int); diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index 0aab80bba9a7edc370a1777d9144f94e69b4cbb3..fc405d2fd5b60680d72e454aaff22bdc7b5f75aa 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -33,8 +33,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -AtomVecTri::AtomVecTri(LAMMPS *lmp, int narg, char **arg) : - AtomVec(lmp, narg, arg) +AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp) { molecular = 0; @@ -117,6 +116,7 @@ void AtomVecTri::grow_reset() x = atom->x; v = atom->v; f = atom->f; molecule = atom->molecule; rmass = atom->rmass; angmom = atom->angmom; torque = atom->torque; + tri = atom->tri; } /* ---------------------------------------------------------------------- @@ -157,16 +157,16 @@ void AtomVecTri::copy(int i, int j, int delflag) angmom[j][1] = angmom[i][1]; angmom[j][2] = angmom[i][2]; - // if delflag and atom J has bonus data, then delete it + // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && tri[j] >= 0) { copy_bonus(nlocal_bonus-1,tri[j]); nlocal_bonus--; } - // if atom I has bonus data and not deleting I, repoint I's bonus to J + // if atom I has bonus data, reset I's bonus.ilocal to loc J - if (tri[i] >= 0 && i != j) bonus[tri[i]].ilocal = j; + if (tri[i] >= 0) bonus[tri[i]].ilocal = j; tri[j] = tri[i]; if (atom->nextra_grow) @@ -1320,7 +1320,7 @@ void AtomVecTri::create_atom(int itype, double *coord) } /* ---------------------------------------------------------------------- - unpack one tri from Atoms section of data file + unpack one line from Atoms section of data file initialize other atom quantities ------------------------------------------------------------------------- */ @@ -1387,7 +1387,7 @@ int AtomVecTri::data_atom_hybrid(int nlocal, char **values) } /* ---------------------------------------------------------------------- - unpack one tri from Tris section of data file + unpack one line from Tris section of data file ------------------------------------------------------------------------- */ void AtomVecTri::data_atom_bonus(int m, char **values) @@ -1511,7 +1511,7 @@ void AtomVecTri::data_atom_bonus(int m, char **values) } /* ---------------------------------------------------------------------- - unpack one tri from Velocities section of data file + unpack one line from Velocities section of data file ------------------------------------------------------------------------- */ void AtomVecTri::data_vel(int m, char **values) @@ -1555,7 +1555,8 @@ bigint AtomVecTri::memory_usage() if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax); if (atom->memcheck("angmom")) bytes += memory->usage(angmom,nmax,3); - if (atom->memcheck("torque")) bytes += memory->usage(torque,nmax*comm->nthreads,3); + if (atom->memcheck("torque")) bytes += + memory->usage(torque,nmax*comm->nthreads,3); if (atom->memcheck("tri")) bytes += memory->usage(tri,nmax); bytes += nmax_bonus*sizeof(Bonus); diff --git a/src/atom_vec_tri.h b/src/atom_vec_tri.h index 245c32dde1db777ea95c1ea54de2b71b1f8bf89b..bdc5a8bca557a039160a19b6cefee8054f21529d 100644 --- a/src/atom_vec_tri.h +++ b/src/atom_vec_tri.h @@ -34,7 +34,7 @@ class AtomVecTri : public AtomVec { }; struct Bonus *bonus; - AtomVecTri(class LAMMPS *, int, char **); + AtomVecTri(class LAMMPS *); ~AtomVecTri(); void init(); void grow(int); diff --git a/src/comm.cpp b/src/comm.cpp index 45eefcec2b82bd35d4bc48e2cb578277dad5417d..46d937edbaf923c79cab4a4b6ea5586cbd080ff3 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -798,10 +798,13 @@ void Comm::exchange() // clear global->local map for owned and ghost atoms // b/c atoms migrate to new procs in exchange() and - // new ghosts are created in borders() + // new ghosts are created in borders() // map_set() is done at end of borders() + // clear ghost count and any ghost bonus data internal to AtomVec if (map_style) atom->map_clear(); + atom->nghost = 0; + atom->avec->clear_bonus(); // subbox bounds for orthogonal or triclinic @@ -836,6 +839,7 @@ void Comm::exchange() } atom->nlocal = nlocal; + // send/recv atoms in both directions // if 1 proc in dimension, no send/recv, set recv buf to send buf // if 2 procs in dimension, single send/recv @@ -907,11 +911,6 @@ void Comm::borders() MPI_Status status; AtomVec *avec = atom->avec; - // clear old ghosts and any ghost bonus data internal to AtomVec - - atom->nghost = 0; - atom->avec->clear_bonus(); - // do swaps over all 3 dimensions iswap = 0; diff --git a/src/compute_property_atom.cpp b/src/compute_property_atom.cpp index d3ae7171f45742f6b1dfb31df0516d7302f07241..382286fec61b9643745aaf78167003c07f3c9e3b 100644 --- a/src/compute_property_atom.cpp +++ b/src/compute_property_atom.cpp @@ -19,6 +19,7 @@ #include "atom_vec_ellipsoid.h" #include "atom_vec_line.h" #include "atom_vec_tri.h" +#include "atom_vec_body.h" #include "update.h" #include "domain.h" #include "memory.h" @@ -191,26 +192,36 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) : if (!avec_ellipsoid) error->all(FLERR,"Compute property/atom for " "atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_shapez; + } else if (strcmp(arg[iarg],"quatw") == 0) { avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - if (!avec_ellipsoid) error->all(FLERR,"Compute property/atom for " - "atom property that isn't allocated"); + avec_body = (AtomVecBody *) atom->style_match("body"); + if (!avec_ellipsoid && !avec_body) + error->all(FLERR,"Compute property/atom for " + "atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_quatw; } else if (strcmp(arg[iarg],"quati") == 0) { avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - if (!avec_ellipsoid) error->all(FLERR,"Compute property/atom for " - "atom property that isn't allocated"); + avec_body = (AtomVecBody *) atom->style_match("body"); + if (!avec_ellipsoid && !avec_body) + error->all(FLERR,"Compute property/atom for " + "atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_quati; } else if (strcmp(arg[iarg],"quatj") == 0) { avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - if (!avec_ellipsoid) error->all(FLERR,"Compute property/atom for " - "atom property that isn't allocated"); + avec_body = (AtomVecBody *) atom->style_match("body"); + if (!avec_ellipsoid && !avec_body) + error->all(FLERR,"Compute property/atom for " + "atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_quatj; } else if (strcmp(arg[iarg],"quatk") == 0) { avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); - if (!avec_ellipsoid) error->all(FLERR,"Compute property/atom for " - "atom property that isn't allocated"); + avec_body = (AtomVecBody *) atom->style_match("body"); + if (!avec_ellipsoid && !avec_body) + error->all(FLERR,"Compute property/atom for " + "atom property that isn't allocated"); pack_choice[i] = &ComputePropertyAtom::pack_quatk; + } else if (strcmp(arg[iarg],"tqx") == 0) { if (!atom->torque_flag) error->all(FLERR,"Compute property/atom for " @@ -349,6 +360,7 @@ void ComputePropertyAtom::init() avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid"); avec_line = (AtomVecLine *) atom->style_match("line"); avec_tri = (AtomVecTri *) atom->style_match("tri"); + avec_body = (AtomVecBody *) atom->style_match("body"); } /* ---------------------------------------------------------------------- */ @@ -1136,16 +1148,31 @@ void ComputePropertyAtom::pack_shapez(int n) void ComputePropertyAtom::pack_quatw(int n) { - AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; - int *ellipsoid = atom->ellipsoid; - int *mask = atom->mask; - int nlocal = atom->nlocal; + if (avec_ellipsoid) { + AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; + int *ellipsoid = atom->ellipsoid; + int *mask = atom->mask; + int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - if ((mask[i] & groupbit) && ellipsoid[i] >= 0) - buf[n] = bonus[ellipsoid[i]].quat[0]; - else buf[n] = 0.0; - n += nvalues; + for (int i = 0; i < nlocal; i++) { + if ((mask[i] & groupbit) && ellipsoid[i] >= 0) + buf[n] = bonus[ellipsoid[i]].quat[0]; + else buf[n] = 0.0; + n += nvalues; + } + + } else { + AtomVecBody::Bonus *bonus = avec_body->bonus; + int *body = atom->body; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if ((mask[i] & groupbit) && body[i] >= 0) + buf[n] = bonus[body[i]].quat[0]; + else buf[n] = 0.0; + n += nvalues; + } } } @@ -1153,16 +1180,31 @@ void ComputePropertyAtom::pack_quatw(int n) void ComputePropertyAtom::pack_quati(int n) { - AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; - int *ellipsoid = atom->ellipsoid; - int *mask = atom->mask; - int nlocal = atom->nlocal; + if (avec_ellipsoid) { + AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; + int *ellipsoid = atom->ellipsoid; + int *mask = atom->mask; + int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - if ((mask[i] & groupbit) && ellipsoid[i] >= 0) - buf[n] = bonus[ellipsoid[i]].quat[1]; - else buf[n] = 0.0; - n += nvalues; + for (int i = 0; i < nlocal; i++) { + if ((mask[i] & groupbit) && ellipsoid[i] >= 0) + buf[n] = bonus[ellipsoid[i]].quat[1]; + else buf[n] = 0.0; + n += nvalues; + } + + } else { + AtomVecBody::Bonus *bonus = avec_body->bonus; + int *body = atom->body; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if ((mask[i] & groupbit) && body[i] >= 0) + buf[n] = bonus[body[i]].quat[1]; + else buf[n] = 0.0; + n += nvalues; + } } } @@ -1170,16 +1212,31 @@ void ComputePropertyAtom::pack_quati(int n) void ComputePropertyAtom::pack_quatj(int n) { - AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; - int *ellipsoid = atom->ellipsoid; - int *mask = atom->mask; - int nlocal = atom->nlocal; + if (avec_ellipsoid) { + AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; + int *ellipsoid = atom->ellipsoid; + int *mask = atom->mask; + int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - if ((mask[i] & groupbit) && ellipsoid[i] >= 0) - buf[n] = bonus[ellipsoid[i]].quat[2]; - else buf[n] = 0.0; - n += nvalues; + for (int i = 0; i < nlocal; i++) { + if ((mask[i] & groupbit) && ellipsoid[i] >= 0) + buf[n] = bonus[ellipsoid[i]].quat[2]; + else buf[n] = 0.0; + n += nvalues; + } + + } else { + AtomVecBody::Bonus *bonus = avec_body->bonus; + int *body = atom->body; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if ((mask[i] & groupbit) && body[i] >= 0) + buf[n] = bonus[body[i]].quat[2]; + else buf[n] = 0.0; + n += nvalues; + } } } @@ -1187,16 +1244,31 @@ void ComputePropertyAtom::pack_quatj(int n) void ComputePropertyAtom::pack_quatk(int n) { - AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; - int *ellipsoid = atom->ellipsoid; - int *mask = atom->mask; - int nlocal = atom->nlocal; + if (avec_ellipsoid) { + AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus; + int *ellipsoid = atom->ellipsoid; + int *mask = atom->mask; + int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - if ((mask[i] & groupbit) && ellipsoid[i] >= 0) - buf[n] = bonus[ellipsoid[i]].quat[3]; - else buf[n] = 0.0; - n += nvalues; + for (int i = 0; i < nlocal; i++) { + if ((mask[i] & groupbit) && ellipsoid[i] >= 0) + buf[n] = bonus[ellipsoid[i]].quat[3]; + else buf[n] = 0.0; + n += nvalues; + } + + } else { + AtomVecBody::Bonus *bonus = avec_body->bonus; + int *body = atom->body; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if ((mask[i] & groupbit) && body[i] >= 0) + buf[n] = bonus[body[i]].quat[3]; + else buf[n] = 0.0; + n += nvalues; + } } } diff --git a/src/compute_property_atom.h b/src/compute_property_atom.h index b709e180775ec08969fadf8ea3db414c4073eded..bc8a4b0528cca8ca7bb5f04086fc01d531721df3 100644 --- a/src/compute_property_atom.h +++ b/src/compute_property_atom.h @@ -41,6 +41,7 @@ class ComputePropertyAtom : public Compute { class AtomVecEllipsoid *avec_ellipsoid; class AtomVecLine *avec_line; class AtomVecTri *avec_tri; + class AtomVecBody *avec_body; typedef void (ComputePropertyAtom::*FnPtrPack)(int); FnPtrPack *pack_choice; // ptrs to pack functions diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 331ee1e4d41b14de05925c9cc6feb01891d43f04..e865a3f70baa43406b59bf82cd7328331217a3fe 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -194,6 +194,17 @@ void DumpLocal::write_header(bigint ndump) fprintf(fp,BIGINT_FORMAT "\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF %s\n",label); fprintf(fp,BIGINT_FORMAT "\n",ndump); + if (domain->triclinic) { + fprintf(fp,"ITEM: BOX BOUNDS xy xz yz %s\n",boundstr); + fprintf(fp,"%g %g %g\n",boxxlo,boxxhi,boxxy); + fprintf(fp,"%g %g %g\n",boxylo,boxyhi,boxxz); + fprintf(fp,"%g %g %g\n",boxzlo,boxzhi,boxyz); + } else { + fprintf(fp,"ITEM: BOX BOUNDS %s\n",boundstr); + fprintf(fp,"%g %g\n",boxxlo,boxxhi); + fprintf(fp,"%g %g\n",boxylo,boxyhi); + fprintf(fp,"%g %g\n",boxzlo,boxzhi); + } fprintf(fp,"ITEM: %s %s\n",label,columns); } } @@ -223,13 +234,15 @@ int DumpLocal::count() for (int i = 0; i < ncompute; i++) { if (nmine < 0) nmine = compute[i]->size_local_rows; else if (nmine != compute[i]->size_local_rows) - error->one(FLERR,"Dump local count is not consistent across input fields"); + error->one(FLERR, + "Dump local count is not consistent across input fields"); } for (int i = 0; i < nfix; i++) { if (nmine < 0) nmine = fix[i]->size_local_rows; else if (nmine != fix[i]->size_local_rows) - error->one(FLERR,"Dump local count is not consistent across input fields"); + error->one(FLERR, + "Dump local count is not consistent across input fields"); } return nmine; diff --git a/src/math_extra.h b/src/math_extra.h index 515e55f5f8b297fde581ea3b3be21d223ea77231..d1691f395b03147f1912b8b24730a7950f89ec75 100755 --- a/src/math_extra.h +++ b/src/math_extra.h @@ -55,7 +55,7 @@ namespace MathExtra { const double mat2[3][3], double ans[3][3]); inline void invert3(const double mat[3][3], double ans[3][3]); - inline void matvec(const double mat[3][3], const double*vec, double *ans); + inline void matvec(const double mat[3][3], const double *vec, double *ans); inline void matvec(const double *ex, const double *ey, const double *ez, const double *vec, double *ans); inline void transpose_matvec(const double mat[3][3], const double*vec, diff --git a/src/read_data.cpp b/src/read_data.cpp index d14d5084ad11f5d7f04443fdc0a971ac1482ee4c..0065472021aabb172a61f1a2b6e4810edc0fbc2a 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -44,9 +44,10 @@ using namespace LAMMPS_NS; #define LB_FACTOR 1.1 #define CHUNK 1024 #define DELTA 4 // must be 2 or larger +#define MAXBODY 20 // max # of lines in one body, also in Atom class // customize for new sections -#define NSECTIONS 23 // change when add to header::section_keywords +#define NSECTIONS 24 // change when add to header::section_keywords /* ---------------------------------------------------------------------- */ @@ -68,6 +69,8 @@ ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp) avec_line = (AtomVecLine *) atom->style_match("line"); ntris = 0; avec_tri = (AtomVecTri *) atom->style_match("tri"); + nbodies = 0; + avec_body = (AtomVecBody *) atom->style_match("body"); } /* ---------------------------------------------------------------------- */ @@ -219,6 +222,11 @@ void ReadData::command(int narg, char **arg) error->all(FLERR,"Invalid data file section: Triangles"); if (atomflag == 0) error->all(FLERR,"Must read Atoms before Triangles"); bonus(ntris,(AtomVec *) avec_tri,"triangles"); + } else if (strcmp(keyword,"Bodies") == 0) { + if (!avec_body) + error->all(FLERR,"Invalid data file section: Bodies"); + if (atomflag == 0) error->all(FLERR,"Must read Atoms before Bodies"); + bodies(); } else if (strcmp(keyword,"Bonds") == 0) { if (atom->avec->bonds_allow == 0) @@ -377,7 +385,7 @@ void ReadData::header(int flag) // customize for new sections const char *section_keywords[NSECTIONS] = - {"Atoms","Velocities","Ellipsoids","Lines","Triangles", + {"Atoms","Velocities","Ellipsoids","Lines","Triangles","Bodies", "Bonds","Angles","Dihedrals","Impropers", "Masses","Pair Coeffs","Bond Coeffs","Angle Coeffs", "Dihedral Coeffs","Improper Coeffs", @@ -452,6 +460,10 @@ void ReadData::header(int flag) if (!avec_tri && me == 0) error->one(FLERR,"No triangles allowed with this atom style"); sscanf(line,BIGINT_FORMAT,&ntris); + } else if (strstr(line,"bodies")) { + if (!avec_body && me == 0) + error->one(FLERR,"No bodies allowed with this atom style"); + sscanf(line,BIGINT_FORMAT,&nbodies); } else if (strstr(line,"bonds")) sscanf(line,BIGINT_FORMAT,&atom->nbonds); @@ -718,6 +730,86 @@ void ReadData::bonus(bigint nbonus, AtomVec *ptr, const char *type) } } +/* ---------------------------------------------------------------------- + read all body data + variable amount of info per body, described by ninteger and ndouble + to find atoms, must build atom map if not a molecular system +------------------------------------------------------------------------- */ + +void ReadData::bodies() +{ + int i,m,nchunk,nmax,ninteger,ndouble,tmp,onebody; + char *eof; + + int mapflag = 0; + if (atom->map_style == 0) { + mapflag = 1; + atom->map_style = 1; + atom->map_init(); + atom->map_set(); + } + + // nmax = max # of bodies to read in this chunk + // nchunk = actual # readr + + bigint nread = 0; + bigint natoms = nbodies; + + while (nread < natoms) { + if (natoms-nread > CHUNK) nmax = CHUNK; + else nmax = natoms-nread; + + if (me == 0) { + nchunk = 0; + nlines = 0; + m = 0; + + while (nchunk < nmax && nlines <= CHUNK-MAXBODY) { + eof = fgets(&buffer[m],MAXLINE,fp); + if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); + sscanf(&buffer[m],"%d %d %d",&tmp,&ninteger,&ndouble); + m += strlen(&buffer[m]); + + onebody = 0; + if (ninteger) onebody += (ninteger-1)/10 + 1; + if (ndouble) onebody += (ndouble-1)/10 + 1; + if (onebody+1 > MAXBODY) + error->one(FLERR, + "Too many lines in one body in data file - boost MAXBODY"); + + for (i = 0; i < onebody; i++) { + eof = fgets(&buffer[m],MAXLINE,fp); + if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); + m += strlen(&buffer[m]); + } + + nchunk++; + nlines += onebody+1; + } + + if (buffer[m-1] != '\n') strcpy(&buffer[m++],"\n"); + m++; + } + + MPI_Bcast(&nchunk,1,MPI_INT,0,world); + MPI_Bcast(&m,1,MPI_INT,0,world); + MPI_Bcast(buffer,m,MPI_CHAR,0,world); + + atom->data_bodies(nchunk,buffer,avec_body); + nread += nchunk; + } + + if (mapflag) { + atom->map_delete(); + atom->map_style = 0; + } + + if (me == 0) { + if (screen) fprintf(screen," " BIGINT_FORMAT " bodies\n",natoms); + if (logfile) fprintf(logfile," " BIGINT_FORMAT " bodies\n",natoms); + } +} + /* ---------------------------------------------------------------------- */ void ReadData::bonds() @@ -1157,6 +1249,7 @@ void ReadData::scan(int &bond_per_atom, int &angle_per_atom, int ellipsoid_flag = 0; int line_flag = 0; int tri_flag = 0; + int body_flag = 0; // customize for new sections // allocate topology counting vector @@ -1203,6 +1296,10 @@ void ReadData::scan(int &bond_per_atom, int &angle_per_atom, if (!avec_tri) error->one(FLERR,"Invalid data file section: Triangles"); tri_flag = 1; skip_lines(ntris); + } else if (strcmp(keyword,"Bodies") == 0) { + if (!avec_body) error->one(FLERR,"Invalid data file section: Bodies"); + body_flag = 1; + skip_lines(nbodies); } else if (strcmp(keyword,"Pair Coeffs") == 0) { if (force->pair == NULL) @@ -1434,6 +1531,8 @@ void ReadData::scan(int &bond_per_atom, int &angle_per_atom, error->one(FLERR,"Needed bonus data not in data file"); if (ntris && !tri_flag) error->one(FLERR,"Needed bonus data not in data file"); + if (nbodies && !body_flag) + error->one(FLERR,"Needed bonus data not in data file"); } /* ---------------------------------------------------------------------- diff --git a/src/read_data.h b/src/read_data.h index df28fa2448905bfb18084a383ac82e53bcb2789b..07bc716d4598e50c2cb5d5b094afeb4965dc445d 100644 --- a/src/read_data.h +++ b/src/read_data.h @@ -49,6 +49,8 @@ class ReadData : protected Pointers { class AtomVecLine *avec_line; bigint ntris; class AtomVecTri *avec_tri; + bigint nbodies; + class AtomVecBody *avec_body; void open(char *); void scan(int &, int &, int &, int &); @@ -61,6 +63,7 @@ class ReadData : protected Pointers { void atoms(); void velocities(); void bonus(bigint, class AtomVec *, const char *); + void bodies(); void bonds(); void angles(); diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 3afd4c42e21de2ba830e120b65e1c4b67af6ca99..072a13c878140ff13af6ace991c9d236af9a991f 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -627,6 +627,8 @@ void ReadRestart::header() } atom->create_avec(style,nwords,words); + atom->avec->read_restart_settings(fp); + for (int i = 0; i < nwords; i++) delete [] words[i]; delete [] words; delete [] style; diff --git a/src/write_restart.cpp b/src/write_restart.cpp index 8305413f8904b17ced92cc9304b8da74167ffe9b..77f2bed05ff8958a67f749b7e59218002db919ac 100644 --- a/src/write_restart.cpp +++ b/src/write_restart.cpp @@ -326,6 +326,7 @@ void WriteRestart::header() // atom_style must be written before atom class values // so read_restart can create class before reading class values // if style = hybrid, also write sub-class styles + // avec->write_restart() writes atom_style specific info write_char(ATOM_STYLE,atom->atom_style); @@ -341,6 +342,8 @@ void WriteRestart::header() } } + if (me == 0) atom->avec->write_restart_settings(fp); + write_bigint(NATOMS,natoms); write_int(NTYPES,atom->ntypes); write_bigint(NBONDS,atom->nbonds);