diff --git a/doc/Manual.html b/doc/Manual.html index cab1d8cad3..3517f0b327 100644 --- a/doc/Manual.html +++ b/doc/Manual.html @@ -22,7 +22,7 @@

LAMMPS-ICMS Documentation

-

27 Jan 2014 version +

29 Jan 2014 version

Version info:

diff --git a/doc/Manual.txt b/doc/Manual.txt index e10124586c..74c2bc2192 100644 --- a/doc/Manual.txt +++ b/doc/Manual.txt @@ -18,7 +18,7 @@

LAMMPS-ICMS Documentation :c,h3 -27 Jan 2014 version :c,h4 +29 Jan 2014 version :c,h4 Version info: :h4 diff --git a/doc/atom_style.html b/doc/atom_style.html index fdadf243d5..d7af8e203f 100644 --- a/doc/atom_style.html +++ b/doc/atom_style.html @@ -15,13 +15,15 @@

atom_style style args 
 
-

The ID of a molecule template can only contain alphanumeric characters and underscores. @@ -49,6 +49,18 @@ contains multiple molecules. The atom_style template command allows multiple-molecule templates to define a system with more than one templated molecule.

+

IMPORTANT NOTE: When using the atom_style template +command with a molecule template that contains multiple molecules, you +should insure the atom types, bond types, angle_types, etc in all the +molecules are consistent. E.g. if one molecule represents H2O and +another CO2, then you probably do not want each molecule file to +define 2 atom types and a single bond type, because they will conflict +with each other when a mixture system of H2O and CO2 molecules is +defined, e.g. by the read_data command. Rather the +H2O molecule should define atom types 1 and 2, and bond type 1. And +the CO2 molecule should define atom types 3 and 4 (or atom types 3 and +2 if a single oxygen type is desired), and bond type 2. +

The format of an individual molecule file is similar to the data file read by the read_data commands, and is as follows.

diff --git a/doc/molecule.txt b/doc/molecule.txt index 2c76cab4fd..b70f165c7f 100644 --- a/doc/molecule.txt +++ b/doc/molecule.txt @@ -34,7 +34,7 @@ templates (or will in the future) include: "fix shake"_fix_shake.html "fix gcmc"_fix_gcmc.html (not yet) "create_atoms"_create_atoms.html -"atom_style template"_atom_style.html (not yet) :ul +"atom_style template"_atom_style.html :ul The ID of a molecule template can only contain alphanumeric characters and underscores. @@ -46,6 +46,18 @@ contains multiple molecules. The "atom_style template"_atom_style.html command allows multiple-molecule templates to define a system with more than one templated molecule. +IMPORTANT NOTE: When using the "atom_style template"_atom_style.html +command with a molecule template that contains multiple molecules, you +should insure the atom types, bond types, angle_types, etc in all the +molecules are consistent. E.g. if one molecule represents H2O and +another CO2, then you probably do not want each molecule file to +define 2 atom types and a single bond type, because they will conflict +with each other when a mixture system of H2O and CO2 molecules is +defined, e.g. by the "read_data"_read_data.html command. Rather the +H2O molecule should define atom types 1 and 2, and bond type 1. And +the CO2 molecule should define atom types 3 and 4 (or atom types 3 and +2 if a single oxygen type is desired), and bond type 2. + The format of an individual molecule file is similar to the data file read by the "read_data"_read_data.html commands, and is as follows. diff --git a/doc/read_data.html b/doc/read_data.html index 7db005e662..290a6797c9 100644 --- a/doc/read_data.html +++ b/doc/read_data.html @@ -208,6 +208,15 @@ are point particles. See the discussion of ellipsoidflag and the Triangles section below. See the discussion of bodyflag and the Bodies section below.

+

IMPORTANT NOTE: For atom_style template, the +molecular topology (bonds,angles,etc) is contained in the molecule +templates read-in by the molecule command. This means +you cannot set the bonds, angles, etc header keywords in the data +file, nor can you define Bonds, Angles, etc sections as discussed +below. You can set the bond types, angle types, etc header +keywords, though it is not necessary. If specified, they must match +the maximum values defined in any of the template molecules. +


These are the section keywords for the body of the file. @@ -343,6 +352,7 @@ of analysis. molecular atom-ID molecule-ID atom-type x y z peri atom-ID atom-type volume density x y z sphere atom-ID atom-type diameter density x y z +template atom-ID molecule-ID template-index template-atom atom-type x y z tri atom-ID molecule-ID atom-type triangleflag density x y z wavepacket atom-ID atom-type charge spin eradius etag cs_re cs_im x y z hybrid atom-ID atom-type x y z sub-style1 sub-style2 ... @@ -359,6 +369,8 @@ of analysis.

  • lineflag = 1 for line segment particles, 0 for point particles
  • triangleflag = 1 for triangular particles, 0 for point particles
  • bodyflag = 1 for body particles, 0 for point particles +
  • template-index = which molecule within the molecule template the atom is part of +
  • template-atom = which atom within a template molecule the atom is
  • density = density of particle (mass/distance^3 or mass/distance^2 or mass/distance units, depending on dimensionality of particle)
  • mass = mass of particle (mass units)
  • volume = volume of particle (distance^3 units) @@ -382,11 +394,11 @@ setting in the data file header. in dump files. Normally, it is a unique value from 1 to Natoms for each atom. Unique values larger than Natoms can be used, but they will cause extra memory to be allocated on each processor, if an atom -map array is used (see the atom_modify command). -If an atom map array is not used (e.g. an atomic system with no -bonds), and velocities are not assigned in the data file, and you -don't care if unique atom IDs appear in dump files, then the atom-IDs -can all be set to 0. +map array is used, but not if an atom map hash is used; see the +atom_modify command for details. If an atom map is +not used (e.g. an atomic system with no bonds), and you don't care if +unique atom IDs appear in dump files, then the atom-IDs can all be set +to 0.

    The molecule ID is a 2nd identifier attached to an atom. Normally, it is a number from 1 to N, identifying which molecule the atom belongs @@ -403,6 +415,16 @@ Additional attributes must be defined for each ellipsoid, line, triangle, or body in the corresponding Ellipsoids, Lines, Triangles, or Bodies section.

    +

    The template-index and template-atom are only defined used by +atom_style template. In this case the +molecule command is used to define a molecule template +which contains one or more molecules. If an atom belongs to one of +those molecules, its template-index and template-atom are both set +to positive integers; if not the values are both 0. The +template-index is which molecule (1 to Nmols) the atom belongs to. +The template-atom is which atom (1 to Natoms) within the molecule +the atom is. +

    Some pair styles and fixes and computes that operate on finite-size particles allow for a mixture of finite-size and point particles. See the doc pages of individual commands for details. diff --git a/doc/read_data.txt b/doc/read_data.txt index 8d8aaef3ac..59bd1e131a 100644 --- a/doc/read_data.txt +++ b/doc/read_data.txt @@ -202,6 +202,15 @@ are point particles. See the discussion of ellipsoidflag and the {Triangles} section below. See the discussion of bodyflag and the {Bodies} section below. +IMPORTANT NOTE: For "atom_style template"_atom_style.html, the +molecular topology (bonds,angles,etc) is contained in the molecule +templates read-in by the "molecule"_molecule.html command. This means +you cannot set the {bonds}, {angles}, etc header keywords in the data +file, nor can you define {Bonds}, {Angles}, etc sections as discussed +below. You can set the {bond types}, {angle types}, etc header +keywords, though it is not necessary. If specified, they must match +the maximum values defined in any of the template molecules. + :line These are the section keywords for the body of the file. @@ -320,6 +329,7 @@ meso: atom-ID atom-type rho e cv x y z molecular: atom-ID molecule-ID atom-type x y z peri: atom-ID atom-type volume density x y z sphere: atom-ID atom-type diameter density x y z +template: atom-ID molecule-ID template-index template-atom atom-type x y z tri: atom-ID molecule-ID atom-type triangleflag density x y z wavepacket: atom-ID atom-type charge spin eradius etag cs_re cs_im x y z hybrid: atom-ID atom-type x y z sub-style1 sub-style2 ... :tb(s=:) @@ -335,6 +345,8 @@ ellipsoidflag = 1 for ellipsoidal particles, 0 for point particles lineflag = 1 for line segment particles, 0 for point particles triangleflag = 1 for triangular particles, 0 for point particles bodyflag = 1 for body particles, 0 for point particles +template-index = which molecule within the molecule template the atom is part of +template-atom = which atom within a template molecule the atom is density = density of particle (mass/distance^3 or mass/distance^2 or mass/distance units, depending on dimensionality of particle) mass = mass of particle (mass units) volume = volume of particle (distance^3 units) @@ -358,11 +370,11 @@ The atom-ID is used to identify the atom throughout the simulation and in dump files. Normally, it is a unique value from 1 to Natoms for each atom. Unique values larger than Natoms can be used, but they will cause extra memory to be allocated on each processor, if an atom -map array is used (see the "atom_modify"_atom_modify.html command). -If an atom map array is not used (e.g. an atomic system with no -bonds), and velocities are not assigned in the data file, and you -don't care if unique atom IDs appear in dump files, then the atom-IDs -can all be set to 0. +map array is used, but not if an atom map hash is used; see the +"atom_modify"_atom_modify.html command for details. If an atom map is +not used (e.g. an atomic system with no bonds), and you don't care if +unique atom IDs appear in dump files, then the atom-IDs can all be set +to 0. The molecule ID is a 2nd identifier attached to an atom. Normally, it is a number from 1 to N, identifying which molecule the atom belongs @@ -379,6 +391,16 @@ Additional attributes must be defined for each ellipsoid, line, triangle, or body in the corresponding {Ellipsoids}, {Lines}, {Triangles}, or {Bodies} section. +The {template-index} and {template-atom} are only defined used by +"atom_style template"_atom_style.html. In this case the +"molecule"_molecule.html command is used to define a molecule template +which contains one or more molecules. If an atom belongs to one of +those molecules, its {template-index} and {template-atom} are both set +to positive integers; if not the values are both 0. The +{template-index} is which molecule (1 to Nmols) the atom belongs to. +The {template-atom} is which atom (1 to Natoms) within the molecule +the atom is. + Some pair styles and fixes and computes that operate on finite-size particles allow for a mixture of finite-size and point particles. See the doc pages of individual commands for details. diff --git a/lib/gpu/Makefile.linux b/lib/gpu/Makefile.linux index a98302b8fd..f605a2e32e 100644 --- a/lib/gpu/Makefile.linux +++ b/lib/gpu/Makefile.linux @@ -17,13 +17,16 @@ CUDA_ARCH = -arch=sm_21 # older CUDA #CUDA_ARCH = -arch=sm_10 -DCUDA_PRE_THREE -CUDA_PRECISION = -D_SINGLE_SINGLE +# system-specific settings, should match with LAMMPS_SMALLBIG (default), LAMMPS_BIGBIG or LAMMPS_SMALLSMALL +LMP_INC = -DLAMMPS_BIGBIG + +CUDA_PRECISION = -D_SINGLE_DOUBLE CUDA_INCLUDE = -I$(CUDA_HOME)/include CUDA_LIB = -L$(CUDA_HOME)/lib64 -CUDA_OPTS = -DUNIX -O3 -Xptxas -v --use_fast_math +CUDA_OPTS = -DUNIX -O3 -Xptxas -v --use_fast_math $(LMP_INC) CUDR_CPP = mpic++ -DMPI_GERYON -DUCL_NO_EXIT -DMPICH_IGNORE_CXX_SEEK -CUDR_OPTS = -O2 # -xHost -no-prec-div -ansi-alias +CUDR_OPTS = -O2 $(LMP_INC) # -xHost -no-prec-div -ansi-alias BIN_DIR = ./ OBJ_DIR = ./obj diff --git a/lib/gpu/Makefile.linux_opencl b/lib/gpu/Makefile.linux_opencl index 754730fa60..a417772b4c 100644 --- a/lib/gpu/Makefile.linux_opencl +++ b/lib/gpu/Makefile.linux_opencl @@ -11,9 +11,13 @@ OCL_TUNE = -DFERMI_OCL # -- Uncomment for NVIDIA Fermi # OCL_TUNE = -DCYPRESS_OCL # -- Uncomment for AMD Cypress # OCL_TUNE = -DGENERIC_OCL # -- Uncomment for generic device -OCL_CPP = mpic++ $(DEFAULT_DEVICE) -O3 -DMPI_GERYON -DUCL_NO_EXIT -DMPICH_IGNORE_CXX_SEEK +# system-specific settings, should match with LAMMPS_SMALLBIG (default), LAMMPS_BIGBIG and LAMMPS_SMALLSMALL +LMP_INC = #-DLAMMPS_BIGBIG + +OCL_INC = -I/usr/local/cuda/include # Path to CL directory +OCL_CPP = mpic++ $(DEFAULT_DEVICE) -O3 -DMPI_GERYON -DUCL_NO_EXIT -DMPICH_IGNORE_CXX_SEEK $(LMP_INC) $(OCL_INC) OCL_LINK = -lOpenCL -OCL_PREC = -D_SINGLE_SINGLE +OCL_PREC = -D_SINGLE_DOUBLE BIN_DIR = ./ OBJ_DIR = ./obj_ocl diff --git a/lib/gpu/README b/lib/gpu/README index 59510131d6..45c8ce49ba 100644 --- a/lib/gpu/README +++ b/lib/gpu/README @@ -82,7 +82,7 @@ and Brown, W.M., Masako, Y. Implementing Molecular Dynamics on Hybrid High Performance Computers - Three-Body Potentials. Computer Physics Communications. -2013. In press. +2013. 184: p. 2785–2793. ---- @@ -103,37 +103,33 @@ Current styles supporting GPU acceleration: 11 eam/alloy 12 eam/fs 13 eam - 14 eam/lj - 15 gauss - 16 gayberne - 17 lj96/cut - 18 lj/charmm/coul/long - 19 lj/class2/coul/long - 20 lj/class2 - 21 lj/cut/coul/cut - 22 lj/cut/coul/debye - 23 lj/cut/coul/dsf - 24 lj/cut/coul/long - 25 lj/cut/coul/msm - 26 lj/cut/coul/wolf/fsw - 27 lj/cut/dipole/cut - 28 lj/cut - 29 lj/cut/tgpu - 30 lj/expand - 31 lj/sdk/coul/long - 32 cg/cmm/coul/long - 33 lj/sdk - 34 cg/cmm - 35 lj/sf/dipole/sf - 36 mie/cut - 37 morse - 38 resquared - 39 soft - 40 sw - 41 table - 42 yukawa/colloid - 43 yukawa - 44 pppm + 14 gauss + 15 gayberne + 16 lj96/cut + 17 lj/charmm/coul/long + 18 lj/class2/coul/long + 19 lj/class2 + 20 lj/cut/coul/cut + 21 lj/cut/coul/debye + 22 lj/cut/coul/dsf + 23 lj/cut/coul/long + 24 lj/cut/coul/msm + 25 lj/cut/dipole/cut + 26 lj/cut + 27 lj/expand + 28 lj/gromacs + 29 lj/sdk/coul/long + 30 lj/sdk + 31 lj/sf/dipole/sf + 32 mie/cut + 33 morse + 34 resquared + 35 soft + 36 sw + 37 table + 38 yukawa/colloid + 39 yukawa + 40 pppm MULTIPLE LAMMPS PROCESSES @@ -200,6 +196,10 @@ NOTE: The lj/cut/coul/long/gpu, cg/cmm/coul/long/gpu, coul/long/gpu, lj/charmm/coul/long/gpu and pppm/gpu styles will only be installed if the KSPACE package has been installed. +NOTE: The system-specific setting LAMMPS_SMALLBIG (default), LAMMPS_BIGBIG, + or LAMMPS_SMALLSMALL if specified when building LAMMPS (i.e. in + src/MAKE/Makefile.foo) should be consistent with that specified + when building libgpu.a (i.e. by LMP_INC in the lib/gpu/Makefile.bar). EXAMPLE BUILD PROCESS -------------------------------- diff --git a/lib/gpu/lal_atom.h b/lib/gpu/lal_atom.h index 171141f7ea..4731b1b08d 100644 --- a/lib/gpu/lal_atom.h +++ b/lib/gpu/lal_atom.h @@ -373,7 +373,7 @@ class Atom { /// Cell list identifiers for device nbor builds UCL_D_Vec dev_particle_id; /// Atom tag information for device nbor builds - UCL_D_Vec dev_tag; + UCL_D_Vec dev_tag; /// Cell list identifiers for hybrid nbor builds UCL_H_Vec host_cell_id; diff --git a/lib/gpu/lal_base_atomic.cpp b/lib/gpu/lal_base_atomic.cpp index b24f7e9661..191f218bd8 100644 --- a/lib/gpu/lal_base_atomic.cpp +++ b/lib/gpu/lal_base_atomic.cpp @@ -150,8 +150,8 @@ template inline void BaseAtomicT::build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, - int **nspecial, int **special, + double *subhi, tagint *tag, + int **nspecial, tagint **special, bool &success) { success=true; resize_atom(inum,nall,success); @@ -216,8 +216,8 @@ void BaseAtomicT::compute(const int f_ago, const int inum_full, template int ** BaseAtomicT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, const bool eflag, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, diff --git a/lib/gpu/lal_base_atomic.h b/lib/gpu/lal_base_atomic.h index 74c8530f7f..eaf55f46e2 100644 --- a/lib/gpu/lal_base_atomic.h +++ b/lib/gpu/lal_base_atomic.h @@ -119,8 +119,8 @@ class BaseAtomic { /// Build neighbor list on device void build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, bool &success); + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, bool &success); /// Pair loop with host neighboring void compute(const int f_ago, const int inum_full, @@ -132,16 +132,16 @@ class BaseAtomic { /// Pair loop with device neighboring int * compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success); /// Pair loop with device neighboring int ** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success); diff --git a/lib/gpu/lal_base_charge.cpp b/lib/gpu/lal_base_charge.cpp index 8e06a4d18c..e7fe2b62f4 100644 --- a/lib/gpu/lal_base_charge.cpp +++ b/lib/gpu/lal_base_charge.cpp @@ -153,8 +153,8 @@ template inline void BaseChargeT::build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, - int **nspecial, int **special, + double *subhi, tagint *tag, + int **nspecial, tagint **special, bool &success) { success=true; resize_atom(inum,nall,success); @@ -225,8 +225,8 @@ void BaseChargeT::compute(const int f_ago, const int inum_full, template int** BaseChargeT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, const bool eflag, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, diff --git a/lib/gpu/lal_base_charge.h b/lib/gpu/lal_base_charge.h index 3ca4705177..e791507432 100644 --- a/lib/gpu/lal_base_charge.h +++ b/lib/gpu/lal_base_charge.h @@ -122,8 +122,8 @@ class BaseCharge { /// Build neighbor list on device void build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, bool &success); + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, bool &success); /// Pair loop with host neighboring void compute(const int f_ago, const int inum_full, const int nall, @@ -136,8 +136,8 @@ class BaseCharge { /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double *charge, double *boxlo, double *prd); diff --git a/lib/gpu/lal_base_dipole.cpp b/lib/gpu/lal_base_dipole.cpp index ed3d720d2c..12e3b20d96 100644 --- a/lib/gpu/lal_base_dipole.cpp +++ b/lib/gpu/lal_base_dipole.cpp @@ -155,8 +155,8 @@ template inline void BaseDipoleT::build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, - int **nspecial, int **special, + double *subhi, tagint *tag, + int **nspecial, tagint **special, bool &success) { success=true; resize_atom(inum,nall,success); @@ -229,8 +229,8 @@ void BaseDipoleT::compute(const int f_ago, const int inum_full, template int** BaseDipoleT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, const bool eflag, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, diff --git a/lib/gpu/lal_base_dipole.h b/lib/gpu/lal_base_dipole.h index 51e357afda..2e495c8747 100644 --- a/lib/gpu/lal_base_dipole.h +++ b/lib/gpu/lal_base_dipole.h @@ -121,8 +121,8 @@ class BaseDipole { /// Build neighbor list on device void build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, bool &success); + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, bool &success); /// Pair loop with host neighboring void compute(const int f_ago, const int inum_full, const int nall, @@ -135,8 +135,8 @@ class BaseDipole { /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double *charge, double **mu, double *boxlo, double *prd); diff --git a/lib/gpu/lal_base_ellipsoid.cpp b/lib/gpu/lal_base_ellipsoid.cpp index 18bcf3c100..4200c02e1c 100644 --- a/lib/gpu/lal_base_ellipsoid.cpp +++ b/lib/gpu/lal_base_ellipsoid.cpp @@ -315,8 +315,8 @@ template inline void BaseEllipsoidT::build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, - int **nspecial, int **special, + double *subhi, tagint *tag, + int **nspecial, tagint **special, bool &success) { success=true; resize_atom(nall,success); @@ -392,8 +392,8 @@ int* BaseEllipsoidT::compute(const int f_ago, const int inum_full, template int** BaseEllipsoidT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, diff --git a/lib/gpu/lal_base_ellipsoid.h b/lib/gpu/lal_base_ellipsoid.h index 96e2e3ee50..e289430f43 100644 --- a/lib/gpu/lal_base_ellipsoid.h +++ b/lib/gpu/lal_base_ellipsoid.h @@ -160,8 +160,8 @@ class BaseEllipsoid { /// Build neighbor list on device void build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, bool &success); + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, bool &success); /// Pair loop with host neighboring int* compute(const int f_ago, const int inum_full, const int nall, @@ -173,8 +173,8 @@ class BaseEllipsoid { /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double **host_quat); diff --git a/lib/gpu/lal_base_three.cpp b/lib/gpu/lal_base_three.cpp index fe64cf44ed..9418293cce 100644 --- a/lib/gpu/lal_base_three.cpp +++ b/lib/gpu/lal_base_three.cpp @@ -186,8 +186,8 @@ template inline void BaseThreeT::build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, - int **nspecial, int **special, + double *subhi, tagint *tag, + int **nspecial, tagint **special, bool &success) { success=true; resize_atom(inum,nall,success); @@ -267,8 +267,8 @@ void BaseThreeT::compute(const int f_ago, const int nlocal, const int nall, template int ** BaseThreeT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, const bool eflag, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, diff --git a/lib/gpu/lal_base_three.h b/lib/gpu/lal_base_three.h index 7e167f4655..f457b5bd55 100644 --- a/lib/gpu/lal_base_three.h +++ b/lib/gpu/lal_base_three.h @@ -131,8 +131,8 @@ class BaseThree { /// Build neighbor list on device void build_nbor_list(const int inum, const int host_inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, bool &success); + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, bool &success); /// Pair loop with host neighboring void compute(const int f_ago, const int inum_full, const int nall, @@ -144,16 +144,16 @@ class BaseThree { /// Pair loop with device neighboring int * compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success); /// Pair loop with device neighboring int ** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success); diff --git a/lib/gpu/lal_beck_ext.cpp b/lib/gpu/lal_beck_ext.cpp index 3148547605..28ca0df346 100644 --- a/lib/gpu/lal_beck_ext.cpp +++ b/lib/gpu/lal_beck_ext.cpp @@ -94,8 +94,8 @@ void beck_gpu_clear() { int ** beck_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_born_coul_long_ext.cpp b/lib/gpu/lal_born_coul_long_ext.cpp index 3d8810fcae..382e9a2b2c 100644 --- a/lib/gpu/lal_born_coul_long_ext.cpp +++ b/lib/gpu/lal_born_coul_long_ext.cpp @@ -102,8 +102,8 @@ void borncl_gpu_clear() { int** borncl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_born_coul_wolf_ext.cpp b/lib/gpu/lal_born_coul_wolf_ext.cpp index bffab31d1d..b56c526119 100644 --- a/lib/gpu/lal_born_coul_wolf_ext.cpp +++ b/lib/gpu/lal_born_coul_wolf_ext.cpp @@ -104,8 +104,8 @@ void borncw_gpu_clear() { int** borncw_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_born_ext.cpp b/lib/gpu/lal_born_ext.cpp index a3fcfad4e8..ec114f6613 100644 --- a/lib/gpu/lal_born_ext.cpp +++ b/lib/gpu/lal_born_ext.cpp @@ -98,8 +98,8 @@ void born_gpu_clear() { int ** born_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_buck_coul_ext.cpp b/lib/gpu/lal_buck_coul_ext.cpp index be5dc718d7..dd696fc6bb 100644 --- a/lib/gpu/lal_buck_coul_ext.cpp +++ b/lib/gpu/lal_buck_coul_ext.cpp @@ -101,8 +101,8 @@ void buckc_gpu_clear() { int ** buckc_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_buck_coul_long_ext.cpp b/lib/gpu/lal_buck_coul_long_ext.cpp index 9f614ffb16..9c0c331ee1 100644 --- a/lib/gpu/lal_buck_coul_long_ext.cpp +++ b/lib/gpu/lal_buck_coul_long_ext.cpp @@ -100,8 +100,8 @@ void buckcl_gpu_clear() { int** buckcl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_buck_ext.cpp b/lib/gpu/lal_buck_ext.cpp index 4b25e7356c..5027c92d79 100644 --- a/lib/gpu/lal_buck_ext.cpp +++ b/lib/gpu/lal_buck_ext.cpp @@ -95,8 +95,8 @@ void buck_gpu_clear() { int ** buck_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_cg_cmm_ext.cpp b/lib/gpu/lal_cg_cmm_ext.cpp index 0100ac8901..0d2c3d8fbf 100644 --- a/lib/gpu/lal_cg_cmm_ext.cpp +++ b/lib/gpu/lal_cg_cmm_ext.cpp @@ -95,8 +95,8 @@ void cmm_gpu_clear() { int** cmm_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_cg_cmm_long_ext.cpp b/lib/gpu/lal_cg_cmm_long_ext.cpp index 9197e75e07..966588bf9b 100644 --- a/lib/gpu/lal_cg_cmm_long_ext.cpp +++ b/lib/gpu/lal_cg_cmm_long_ext.cpp @@ -99,8 +99,8 @@ void cmml_gpu_clear() { int** cmml_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_charmm_long_ext.cpp b/lib/gpu/lal_charmm_long_ext.cpp index 8f359e361c..807988a3e8 100644 --- a/lib/gpu/lal_charmm_long_ext.cpp +++ b/lib/gpu/lal_charmm_long_ext.cpp @@ -104,8 +104,8 @@ void crml_gpu_clear() { int** crml_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_colloid_ext.cpp b/lib/gpu/lal_colloid_ext.cpp index 50c95c1e25..ea83cb6417 100644 --- a/lib/gpu/lal_colloid_ext.cpp +++ b/lib/gpu/lal_colloid_ext.cpp @@ -101,8 +101,8 @@ void colloid_gpu_clear() { int ** colloid_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_coul_dsf_ext.cpp b/lib/gpu/lal_coul_dsf_ext.cpp index 851df0f53d..e65a090a16 100644 --- a/lib/gpu/lal_coul_dsf_ext.cpp +++ b/lib/gpu/lal_coul_dsf_ext.cpp @@ -95,8 +95,8 @@ void cdsf_gpu_clear() { int** cdsf_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_coul_long_ext.cpp b/lib/gpu/lal_coul_long_ext.cpp index 156de0be0a..74581ed081 100644 --- a/lib/gpu/lal_coul_long_ext.cpp +++ b/lib/gpu/lal_coul_long_ext.cpp @@ -93,8 +93,8 @@ void cl_gpu_clear() { int** cl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_device.cpp b/lib/gpu/lal_device.cpp index e3f1037baf..c93d69f3eb 100644 --- a/lib/gpu/lal_device.cpp +++ b/lib/gpu/lal_device.cpp @@ -211,7 +211,7 @@ int DeviceT::set_ocl_params(char *ocl_vendor) { " -DBLOCK_CELL_ID="+params[11]+ " -DMAX_BIO_SHARED_TYPES="+params[12]; } - _ocl_compile_string="-cl-fast-relaxed-math -cl-mad-enable "+ + _ocl_compile_string="-cl-fast-relaxed-math -cl-mad-enable "+std::string(OCL_INT_TYPE)+" "+ std::string(OCL_PRECISION_COMPILE)+" "+_ocl_vendor_string; #endif return 0; diff --git a/lib/gpu/lal_dipole_lj_ext.cpp b/lib/gpu/lal_dipole_lj_ext.cpp index 48db22d991..55bbe0b804 100644 --- a/lib/gpu/lal_dipole_lj_ext.cpp +++ b/lib/gpu/lal_dipole_lj_ext.cpp @@ -98,8 +98,8 @@ void dpl_gpu_clear() { int** dpl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double **host_mu, diff --git a/lib/gpu/lal_dipole_lj_sf_ext.cpp b/lib/gpu/lal_dipole_lj_sf_ext.cpp index ad2bf10b0b..8abf78c903 100644 --- a/lib/gpu/lal_dipole_lj_sf_ext.cpp +++ b/lib/gpu/lal_dipole_lj_sf_ext.cpp @@ -98,8 +98,8 @@ void dplsf_gpu_clear() { int** dplsf_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double **host_mu, diff --git a/lib/gpu/lal_eam.cpp b/lib/gpu/lal_eam.cpp index 54e5998ddd..c856a8e667 100644 --- a/lib/gpu/lal_eam.cpp +++ b/lib/gpu/lal_eam.cpp @@ -346,7 +346,7 @@ void EAMT::compute(const int f_ago, const int inum_full, const int nlocal, template int** EAMT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, int **special, + double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, int &inum, diff --git a/lib/gpu/lal_eam.h b/lib/gpu/lal_eam.h index 96dcb9bebc..698f9938cb 100644 --- a/lib/gpu/lal_eam.h +++ b/lib/gpu/lal_eam.h @@ -79,8 +79,8 @@ class EAM : public BaseAtomic { /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, int &inum, void **fp_ptr); diff --git a/lib/gpu/lal_eam_ext.cpp b/lib/gpu/lal_eam_ext.cpp index e603f9cff7..d56f750e2f 100644 --- a/lib/gpu/lal_eam_ext.cpp +++ b/lib/gpu/lal_eam_ext.cpp @@ -108,8 +108,8 @@ void eam_gpu_clear() { int ** eam_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, int &inum, void **fp_ptr) { diff --git a/lib/gpu/lal_gauss_ext.cpp b/lib/gpu/lal_gauss_ext.cpp index 8adb96855c..ed0db220e8 100644 --- a/lib/gpu/lal_gauss_ext.cpp +++ b/lib/gpu/lal_gauss_ext.cpp @@ -94,8 +94,8 @@ void gauss_gpu_clear() { int ** gauss_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_gayberne_ext.cpp b/lib/gpu/lal_gayberne_ext.cpp index a18f4bcd73..e674fb376b 100644 --- a/lib/gpu/lal_gayberne_ext.cpp +++ b/lib/gpu/lal_gayberne_ext.cpp @@ -102,17 +102,17 @@ void gb_gpu_clear() { GBMF.clear(); } - int** compute(const int ago, const int inum_full, const int nall, +int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double **host_quat); int** gb_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, int **special, + double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, diff --git a/lib/gpu/lal_lj96_ext.cpp b/lib/gpu/lal_lj96_ext.cpp index ce3a5a87b6..14c32ef95e 100644 --- a/lib/gpu/lal_lj96_ext.cpp +++ b/lib/gpu/lal_lj96_ext.cpp @@ -94,8 +94,8 @@ void lj96_gpu_clear() { int** lj96_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_lj_class2_long_ext.cpp b/lib/gpu/lal_lj_class2_long_ext.cpp index 6152dc27c0..4bb3aad7ad 100644 --- a/lib/gpu/lal_lj_class2_long_ext.cpp +++ b/lib/gpu/lal_lj_class2_long_ext.cpp @@ -99,8 +99,8 @@ void c2cl_gpu_clear() { int** c2cl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_lj_coul_debye_ext.cpp b/lib/gpu/lal_lj_coul_debye_ext.cpp index 3658d8a5be..67f5a0075f 100644 --- a/lib/gpu/lal_lj_coul_debye_ext.cpp +++ b/lib/gpu/lal_lj_coul_debye_ext.cpp @@ -99,8 +99,8 @@ void ljcd_gpu_clear() { int** ljcd_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_lj_coul_ext.cpp b/lib/gpu/lal_lj_coul_ext.cpp index 1faf528991..3b5cc09805 100644 --- a/lib/gpu/lal_lj_coul_ext.cpp +++ b/lib/gpu/lal_lj_coul_ext.cpp @@ -98,8 +98,8 @@ void ljc_gpu_clear() { int** ljc_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_lj_coul_long_ext.cpp b/lib/gpu/lal_lj_coul_long_ext.cpp index a7a485b4c2..8453ded9c5 100644 --- a/lib/gpu/lal_lj_coul_long_ext.cpp +++ b/lib/gpu/lal_lj_coul_long_ext.cpp @@ -99,8 +99,8 @@ void ljcl_gpu_clear() { int** ljcl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_lj_coul_msm_ext.cpp b/lib/gpu/lal_lj_coul_msm_ext.cpp index af4c93bb8f..ecf3254cf9 100644 --- a/lib/gpu/lal_lj_coul_msm_ext.cpp +++ b/lib/gpu/lal_lj_coul_msm_ext.cpp @@ -101,8 +101,8 @@ void ljcm_gpu_clear() { int** ljcm_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_lj_dsf_ext.cpp b/lib/gpu/lal_lj_dsf_ext.cpp index 5f1f17ee5b..719a792d7f 100644 --- a/lib/gpu/lal_lj_dsf_ext.cpp +++ b/lib/gpu/lal_lj_dsf_ext.cpp @@ -102,8 +102,8 @@ void ljd_gpu_clear() { int** ljd_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, diff --git a/lib/gpu/lal_lj_expand_ext.cpp b/lib/gpu/lal_lj_expand_ext.cpp index c6939cdf96..6ba9754923 100644 --- a/lib/gpu/lal_lj_expand_ext.cpp +++ b/lib/gpu/lal_lj_expand_ext.cpp @@ -95,8 +95,8 @@ void lje_gpu_clear() { int** lje_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_lj_ext.cpp b/lib/gpu/lal_lj_ext.cpp index 650eadbfc2..9d27b32c43 100644 --- a/lib/gpu/lal_lj_ext.cpp +++ b/lib/gpu/lal_lj_ext.cpp @@ -94,8 +94,8 @@ void ljl_gpu_clear() { int ** ljl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_lj_gromacs_ext.cpp b/lib/gpu/lal_lj_gromacs_ext.cpp index c2db048fe6..b5eb0038b7 100644 --- a/lib/gpu/lal_lj_gromacs_ext.cpp +++ b/lib/gpu/lal_lj_gromacs_ext.cpp @@ -99,8 +99,8 @@ void ljgrm_gpu_clear() { int ** ljgrm_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_mie_ext.cpp b/lib/gpu/lal_mie_ext.cpp index d3f17a92b4..d7c4187a42 100644 --- a/lib/gpu/lal_mie_ext.cpp +++ b/lib/gpu/lal_mie_ext.cpp @@ -98,8 +98,8 @@ void mie_gpu_clear() { int ** mie_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_morse_ext.cpp b/lib/gpu/lal_morse_ext.cpp index 5277ba43f0..3994473fd3 100644 --- a/lib/gpu/lal_morse_ext.cpp +++ b/lib/gpu/lal_morse_ext.cpp @@ -95,8 +95,8 @@ void mor_gpu_clear() { int** mor_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_neighbor.cpp b/lib/gpu/lal_neighbor.cpp index 28d1c1c79e..074eaa842b 100644 --- a/lib/gpu/lal_neighbor.cpp +++ b/lib/gpu/lal_neighbor.cpp @@ -394,8 +394,8 @@ void Neighbor::resize_max_neighbors(const int maxn, bool &success) { template void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, const int nall, Atom &atom, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, bool &success, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, bool &success, int &mn) { _nbor_time_avail=true; const int nt=inum+host_inum; @@ -428,7 +428,8 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, if (_maxspecial>0) { time_nbor.start(); - UCL_H_Vec view_nspecial, view_special, view_tag; + UCL_H_Vec view_nspecial; + UCL_H_Vec view_special, view_tag; view_nspecial.view(nspecial[0],nt*3,*dev); view_special.view(special[0],nt*_maxspecial,*dev); view_tag.view(tag,nall,*dev); @@ -620,5 +621,5 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, template void Neighbor::build_nbor_list (double **x, const int inum, const int host_inum, const int nall, Atom &atom, double *sublo, double *subhi, - int *, int **, int **, bool &success, int &mn); + tagint *, int **, tagint **, bool &success, int &mn); diff --git a/lib/gpu/lal_neighbor.h b/lib/gpu/lal_neighbor.h index f3463ccfa4..7653291bbb 100644 --- a/lib/gpu/lal_neighbor.h +++ b/lib/gpu/lal_neighbor.h @@ -173,7 +173,7 @@ class Neighbor { template void build_nbor_list(double **x, const int inum, const int host_inum, const int nall, Atom &atom, double *sublo, - double *subhi, int *tag, int **nspecial, int **special, + double *subhi, tagint *tag, int **nspecial, tagint **special, bool &success, int &max_nbors); /// Return the number of bytes used on device @@ -212,7 +212,7 @@ class Neighbor { /// Device storage for special neighbor counts UCL_D_Vec dev_nspecial; /// Device storage for special neighbors - UCL_D_Vec dev_special, dev_special_t; + UCL_D_Vec dev_special, dev_special_t; /// Host/Device storage for number of particles per cell UCL_Vector cell_counts; int *cell_iter; diff --git a/lib/gpu/lal_neighbor_gpu.cu b/lib/gpu/lal_neighbor_gpu.cu index cc4e210932..4f8464e803 100644 --- a/lib/gpu/lal_neighbor_gpu.cu +++ b/lib/gpu/lal_neighbor_gpu.cu @@ -16,6 +16,16 @@ #ifdef NV_KERNEL #include "lal_preprocessor.h" +#ifdef LAMMPS_SMALLBIG +#define tagint int +#endif +#ifdef LAMMPS_BIGBIG +#include "inttypes.h" +#define tagint int64_t +#endif +#ifdef LAMMPS_SMALLSMALL +#define tagint int +#endif #ifndef _DOUBLE_DOUBLE texture pos_tex; #else @@ -93,15 +103,22 @@ __kernel void kernel_calc_cell_counts(const unsigned *restrict cell_id, #else #define pos_tex x_ +#ifdef LAMMPS_SMALLBIG +#define tagint int +#endif +#ifdef LAMMPS_BIGBIG +#define tagint long long int +#endif +#ifdef LAMMPS_SMALLSMALL +#define tagint int +#endif #endif - - -__kernel void transpose(__global int *restrict out, - const __global int *restrict in, +__kernel void transpose(__global tagint *restrict out, + const __global tagint *restrict in, int columns_in, int rows_in) { - __local int block[BLOCK_CELL_2D][BLOCK_CELL_2D+1]; + __local tagint block[BLOCK_CELL_2D][BLOCK_CELL_2D+1]; unsigned ti=THREAD_ID_X; unsigned tj=THREAD_ID_Y; @@ -239,9 +256,9 @@ __kernel void calc_neigh_list_cell(const __global numtyp4 *restrict x_, __kernel void kernel_special(__global int *dev_nbor, __global int *host_nbor_list, const __global int *host_numj, - const __global int *restrict tag, + const __global tagint *restrict tag, const __global int *restrict nspecial, - const __global int *restrict special, + const __global tagint *restrict special, int inum, int nt, int max_nbors, int t_per_atom) { int tid=THREAD_ID_X; int ii=fast_mul((int)BLOCK_ID_X,(int)(BLOCK_SIZE_X)/t_per_atom); @@ -275,7 +292,7 @@ __kernel void kernel_special(__global int *dev_nbor, for ( ; list> SBBITS & 3; }; #define BLOCK_ELLIPSE BLOCK_PAIR #endif +// default to 32-bit smallint and other ints, 64-bit bigint: same as defined in src/lmptype.h +#if !defined(LAMMPS_SMALLSMALL) && !defined(LAMMPS_BIGBIG) && !defined(LAMMPS_SMALLBIG) +#define LAMMPS_SMALLBIG +#endif diff --git a/lib/gpu/lal_re_squared_ext.cpp b/lib/gpu/lal_re_squared_ext.cpp index 18bb1f681d..e1d8fffb8f 100644 --- a/lib/gpu/lal_re_squared_ext.cpp +++ b/lib/gpu/lal_re_squared_ext.cpp @@ -101,15 +101,15 @@ void re_gpu_clear() { int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **numj, const double cpu_time, bool &success, double **host_quat); int** re_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, int **special, + double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, diff --git a/lib/gpu/lal_soft_ext.cpp b/lib/gpu/lal_soft_ext.cpp index effae9639c..506f4878b5 100644 --- a/lib/gpu/lal_soft_ext.cpp +++ b/lib/gpu/lal_soft_ext.cpp @@ -94,8 +94,8 @@ void soft_gpu_clear() { int ** soft_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_sw.cu b/lib/gpu/lal_sw.cu index 85cbfd023f..54319c1a7d 100644 --- a/lib/gpu/lal_sw.cu +++ b/lib/gpu/lal_sw.cu @@ -393,8 +393,6 @@ __kernel void k_sw_three_center(const __global numtyp4 *restrict x_, if (rsq1 > sw3_ijparam.y) continue; numtyp4 sw1_ijparam; fetch4(sw1_ijparam,ijparam,sw1_tex); - sw_sigma=sw1_ijparam.y; - sw_gamma=sw1_ijparam.w; sw_sigma_gamma_ij=sw1_ijparam.y*sw1_ijparam.w; //sw_sigma*sw_gamma; sw_cut_ij=sw3_ijparam.x; @@ -418,15 +416,11 @@ __kernel void k_sw_three_center(const __global numtyp4 *restrict x_, numtyp rsq2 = delr2x*delr2x + delr2y*delr2y + delr2z*delr2z; if (rsq2 < sw3_ikparam.y) { // sw_cutsq=sw3[ikparam].y; numtyp4 sw1_ikparam; fetch4(sw1_ikparam,ikparam,sw1_tex); - sw_sigma=sw1_ikparam.y; - sw_gamma=sw1_ikparam.w; sw_sigma_gamma_ik=sw1_ikparam.y*sw1_ikparam.w; //sw_sigma*sw_gamma; sw_cut_ik=sw3_ikparam.x; int ijkparam=elem2param[itype*nelements*nelements+jtype*nelements+ktype]; numtyp4 sw1_ijkparam; fetch4(sw1_ijkparam,ijkparam,sw1_tex); - sw_epsilon=sw1_ijkparam.x; - sw_lambda=sw1_ijkparam.z; sw_lambda_epsilon_ijk=sw1_ijkparam.x*sw1_ijkparam.z; //sw_lambda*sw_epsilon; sw_lambda_epsilon2_ijk=(numtyp)2.0*sw_lambda_epsilon_ijk; numtyp4 sw3_ijkparam; fetch4(sw3_ijkparam,ijkparam,sw3_tex); @@ -522,8 +516,6 @@ __kernel void k_sw_three_end(const __global numtyp4 *restrict x_, if (rsq1 > sw3_ijparam.y) continue; numtyp4 sw1_ijparam; fetch4(sw1_ijparam,ijparam,sw1_tex); - sw_sigma=sw1_ijparam.y; - sw_gamma=sw1_ijparam.w; sw_sigma_gamma_ij=sw1_ijparam.y*sw1_ijparam.w; //sw_sigma*sw_gamma; sw_cut_ij=sw3_ijparam.x; @@ -559,15 +551,11 @@ __kernel void k_sw_three_end(const __global numtyp4 *restrict x_, if (rsq2 < sw3_ikparam.y) { numtyp4 sw1_ikparam; fetch4(sw1_ikparam,ikparam,sw1_tex); - sw_sigma=sw1_ikparam.y; - sw_gamma=sw1_ikparam.w; sw_sigma_gamma_ik=sw1_ikparam.y*sw1_ikparam.w; //sw_sigma*sw_gamma; sw_cut_ik=sw3_ikparam.x; int ijkparam=elem2param[itype*nelements*nelements+jtype*nelements+ktype]; numtyp4 sw1_ijkparam; fetch4(sw1_ijkparam,ijkparam,sw1_tex); - sw_epsilon=sw1_ijkparam.x; - sw_lambda=sw1_ijkparam.z; sw_lambda_epsilon_ijk=sw1_ijkparam.x*sw1_ijkparam.z; //sw_lambda*sw_epsilon; sw_lambda_epsilon2_ijk=(numtyp)2.0*sw_lambda_epsilon_ijk; numtyp4 sw3_ijkparam; fetch4(sw3_ijkparam,ijkparam,sw3_tex); @@ -663,8 +651,6 @@ __kernel void k_sw_three_end_vatom(const __global numtyp4 *restrict x_, if (rsq1 > sw3_ijparam.y) continue; numtyp4 sw1_ijparam; fetch4(sw1_ijparam,ijparam,sw1_tex); - sw_sigma=sw1_ijparam.y; - sw_gamma=sw1_ijparam.w; sw_sigma_gamma_ij=sw1_ijparam.y*sw1_ijparam.w; //sw_sigma*sw_gamma; sw_cut_ij=sw3_ijparam.x; @@ -700,15 +686,11 @@ __kernel void k_sw_three_end_vatom(const __global numtyp4 *restrict x_, if (rsq2 < sw3_ikparam.y) { numtyp4 sw1_ikparam; fetch4(sw1_ikparam,ikparam,sw1_tex); - sw_sigma=sw1_ikparam.y; - sw_gamma=sw1_ikparam.w; sw_sigma_gamma_ik=sw1_ikparam.y*sw1_ikparam.w; //sw_sigma*sw_gamma; sw_cut_ik=sw3_ikparam.x; int ijkparam=elem2param[itype*nelements*nelements+jtype*nelements+ktype]; numtyp4 sw1_ijkparam; fetch4(sw1_ijkparam,ijkparam,sw1_tex); - sw_epsilon=sw1_ijkparam.x; - sw_lambda=sw1_ijkparam.z; sw_lambda_epsilon_ijk=sw1_ijkparam.x*sw1_ijkparam.z; //sw_lambda*sw_epsilon; sw_lambda_epsilon2_ijk=(numtyp)2.0*sw_lambda_epsilon_ijk; numtyp4 sw3_ijkparam; fetch4(sw3_ijkparam,ijkparam,sw3_tex); diff --git a/lib/gpu/lal_sw_ext.cpp b/lib/gpu/lal_sw_ext.cpp index 16b6828325..e2d1b5e4dd 100644 --- a/lib/gpu/lal_sw_ext.cpp +++ b/lib/gpu/lal_sw_ext.cpp @@ -105,8 +105,8 @@ void sw_gpu_clear() { int ** sw_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_table_ext.cpp b/lib/gpu/lal_table_ext.cpp index 55fe9318be..172acb7d39 100644 --- a/lib/gpu/lal_table_ext.cpp +++ b/lib/gpu/lal_table_ext.cpp @@ -94,8 +94,8 @@ void table_gpu_clear() { int ** table_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/lib/gpu/lal_yukawa_colloid.cpp b/lib/gpu/lal_yukawa_colloid.cpp index f86a257821..70282a7117 100644 --- a/lib/gpu/lal_yukawa_colloid.cpp +++ b/lib/gpu/lal_yukawa_colloid.cpp @@ -189,8 +189,8 @@ void YukawaColloidT::compute(const int f_ago, const int inum_full, template int** YukawaColloidT::compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *rad) { diff --git a/lib/gpu/lal_yukawa_colloid.h b/lib/gpu/lal_yukawa_colloid.h index 2b6cbe4ecd..5a9ee7ae6e 100644 --- a/lib/gpu/lal_yukawa_colloid.h +++ b/lib/gpu/lal_yukawa_colloid.h @@ -82,8 +82,8 @@ class YukawaColloid : public BaseAtomic { /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *rad); diff --git a/lib/gpu/lal_yukawa_colloid_ext.cpp b/lib/gpu/lal_yukawa_colloid_ext.cpp index a1bd0ee1ff..0e3c653e06 100644 --- a/lib/gpu/lal_yukawa_colloid_ext.cpp +++ b/lib/gpu/lal_yukawa_colloid_ext.cpp @@ -94,8 +94,8 @@ void ykcolloid_gpu_clear() { int ** ykcolloid_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_rad) { diff --git a/lib/gpu/lal_yukawa_ext.cpp b/lib/gpu/lal_yukawa_ext.cpp index 5737bc1026..1cc89885aa 100644 --- a/lib/gpu/lal_yukawa_ext.cpp +++ b/lib/gpu/lal_yukawa_ext.cpp @@ -94,8 +94,8 @@ void yukawa_gpu_clear() { int ** yukawa_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success) { diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 776bdd0b64..de90ded919 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -11,10 +11,6 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#ifdef LAMMPS_BIGBIG -#error LAMMPS_BIGBIG is not yet supported by the GPU package -#endif - #include "string.h" #include "stdlib.h" #include "fix_gpu.h" @@ -163,6 +159,12 @@ int FixGPU::setmask() void FixGPU::init() { + // GPU package cannot be used with atom_style template + + if (atom->molecular == 2) + error->all(FLERR,"GPU package does not (yet) work with " + "atom_style template"); + // hybrid cannot be used with force/neigh option if (_gpu_mode == GPU_NEIGH || _gpu_mode == GPU_HYB_NEIGH) @@ -188,7 +190,7 @@ void FixGPU::init() force->pair->no_virial_fdotr_compute = 1; } - // r-RESPA support + // rRESPA support if (strstr(update->integrate_style,"respa")) _nlevels_respa = ((Respa *) update->integrate)->nlevels; diff --git a/src/GPU/pair_beck_gpu.cpp b/src/GPU/pair_beck_gpu.cpp index b5babba008..8ef8664ac7 100644 --- a/src/GPU/pair_beck_gpu.cpp +++ b/src/GPU/pair_beck_gpu.cpp @@ -37,6 +37,9 @@ #include "gpu_extra.h" #include "math_special.h" +using namespace LAMMPS_NS; +using namespace MathSpecial; + // External functions from cuda library for atom decomposition int beck_gpu_init(const int ntypes, double **cutsq, double **host_aa, @@ -47,8 +50,8 @@ int beck_gpu_init(const int ntypes, double **cutsq, double **host_aa, void beck_gpu_clear(); int ** beck_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -59,9 +62,6 @@ void beck_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double beck_gpu_bytes(); -using namespace LAMMPS_NS; -using namespace MathSpecial; - /* ---------------------------------------------------------------------- */ PairBeckGPU::PairBeckGPU(LAMMPS *lmp) : PairBeck(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_born_coul_long_gpu.cpp b/src/GPU/pair_born_coul_long_gpu.cpp index 073d25ed22..a9fd7a703e 100644 --- a/src/GPU/pair_born_coul_long_gpu.cpp +++ b/src/GPU/pair_born_coul_long_gpu.cpp @@ -46,6 +46,9 @@ #define A4 -1.453152027 #define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace MathConst; + // External functions from cuda library for atom decomposition int borncl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, @@ -61,8 +64,8 @@ int borncl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, void borncl_gpu_clear(); int** borncl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, @@ -75,9 +78,6 @@ void borncl_gpu_compute(const int ago, const int inum_full, const int nall, const int nlocal, double *boxlo, double *prd); double borncl_gpu_bytes(); -using namespace LAMMPS_NS; -using namespace MathConst; - /* ---------------------------------------------------------------------- */ PairBornCoulLongGPU::PairBornCoulLongGPU(LAMMPS *lmp) : diff --git a/src/GPU/pair_born_coul_wolf_gpu.cpp b/src/GPU/pair_born_coul_wolf_gpu.cpp index aa6c989f81..af0d79905d 100644 --- a/src/GPU/pair_born_coul_wolf_gpu.cpp +++ b/src/GPU/pair_born_coul_wolf_gpu.cpp @@ -37,6 +37,9 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; +using namespace MathConst; + // External functions from cuda library for atom decomposition int borncw_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, @@ -52,8 +55,8 @@ int borncw_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, void borncw_gpu_clear(); int ** borncw_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, @@ -66,9 +69,6 @@ void borncw_gpu_compute(const int ago, const int inum_full, const int nall, const int nlocal, double *boxlo, double *prd); double borncw_gpu_bytes(); -using namespace LAMMPS_NS; -using namespace MathConst; - /* ---------------------------------------------------------------------- */ PairBornCoulWolfGPU::PairBornCoulWolfGPU(LAMMPS *lmp) : PairBornCoulWolf(lmp), diff --git a/src/GPU/pair_born_gpu.cpp b/src/GPU/pair_born_gpu.cpp index edd84a6a11..9a95aa3680 100644 --- a/src/GPU/pair_born_gpu.cpp +++ b/src/GPU/pair_born_gpu.cpp @@ -36,6 +36,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int born_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, @@ -48,8 +50,8 @@ int born_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, void born_gpu_clear(); int ** born_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -60,8 +62,6 @@ void born_gpu_compute(const int ago, const int inum_full, const int nall, const double cpu_time, bool &success); double born_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairBornGPU::PairBornGPU(LAMMPS *lmp) : PairBorn(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_buck_coul_cut_gpu.cpp b/src/GPU/pair_buck_coul_cut_gpu.cpp index 9a7485713b..f3a7c04418 100644 --- a/src/GPU/pair_buck_coul_cut_gpu.cpp +++ b/src/GPU/pair_buck_coul_cut_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int buckc_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, @@ -48,8 +50,8 @@ int buckc_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, void buckc_gpu_clear(); int ** buckc_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, @@ -62,8 +64,6 @@ void buckc_gpu_compute(const int ago, const int inum_full, const int nall, const int nlocal, double *boxlo, double *prd); double buckc_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairBuckCoulCutGPU::PairBuckCoulCutGPU(LAMMPS *lmp) : PairBuckCoulCut(lmp), diff --git a/src/GPU/pair_buck_coul_long_gpu.cpp b/src/GPU/pair_buck_coul_long_gpu.cpp index 6787062a09..752e45e0c3 100644 --- a/src/GPU/pair_buck_coul_long_gpu.cpp +++ b/src/GPU/pair_buck_coul_long_gpu.cpp @@ -44,6 +44,8 @@ #define A4 -1.453152027 #define A5 1.061405429 +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int buckcl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, @@ -57,8 +59,8 @@ int buckcl_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, void buckcl_gpu_clear(); int** buckcl_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, @@ -71,8 +73,6 @@ void buckcl_gpu_compute(const int ago, const int inum_full, const int nall, const int nlocal, double *boxlo, double *prd); double buckcl_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairBuckCoulLongGPU::PairBuckCoulLongGPU(LAMMPS *lmp) : diff --git a/src/GPU/pair_buck_gpu.cpp b/src/GPU/pair_buck_gpu.cpp index 56443acff2..c96161d913 100644 --- a/src/GPU/pair_buck_gpu.cpp +++ b/src/GPU/pair_buck_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int buck_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, @@ -46,8 +48,8 @@ int buck_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, void buck_gpu_clear(); int ** buck_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -58,8 +60,6 @@ void buck_gpu_compute(const int ago, const int inum_full, const int nall, const double cpu_time, bool &success); double buck_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairBuckGPU::PairBuckGPU(LAMMPS *lmp) : PairBuck(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_colloid_gpu.cpp b/src/GPU/pair_colloid_gpu.cpp index b2ed92192d..59cde0c337 100644 --- a/src/GPU/pair_colloid_gpu.cpp +++ b/src/GPU/pair_colloid_gpu.cpp @@ -36,6 +36,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int colloid_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -49,8 +51,8 @@ int colloid_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void colloid_gpu_clear(); int ** colloid_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -61,8 +63,6 @@ void colloid_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double colloid_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairColloidGPU::PairColloidGPU(LAMMPS *lmp) : PairColloid(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_coul_dsf_gpu.cpp b/src/GPU/pair_coul_dsf_gpu.cpp index f632fc072a..dc7e8a1d23 100644 --- a/src/GPU/pair_coul_dsf_gpu.cpp +++ b/src/GPU/pair_coul_dsf_gpu.cpp @@ -36,6 +36,15 @@ #include "gpu_extra.h" #define MY_PIS 1.77245385090551602729 +#define EWALD_F 1.12837917 +#define EWALD_P 0.3275911 +#define A1 0.254829592 +#define A2 -0.284496736 +#define A3 1.421413741 +#define A4 -1.453152027 +#define A5 1.061405429 + +using namespace LAMMPS_NS; // External functions from cuda library for atom decomposition @@ -49,8 +58,8 @@ int cdsf_gpu_init(const int ntypes, const int nlocal, const int nall, void cdsf_gpu_clear(); int ** cdsf_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, @@ -64,16 +73,6 @@ void cdsf_gpu_compute(const int ago, const int inum, double *boxlo, double *prd); double cdsf_gpu_bytes(); -using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - /* ---------------------------------------------------------------------- */ PairCoulDSFGPU::PairCoulDSFGPU(LAMMPS *lmp) : PairCoulDSF(lmp), diff --git a/src/GPU/pair_coul_long_gpu.cpp b/src/GPU/pair_coul_long_gpu.cpp index f4c4eff99a..5acad5aa88 100644 --- a/src/GPU/pair_coul_long_gpu.cpp +++ b/src/GPU/pair_coul_long_gpu.cpp @@ -44,6 +44,8 @@ #define A4 -1.453152027 #define A5 1.061405429 +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int cl_gpu_init(const int nlocal, const int nall, const int max_nbors, @@ -53,8 +55,8 @@ int cl_gpu_init(const int nlocal, const int nall, const int max_nbors, void cl_gpu_clear(); int ** cl_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, const bool eflag, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, @@ -67,8 +69,6 @@ void cl_gpu_compute(const int ago, const int inum, const int nall, const int nlocal, double *boxlo, double *prd); double cl_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairCoulLongGPU::PairCoulLongGPU(LAMMPS *lmp) : diff --git a/src/GPU/pair_eam_gpu.cpp b/src/GPU/pair_eam_gpu.cpp index 102d74babd..847391ea51 100644 --- a/src/GPU/pair_eam_gpu.cpp +++ b/src/GPU/pair_eam_gpu.cpp @@ -31,10 +31,10 @@ #include "neigh_request.h" #include "gpu_extra.h" -using namespace LAMMPS_NS; - #define MAXLINE 1024 +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int eam_gpu_init(const int ntypes, double host_cutforcesq, @@ -49,7 +49,7 @@ int eam_gpu_init(const int ntypes, double host_cutforcesq, void eam_gpu_clear(); int** eam_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, int **special, + double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, diff --git a/src/GPU/pair_gauss_gpu.cpp b/src/GPU/pair_gauss_gpu.cpp index 05c2aedc86..8ea04d403b 100644 --- a/src/GPU/pair_gauss_gpu.cpp +++ b/src/GPU/pair_gauss_gpu.cpp @@ -36,6 +36,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int gauss_gpu_init(const int ntypes, double **cutsq, double **host_a, @@ -45,8 +47,8 @@ int gauss_gpu_init(const int ntypes, double **cutsq, double **host_a, void gauss_gpu_clear(); int ** gauss_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -57,8 +59,6 @@ void gauss_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double gauss_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairGaussGPU::PairGaussGPU(LAMMPS *lmp) : PairGauss(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_gayberne_gpu.cpp b/src/GPU/pair_gayberne_gpu.cpp index ec12cdc423..8af4f24a71 100644 --- a/src/GPU/pair_gayberne_gpu.cpp +++ b/src/GPU/pair_gayberne_gpu.cpp @@ -37,6 +37,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int gb_gpu_init(const int ntypes, const double gamma, const double upsilon, @@ -50,7 +52,7 @@ int gb_gpu_init(const int ntypes, const double gamma, const double upsilon, void gb_gpu_clear(); int ** gb_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, int **special, + double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -62,8 +64,6 @@ int * gb_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success, double **host_quat); double gb_gpu_bytes(); -using namespace LAMMPS_NS; - enum{SPHERE_SPHERE,SPHERE_ELLIPSE,ELLIPSE_SPHERE,ELLIPSE_ELLIPSE}; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pair_lj96_cut_gpu.cpp b/src/GPU/pair_lj96_cut_gpu.cpp index cd61efe8ed..516c22c086 100644 --- a/src/GPU/pair_lj96_cut_gpu.cpp +++ b/src/GPU/pair_lj96_cut_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int lj96_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -45,8 +47,8 @@ int lj96_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void lj96_gpu_clear(); int ** lj96_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -57,8 +59,6 @@ void lj96_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double lj96_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJ96CutGPU::PairLJ96CutGPU(LAMMPS *lmp) : PairLJ96Cut(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_lj_charmm_coul_long_gpu.cpp b/src/GPU/pair_lj_charmm_coul_long_gpu.cpp index 226486e92d..d77c39e90f 100644 --- a/src/GPU/pair_lj_charmm_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_charmm_coul_long_gpu.cpp @@ -44,6 +44,8 @@ #define A4 -1.453152027 #define A5 1.061405429 +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int crml_gpu_init(const int ntypes, double cut_bothsq, double **host_lj1, @@ -59,8 +61,8 @@ int crml_gpu_init(const int ntypes, double cut_bothsq, double **host_lj1, void crml_gpu_clear(); int ** crml_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, const bool eflag, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, @@ -73,8 +75,6 @@ void crml_gpu_compute(const int ago, const int inum, const int nall, const int nlocal, double *boxlo, double *prd); double crml_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJCharmmCoulLongGPU::PairLJCharmmCoulLongGPU(LAMMPS *lmp) : diff --git a/src/GPU/pair_lj_class2_coul_long_gpu.cpp b/src/GPU/pair_lj_class2_coul_long_gpu.cpp index 9c02f93c18..a1417ab6ed 100644 --- a/src/GPU/pair_lj_class2_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_class2_coul_long_gpu.cpp @@ -44,6 +44,8 @@ #define A4 -1.453152027 #define A5 1.061405429 +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int c2cl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -57,8 +59,8 @@ int c2cl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void c2cl_gpu_clear(); int ** c2cl_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, const bool eflag, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, @@ -71,8 +73,6 @@ void c2cl_gpu_compute(const int ago, const int inum, const int nall, const int nlocal, double *boxlo, double *prd); double c2cl_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJClass2CoulLongGPU::PairLJClass2CoulLongGPU(LAMMPS *lmp) : diff --git a/src/GPU/pair_lj_class2_gpu.cpp b/src/GPU/pair_lj_class2_gpu.cpp index 8e1100b097..8ae2561246 100644 --- a/src/GPU/pair_lj_class2_gpu.cpp +++ b/src/GPU/pair_lj_class2_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int lj96_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -45,8 +47,8 @@ int lj96_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void lj96_gpu_clear(); int ** lj96_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -57,8 +59,6 @@ void lj96_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double lj96_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJClass2GPU::PairLJClass2GPU(LAMMPS *lmp) : PairLJClass2(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_lj_cut_coul_cut_gpu.cpp b/src/GPU/pair_lj_cut_coul_cut_gpu.cpp index 8d83ceb255..43edaa67bc 100644 --- a/src/GPU/pair_lj_cut_coul_cut_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_cut_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int ljc_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -47,8 +49,8 @@ int ljc_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void ljc_gpu_clear(); int ** ljc_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, @@ -62,8 +64,6 @@ void ljc_gpu_compute(const int ago, const int inum, double *boxlo, double *prd); double ljc_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJCutCoulCutGPU::PairLJCutCoulCutGPU(LAMMPS *lmp) : PairLJCutCoulCut(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_lj_cut_coul_debye_gpu.cpp b/src/GPU/pair_lj_cut_coul_debye_gpu.cpp index e4c756c7f7..0b7fca3002 100644 --- a/src/GPU/pair_lj_cut_coul_debye_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_debye_gpu.cpp @@ -36,6 +36,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int ljcd_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -49,8 +51,8 @@ int ljcd_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void ljcd_gpu_clear(); int ** ljcd_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, @@ -64,8 +66,6 @@ void ljcd_gpu_compute(const int ago, const int inum, const int nall, double *boxlo, double *prd); double ljcd_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJCutCoulDebyeGPU::PairLJCutCoulDebyeGPU(LAMMPS *lmp) : diff --git a/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp b/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp index 7822c4e675..ea61ea3ebc 100644 --- a/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp @@ -36,6 +36,15 @@ #include "gpu_extra.h" #define MY_PIS 1.77245385090551602729 +#define EWALD_F 1.12837917 +#define EWALD_P 0.3275911 +#define A1 0.254829592 +#define A2 -0.284496736 +#define A3 1.421413741 +#define A4 -1.453152027 +#define A5 1.061405429 + +using namespace LAMMPS_NS; // External functions from cuda library for atom decomposition @@ -51,8 +60,8 @@ int ljd_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void ljd_gpu_clear(); int ** ljd_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, @@ -66,16 +75,6 @@ void ljd_gpu_compute(const int ago, const int inum, double *boxlo, double *prd); double ljd_gpu_bytes(); -using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - /* ---------------------------------------------------------------------- */ PairLJCutCoulDSFGPU::PairLJCutCoulDSFGPU(LAMMPS *lmp) : PairLJCutCoulDSF(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_lj_cut_coul_long_gpu.cpp b/src/GPU/pair_lj_cut_coul_long_gpu.cpp index 513034facb..bd64c92e85 100644 --- a/src/GPU/pair_lj_cut_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_long_gpu.cpp @@ -44,6 +44,8 @@ #define A4 -1.453152027 #define A5 1.061405429 +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int ljcl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -57,8 +59,8 @@ int ljcl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void ljcl_gpu_clear(); int ** ljcl_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, const bool eflag, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, @@ -71,8 +73,6 @@ void ljcl_gpu_compute(const int ago, const int inum, const int nall, const int nlocal, double *boxlo, double *prd); double ljcl_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJCutCoulLongGPU::PairLJCutCoulLongGPU(LAMMPS *lmp) : diff --git a/src/GPU/pair_lj_cut_coul_msm_gpu.cpp b/src/GPU/pair_lj_cut_coul_msm_gpu.cpp index c9fad77f61..78e0243c36 100644 --- a/src/GPU/pair_lj_cut_coul_msm_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_msm_gpu.cpp @@ -37,6 +37,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int ljcm_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -50,8 +52,8 @@ int ljcm_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void ljcm_gpu_clear(); int ** ljcm_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, double *prd); @@ -63,8 +65,6 @@ void ljcm_gpu_compute(const int ago, const int inum, const int nall, const int nlocal, double *boxlo, double *prd); double ljcm_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJCutCoulMSMGPU::PairLJCutCoulMSMGPU(LAMMPS *lmp) : diff --git a/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp b/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp index e70cc3af85..65d037e524 100644 --- a/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp +++ b/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp @@ -36,6 +36,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int dpl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -48,8 +50,8 @@ int dpl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void dpl_gpu_clear(); int ** dpl_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, - int **nspecial, int **special, const bool eflag, + double *sublo, double *subhi, tagint *tag, + int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, @@ -64,8 +66,6 @@ void dpl_gpu_compute(const int ago, const int inum, const int nlocal, double *boxlo, double *prd); double dpl_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJCutDipoleCutGPU::PairLJCutDipoleCutGPU(LAMMPS *lmp) : PairLJCutDipoleCut(lmp), diff --git a/src/GPU/pair_lj_cut_gpu.cpp b/src/GPU/pair_lj_cut_gpu.cpp index 3d4db278c6..01d3053f09 100644 --- a/src/GPU/pair_lj_cut_gpu.cpp +++ b/src/GPU/pair_lj_cut_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int ljl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -45,8 +47,8 @@ int ljl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void ljl_gpu_clear(); int ** ljl_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -57,8 +59,6 @@ void ljl_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double ljl_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJCutGPU::PairLJCutGPU(LAMMPS *lmp) : PairLJCut(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_lj_expand_gpu.cpp b/src/GPU/pair_lj_expand_gpu.cpp index 11f5495b8e..521af1c03e 100644 --- a/src/GPU/pair_lj_expand_gpu.cpp +++ b/src/GPU/pair_lj_expand_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int lje_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -46,8 +48,8 @@ int lje_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void lje_gpu_clear(); int ** lje_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -58,8 +60,6 @@ void lje_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double lje_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJExpandGPU::PairLJExpandGPU(LAMMPS *lmp) : PairLJExpand(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_lj_gromacs_gpu.cpp b/src/GPU/pair_lj_gromacs_gpu.cpp index 97d2f53884..d3d10c6a10 100644 --- a/src/GPU/pair_lj_gromacs_gpu.cpp +++ b/src/GPU/pair_lj_gromacs_gpu.cpp @@ -37,6 +37,8 @@ #include "kspace.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int ljgrm_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -50,8 +52,8 @@ int ljgrm_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void ljgrm_gpu_clear(); int ** ljgrm_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -62,9 +64,6 @@ void ljgrm_gpu_compute(const int ago, const int inum_full, const int nall, const double cpu_time, bool &success); double ljgrm_gpu_bytes(); - -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJGromacsGPU::PairLJGromacsGPU(LAMMPS *lmp) : diff --git a/src/GPU/pair_lj_sdk_coul_long_gpu.cpp b/src/GPU/pair_lj_sdk_coul_long_gpu.cpp index 6fd58dd0f5..2f33c17d02 100644 --- a/src/GPU/pair_lj_sdk_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_sdk_coul_long_gpu.cpp @@ -44,6 +44,8 @@ #define A4 -1.453152027 #define A5 1.061405429 +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int cmml_gpu_init(const int ntypes, double **cutsq, int **lj_type, @@ -57,8 +59,8 @@ int cmml_gpu_init(const int ntypes, double **cutsq, int **lj_type, void cmml_gpu_clear(); int ** cmml_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double *boxlo, @@ -73,7 +75,7 @@ double cmml_gpu_bytes(); #include "lj_sdk_common.h" -using namespace LAMMPS_NS; + using namespace LJSDKParms; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pair_lj_sdk_gpu.cpp b/src/GPU/pair_lj_sdk_gpu.cpp index 745433458b..8adfd1f3dd 100644 --- a/src/GPU/pair_lj_sdk_gpu.cpp +++ b/src/GPU/pair_lj_sdk_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int cmm_gpu_init(const int ntypes, double **cutsq, int **cg_types, @@ -46,8 +48,8 @@ int cmm_gpu_init(const int ntypes, double **cutsq, int **cg_types, void cmm_gpu_clear(); int ** cmm_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -60,7 +62,6 @@ double cmm_gpu_bytes(); #include "lj_sdk_common.h" -using namespace LAMMPS_NS; using namespace LJSDKParms; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp b/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp index dfe482b82b..33f6a712d9 100644 --- a/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp +++ b/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp @@ -36,6 +36,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int dplsf_gpu_init(const int ntypes, double **cutsq, double **host_lj1, @@ -48,8 +50,8 @@ int dplsf_gpu_init(const int ntypes, double **cutsq, double **host_lj1, void dplsf_gpu_clear(); int ** dplsf_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_q, double **host_mu, @@ -63,8 +65,6 @@ void dplsf_gpu_compute(const int ago, const int inum, double *boxlo, double *prd); double dplsf_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairLJSFDipoleSFGPU::PairLJSFDipoleSFGPU(LAMMPS *lmp) : PairLJSFDipoleSF(lmp), diff --git a/src/GPU/pair_mie_cut_gpu.cpp b/src/GPU/pair_mie_cut_gpu.cpp index b4771d5956..e92f5bf925 100644 --- a/src/GPU/pair_mie_cut_gpu.cpp +++ b/src/GPU/pair_mie_cut_gpu.cpp @@ -36,6 +36,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int mie_gpu_init(const int ntypes, double **cutsq, double **host_mie1, @@ -47,8 +49,8 @@ int mie_gpu_init(const int ntypes, double **cutsq, double **host_mie1, void mie_gpu_clear(); int ** mie_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -59,8 +61,6 @@ void mie_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double mie_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairMIECutGPU::PairMIECutGPU(LAMMPS *lmp) : PairMIECut(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_morse_gpu.cpp b/src/GPU/pair_morse_gpu.cpp index 0deae8ef12..c24f1f2615 100644 --- a/src/GPU/pair_morse_gpu.cpp +++ b/src/GPU/pair_morse_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int mor_gpu_init(const int ntypes, double **cutsq, double **host_morse1, @@ -45,8 +47,8 @@ int mor_gpu_init(const int ntypes, double **cutsq, double **host_morse1, void mor_gpu_clear(); int ** mor_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -57,8 +59,6 @@ void mor_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double mor_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairMorseGPU::PairMorseGPU(LAMMPS *lmp) : PairMorse(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_resquared_gpu.cpp b/src/GPU/pair_resquared_gpu.cpp index 07cf75906e..4bc0903139 100644 --- a/src/GPU/pair_resquared_gpu.cpp +++ b/src/GPU/pair_resquared_gpu.cpp @@ -37,6 +37,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int re_gpu_init(const int ntypes, double **shape, double **well, @@ -49,7 +51,7 @@ int re_gpu_init(const int ntypes, double **shape, double **well, void re_gpu_clear(); int ** re_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, int **special, + double *subhi, tagint *tag, int **nspecial, tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, @@ -61,8 +63,6 @@ int * re_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success, double **host_quat); double re_gpu_bytes(); -using namespace LAMMPS_NS; - enum{SPHERE_SPHERE,SPHERE_ELLIPSE,ELLIPSE_SPHERE,ELLIPSE_ELLIPSE}; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pair_soft_gpu.cpp b/src/GPU/pair_soft_gpu.cpp index f6efaf2feb..d4d5f10111 100644 --- a/src/GPU/pair_soft_gpu.cpp +++ b/src/GPU/pair_soft_gpu.cpp @@ -37,6 +37,8 @@ #include "gpu_extra.h" #include "math_const.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int soft_gpu_init(const int ntypes, double **cutsq, double **prefactor, @@ -46,8 +48,8 @@ int soft_gpu_init(const int ntypes, double **cutsq, double **prefactor, void soft_gpu_clear(); int ** soft_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -58,7 +60,7 @@ void soft_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double soft_gpu_bytes(); -using namespace LAMMPS_NS; + using namespace MathConst; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pair_sw_gpu.cpp b/src/GPU/pair_sw_gpu.cpp index db7a1f6617..d27b45da36 100644 --- a/src/GPU/pair_sw_gpu.cpp +++ b/src/GPU/pair_sw_gpu.cpp @@ -33,6 +33,8 @@ #include "domain.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int sw_gpu_init(const int ntypes, const int inum, const int nall, const int max_nbors, @@ -47,8 +49,8 @@ int sw_gpu_init(const int ntypes, const int inum, const int nall, const int max_ void sw_gpu_clear(); int ** sw_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -61,8 +63,6 @@ double sw_gpu_bytes(); extern double lmp_gpu_forces(double **f, double **tor, double *eatom, double **vatom, double *virial, double &ecoul); -using namespace LAMMPS_NS; - #define MAXLINE 1024 #define DELTA 4 diff --git a/src/GPU/pair_table_gpu.cpp b/src/GPU/pair_table_gpu.cpp index 797ac8268d..35045bb2c9 100644 --- a/src/GPU/pair_table_gpu.cpp +++ b/src/GPU/pair_table_gpu.cpp @@ -40,6 +40,8 @@ #define SPLINE 2 #define BITMAP 3 +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int table_gpu_init(const int ntypes, double **cutsq, @@ -51,8 +53,8 @@ int table_gpu_init(const int ntypes, double **cutsq, void table_gpu_clear(); int ** table_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -63,8 +65,6 @@ void table_gpu_compute(const int ago, const int inum, const int nall, const double cpu_time, bool &success); double table_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairTableGPU::PairTableGPU(LAMMPS *lmp) : PairTable(lmp), diff --git a/src/GPU/pair_yukawa_colloid_gpu.cpp b/src/GPU/pair_yukawa_colloid_gpu.cpp index 4cd7c6bba5..dfff5465ed 100644 --- a/src/GPU/pair_yukawa_colloid_gpu.cpp +++ b/src/GPU/pair_yukawa_colloid_gpu.cpp @@ -36,6 +36,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int ykcolloid_gpu_init(const int ntypes, double **cutsq, double **host_a, @@ -46,8 +48,8 @@ int ykcolloid_gpu_init(const int ntypes, double **cutsq, double **host_a, void ykcolloid_gpu_clear(); int ** ykcolloid_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, - double *sublo, double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *sublo, double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success, double *host_rad); @@ -59,8 +61,6 @@ void ykcolloid_gpu_compute(const int ago, const int inum_full, const double cpu_time, bool &success, double *host_rad); double ykcolloid_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairYukawaColloidGPU::PairYukawaColloidGPU(LAMMPS *lmp) : PairYukawaColloid(lmp), diff --git a/src/GPU/pair_yukawa_gpu.cpp b/src/GPU/pair_yukawa_gpu.cpp index 49554e5469..c120f6a890 100644 --- a/src/GPU/pair_yukawa_gpu.cpp +++ b/src/GPU/pair_yukawa_gpu.cpp @@ -35,6 +35,8 @@ #include "string.h" #include "gpu_extra.h" +using namespace LAMMPS_NS; + // External functions from cuda library for atom decomposition int yukawa_gpu_init(const int ntypes, double **cutsq, double kappa, @@ -45,8 +47,8 @@ int yukawa_gpu_init(const int ntypes, double **cutsq, double kappa, void yukawa_gpu_clear(); int ** yukawa_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, - double *subhi, int *tag, int **nspecial, - int **special, const bool eflag, const bool vflag, + double *subhi, tagint *tag, int **nspecial, + tagint **special, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, int **ilist, int **jnum, const double cpu_time, bool &success); @@ -57,8 +59,6 @@ void yukawa_gpu_compute(const int ago, const int inum_full, const int nall, const double cpu_time, bool &success); double yukawa_gpu_bytes(); -using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ PairYukawaGPU::PairYukawaGPU(LAMMPS *lmp) : PairYukawa(lmp), diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp index 55411a735d..55e5191b0e 100644 --- a/src/GRANULAR/fix_pour.cpp +++ b/src/GRANULAR/fix_pour.cpp @@ -121,9 +121,14 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Fix pour molecule must have coordinates"); if (onemol->typeflag == 0) error->all(FLERR,"Fix pour molecule must have atom types"); - if (ntype+onemol->maxtype <= 0 || ntype+onemol->maxtype > atom->ntypes) + if (ntype+onemol->ntypes <= 0 || ntype+onemol->ntypes > atom->ntypes) error->all(FLERR,"Invalid atom type in fix pour mol command"); + if (atom->molecular == 2 && onemol != atom->avec->onemols[0]) + error->all(FLERR,"Fix pour molecule template ID must be same " + "as atom style template ID"); + onemol->check_attributes(0); + // fix pour uses geoemetric center of molecule for insertion onemol->compute_center(); @@ -325,7 +330,8 @@ void FixPour::init() int tmp; if (onemol != (Molecule *) fixrigid->extract("onemol",tmp)) error->all(FLERR, - "Fix pour and fix rigid/small not using same molecule ID"); + "Fix pour and fix rigid/small not using " + "same molecule template ID"); } // if shakeflag defined, check for SHAKE fix @@ -338,7 +344,8 @@ void FixPour::init() fixshake = modify->fix[ifix]; int tmp; if (onemol != (Molecule *) fixshake->extract("onemol",tmp)) - error->all(FLERR,"Fix pour and fix shake not using same molecule ID"); + error->all(FLERR,"Fix pour and fix shake not using " + "same molecule template ID"); } } @@ -585,8 +592,13 @@ void FixPour::pre_exchange() else atom->avec->create_atom(ntype+onemol->type[m],coords[m]); int n = atom->nlocal - 1; atom->tag[n] = maxtag_all + m+1; - if (mode == MOLECULE && atom->molecule_flag) - atom->molecule[n] = maxmol_all+1; + if (mode == MOLECULE) { + if (atom->molecular) atom->molecule[n] = maxmol_all+1; + if (atom->molecular == 2) { + atom->molindex[n] = 0; + atom->molatom[n] = m; + } + } atom->mask[n] = 1 | groupbit; atom->image[n] = imageflags[m]; atom->v[n][0] = vnew[0]; diff --git a/src/MC/fix_bond_break.cpp b/src/MC/fix_bond_break.cpp index 50f718492c..53b10ddba5 100644 --- a/src/MC/fix_bond_break.cpp +++ b/src/MC/fix_bond_break.cpp @@ -78,7 +78,7 @@ FixBondBreak::FixBondBreak(LAMMPS *lmp, int narg, char **arg) : // error check - if (atom->molecular == 0) + if (atom->molecular != 1) error->all(FLERR,"Cannot use fix bond/break with non-molecular systems"); // initialize Marsaglia RNG with processor-unique seed diff --git a/src/MC/fix_bond_create.cpp b/src/MC/fix_bond_create.cpp index 015a527015..ee7cfa2767 100644 --- a/src/MC/fix_bond_create.cpp +++ b/src/MC/fix_bond_create.cpp @@ -107,7 +107,7 @@ FixBondCreate::FixBondCreate(LAMMPS *lmp, int narg, char **arg) : // error check - if (atom->molecular == 0) + if (atom->molecular != 1) error->all(FLERR,"Cannot use fix bond/create with non-molecular systems"); if (iatomtype == jatomtype && ((imaxbond != jmaxbond) || (inewtype != jnewtype))) diff --git a/src/MC/fix_bond_swap.cpp b/src/MC/fix_bond_swap.cpp index 79b298391a..de5c9ebec2 100644 --- a/src/MC/fix_bond_swap.cpp +++ b/src/MC/fix_bond_swap.cpp @@ -72,6 +72,11 @@ FixBondSwap::FixBondSwap(LAMMPS *lmp, int narg, char **arg) : int seed = force->inumeric(FLERR,arg[5]); random = new RanMars(lmp,seed + comm->me); + // error check + + if (atom->molecular != 1) + error->all(FLERR,"Cannot use fix bond/swap with non-molecular systems"); + // create a new compute temp style // id = fix-ID + temp, compute group = fix group diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index 4dd5593706..5fe5882b7a 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -49,6 +49,9 @@ FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) : { if (narg < 11) error->all(FLERR,"Illegal fix gcmc command"); + if (atom->molecular == 2) + error->all(FLERR,"Fix gcmc does not (yet) work with atom_style template"); + vector_flag = 1; size_vector = 8; global_freq = 1; @@ -1076,21 +1079,12 @@ void FixGCMC::get_model_molecule() // old_atom = original atom class // atom = new model atom class - // if old_atom style was hybrid, pass sub-style names to create_avec Atom *old_atom = atom; atom = new Atom(lmp); atom->settings(old_atom); - - int nstyles = 0; - char **keywords = NULL; - if (strcmp(old_atom->atom_style,"hybrid") == 0) { - AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) old_atom->avec; - nstyles = avec_hybrid->nstyles; - keywords = avec_hybrid->keywords; - } - - atom->create_avec(old_atom->atom_style,nstyles,keywords); + atom->create_avec(old_atom->atom_style, + old_atom->avec->nargcopy,old_atom->avec->argcopy); // assign atom and topology counts in model atom class from old_atom diff --git a/src/MISC/fix_deposit.cpp b/src/MISC/fix_deposit.cpp index f1f16a424f..371feda868 100644 --- a/src/MISC/fix_deposit.cpp +++ b/src/MISC/fix_deposit.cpp @@ -103,9 +103,14 @@ FixDeposit::FixDeposit(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Fix deposit molecule must have coordinates"); if (onemol->typeflag == 0) error->all(FLERR,"Fix deposit molecule must have atom types"); - if (ntype+onemol->maxtype <= 0 || ntype+onemol->maxtype > atom->ntypes) + if (ntype+onemol->ntypes <= 0 || ntype+onemol->ntypes > atom->ntypes) error->all(FLERR,"Invalid atom type in fix deposit mol command"); + if (atom->molecular == 2 && onemol != atom->avec->onemols[0]) + error->all(FLERR,"Fix deposit molecule template ID must be same " + "as atom style template ID"); + onemol->check_attributes(0); + // fix deposit uses geoemetric center of molecule for insertion onemol->compute_center(); @@ -216,7 +221,8 @@ void FixDeposit::init() int tmp; if (onemol != (Molecule *) fixrigid->extract("onemol",tmp)) error->all(FLERR, - "Fix deposit and fix rigid/small not using same molecule ID"); + "Fix deposit and fix rigid/small not using " + "same molecule template ID"); } // if shakeflag defined, check for SHAKE fix @@ -229,7 +235,8 @@ void FixDeposit::init() fixshake = modify->fix[ifix]; int tmp; if (onemol != (Molecule *) fixshake->extract("onemol",tmp)) - error->all(FLERR,"Fix deposit and fix shake not using same molecule ID"); + error->all(FLERR,"Fix deposit and fix shake not using " + "same molecule template ID"); } } @@ -442,8 +449,13 @@ void FixDeposit::pre_exchange() else atom->avec->create_atom(ntype+onemol->type[m],coords[m]); n = atom->nlocal - 1; atom->tag[n] = maxtag_all + m+1; - if (mode == MOLECULE && atom->molecule_flag) - atom->molecule[n] = maxmol_all+1; + if (mode == MOLECULE) { + if (atom->molecular) atom->molecule[n] = maxmol_all+1; + if (atom->molecular == 2) { + atom->molindex[n] = 0; + atom->molatom[n] = m; + } + } atom->mask[n] = 1 | groupbit; atom->image[n] = imageflags[m]; atom->v[n][0] = vnew[0]; diff --git a/src/MISC/fix_evaporate.cpp b/src/MISC/fix_evaporate.cpp index 421c22e666..208c944514 100644 --- a/src/MISC/fix_evaporate.cpp +++ b/src/MISC/fix_evaporate.cpp @@ -17,6 +17,7 @@ #include "fix_evaporate.h" #include "atom.h" #include "atom_vec.h" +#include "molecule.h" #include "update.h" #include "domain.h" #include "region.h" @@ -234,9 +235,13 @@ void FixEvaporate::pre_exchange() // keep ndel,ndeltopo,ncount,nall,nbefore current after each mol deletion } else { - int me,proc,iatom,ndelone,ndelall; - tagint imol; + int me,proc,iatom,ndelone,ndelall,index; + tagint imolecule; tagint *molecule = atom->molecule; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + int molecular = atom->molecular; + Molecule **onemols = atom->avec->onemols; ndeltopo[0] = ndeltopo[1] = ndeltopo[2] = ndeltopo[3] = 0; @@ -248,57 +253,70 @@ void FixEvaporate::pre_exchange() if (iwhichglobal >= nbefore && iwhichglobal < nbefore + ncount) { iwhichlocal = iwhichglobal - nbefore; iatom = list[iwhichlocal]; - imol = molecule[iatom]; + imolecule = molecule[iatom]; me = comm->me; } else me = -1; // bcast mol ID to delete all atoms from // if mol ID > 0, delete any atom in molecule and decrement counters // if mol ID == 0, delete single iatom - // be careful to delete correct # of bond,angle,etc for newton on or off + // logic with ndeltopo is to count # of deleted bonds,angles,etc + // for atom->molecular = 1, do this for each deleted atom in molecule + // for atom->molecular = 2, use Molecule counts for just 1st atom in mol MPI_Allreduce(&me,&proc,1,MPI_INT,MPI_MAX,world); - MPI_Bcast(&imol,1,MPI_LMP_TAGINT,proc,world); + MPI_Bcast(&imolecule,1,MPI_LMP_TAGINT,proc,world); ndelone = 0; for (i = 0; i < nlocal; i++) { - if (imol && molecule[i] == imol) { + if (imolecule && molecule[i] == imolecule) { mark[i] = 1; ndelone++; - if (atom->avec->bonds_allow) { - if (force->newton_bond) ndeltopo[0] += atom->num_bond[i]; - else { - for (j = 0; j < atom->num_bond[i]; j++) { - if (tag[i] < atom->bond_atom[i][j]) ndeltopo[0]++; + if (molecular == 1) { + if (atom->avec->bonds_allow) { + if (force->newton_bond) ndeltopo[0] += atom->num_bond[i]; + else { + for (j = 0; j < atom->num_bond[i]; j++) { + if (tag[i] < atom->bond_atom[i][j]) ndeltopo[0]++; + } } } - } - if (atom->avec->angles_allow) { - if (force->newton_bond) ndeltopo[1] += atom->num_angle[i]; - else { - for (j = 0; j < atom->num_angle[i]; j++) { - m = atom->map(atom->angle_atom2[i][j]); - if (m >= 0 && m < nlocal) ndeltopo[1]++; + if (atom->avec->angles_allow) { + if (force->newton_bond) ndeltopo[1] += atom->num_angle[i]; + else { + for (j = 0; j < atom->num_angle[i]; j++) { + m = atom->map(atom->angle_atom2[i][j]); + if (m >= 0 && m < nlocal) ndeltopo[1]++; + } } } - } - if (atom->avec->dihedrals_allow) { - if (force->newton_bond) ndeltopo[2] += atom->num_dihedral[i]; - else { - for (j = 0; j < atom->num_dihedral[i]; j++) { - m = atom->map(atom->dihedral_atom2[i][j]); - if (m >= 0 && m < nlocal) ndeltopo[2]++; + if (atom->avec->dihedrals_allow) { + if (force->newton_bond) ndeltopo[2] += atom->num_dihedral[i]; + else { + for (j = 0; j < atom->num_dihedral[i]; j++) { + m = atom->map(atom->dihedral_atom2[i][j]); + if (m >= 0 && m < nlocal) ndeltopo[2]++; + } } } - } - if (atom->avec->impropers_allow) { - if (force->newton_bond) ndeltopo[3] += atom->num_improper[i]; - else { - for (j = 0; j < atom->num_improper[i]; j++) { - m = atom->map(atom->improper_atom2[i][j]); - if (m >= 0 && m < nlocal) ndeltopo[3]++; + if (atom->avec->impropers_allow) { + if (force->newton_bond) ndeltopo[3] += atom->num_improper[i]; + else { + for (j = 0; j < atom->num_improper[i]; j++) { + m = atom->map(atom->improper_atom2[i][j]); + if (m >= 0 && m < nlocal) ndeltopo[3]++; + } } } + + } else { + if (molatom[i] == 0) { + index = molindex[i]; + ndeltopo[0] += onemols[index]->nbonds; + ndeltopo[1] += onemols[index]->nangles; + ndeltopo[2] += onemols[index]->ndihedrals; + ndeltopo[3] += onemols[index]->nimpropers; + } } } else if (me == proc && i == iatom) { diff --git a/src/MOLECULE/atom_vec_template.cpp b/src/MOLECULE/atom_vec_template.cpp new file mode 100644 index 0000000000..bde8b14d7c --- /dev/null +++ b/src/MOLECULE/atom_vec_template.cpp @@ -0,0 +1,873 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "string.h" +#include "stdlib.h" +#include "atom_vec_template.h" +#include "atom.h" +#include "molecule.h" +#include "comm.h" +#include "domain.h" +#include "modify.h" +#include "fix.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; + +#define DELTA 10000 + +/* ---------------------------------------------------------------------- */ + +AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp) +{ + molecular = 2; + mass_type = 1; + + comm_x_only = comm_f_only = 1; + size_forward = 3; + size_reverse = 3; + size_border = 9; + size_velocity = 3; + size_data_atom = 8; + size_data_vel = 4; + xcol_data = 6; + + atom->molecule_flag = 1; +} + +/* ---------------------------------------------------------------------- + process additional arg = molecule template ID +------------------------------------------------------------------------- */ + +void AtomVecTemplate::process_args(int narg, char **arg) +{ + if (narg != 1) error->all(FLERR,"Invalid atom_style template command"); + + int imol = atom->find_molecule(arg[0]); + if (imol == -1) error->all(FLERR,"Molecule template ID for " + "atom_style template does not exist"); + + onemols = &atom->molecules[imol]; + nset = atom->molecules[imol]->nset; + + // error check on molecule template fields + + for (int i = 0; i < nset; i++) { + if (onemols[i]->typeflag == 0) + error->all(FLERR,"Atom style template molecule must have atom types"); + + // set bonds_allow,angles_allow,etc based on the molecules in template set + // similar to how atom_style bond,angle,full set it + + for (int i = 0; i < nset; i++) { + if (onemols[i]->bondflag) bonds_allow = 1; + if (onemols[i]->angleflag) angles_allow = 1; + if (onemols[i]->dihedralflag) dihedrals_allow = 1; + if (onemols[i]->improperflag) impropers_allow = 1; + } + + // set nbondtypes,nangletypes,etc based on the molecules in template set + // do this here b/c data file will typically not contain these settings + + for (int i = 0; i < nset; i++) { + atom->nbondtypes = MAX(atom->nbondtypes,onemols[i]->nbondtypes); + atom->nangletypes = MAX(atom->nangletypes,onemols[i]->nangletypes); + atom->ndihedraltypes = MAX(atom->ndihedraltypes,onemols[i]->ndihedraltypes); + atom->nimpropertypes = MAX(atom->nimpropertypes,onemols[i]->nimpropertypes); + } +} + +/* ---------------------------------------------------------------------- + grow atom arrays + n = 0 grows arrays by DELTA + n > 0 allocates arrays to size n +------------------------------------------------------------------------- */ + +void AtomVecTemplate::grow(int n) +{ + if (n == 0) nmax += DELTA; + else nmax = n; + atom->nmax = nmax; + if (nmax < 0 || nmax > MAXSMALLINT) + error->one(FLERR,"Per-processor system is too big"); + + tag = memory->grow(atom->tag,nmax,"atom:tag"); + type = memory->grow(atom->type,nmax,"atom:type"); + mask = memory->grow(atom->mask,nmax,"atom:mask"); + image = memory->grow(atom->image,nmax,"atom:image"); + x = memory->grow(atom->x,nmax,3,"atom:x"); + v = memory->grow(atom->v,nmax,3,"atom:v"); + f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f"); + + molecule = memory->grow(atom->molecule,nmax,"atom:molecule"); + molindex = memory->grow(atom->molindex,nmax,"atom:molindex"); + molatom = memory->grow(atom->molatom,nmax,"atom:molatom"); + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); +} + +/* ---------------------------------------------------------------------- + reset local array ptrs +------------------------------------------------------------------------- */ + +void AtomVecTemplate::grow_reset() +{ + tag = atom->tag; type = atom->type; + mask = atom->mask; image = atom->image; + x = atom->x; v = atom->v; f = atom->f; + molecule = atom->molecule; + molindex = atom->molindex; molatom = atom->molatom; +} + +/* ---------------------------------------------------------------------- + copy atom I info to atom J +------------------------------------------------------------------------- */ + +void AtomVecTemplate::copy(int i, int j, int delflag) +{ + tag[j] = tag[i]; + type[j] = type[i]; + mask[j] = mask[i]; + image[j] = image[i]; + x[j][0] = x[i][0]; + x[j][1] = x[i][1]; + x[j][2] = x[i][2]; + v[j][0] = v[i][0]; + v[j][1] = v[i][1]; + v[j][2] = v[i][2]; + + molecule[j] = molecule[i]; + molindex[j] = molindex[i]; + molatom[j] = molatom[i]; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag); +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecTemplate::pack_comm(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; + dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; + dz = pbc[2]*domain->zprd; + } + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecTemplate::pack_comm_vel(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz,dvx,dvy,dvz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz; + dy = pbc[1]*domain->yprd + pbc[3]*domain->yz; + dz = pbc[2]*domain->zprd; + } + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecTemplate::unpack_comm(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + } +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecTemplate::unpack_comm_vel(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + v[i][0] = buf[m++]; + v[i][1] = buf[m++]; + v[i][2] = buf[m++]; + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecTemplate::pack_reverse(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = f[i][0]; + buf[m++] = f[i][1]; + buf[m++] = f[i][2]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecTemplate::unpack_reverse(int n, int *list, double *buf) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + f[j][0] += buf[m++]; + f[j][1] += buf[m++]; + f[j][2] += buf[m++]; + } +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecTemplate::pack_border(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = ubuf(molindex[j]).d; + buf[m++] = ubuf(molatom[j]).d; + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = ubuf(molindex[j]).d; + buf[m++] = ubuf(molatom[j]).d; + } + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); + + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecTemplate::pack_border_vel(int n, int *list, double *buf, + int pbc_flag, int *pbc) +{ + int i,j,m; + double dx,dy,dz,dvx,dvy,dvz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = ubuf(molindex[j]).d; + buf[m++] = ubuf(molatom[j]).d; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0]*domain->xprd; + dy = pbc[1]*domain->yprd; + dz = pbc[2]*domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = ubuf(molindex[j]).d; + buf[m++] = ubuf(molatom[j]).d; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } else { + dvx = pbc[0]*h_rate[0] + pbc[5]*h_rate[5] + pbc[4]*h_rate[4]; + dvy = pbc[1]*h_rate[1] + pbc[3]*h_rate[3]; + dvz = pbc[2]*h_rate[2]; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = ubuf(molindex[j]).d; + buf[m++] = ubuf(molatom[j]).d; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; + } + } + } + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->pack_border(n,list,&buf[m]); + + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecTemplate::pack_border_hybrid(int n, int *list, double *buf) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(molecule[j]).d; + buf[m++] = ubuf(molindex[j]).d; + buf[m++] = ubuf(molatom[j]).d; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecTemplate::unpack_border(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (i == nmax) grow(0); + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + tag[i] = (tagint) ubuf(buf[m++]).i; + type[i] = (int) ubuf(buf[m++]).i; + mask[i] = (int) ubuf(buf[m++]).i; + molecule[i] = (tagint) ubuf(buf[m++]).i; + molindex[i] = (int) ubuf(buf[m++]).i; + molatom[i] = (int) ubuf(buf[m++]).i; + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]-> + unpack_border(n,first,&buf[m]); +} + +/* ---------------------------------------------------------------------- */ + +void AtomVecTemplate::unpack_border_vel(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (i == nmax) grow(0); + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + tag[i] = (tagint) ubuf(buf[m++]).i; + type[i] = (int) ubuf(buf[m++]).i; + mask[i] = (int) ubuf(buf[m++]).i; + molecule[i] = (tagint) ubuf(buf[m++]).i; + molindex[i] = (int) ubuf(buf[m++]).i; + molatom[i] = (int) ubuf(buf[m++]).i; + v[i][0] = buf[m++]; + v[i][1] = buf[m++]; + v[i][2] = buf[m++]; + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]-> + unpack_border(n,first,&buf[m]); +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecTemplate::unpack_border_hybrid(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + molecule[i] = (tagint) ubuf(buf[m++]).i; + molindex[i] = (int) ubuf(buf[m++]).i; + molatom[i] = (int) ubuf(buf[m++]).i; + } + return m; +} + +/* ---------------------------------------------------------------------- + pack data for atom I for sending to another proc + xyz must be 1st 3 values, so comm::exchange() can test on them +------------------------------------------------------------------------- */ + +int AtomVecTemplate::pack_exchange(int i, double *buf) +{ + int m = 1; + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + buf[m++] = x[i][2]; + buf[m++] = v[i][0]; + buf[m++] = v[i][1]; + buf[m++] = v[i][2]; + buf[m++] = ubuf(tag[i]).d; + buf[m++] = ubuf(type[i]).d; + buf[m++] = ubuf(mask[i]).d; + buf[m++] = ubuf(image[i]).d; + + buf[m++] = ubuf(molecule[i]).d; + buf[m++] = ubuf(molindex[i]).d; + buf[m++] = ubuf(molatom[i]).d; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); + + buf[0] = m; + return m; +} + +/* ---------------------------------------------------------------------- */ + +int AtomVecTemplate::unpack_exchange(double *buf) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + int m = 1; + x[nlocal][0] = buf[m++]; + x[nlocal][1] = buf[m++]; + x[nlocal][2] = buf[m++]; + v[nlocal][0] = buf[m++]; + v[nlocal][1] = buf[m++]; + v[nlocal][2] = buf[m++]; + tag[nlocal] = (tagint) ubuf(buf[m++]).i; + type[nlocal] = (int) ubuf(buf[m++]).i; + mask[nlocal] = (int) ubuf(buf[m++]).i; + image[nlocal] = (imageint) ubuf(buf[m++]).i; + + molecule[nlocal] = (tagint) ubuf(buf[m++]).i; + molindex[nlocal] = (int) ubuf(buf[m++]).i; + molatom[nlocal] = (int) ubuf(buf[m++]).i; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]-> + unpack_exchange(nlocal,&buf[m]); + + atom->nlocal++; + return m; +} + +/* ---------------------------------------------------------------------- + size of restart data for all atoms owned by this proc + include extra data stored by fixes +------------------------------------------------------------------------- */ + +int AtomVecTemplate::size_restart() +{ + int i; + + int nlocal = atom->nlocal; + int n = 14 * nlocal; + + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + for (i = 0; i < nlocal; i++) + n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); + + return n; +} + +/* ---------------------------------------------------------------------- + pack atom I's data for restart file including extra quantities + xyz must be 1st 3 values, so that read_restart can test on them + molecular types may be negative, but write as positive +------------------------------------------------------------------------- */ + +int AtomVecTemplate::pack_restart(int i, double *buf) +{ + int m = 1; + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + buf[m++] = x[i][2]; + buf[m++] = ubuf(tag[i]).d; + buf[m++] = ubuf(type[i]).d; + buf[m++] = ubuf(mask[i]).d; + buf[m++] = ubuf(image[i]).d; + buf[m++] = v[i][0]; + buf[m++] = v[i][1]; + buf[m++] = v[i][2]; + + buf[m++] = ubuf(molecule[i]).d; + buf[m++] = ubuf(molindex[i]).d; + buf[m++] = ubuf(molatom[i]).d; + + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); + + buf[0] = m; + return m; +} + +/* ---------------------------------------------------------------------- + unpack data for one atom from restart file including extra quantities +------------------------------------------------------------------------- */ + +int AtomVecTemplate::unpack_restart(double *buf) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) { + grow(0); + if (atom->nextra_store) + memory->grow(atom->extra,nmax,atom->nextra_store,"atom:extra"); + } + + int m = 1; + x[nlocal][0] = buf[m++]; + x[nlocal][1] = buf[m++]; + x[nlocal][2] = buf[m++]; + tag[nlocal] = (tagint) ubuf(buf[m++]).i; + type[nlocal] = (int) ubuf(buf[m++]).i; + mask[nlocal] = (int) ubuf(buf[m++]).i; + image[nlocal] = (imageint) ubuf(buf[m++]).i; + v[nlocal][0] = buf[m++]; + v[nlocal][1] = buf[m++]; + v[nlocal][2] = buf[m++]; + + molecule[nlocal] = (tagint) ubuf(buf[m++]).i; + molindex[nlocal] = (int) ubuf(buf[m++]).i; + molatom[nlocal] = (int) ubuf(buf[m++]).i; + + double **extra = atom->extra; + if (atom->nextra_store) { + int size = static_cast (buf[0]) - m; + for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++]; + } + + atom->nlocal++; + return m; +} + +/* ---------------------------------------------------------------------- + create one atom of itype at coord + set other values to defaults +------------------------------------------------------------------------- */ + +void AtomVecTemplate::create_atom(int itype, double *coord) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + tag[nlocal] = 0; + type[nlocal] = itype; + x[nlocal][0] = coord[0]; + x[nlocal][1] = coord[1]; + x[nlocal][2] = coord[2]; + mask[nlocal] = 1; + image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | + ((imageint) IMGMAX << IMGBITS) | IMGMAX; + v[nlocal][0] = 0.0; + v[nlocal][1] = 0.0; + v[nlocal][2] = 0.0; + + molecule[nlocal] = 0; + molindex[nlocal] = -1; + molatom[nlocal] = -1; + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + unpack one line from Atoms section of data file + initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecTemplate::data_atom(double *coord, imageint imagetmp, char **values) +{ + int nlocal = atom->nlocal; + if (nlocal == nmax) grow(0); + + tag[nlocal] = ATOTAGINT(values[0]); + if (tag[nlocal] <= 0) + error->one(FLERR,"Invalid atom ID in Atoms section of data file"); + + molecule[nlocal] = ATOTAGINT(values[1]); + molindex[nlocal] = atoi(values[2]) - 1; + molatom[nlocal] = atoi(values[3]) - 1; + + if (molindex[nlocal] < 0 || molindex[nlocal] >= nset) + error->one(FLERR,"Invalid template index in Atoms section of data file"); + if (molatom[nlocal] < 0 || + molatom[nlocal] >= onemols[molindex[nlocal]]->natoms) + error->one(FLERR,"Invalid template atom in Atoms section of data file"); + + type[nlocal] = atoi(values[4]); + if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) + error->one(FLERR,"Invalid atom type in Atoms section of data file"); + + x[nlocal][0] = coord[0]; + x[nlocal][1] = coord[1]; + x[nlocal][2] = coord[2]; + + image[nlocal] = imagetmp; + + mask[nlocal] = 1; + v[nlocal][0] = 0.0; + v[nlocal][1] = 0.0; + v[nlocal][2] = 0.0; + + atom->nlocal++; +} + +/* ---------------------------------------------------------------------- + unpack hybrid quantities from one line in Atoms section of data file + initialize other atom quantities for this sub-style +------------------------------------------------------------------------- */ + +int AtomVecTemplate::data_atom_hybrid(int nlocal, char **values) +{ + molecule[nlocal] = ATOTAGINT(values[0]); + molindex[nlocal] = atoi(values[1]) - 1; + molatom[nlocal] = atoi(values[2]) - 1; + return 3; +} + +/* ---------------------------------------------------------------------- + pack atom info for data file including 3 image flags +------------------------------------------------------------------------- */ + +void AtomVecTemplate::pack_data(double **buf) +{ + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + buf[i][0] = ubuf(tag[i]).d; + buf[i][1] = ubuf(molecule[i]).d; + buf[i][2] = ubuf(molindex[i]+1).d; + buf[i][3] = ubuf(molatom[i]+1).d; + buf[i][4] = ubuf(type[i]).d; + buf[i][5] = x[i][0]; + buf[i][6] = x[i][1]; + buf[i][7] = x[i][2]; + buf[i][8] = ubuf((image[i] & IMGMASK) - IMGMAX).d; + buf[i][9] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; + buf[i][10] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; + } +} + +/* ---------------------------------------------------------------------- + pack hybrid atom info for data file +------------------------------------------------------------------------- */ + +int AtomVecTemplate::pack_data_hybrid(int i, double *buf) +{ + buf[0] = ubuf(molecule[i]).d; + buf[1] = ubuf(molindex[i]+1).d; + buf[2] = ubuf(molatom[i]+1).d; + return 3; +} + +/* ---------------------------------------------------------------------- + write atom info to data file including 3 image flags +------------------------------------------------------------------------- */ + +void AtomVecTemplate::write_data(FILE *fp, int n, double **buf) +{ + for (int i = 0; i < n; i++) + fprintf(fp,TAGINT_FORMAT " " TAGINT_FORMAT + " %d %d %d %-1.16e %-1.16e %-1.16e %d %d %d\n", + (tagint) ubuf(buf[i][0]).i,(tagint) ubuf(buf[i][1]).i, + (int) ubuf(buf[i][2]).i,(int) ubuf(buf[i][3]).i, + (int) ubuf(buf[i][4]).i, + buf[i][5],buf[i][6],buf[i][7], + (int) ubuf(buf[i][8]).i,(int) ubuf(buf[i][9]).i, + (int) ubuf(buf[i][10]).i); +} + +/* ---------------------------------------------------------------------- + write hybrid atom info to data file +------------------------------------------------------------------------- */ + +int AtomVecTemplate::write_data_hybrid(FILE *fp, double *buf) +{ + fprintf(fp," " TAGINT_FORMAT " %d %d %d", + (tagint) ubuf(buf[0]).i,(int) ubuf(buf[0]).i,(int) ubuf(buf[0]).i); + return 3; +} + +/* ---------------------------------------------------------------------- + return # of bytes of allocated memory +------------------------------------------------------------------------- */ + +bigint AtomVecTemplate::memory_usage() +{ + bigint bytes = 0; + + if (atom->memcheck("tag")) bytes += memory->usage(tag,nmax); + if (atom->memcheck("type")) bytes += memory->usage(type,nmax); + if (atom->memcheck("mask")) bytes += memory->usage(mask,nmax); + if (atom->memcheck("image")) bytes += memory->usage(image,nmax); + if (atom->memcheck("x")) bytes += memory->usage(x,nmax,3); + if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); + if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3); + + if (atom->memcheck("molecule")) bytes += memory->usage(molecule,nmax); + if (atom->memcheck("molindex")) bytes += memory->usage(molindex,nmax); + if (atom->memcheck("molatom")) bytes += memory->usage(molatom,nmax); + + return bytes; +} diff --git a/src/MOLECULE/atom_vec_template.h b/src/MOLECULE/atom_vec_template.h new file mode 100644 index 0000000000..a5423066f4 --- /dev/null +++ b/src/MOLECULE/atom_vec_template.h @@ -0,0 +1,88 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef ATOM_CLASS + +AtomStyle(template,AtomVecTemplate) + +#else + +#ifndef LMP_ATOM_VEC_TEMPLATE_H +#define LMP_ATOM_VEC_TEMPLATE_H + +#include "atom_vec.h" + +namespace LAMMPS_NS { + +class AtomVecTemplate : public AtomVec { + public: + AtomVecTemplate(class LAMMPS *); + virtual ~AtomVecTemplate() {} + void process_args(int, char **); + void grow(int); + void grow_reset(); + void copy(int, int, int); + virtual int pack_comm(int, int *, double *, int, int *); + virtual int pack_comm_vel(int, int *, double *, int, int *); + virtual void unpack_comm(int, int, double *); + virtual void unpack_comm_vel(int, int, double *); + int pack_reverse(int, int, double *); + void unpack_reverse(int, int *, double *); + virtual int pack_border(int, int *, double *, int, int *); + virtual int pack_border_vel(int, int *, double *, int, int *); + int pack_border_hybrid(int, int *, double *); + virtual void unpack_border(int, int, double *); + virtual void unpack_border_vel(int, int, double *); + int unpack_border_hybrid(int, int, double *); + virtual int pack_exchange(int, double *); + virtual int unpack_exchange(double *); + int size_restart(); + int pack_restart(int, double *); + int unpack_restart(double *); + void create_atom(int, double *); + void data_atom(double *, tagint, char **); + int data_atom_hybrid(int, char **); + void pack_data(double **); + int pack_data_hybrid(int, double *); + void write_data(FILE *, int, double **); + int write_data_hybrid(FILE *, double *); + bigint memory_usage(); + + protected: + int *tag,*type,*mask; + tagint *image; + double **x,**v,**f; + int *molecule,*molindex,*molatom; +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Per-processor system is too big + +The number of owned atoms plus ghost atoms on a single +processor must fit in 32-bit integer. + +E: Invalid atom ID in Atoms section of data file + +Atom IDs must be positive integers. + +E: Invalid atom type in Atoms section of data file + +Atom types must range from 1 to specified # of types. + +*/ diff --git a/src/MOLECULE/bond_quartic.cpp b/src/MOLECULE/bond_quartic.cpp index d2f7a47b20..a0d2e5b702 100644 --- a/src/MOLECULE/bond_quartic.cpp +++ b/src/MOLECULE/bond_quartic.cpp @@ -233,12 +233,12 @@ void BondQuartic::init_style() { if (force->pair == NULL || force->pair->single_enable == 0) error->all(FLERR,"Pair style does not support bond_style quartic"); - if (force->angle) - error->all(FLERR,"Bond style quartic cannot be used with 3,4-body interactions"); - if (force->dihedral) - error->all(FLERR,"Bond style quartic cannot be used with 3,4-body interactions"); - if (force->improper) - error->all(FLERR,"Bond style quartic cannot be used with 3,4-body interactions"); + if (force->angle || force->dihedral || force->improper) + error->all(FLERR, + "Bond style quartic cannot be used with 3,4-body interactions"); + if (atom->molecular == 2) + error->all(FLERR, + "Bond style quartic cannot be used with atom style template"); // special bonds must be 1 1 1 diff --git a/src/MOLECULE/pair_hbond_dreiding_lj.cpp b/src/MOLECULE/pair_hbond_dreiding_lj.cpp index a25e116e96..3714071301 100644 --- a/src/MOLECULE/pair_hbond_dreiding_lj.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_lj.cpp @@ -21,6 +21,8 @@ #include "string.h" #include "pair_hbond_dreiding_lj.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "comm.h" #include "force.h" #include "neighbor.h" @@ -77,7 +79,8 @@ PairHbondDreidingLJ::~PairHbondDreidingLJ() void PairHbondDreidingLJ::compute(int eflag, int vflag) { - int i,j,k,m,ii,jj,kk,inum,jnum,knum,itype,jtype,ktype; + int i,j,k,m,ii,jj,kk,inum,jnum,knum,itype,jtype,ktype,iatom,imol; + tagint tagprev; double delx,dely,delz,rsq,rsq1,rsq2,r1,r2; double factor_hb,force_angle,force_kernel,evdwl,eng_lj,ehbond,force_switch; double c,s,a,b,ac,a11,a12,a22,vx1,vx2,vy1,vy2,vz1,vz2,d; @@ -85,6 +88,7 @@ void PairHbondDreidingLJ::compute(int eflag, int vflag) double r2inv,r10inv; double switch1,switch2; int *ilist,*jlist,*numneigh,**firstneigh; + int *tlist; tagint *klist; evdwl = ehbond = 0.0; @@ -93,10 +97,15 @@ void PairHbondDreidingLJ::compute(int eflag, int vflag) double **x = atom->x; double **f = atom->f; + tagint *tag = atom->tag; + int *molindex = atom->molindex; + int *molatom = atom->molatom; tagint **special = atom->special; - int *type = atom->type; int **nspecial = atom->nspecial; + int *type = atom->type; double *special_lj = force->special_lj; + int molecular = atom->molecular; + Molecule **onemols = atom->avec->onemols; inum = list->inum; ilist = list->ilist; @@ -113,8 +122,17 @@ void PairHbondDreidingLJ::compute(int eflag, int vflag) i = ilist[ii]; itype = type[i]; if (!donor[itype]) continue; - klist = special[i]; - knum = nspecial[i][0]; + if (molecular == 1) { + klist = special[i]; + knum = nspecial[i][0]; + } else { + if (molindex[i] < 0) continue; + imol = molindex[i]; + iatom = molatom[i]; + tlist = onemols[imol]->special[iatom]; + knum = onemols[imol]->nspecial[iatom][0]; + tagprev = tag[i] - iatom - 1; + } jlist = firstneigh[i]; jnum = numneigh[i]; @@ -132,7 +150,8 @@ void PairHbondDreidingLJ::compute(int eflag, int vflag) rsq = delx*delx + dely*dely + delz*delz; for (kk = 0; kk < knum; kk++) { - k = atom->map(klist[kk]); + if (molecular == 1) k = atom->map(klist[kk]); + else k = atom->map(tlist[kk]+tagprev); if (k < 0) continue; ktype = type[k]; m = type2param[itype][jtype][ktype]; @@ -454,16 +473,16 @@ double PairHbondDreidingLJ::single(int i, int j, int itype, int jtype, double &fforce) { int k,kk,ktype,knum,m; + tagint tagprev; double eng,eng_lj,force_kernel,force_angle; double rsq1,rsq2,r1,r2,c,s,ac,r2inv,r10inv,factor_hb; double switch1,switch2; double delr1[3],delr2[3]; + int *tlist; tagint *klist; double **x = atom->x; - tagint **special = atom->special; int *type = atom->type; - int **nspecial = atom->nspecial; double *special_lj = force->special_lj; eng = 0.0; @@ -474,13 +493,26 @@ double PairHbondDreidingLJ::single(int i, int j, int itype, int jtype, if (!donor[itype]) return 0.0; if (!acceptor[jtype]) return 0.0; - klist = special[i]; - knum = nspecial[i][0]; + int molecular = atom->molecular; + if (molecular == 1) { + klist = atom->special[i]; + knum = atom->nspecial[i][0]; + } else { + if (atom->molindex[i] < 0) return 0.0; + int imol = atom->molindex[i]; + int iatom = atom->molatom[i]; + Molecule **onemols = atom->avec->onemols; + tlist = onemols[imol]->special[iatom]; + knum = onemols[imol]->nspecial[iatom][0]; + tagprev = atom->tag[i] - iatom - 1; + } factor_hb = special_lj[sbmask(j)]; for (kk = 0; kk < knum; kk++) { - k = atom->map(klist[kk]); + if (molecular == 1) k = atom->map(klist[kk]); + else k = atom->map(tlist[kk]+tagprev); + if (k < 0) continue; ktype = type[k]; m = type2param[itype][jtype][ktype]; diff --git a/src/MOLECULE/pair_hbond_dreiding_morse.cpp b/src/MOLECULE/pair_hbond_dreiding_morse.cpp index 975bc94331..195f76a48c 100644 --- a/src/MOLECULE/pair_hbond_dreiding_morse.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_morse.cpp @@ -21,6 +21,8 @@ #include "string.h" #include "pair_hbond_dreiding_morse.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "comm.h" #include "force.h" #include "neighbor.h" @@ -48,13 +50,15 @@ PairHbondDreidingMorse::PairHbondDreidingMorse(LAMMPS *lmp) : void PairHbondDreidingMorse::compute(int eflag, int vflag) { - int i,j,k,m,ii,jj,kk,inum,jnum,knum,itype,jtype,ktype; + int i,j,k,m,ii,jj,kk,inum,jnum,knum,itype,jtype,ktype,imol,iatom; + tagint tagprev; double delx,dely,delz,rsq,rsq1,rsq2,r1,r2; double factor_hb,force_angle,force_kernel,force_switch,evdwl,ehbond; double c,s,a,b,d,ac,a11,a12,a22,vx1,vx2,vy1,vy2,vz1,vz2; double fi[3],fj[3],delr1[3],delr2[3]; double r,dr,dexp,eng_morse,switch1,switch2; int *ilist,*jlist,*numneigh,**firstneigh; + int *tlist; tagint *klist; evdwl = ehbond = 0.0; @@ -63,10 +67,15 @@ void PairHbondDreidingMorse::compute(int eflag, int vflag) double **x = atom->x; double **f = atom->f; + tagint *tag = atom->tag; + int *molindex = atom->molindex; + int *molatom = atom->molatom; tagint **special = atom->special; - int *type = atom->type; int **nspecial = atom->nspecial; + int *type = atom->type; double *special_lj = force->special_lj; + int molecular = atom->molecular; + Molecule **onemols = atom->avec->onemols; inum = list->inum; ilist = list->ilist; @@ -83,8 +92,17 @@ void PairHbondDreidingMorse::compute(int eflag, int vflag) i = ilist[ii]; itype = type[i]; if (!donor[itype]) continue; - klist = special[i]; - knum = nspecial[i][0]; + if (molecular == 1) { + klist = special[i]; + knum = nspecial[i][0]; + } else { + if (molindex[i] < 0) continue; + imol = molindex[i]; + iatom = molatom[i]; + tlist = onemols[imol]->special[iatom]; + knum = onemols[imol]->nspecial[iatom][0]; + tagprev = tag[i] - iatom - 1; + } jlist = firstneigh[i]; jnum = numneigh[i]; @@ -102,7 +120,8 @@ void PairHbondDreidingMorse::compute(int eflag, int vflag) rsq = delx*delx + dely*dely + delz*delz; for (kk = 0; kk < knum; kk++) { - k = atom->map(klist[kk]); + if (molecular == 1) k = atom->map(klist[kk]); + else k = atom->map(tlist[kk]+tagprev); if (k < 0) continue; ktype = type[k]; m = type2param[itype][jtype][ktype]; @@ -357,16 +376,16 @@ double PairHbondDreidingMorse::single(int i, int j, int itype, int jtype, double &fforce) { int k,kk,ktype,knum,m; + tagint tagprev; double eng,eng_morse,force_kernel,force_angle; double rsq1,rsq2,r1,r2,c,s,ac,r,dr,dexp,factor_hb; double switch1,switch2; double delr1[3],delr2[3]; + int *tlist; tagint *klist; double **x = atom->x; - tagint **special = atom->special; int *type = atom->type; - int **nspecial = atom->nspecial; double *special_lj = force->special_lj; eng = 0.0; @@ -377,13 +396,26 @@ double PairHbondDreidingMorse::single(int i, int j, int itype, int jtype, if (!donor[itype]) return 0.0; if (!acceptor[jtype]) return 0.0; - klist = special[i]; - knum = nspecial[i][0]; + int molecular = atom->molecular; + if (molecular == 1) { + klist = atom->special[i]; + knum = atom->nspecial[i][0]; + } else { + if (atom->molindex[i] < 0) return 0.0; + int imol = atom->molindex[i]; + int iatom = atom->molatom[i]; + Molecule **onemols = atom->avec->onemols; + tlist = onemols[imol]->special[iatom]; + knum = onemols[imol]->nspecial[iatom][0]; + tagprev = atom->tag[i] - iatom - 1; + } factor_hb = special_lj[sbmask(j)]; for (kk = 0; kk < knum; kk++) { - k = atom->map(klist[kk]); + if (molecular == 1) k = atom->map(klist[kk]); + else k = atom->map(tlist[kk]+tagprev); + if (k < 0) continue; ktype = type[k]; m = type2param[itype][jtype][ktype]; diff --git a/src/MPIIO/dump_atom_mpiio.cpp b/src/MPIIO/dump_atom_mpiio.cpp index 23ff70856b..6d60b9f3a3 100644 --- a/src/MPIIO/dump_atom_mpiio.cpp +++ b/src/MPIIO/dump_atom_mpiio.cpp @@ -38,15 +38,13 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ DumpAtomMPIIO::DumpAtomMPIIO(LAMMPS *lmp, int narg, char **arg) : - DumpAtom(lmp, narg, arg) -{ -} + DumpAtom(lmp, narg, arg) {} /* ---------------------------------------------------------------------- */ DumpAtomMPIIO::~DumpAtomMPIIO() { - if (multifile == 0) MPI_File_close(&mpifh); + if (multifile == 0) MPI_File_close(&mpifh); } /* ---------------------------------------------------------------------- */ diff --git a/src/MPIIO/dump_atom_mpiio.h b/src/MPIIO/dump_atom_mpiio.h index c3a05c6aee..aad196dae0 100644 --- a/src/MPIIO/dump_atom_mpiio.h +++ b/src/MPIIO/dump_atom_mpiio.h @@ -11,13 +11,9 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing author: Paul Coffman (IBM) -------------------------------------------------------------------------- */ - #ifdef DUMP_CLASS -DumpStyle(atom_mpiio,DumpAtomMPIIO) +DumpStyle(atom/mpiio,DumpAtomMPIIO) #else diff --git a/src/MPIIO/dump_custom_mpiio.cpp b/src/MPIIO/dump_custom_mpiio.cpp index 4ba0f3e852..d668fa0a0a 100644 --- a/src/MPIIO/dump_custom_mpiio.cpp +++ b/src/MPIIO/dump_custom_mpiio.cpp @@ -59,22 +59,19 @@ enum{INT,DOUBLE,STRING}; // same as in DumpCFG /* ---------------------------------------------------------------------- */ DumpCustomMPIIO::DumpCustomMPIIO(LAMMPS *lmp, int narg, char **arg) : - DumpCustom(lmp, narg, arg) -{ -} + DumpCustom(lmp, narg, arg) {} /* ---------------------------------------------------------------------- */ DumpCustomMPIIO::~DumpCustomMPIIO() { - if (multifile == 0) MPI_File_close(&mpifh); + if (multifile == 0) MPI_File_close(&mpifh); } /* ---------------------------------------------------------------------- */ void DumpCustomMPIIO::openfile() { - if (singlefile_opened) { // single file already opened, so just return after resetting filesize mpifo = currentFileSize; MPI_File_set_size(mpifh,mpifo+headerSize+sumFileSize); @@ -140,7 +137,6 @@ void DumpCustomMPIIO::openfile() void DumpCustomMPIIO::write() { - if (domain->triclinic == 0) { boxxlo = domain->boxlo[0]; boxxhi = domain->boxhi[0]; @@ -504,7 +500,6 @@ void DumpCustomMPIIO::header_item_triclinic(bigint ndump) void DumpCustomMPIIO::write_data(int n, double *mybuf) { - (this->*write_choice)(n,mybuf); } @@ -512,7 +507,6 @@ void DumpCustomMPIIO::write_data(int n, double *mybuf) void DumpCustomMPIIO::write_binary(int n, double *mybuf) { - MPI_Status mpiStatus; n *= size_one; diff --git a/src/MPIIO/dump_custom_mpiio.h b/src/MPIIO/dump_custom_mpiio.h index 9bf263f066..1e4c6de667 100644 --- a/src/MPIIO/dump_custom_mpiio.h +++ b/src/MPIIO/dump_custom_mpiio.h @@ -11,13 +11,9 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing author: Paul Coffman (IBM) -------------------------------------------------------------------------- */ - #ifdef DUMP_CLASS -DumpStyle(custom_mpiio,DumpCustomMPIIO) +DumpStyle(custom/mpiio,DumpCustomMPIIO) #else @@ -42,6 +38,7 @@ class DumpCustomMPIIO : public DumpCustom { MPI_Offset mpifo,offsetFromHeader,headerSize, currentFileSize; int performEstimate; // switch for write_data and write_header methods to use for gathering data and detemining filesize for preallocation vs actually writing the data char *filecurrent; // name of file for this round (with % and * replaced) + #if defined(_OPENMP) int convert_string_omp(int, double *); // multithreaded version of convert_string #endif @@ -63,8 +60,6 @@ class DumpCustomMPIIO : public DumpCustom { FnPtrData write_choice; // ptr to write data functions void write_binary(int, double *); void write_string(int, double *); - - }; } diff --git a/src/MPIIO/dump_xyz_mpiio.cpp b/src/MPIIO/dump_xyz_mpiio.cpp index e8534354c1..a0f5b45bba 100644 --- a/src/MPIIO/dump_xyz_mpiio.cpp +++ b/src/MPIIO/dump_xyz_mpiio.cpp @@ -59,15 +59,13 @@ enum{INT,DOUBLE,STRING}; // same as in DumpCFG /* ---------------------------------------------------------------------- */ DumpXYZMPIIO::DumpXYZMPIIO(LAMMPS *lmp, int narg, char **arg) : - DumpXYZ(lmp, narg, arg) -{ -} + DumpXYZ(lmp, narg, arg) {} /* ---------------------------------------------------------------------- */ DumpXYZMPIIO::~DumpXYZMPIIO() { - if (multifile == 0) MPI_File_close(&mpifh); + if (multifile == 0) MPI_File_close(&mpifh); } /* ---------------------------------------------------------------------- */ @@ -251,7 +249,6 @@ void DumpXYZMPIIO::init_style() void DumpXYZMPIIO::write_header(bigint n) { - MPI_Status mpiStatus; if (performEstimate) { @@ -275,7 +272,6 @@ void DumpXYZMPIIO::write_header(bigint n) void DumpXYZMPIIO::write_data(int n, double *mybuf) { - (this->*write_choice)(n,mybuf); } @@ -287,7 +283,6 @@ void DumpXYZMPIIO::write_string(int n, double *mybuf) if (performEstimate) { - #if defined(_OPENMP) int nthreads = omp_get_max_threads(); if (nthreads > 1) diff --git a/src/MPIIO/dump_xyz_mpiio.h b/src/MPIIO/dump_xyz_mpiio.h index 56aa408c57..281bf0b999 100644 --- a/src/MPIIO/dump_xyz_mpiio.h +++ b/src/MPIIO/dump_xyz_mpiio.h @@ -11,13 +11,9 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing author: Paul Coffman (IBM) -------------------------------------------------------------------------- */ - #ifdef DUMP_CLASS -DumpStyle(xyz_mpiio,DumpXYZMPIIO) +DumpStyle(xyz/mpiio,DumpXYZMPIIO) #else diff --git a/src/MPIIO/restart_mpiio.cpp b/src/MPIIO/restart_mpiio.cpp index 98d1e15d34..6c7b5b019f 100644 --- a/src/MPIIO/restart_mpiio.cpp +++ b/src/MPIIO/restart_mpiio.cpp @@ -39,7 +39,7 @@ RestartMPIIO::RestartMPIIO(LAMMPS *lmp) : Pointers(lmp) void RestartMPIIO::openForRead(char *filename) { - int err = MPI_File_open(world, filename, MPI_MODE_RDONLY , + int err = MPI_File_open(world, filename, MPI_MODE_RDONLY , MPI_INFO_NULL, &mpifh); if (err != MPI_SUCCESS) { char str[MPI_MAX_ERROR_STRING+128]; @@ -59,7 +59,7 @@ void RestartMPIIO::openForRead(char *filename) void RestartMPIIO::openForWrite(char *filename) { - int err = MPI_File_open(world, filename, MPI_MODE_APPEND | MPI_MODE_WRONLY, + int err = MPI_File_open(world, filename, MPI_MODE_APPEND | MPI_MODE_WRONLY, MPI_INFO_NULL, &mpifh); if (err != MPI_SUCCESS) { char str[MPI_MAX_ERROR_STRING+128]; @@ -73,7 +73,7 @@ void RestartMPIIO::openForWrite(char *filename) } /* ---------------------------------------------------------------------- - determine the absolute offset for the data to be written with + determine the absolute offset for the data to be written with MPI_Scan of the send sizes compute the file size based off the MPI_Scan send size value on the last rank set the filesize with ftruncate via MPI_File_set_size @@ -83,13 +83,13 @@ void RestartMPIIO::openForWrite(char *filename) void RestartMPIIO::write(MPI_Offset headerOffset, int send_size, double *buf) { MPI_Status mpiStatus; - long incPrefix = 0; - long longSendSize = (long) send_size; - MPI_Scan(&longSendSize,&incPrefix,1,MPI_LONG,MPI_SUM,world); - - long largestIncPrefix = incPrefix; - MPI_Bcast(&largestIncPrefix, 1, MPI_LONG, (nprocs-1), world); - + bigint incPrefix = 0; + bigint bigintSendSize = (bigint) send_size; + MPI_Scan(&bigintSendSize,&incPrefix,1,MPI_LMP_BIGINT,MPI_SUM,world); + + bigint largestIncPrefix = incPrefix; + MPI_Bcast(&largestIncPrefix, 1, MPI_LMP_BIGINT, (nprocs-1), world); + int err = MPI_File_set_size(mpifh, (headerOffset+(largestIncPrefix*sizeof(double)))); if (err != MPI_SUCCESS) { @@ -101,9 +101,9 @@ void RestartMPIIO::write(MPI_Offset headerOffset, int send_size, double *buf) mpiErrorString); error->one(FLERR,str); } - - err = MPI_File_write_at_all(mpifh,headerOffset + - ((incPrefix-longSendSize)*sizeof(double)), + + err = MPI_File_write_at_all(mpifh,headerOffset + + ((incPrefix-bigintSendSize)*sizeof(double)), buf,send_size,MPI_DOUBLE,&mpiStatus); if (err != MPI_SUCCESS) { char str[MPI_MAX_ERROR_STRING+128]; @@ -119,24 +119,24 @@ void RestartMPIIO::write(MPI_Offset headerOffset, int send_size, double *buf) /* ---------------------------------------------------------------------- read the data into buf via collective MPI-IO by calling MPI_File_read_at_all with the chunkOffset and chunkSize provided - if the consolidated chunksize is greater than INT_MAX + if the consolidated chunksize is greater than INT_MAX can only happen in extreme situation of reading restart file on much fewer ranks than written and with relatively large data sizes follow the collective IO call with rank independant IO to read remaining data ------------------------------------------------------------------------- */ -void RestartMPIIO::read(MPI_Offset chunkOffset, long chunkSize, double *buf) +void RestartMPIIO::read(MPI_Offset chunkOffset, bigint chunkSize, double *buf) { MPI_Status mpiStatus; int intChunkSize; - long remainingSize = 0; + bigint remainingSize = 0; if (chunkSize > INT_MAX) { intChunkSize = INT_MAX; remainingSize = chunkSize - INT_MAX; } else intChunkSize = (int) chunkSize; - + int err = MPI_File_read_at_all(mpifh,chunkOffset,buf,intChunkSize, MPI_DOUBLE,&mpiStatus); if (err != MPI_SUCCESS) { @@ -148,7 +148,7 @@ void RestartMPIIO::read(MPI_Offset chunkOffset, long chunkSize, double *buf) mpiErrorString); error->one(FLERR,str); } - + MPI_Offset currentOffset = chunkOffset+intChunkSize; MPI_Offset bufOffset = intChunkSize; while (remainingSize > 0) { diff --git a/src/MPIIO/restart_mpiio.h b/src/MPIIO/restart_mpiio.h index 87478af588..ed4354effd 100644 --- a/src/MPIIO/restart_mpiio.h +++ b/src/MPIIO/restart_mpiio.h @@ -31,7 +31,7 @@ class RestartMPIIO : protected Pointers { void openForRead(char *); void openForWrite(char *); void write(MPI_Offset, int, double *); - void read(MPI_Offset, long, double *); + void read(MPI_Offset, bigint, double *); void close(); }; diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 07e6f0c191..22208d455a 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -59,7 +59,8 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : // error check - if (atom->molecular == 0) + molecular = atom->molecular; + if (molecular == 0) error->all(FLERR,"Cannot use fix shake with non-molecular system"); // perform initial allocation of atom-based arrays @@ -219,35 +220,23 @@ FixShake::~FixShake() // set bond_type and angle_type back to positive for SHAKE clusters // must set for all SHAKE bonds and angles stored by each atom - int **bond_type = atom->bond_type; - int **angle_type = atom->angle_type; int nlocal = atom->nlocal; - int n; for (int i = 0; i < nlocal; i++) { if (shake_flag[i] == 0) continue; else if (shake_flag[i] == 1) { - n = bondfind(i,shake_atom[i][0],shake_atom[i][1]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = bondfind(i,shake_atom[i][0],shake_atom[i][2]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = anglefind(i,shake_atom[i][1],shake_atom[i][2]); - if (n >= 0) angle_type[i][n] = -angle_type[i][n]; + bondtype_findset(i,shake_atom[i][0],shake_atom[i][1],1); + bondtype_findset(i,shake_atom[i][0],shake_atom[i][2],1); + angletype_findset(i,shake_atom[i][1],shake_atom[i][2],1); } else if (shake_flag[i] == 2) { - n = bondfind(i,shake_atom[i][0],shake_atom[i][1]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; + bondtype_findset(i,shake_atom[i][0],shake_atom[i][1],1); } else if (shake_flag[i] == 3) { - n = bondfind(i,shake_atom[i][0],shake_atom[i][1]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = bondfind(i,shake_atom[i][0],shake_atom[i][2]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; + bondtype_findset(i,shake_atom[i][0],shake_atom[i][1],1); + bondtype_findset(i,shake_atom[i][0],shake_atom[i][2],1); } else if (shake_flag[i] == 4) { - n = bondfind(i,shake_atom[i][0],shake_atom[i][1]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = bondfind(i,shake_atom[i][0],shake_atom[i][2]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = bondfind(i,shake_atom[i][0],shake_atom[i][3]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; + bondtype_findset(i,shake_atom[i][0],shake_atom[i][1],1); + bondtype_findset(i,shake_atom[i][0],shake_atom[i][2],1); + bondtype_findset(i,shake_atom[i][0],shake_atom[i][3],1); } } @@ -655,26 +644,28 @@ int FixShake::dof(int igroup) void FixShake::find_clusters() { - int i,j,m,n; - int flag,flag_all,messtag,nbuf,nbufmax,size; + int i,j,m,n,imol,iatom; + int flag,flag_all,messtag,loop,nbuf,nbufmax,size; + tagint tagprev; double massone; tagint *buf; if (me == 0 && screen) fprintf(screen,"Finding SHAKE clusters ...\n"); - // local copies of atom ptrs + onemols = atom->avec->onemols; tagint *tag = atom->tag; int *type = atom->type; int *mask = atom->mask; double *mass = atom->mass; double *rmass = atom->rmass; - int **bond_type = atom->bond_type; - int **angle_type = atom->angle_type; int **nspecial = atom->nspecial; tagint **special = atom->special; - int nlocal = atom->nlocal; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + int nlocal = atom->nlocal; int angles_allow = atom->avec->angles_allow; // setup ring of procs @@ -699,7 +690,16 @@ void FixShake::find_clusters() // ----------------------------------------------------- int max = 0; - for (i = 0; i < nlocal; i++) max = MAX(max,nspecial[i][0]); + if (molecular == 1) { + for (i = 0; i < nlocal; i++) max = MAX(max,nspecial[i][0]); + } else { + for (i = 0; i < nlocal; i++) { + imol = molindex[i]; + if (imol < 0) continue; + iatom = molatom[i]; + max = MAX(max,onemols[imol]->nspecial[iatom][0]); + } + } int *npartner; memory->create(npartner,nlocal,"shake:npartner"); @@ -720,10 +720,22 @@ void FixShake::find_clusters() // set npartner and partner_tag from special arrays // ----------------------------------------------------- - for (i = 0; i < nlocal; i++) { - npartner[i] = nspecial[i][0]; - for (j = 0; j < npartner[i]; j++) - partner_tag[i][j] = special[i][j]; + if (molecular == 1) { + for (i = 0; i < nlocal; i++) { + npartner[i] = nspecial[i][0]; + for (j = 0; j < npartner[i]; j++) + partner_tag[i][j] = special[i][j]; + } + } else { + for (i = 0; i < nlocal; i++) { + imol = molindex[i]; + if (imol < 0) continue; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + npartner[i] = onemols[imol]->nspecial[iatom][0]; + for (j = 0; j < npartner[i]; j++) + partner_tag[i][j] = onemols[imol]->special[iatom][j] + tagprev;; + } } // ----------------------------------------------------- @@ -756,11 +768,11 @@ void FixShake::find_clusters() else massone = mass[type[m]]; partner_massflag[i][j] = masscheck(massone); } - n = bondfind(i,tag[i],partner_tag[i][j]); - if (n >= 0) partner_bondtype[i][j] = bond_type[i][n]; + n = bondtype_findset(i,tag[i],partner_tag[i][j],0); + if (n) partner_bondtype[i][j] = n; else { - n = bondfind(m,tag[i],partner_tag[i][j]); - if (n >= 0) partner_bondtype[i][j] = bond_type[m][n]; + n = bondtype_findset(m,tag[i],partner_tag[i][j],0); + if (n) partner_bondtype[i][j] = n; } } else nbuf += nper; } @@ -780,8 +792,8 @@ void FixShake::find_clusters() buf[size+2] = 0; buf[size+3] = 0; buf[size+4] = 0; - n = bondfind(i,tag[i],partner_tag[i][j]); - if (n >= 0) buf[size+5] = bond_type[i][n]; + n = bondtype_findset(i,tag[i],partner_tag[i][j],0); + if (n) buf[size+5] = n; else buf[size+5] = 0; size += nper; } @@ -1004,12 +1016,11 @@ void FixShake::find_clusters() } if (nshake[i] == 2 && angles_allow) { - n = anglefind(i,shake_atom[i][1],shake_atom[i][2]); - if (n < 0) continue; - if (angle_type[i][n] < 0) continue; - if (angle_flag[angle_type[i][n]]) { + n = angletype_findset(i,shake_atom[i][1],shake_atom[i][2],0); + if (n <= 0) continue; + if (angle_flag[n]) { shake_flag[i] = 1; - shake_type[i][2] = angle_type[i][n]; + shake_type[i][2] = n; } } } @@ -1097,27 +1108,18 @@ void FixShake::find_clusters() for (i = 0; i < nlocal; i++) { if (shake_flag[i] == 0) continue; else if (shake_flag[i] == 1) { - n = bondfind(i,shake_atom[i][0],shake_atom[i][1]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = bondfind(i,shake_atom[i][0],shake_atom[i][2]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = anglefind(i,shake_atom[i][1],shake_atom[i][2]); - if (n >= 0) angle_type[i][n] = -angle_type[i][n]; + bondtype_findset(i,shake_atom[i][0],shake_atom[i][1],-1); + bondtype_findset(i,shake_atom[i][0],shake_atom[i][2],-1); + angletype_findset(i,shake_atom[i][1],shake_atom[i][2],-1); } else if (shake_flag[i] == 2) { - n = bondfind(i,shake_atom[i][0],shake_atom[i][1]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; + bondtype_findset(i,shake_atom[i][0],shake_atom[i][1],-1); } else if (shake_flag[i] == 3) { - n = bondfind(i,shake_atom[i][0],shake_atom[i][1]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = bondfind(i,shake_atom[i][0],shake_atom[i][2]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; + bondtype_findset(i,shake_atom[i][0],shake_atom[i][1],-1); + bondtype_findset(i,shake_atom[i][0],shake_atom[i][2],-1); } else if (shake_flag[i] == 4) { - n = bondfind(i,shake_atom[i][0],shake_atom[i][1]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = bondfind(i,shake_atom[i][0],shake_atom[i][2]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; - n = bondfind(i,shake_atom[i][0],shake_atom[i][3]); - if (n >= 0) bond_type[i][n] = -bond_type[i][n]; + bondtype_findset(i,shake_atom[i][0],shake_atom[i][1],-1); + bondtype_findset(i,shake_atom[i][0],shake_atom[i][2],-1); + bondtype_findset(i,shake_atom[i][0],shake_atom[i][3],-1); } } @@ -1173,7 +1175,6 @@ void FixShake::ring_bonds(int ndatum, char *cbuf) double *rmass = atom->rmass; double *mass = atom->mass; int *mask = atom->mask; - int **bond_type = atom->bond_type; int *type = atom->type; int nlocal = atom->nlocal; int nmass = fsptr->nmass; @@ -1193,8 +1194,8 @@ void FixShake::ring_bonds(int ndatum, char *cbuf) buf[i+4] = fsptr->masscheck(massone); } if (buf[i+5] == 0) { - n = fsptr->bondfind(m,buf[i],buf[i+1]); - if (n >= 0) buf[i+5] = bond_type[m][n]; + n = fsptr->bondtype_findset(m,buf[i],buf[i+1],0); + if (n) buf[i+5] = n; } } } @@ -2234,45 +2235,116 @@ void FixShake::stats() } /* ---------------------------------------------------------------------- - find a bond between global tags n1 and n2 stored with local atom i - return -1 if don't find it - return bond index if do find it + find a bond between global atom IDs n1 and n2 stored with local atom i + if find it: + if setflag = 0, return bond type + if setflag = -1/1, set bond type to negative/positive and return 0 + if do not find it, return 0 ------------------------------------------------------------------------- */ -int FixShake::bondfind(int i, tagint n1, tagint n2) +int FixShake::bondtype_findset(int i, tagint n1, tagint n2, int setflag) { - tagint *tag = atom->tag; - tagint **bond_atom = atom->bond_atom; - int nbonds = atom->num_bond[i]; + int m,nbonds; + int *btype; - int m; - for (m = 0; m < nbonds; m++) { - if (n1 == tag[i] && n2 == bond_atom[i][m]) break; - if (n1 == bond_atom[i][m] && n2 == tag[i]) break; + if (molecular == 1) { + tagint *tag = atom->tag; + tagint **bond_atom = atom->bond_atom; + nbonds = atom->num_bond[i]; + + for (m = 0; m < nbonds; m++) { + if (n1 == tag[i] && n2 == bond_atom[i][m]) break; + if (n1 == bond_atom[i][m] && n2 == tag[i]) break; + } + + } else { + int imol = atom->molindex[i]; + int iatom = atom->molatom[i]; + tagint *tag = atom->tag; + tagint tagprev = tag[i] - iatom - 1; + int *batom = onemols[imol]->bond_atom[iatom]; + btype = onemols[imol]->bond_type[iatom]; + nbonds = onemols[imol]->num_bond[iatom]; + + for (m = 0; m < nbonds; m++) { + if (n1 == tag[i] && n2 == batom[m]+tagprev) break; + if (n1 == batom[m]+tagprev && n2 == tag[i]) break; + } } - if (m < nbonds) return m; - return -1; + + if (m < nbonds) { + if (setflag == 0) { + if (molecular == 1) return atom->bond_type[i][m]; + else return btype[m]; + } + if (molecular == 1) { + if ((setflag < 0 && atom->bond_type[i][m] > 0) || + (setflag > 0 && atom->bond_type[i][m] < 0)) + atom->bond_type[i][m] = -atom->bond_type[i][m]; + } else { + if ((setflag < 0 && btype[m] > 0) || + (setflag > 0 && btype[m] < 0)) btype[m] = -btype[m]; + } + } + + return 0; } /* ---------------------------------------------------------------------- - find an angle with global end atoms n1 and n2 stored with local atom i - return -1 if don't find it - return angle index if do find it + find an angle with global end atom IDs n1 and n2 stored with local atom i + if find it: + if setflag = 0, return angle type + if setflag = -1/1, set angle type to negative/positive and return 0 + if do not find it, return 0 ------------------------------------------------------------------------- */ -int FixShake::anglefind(int i, tagint n1, tagint n2) +int FixShake::angletype_findset(int i, tagint n1, tagint n2, int setflag) { - tagint **angle_atom1 = atom->angle_atom1; - tagint **angle_atom3 = atom->angle_atom3; - int nangles = atom->num_angle[i]; + int m,nangles; + int *atype; - int m; - for (m = 0; m < nangles; m++) { - if (n1 == angle_atom1[i][m] && n2 == angle_atom3[i][m]) break; - if (n1 == angle_atom3[i][m] && n2 == angle_atom1[i][m]) break; + if (molecular == 1) { + tagint **angle_atom1 = atom->angle_atom1; + tagint **angle_atom3 = atom->angle_atom3; + nangles = atom->num_angle[i]; + + for (m = 0; m < nangles; m++) { + if (n1 == angle_atom1[i][m] && n2 == angle_atom3[i][m]) break; + if (n1 == angle_atom3[i][m] && n2 == angle_atom1[i][m]) break; + } + + } else { + int imol = atom->molindex[i]; + int iatom = atom->molatom[i]; + tagint *tag = atom->tag; + tagint tagprev = tag[i] - iatom - 1; + int *aatom1 = onemols[imol]->angle_atom1[iatom]; + int *aatom3 = onemols[imol]->angle_atom3[iatom]; + atype = onemols[imol]->angle_type[iatom]; + nangles = onemols[imol]->num_angle[iatom]; + + for (m = 0; m < nangles; m++) { + if (n1 == aatom1[m]+tagprev && n2 == aatom3[m]+tagprev) break; + if (n1 == aatom3[m]+tagprev && n2 == aatom1[m]+tagprev) break; + } } - if (m < nangles) return m; - return -1; + + if (m < nangles) { + if (setflag == 0) { + if (molecular == 1) return atom->angle_type[i][m]; + else return atype[m]; + } + if (molecular == 1) { + if ((setflag < 0 && atom->angle_type[i][m] > 0) || + (setflag > 0 && atom->angle_type[i][m] < 0)) + atom->angle_type[i][m] = -atom->angle_type[i][m]; + } else { + if ((setflag < 0 && atype[m] > 0) || + (setflag > 0 && atype[m] < 0)) atype[m] = -atype[m]; + } + } + + return 0; } /* ---------------------------------------------------------------------- diff --git a/src/RIGID/fix_shake.h b/src/RIGID/fix_shake.h index a88e2b6d32..c7f067f01a 100644 --- a/src/RIGID/fix_shake.h +++ b/src/RIGID/fix_shake.h @@ -64,6 +64,7 @@ class FixShake : public Fix { double *mass_list; // constrain bonds to these masses int nmass; // # of masses in mass_list + int molecular; // copy of atom->molecular double *bond_distance,*angle_distance; // constraint distances int ifix_respa; // rRESPA fix needed by SHAKE @@ -102,9 +103,8 @@ class FixShake : public Fix { double *a_ave,*a_max,*a_min; double *a_ave_all,*a_max_all,*a_min_all; - // molecules added on-the-fly with SHAKE constraints - - class Molecule *onemol; + class Molecule **onemols; // atom style template pointer + class Molecule *onemol; // molecule added on-the-fly void find_clusters(); int masscheck(double); @@ -115,8 +115,8 @@ class FixShake : public Fix { void shake4(int); void shake3angle(int); void stats(); - int bondfind(int, tagint, tagint); - int anglefind(int, tagint, tagint); + int bondtype_findset(int, tagint, tagint, int); + int angletype_findset(int, tagint, tagint, int); // static variable for ring communication callback to access class data // callback functions for ring communication diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index 00193b9f9c..3db73bab51 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -945,6 +945,7 @@ void FixSRD::reset_velocities() double *h_ratelo = domain->h_ratelo; for (i = 0; i < nbins; i++) { + vbin[i].value[0] = 0.0; n = vbin[i].n; if (n == 0) continue; vave = vbin[i].vsum; @@ -957,7 +958,7 @@ void FixSRD::reset_velocities() if (dimension == 3) axis = irandom / 2; vsq = 0.0; - for (j = binhead[i]; j >= 0; j = binnext[j]) { + for (j = binhead[i]; j >= 0; j = binnext[j]) { if (axis == 0) { u[0] = v[j][0]-vave[0]; u[1] = sign ? v[j][2]-vave[2] : vave[2]-v[j][2]; @@ -977,11 +978,20 @@ void FixSRD::reset_velocities() v[j][2] = u[2] + vave[2]; } - // NOTE: vsq needs to be summed across shared bins in parallel - // like vave above via the vbin_comm() call - // else the computed scale factor below is incomplete for a shared bin + if (n > 1) vbin[i].value[0] = vsq; + } + + if (shifts[shiftflag].commflag) xbin_comm(shiftflag,1); + + if (tstat) { + for (i = 0; i < nbins; i++){ + n = vbin[i].n; + if (n <= 1) continue; + + // vsum is already average velocity + + vave = vbin[i].vsum; - if (tstat && n > 1) { if (deformflag) { xlamda = vbin[i].xctr; vstream[0] = h_rate[0]*xlamda[0] + h_rate[5]*xlamda[1] + @@ -996,12 +1006,11 @@ void FixSRD::reset_velocities() // tbin = thermal temperature of particles in bin // scale = scale factor for thermal velocity - - tbin = vsq/(n-dof_tstat) * tfactor; + + tbin = vbin[i].value[0]/(n-dof_tstat) * tfactor; scale = sqrt(temperature_srd/tbin); - vsq = 0.0; - for (j = binhead[i]; j >= 0; j = binnext[j]) { + for (j = binhead[i]; j >= 0; j = binnext[j]) { u[0] = (v[j][0] - vave[0]) * scale; u[1] = (v[j][1] - vave[1]) * scale; u[2] = (v[j][2] - vave[2]) * scale; @@ -1010,13 +1019,19 @@ void FixSRD::reset_velocities() v[j][1] = u[1] + vstream[1]; v[j][2] = u[2] + vstream[2]; } + vbin[i].value[0] = vsq; } - // sum partial contribution of my particles to T even if I don't own bin - // but only count bin if I own it, so each bin is counted exactly once + if (shifts[shiftflag].commflag) xbin_comm(shiftflag,1); + } - if (n > 1) srd_bin_temp += vsq/(n-dof_temp); - if (vbin[i].owner) srd_bin_count++; + for (i = 0; i < nbins; i++){ + if (vbin[i].owner) { + if (vbin[i].n > 1) { + srd_bin_temp += vbin[i].value[0]/(vbin[i].n-dof_temp); + srd_bin_count++; + } + } } srd_bin_temp *= tfactor; @@ -1138,6 +1153,103 @@ void FixSRD::vbin_unpack(double *buf, BinAve *vbin, int n, int *list) } } +/* ---------------------------------------------------------------------- + communicate summed particle vsq info for bins that overlap 1 or more procs +------------------------------------------------------------------------- */ + +void FixSRD::xbin_comm(int ishift, int nval) +{ + BinComm *bcomm1,*bcomm2; + MPI_Request request1,request2; + MPI_Status status; + + // send/recv bins in both directions in each dimension + // don't send if nsend = 0 + // due to static bins aliging with proc boundary + // due to dynamic bins across non-periodic global boundary + // copy to self if sendproc = me + // MPI send to another proc if sendproc != me + // don't recv if nrecv = 0 + // copy from self if recvproc = me + // MPI recv from another proc if recvproc != me + + BinAve *vbin = shifts[ishift].vbin; + int *procgrid = comm->procgrid; + + int iswap = 0; + for (int idim = 0; idim < dimension; idim++) { + bcomm1 = &shifts[ishift].bcomm[iswap++]; + bcomm2 = &shifts[ishift].bcomm[iswap++]; + + if (procgrid[idim] == 1) { + if (bcomm1->nsend) + xbin_pack(vbin,bcomm1->nsend,bcomm1->sendlist,sbuf1,nval); + if (bcomm2->nsend) + xbin_pack(vbin,bcomm2->nsend,bcomm2->sendlist,sbuf2,nval); + if (bcomm1->nrecv) + xbin_unpack(sbuf1,vbin,bcomm1->nrecv,bcomm1->recvlist,nval); + if (bcomm2->nrecv) + xbin_unpack(sbuf2,vbin,bcomm2->nrecv,bcomm2->recvlist,nval); + + } else { + if (bcomm1->nrecv) + MPI_Irecv(rbuf1,bcomm1->nrecv*nval,MPI_DOUBLE,bcomm1->recvproc,0, + world,&request1); + if (bcomm2->nrecv) + MPI_Irecv(rbuf2,bcomm2->nrecv*nval,MPI_DOUBLE,bcomm2->recvproc,0, + world,&request2); + if (bcomm1->nsend) { + xbin_pack(vbin,bcomm1->nsend,bcomm1->sendlist,sbuf1,nval); + MPI_Send(sbuf1,bcomm1->nsend*nval,MPI_DOUBLE, + bcomm1->sendproc,0,world); + } + if (bcomm2->nsend) { + xbin_pack(vbin,bcomm2->nsend,bcomm2->sendlist,sbuf2,nval); + MPI_Send(sbuf2,bcomm2->nsend*nval,MPI_DOUBLE, + bcomm2->sendproc,0,world); + } + if (bcomm1->nrecv) { + MPI_Wait(&request1,&status); + xbin_unpack(rbuf1,vbin,bcomm1->nrecv,bcomm1->recvlist,nval); + } + if (bcomm2->nrecv) { + MPI_Wait(&request2,&status); + xbin_unpack(rbuf2,vbin,bcomm2->nrecv,bcomm2->recvlist,nval); + } + } + } +} + +/* ---------------------------------------------------------------------- + pack velocity bin data into a message buffer for sending +------------------------------------------------------------------------- */ + +void FixSRD::xbin_pack(BinAve *vbin, int n, int *list, double *buf, int nval) +{ + int j, k; + int m = 0; + for (int i = 0; i < n; i++) { + j = list[i]; + for (k = 0; k < nval; k++) + buf[m++] = vbin[j].value[k]; + } +} + +/* ---------------------------------------------------------------------- + unpack velocity bin data from a message buffer and sum values to my bins +------------------------------------------------------------------------- */ + +void FixSRD::xbin_unpack(double *buf, BinAve *vbin, int n, int *list, int nval) +{ + int j, k; + int m = 0; + for (int i = 0; i < n; i++) { + j = list[i]; + for (k = 0; k < nval; k++) + vbin[j].value[k] += buf[m++]; + } +} + /* ---------------------------------------------------------------------- detect all collisions between SRD and BIG particles or WALLS assume SRD can be inside at most one BIG particle or WALL at a time diff --git a/src/SRD/fix_srd.h b/src/SRD/fix_srd.h index cd2c01dce7..3b1f3feca1 100644 --- a/src/SRD/fix_srd.h +++ b/src/SRD/fix_srd.h @@ -131,6 +131,7 @@ class FixSRD : public Fix { double xctr[3]; // center point of bin, only used for triclinic double vsum[3]; // sum of v components for SRD particles in bin double random; // random value if I am owner + double value[12]; // extra per-bin values }; struct BinComm { @@ -189,6 +190,10 @@ class FixSRD : public Fix { void vbin_pack(BinAve *, int, int *, double *); void vbin_unpack(double *, BinAve *, int, int *); + void xbin_comm(int, int); + void xbin_pack(BinAve *, int, int *, double *, int); + void xbin_unpack(double *, BinAve *, int, int *, int); + void collisions_single(); void collisions_multi(); diff --git a/src/atom.cpp b/src/atom.cpp index f25a8af453..86ae09bdf5 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -74,6 +74,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) x = v = f = NULL; molecule = NULL; + molindex = molatom = NULL; q = NULL; mu = NULL; omega = angmom = torque = NULL; @@ -215,6 +216,8 @@ Atom::~Atom() memory->destroy(erforce); memory->destroy(molecule); + memory->destroy(molindex); + memory->destroy(molatom); memory->destroy(nspecial); memory->destroy(special); @@ -321,7 +324,8 @@ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix) int sflag; avec = new_avec(style,suffix,sflag); - avec->settings(narg,arg); + avec->store_args(narg,arg); + avec->process_args(narg,arg); avec->grow(1); nmax = 0; avec->reset(); @@ -1336,59 +1340,53 @@ int Atom::find_molecule(char *id) void Atom::add_molecule_atom(Molecule *onemol, int iatom, int ilocal, tagint offset) { - if (onemol->qflag) q[ilocal] = onemol->q[iatom]; - if (onemol->radiusflag) radius[ilocal] = onemol->radius[iatom]; - if (onemol->rmassflag) rmass[ilocal] = onemol->rmass[iatom]; + if (onemol->qflag && q_flag) q[ilocal] = onemol->q[iatom]; + if (onemol->radiusflag && radius_flag) radius[ilocal] = onemol->radius[iatom]; + if (onemol->rmassflag && rmass_flag) rmass[ilocal] = onemol->rmass[iatom]; else if (rmass_flag) rmass[ilocal] = 4.0*MY_PI/3.0 * radius[ilocal]*radius[ilocal]*radius[ilocal]; - if (onemol->bondflag) { - num_bond[ilocal] = onemol->num_bond[iatom]; - for (int i = 0; i < num_bond[ilocal]; i++) { - bond_type[ilocal][i] = onemol->bond_type[iatom][i]; - bond_atom[ilocal][i] = onemol->bond_atom[iatom][i] + offset; - } - } - if (onemol->angleflag) { - num_angle[ilocal] = onemol->num_angle[iatom]; - for (int i = 0; i < num_angle[ilocal]; i++) { - angle_type[ilocal][i] = onemol->angle_type[iatom][i]; - angle_atom1[ilocal][i] = onemol->angle_atom1[iatom][i] + offset; - angle_atom2[ilocal][i] = onemol->angle_atom2[iatom][i] + offset; - angle_atom3[ilocal][i] = onemol->angle_atom3[iatom][i] + offset; - } - } - if (onemol->dihedralflag) { - num_dihedral[ilocal] = onemol->num_dihedral[iatom]; - for (int i = 0; i < num_dihedral[ilocal]; i++) { - dihedral_type[ilocal][i] = onemol->dihedral_type[iatom][i]; - dihedral_atom1[ilocal][i] = onemol->dihedral_atom1[iatom][i] + offset; - dihedral_atom2[ilocal][i] = onemol->dihedral_atom2[iatom][i] + offset; - dihedral_atom3[ilocal][i] = onemol->dihedral_atom3[iatom][i] + offset; - dihedral_atom4[ilocal][i] = onemol->dihedral_atom4[iatom][i] + offset; - } - } - if (onemol->improperflag) { - num_improper[ilocal] = onemol->num_improper[iatom]; - for (int i = 0; i < num_improper[ilocal]; i++) { - improper_type[ilocal][i] = onemol->improper_type[iatom][i]; - improper_atom1[ilocal][i] = onemol->improper_atom1[iatom][i] + offset; - improper_atom2[ilocal][i] = onemol->improper_atom2[iatom][i] + offset; - improper_atom3[ilocal][i] = onemol->improper_atom3[iatom][i] + offset; - improper_atom4[ilocal][i] = onemol->improper_atom4[iatom][i] + offset; - } + if (molecular != 1) return; + + // add bond topology info + // for molecular atom styles, but not atom style template + + if (avec->bonds_allow) num_bond[ilocal] = onemol->num_bond[iatom]; + for (int i = 0; i < num_bond[ilocal]; i++) { + bond_type[ilocal][i] = onemol->bond_type[iatom][i]; + bond_atom[ilocal][i] = onemol->bond_atom[iatom][i] + offset; } - // error check against maxspecial in case user has not done one of these: - // create_box extra/special/per/atom N - // read_data extra special per atom N - // special_bonds extra N - // if explicitly used special_bonds, may not have maintained extra + if (avec->angles_allow) num_angle[ilocal] = onemol->num_angle[iatom]; + for (int i = 0; i < num_angle[ilocal]; i++) { + angle_type[ilocal][i] = onemol->angle_type[iatom][i]; + angle_atom1[ilocal][i] = onemol->angle_atom1[iatom][i] + offset; + angle_atom2[ilocal][i] = onemol->angle_atom2[iatom][i] + offset; + angle_atom3[ilocal][i] = onemol->angle_atom3[iatom][i] + offset; + } + + if (avec->dihedrals_allow) + num_dihedral[ilocal] = onemol->num_dihedral[iatom]; + for (int i = 0; i < num_dihedral[ilocal]; i++) { + dihedral_type[ilocal][i] = onemol->dihedral_type[iatom][i]; + dihedral_atom1[ilocal][i] = onemol->dihedral_atom1[iatom][i] + offset; + dihedral_atom2[ilocal][i] = onemol->dihedral_atom2[iatom][i] + offset; + dihedral_atom3[ilocal][i] = onemol->dihedral_atom3[iatom][i] + offset; + dihedral_atom4[ilocal][i] = onemol->dihedral_atom4[iatom][i] + offset; + } + + if (avec->impropers_allow) + num_improper[ilocal] = onemol->num_improper[iatom]; + for (int i = 0; i < num_improper[ilocal]; i++) { + improper_type[ilocal][i] = onemol->improper_type[iatom][i]; + improper_atom1[ilocal][i] = onemol->improper_atom1[iatom][i] + offset; + improper_atom2[ilocal][i] = onemol->improper_atom2[iatom][i] + offset; + improper_atom3[ilocal][i] = onemol->improper_atom3[iatom][i] + offset; + improper_atom4[ilocal][i] = onemol->improper_atom4[iatom][i] + offset; + } if (onemol->specialflag) { - if (onemol->maxspecial > maxspecial) - error->one(FLERR,"Molecule file special bond counts are too large"); nspecial[ilocal][0] = onemol->nspecial[iatom][0]; nspecial[ilocal][1] = onemol->nspecial[iatom][1]; int n = nspecial[ilocal][2] = onemol->nspecial[iatom][2]; diff --git a/src/atom.h b/src/atom.h index d4c07f81fb..cc044f18d9 100644 --- a/src/atom.h +++ b/src/atom.h @@ -30,7 +30,8 @@ class Atom : protected Pointers { int nlocal,nghost; // # of owned and ghost atoms on this proc int nmax; // max # of owned+ghost in arrays on this proc int tag_enable; // 0/1 if atom ID tags are defined - int molecular; // 0 = atomic, 1 = molecular system + int molecular; // 0 = atomic, 1 = standard molecular system, + // 2 = molecule template system bigint nbonds,nangles,ndihedrals,nimpropers; int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index fba68e808e..b381845e46 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -11,6 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +#include "string.h" #include "stdlib.h" #include "atom_vec.h" #include "atom.h" @@ -29,13 +30,39 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) mass_type = dipole_type = 0; size_data_bonus = 0; cudable = false; + + nargcopy = 0; + argcopy = NULL; +} + +/* ---------------------------------------------------------------------- */ + +AtomVec::~AtomVec() +{ + for (int i = 0; i < nargcopy; i++) delete [] argcopy[i]; + delete [] argcopy; +} + +/* ---------------------------------------------------------------------- + make copy of args for use by restart & replicate +------------------------------------------------------------------------- */ + +void AtomVec::store_args(int narg, char **arg) +{ + nargcopy = narg; + argcopy = new char*[nargcopy]; + for (int i = 0; i < nargcopy; i++) { + int n = strlen(arg[i]) + 1; + argcopy[i] = new char[n]; + strcpy(argcopy[i],arg[i]); + } } /* ---------------------------------------------------------------------- no additional args by default ------------------------------------------------------------------------- */ -void AtomVec::settings(int narg, char **arg) +void AtomVec::process_args(int narg, char **arg) { if (narg) error->all(FLERR,"Invalid atom_style command"); } diff --git a/src/atom_vec.h b/src/atom_vec.h index 4a27b66e6c..224feb1438 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -39,12 +39,19 @@ class AtomVec : protected Pointers { int size_data_bonus; // number of values in Bonus line int xcol_data; // column (1-N) where x is in Atom line + class Molecule **onemols; // list of molecules for style template + int nset; // # of molecules in list + int cudable; // 1 if atom style is CUDA-enabled int *maxsend; // CUDA-specific variable + int nargcopy; // copy of command-line args for atom_style command + char **argcopy; // used when AtomVec is realloced (restart,replicate) + AtomVec(class LAMMPS *); - virtual ~AtomVec() {} - virtual void settings(int, char **); + virtual ~AtomVec(); + void store_args(int, char **); + virtual void process_args(int, char **); virtual void init(); virtual void grow(int) = 0; @@ -78,9 +85,6 @@ 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 *, imageint, char **) = 0; diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 429ac39137..53808be5b4 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -57,10 +57,6 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp) bptr = NULL; - nargcopy = 0; - argcopy = NULL; - copyflag = 1; - if (sizeof(double) == sizeof(int)) intdoubleratio = 1; else if (sizeof(double) == 2*sizeof(int)) intdoubleratio = 2; else error->all(FLERR,"Internal error in atom_style body"); @@ -78,9 +74,6 @@ AtomVecBody::~AtomVecBody() memory->sfree(bonus); delete bptr; - - for (int i = 0; i < nargcopy; i++) delete [] argcopy[i]; - delete [] argcopy; } /* ---------------------------------------------------------------------- @@ -89,7 +82,7 @@ AtomVecBody::~AtomVecBody() set size_forward and size_border to max sizes ------------------------------------------------------------------------- */ -void AtomVecBody::settings(int narg, char **arg) +void AtomVecBody::process_args(int narg, char **arg) { if (narg < 1) error->all(FLERR,"Invalid atom_style body command"); @@ -114,19 +107,6 @@ void AtomVecBody::settings(int narg, char **arg) size_forward = 7 + bptr->size_forward; size_border = 16 + bptr->size_border; - - // make copy of args if called externally, so can write to restart file - // make no copy of args if called from read_restart() - - if (copyflag) { - nargcopy = narg; - argcopy = new char*[nargcopy]; - for (int i = 0; i < nargcopy; i++) { - int n = strlen(arg[i]) + 1; - argcopy[i] = new char[n]; - strcpy(argcopy[i],arg[i]); - } - } } /* ---------------------------------------------------------------------- @@ -1229,41 +1209,6 @@ int AtomVecBody::unpack_restart(double *buf) return m; } -/* ---------------------------------------------------------------------- */ - -void AtomVecBody::write_restart_settings(FILE *fp) -{ - fwrite(&nargcopy,sizeof(int),1,fp); - for (int i = 0; i < nargcopy; i++) { - int n = strlen(argcopy[i]) + 1; - fwrite(&n,sizeof(int),1,fp); - fwrite(argcopy[i],sizeof(char),n,fp); - } -} - -/* ---------------------------------------------------------------------- */ - -void AtomVecBody::read_restart_settings(FILE *fp) -{ - int n; - - int me = comm->me; - if (me == 0) fread(&nargcopy,sizeof(int),1,fp); - MPI_Bcast(&nargcopy,1,MPI_INT,0,world); - argcopy = new char*[nargcopy]; - - for (int i = 0; i < nargcopy; i++) { - if (me == 0) fread(&n,sizeof(int),1,fp); - MPI_Bcast(&n,1,MPI_INT,0,world); - argcopy[i] = new char[n]; - if (me == 0) fread(argcopy[i],sizeof(char),n,fp); - MPI_Bcast(argcopy[i],n,MPI_CHAR,0,world); - } - - copyflag = 0; - settings(nargcopy,argcopy); -} - /* ---------------------------------------------------------------------- create one atom of itype at coord set other values to defaults diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index c16be4e2c8..023208d24c 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -42,7 +42,7 @@ class AtomVecBody : public AtomVec { AtomVecBody(class LAMMPS *); ~AtomVecBody(); - void settings(int, char **); + void process_args(int, char **); void grow(int); void grow_reset(); void copy(int, int, int); @@ -67,8 +67,6 @@ class AtomVecBody : 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 *, imageint, char **); int data_atom_hybrid(int, char **); @@ -99,11 +97,7 @@ class AtomVecBody : public AtomVec { int *body; int nlocal_bonus,nghost_bonus,nmax_bonus; - - int nargcopy; // copy of command-line args - char **argcopy; // for writing to restart file - int copyflag; - int intdoubleratio; // sizeof(double) / sizeof(int) + int intdoubleratio; // sizeof(double) / sizeof(int) MyPoolChunk *icp; MyPoolChunk *dcp; diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index d88f67a854..1af8ee0b98 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -43,7 +43,7 @@ AtomVecHybrid::~AtomVecHybrid() process sub-style args ------------------------------------------------------------------------- */ -void AtomVecHybrid::settings(int narg, char **arg) +void AtomVecHybrid::process_args(int narg, char **arg) { // build list of all known atom styles @@ -55,7 +55,7 @@ void AtomVecHybrid::settings(int narg, char **arg) keywords = new char*[narg]; // allocate each sub-style - // call settings() with set of args that are not atom style names + // call process_args() with set of args that are not atom style names // use known_style() to determine which args these are int i,jarg,dummy; @@ -73,7 +73,7 @@ void AtomVecHybrid::settings(int narg, char **arg) 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]); + styles[nstyles]->process_args(jarg-iarg-1,&arg[iarg+1]); iarg = jarg; nstyles++; } @@ -97,7 +97,12 @@ void AtomVecHybrid::settings(int narg, char **arg) xcol_data = 3; for (int k = 0; k < nstyles; k++) { + if ((styles[k]->molecular == 1 && molecular == 2) || + (styles[k]->molecular == 2 && molecular == 1)) + error->all(FLERR,"Cannot mix molecular and molecule template " + "atom styles"); molecular = MAX(molecular,styles[k]->molecular); + bonds_allow = MAX(bonds_allow,styles[k]->bonds_allow); angles_allow = MAX(angles_allow,styles[k]->angles_allow); dihedrals_allow = MAX(dihedrals_allow,styles[k]->dihedrals_allow); @@ -820,22 +825,6 @@ 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 diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index ce8e332ec4..93abac8728 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -33,7 +33,7 @@ class AtomVecHybrid : public AtomVec { AtomVecHybrid(class LAMMPS *); ~AtomVecHybrid(); - void settings(int, char **); + void process_args(int, char **); void init(); void grow(int); void grow_reset(); @@ -54,8 +54,6 @@ 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 *, imageint, char **); int data_atom_hybrid(int, char **) {return 0;} diff --git a/src/compute_angle_local.cpp b/src/compute_angle_local.cpp index 6e2cd57322..b4f080f86c 100644 --- a/src/compute_angle_local.cpp +++ b/src/compute_angle_local.cpp @@ -16,6 +16,7 @@ #include "compute_angle_local.h" #include "atom.h" #include "atom_vec.h" +#include "molecule.h" #include "update.h" #include "domain.h" #include "force.h" @@ -98,7 +99,7 @@ void ComputeAngleLocal::compute_local() /* ---------------------------------------------------------------------- count angles and compute angle info on this proc - only count angle once if newton_angle is off + only count if 2nd atom is the one storing the angle all atoms in interaction must be in group all atoms in interaction must be known to proc if angle is deleted (type = 0), do not count @@ -109,20 +110,27 @@ void ComputeAngleLocal::compute_local() int ComputeAngleLocal::compute_angles(int flag) { - int i,m,n,atom1,atom2,atom3; + int i,m,n,na,atom1,atom2,atom3,imol,iatom,atype; + tagint tagprev; double delx1,dely1,delz1,delx2,dely2,delz2; double rsq1,rsq2,r1,r2,c; double *tbuf,*ebuf; double **x = atom->x; + tagint *tag = atom->tag; int *num_angle = atom->num_angle; tagint **angle_atom1 = atom->angle_atom1; tagint **angle_atom2 = atom->angle_atom2; tagint **angle_atom3 = atom->angle_atom3; int **angle_type = atom->angle_type; - tagint *tag = atom->tag; int *mask = atom->mask; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int nlocal = atom->nlocal; + int molecular = atom->molecular; if (flag) { if (nvalues == 1) { @@ -141,13 +149,32 @@ int ComputeAngleLocal::compute_angles(int flag) m = n = 0; for (atom2 = 0; atom2 < nlocal; atom2++) { if (!(mask[atom2] & groupbit)) continue; - for (i = 0; i < num_angle[atom2]; i++) { - if (tag[atom2] != angle_atom2[atom2][i]) continue; - atom1 = atom->map(angle_atom1[atom2][i]); + + if (molecular == 1) na = num_angle[atom2]; + else { + if (molindex[atom2] < 0) continue; + imol = molindex[atom2]; + iatom = molatom[atom2]; + na = onemols[imol]->num_angle[iatom]; + } + + for (i = 0; i < na; i++) { + if (molecular == 1) { + if (tag[atom2] != angle_atom2[atom2][i]) continue; + atype = angle_type[atom2][i]; + atom1 = atom->map(angle_atom1[atom2][i]); + atom3 = atom->map(angle_atom3[atom2][i]); + } else { + if (tag[atom2] != onemols[imol]->angle_atom2[atom2][i]) continue; + tagprev = tag[atom1] - iatom - 1; + atype = atom->map(onemols[imol]->angle_type[atom2][i]); + atom1 = atom->map(onemols[imol]->angle_atom1[atom2][i]+tagprev); + atom3 = atom->map(onemols[imol]->angle_atom3[atom2][i]+tagprev); + } + if (atom1 < 0 || !(mask[atom1] & groupbit)) continue; - atom3 = atom->map(angle_atom3[atom2][i]); if (atom3 < 0 || !(mask[atom3] & groupbit)) continue; - if (angle_type[atom2][i] == 0) continue; + if (atype == 0) continue; if (flag) { if (tflag >= 0) { @@ -177,8 +204,8 @@ int ComputeAngleLocal::compute_angles(int flag) } if (eflag >= 0) { - if (angle_type[atom2][i] > 0) - ebuf[n] = angle->single(angle_type[atom2][i],atom1,atom2,atom3); + if (atype > 0) + ebuf[n] = angle->single(atype,atom1,atom2,atom3); else ebuf[n] = 0.0; } n += nvalues; diff --git a/src/compute_bond_local.cpp b/src/compute_bond_local.cpp index ad6697e048..00aefeda3a 100644 --- a/src/compute_bond_local.cpp +++ b/src/compute_bond_local.cpp @@ -16,6 +16,7 @@ #include "compute_bond_local.h" #include "atom.h" #include "atom_vec.h" +#include "molecule.h" #include "update.h" #include "domain.h" #include "force.h" @@ -115,19 +116,26 @@ void ComputeBondLocal::compute_local() int ComputeBondLocal::compute_bonds(int flag) { - int i,m,n,atom1,atom2; + int i,m,n,nb,atom1,atom2,imol,iatom,btype; + tagint tagprev; double delx,dely,delz,rsq; double *dbuf,*ebuf,*fbuf; double *ptr; double **x = atom->x; + tagint *tag = atom->tag; int *num_bond = atom->num_bond; tagint **bond_atom = atom->bond_atom; int **bond_type = atom->bond_type; - tagint *tag = atom->tag; int *mask = atom->mask; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int nlocal = atom->nlocal; int newton_bond = force->newton_bond; + int molecular = atom->molecular; Bond *bond = force->bond; double eng,fbond; @@ -135,11 +143,28 @@ int ComputeBondLocal::compute_bonds(int flag) m = n = 0; for (atom1 = 0; atom1 < nlocal; atom1++) { if (!(mask[atom1] & groupbit)) continue; - for (i = 0; i < num_bond[atom1]; i++) { - atom2 = atom->map(bond_atom[atom1][i]); + + if (molecular == 1) nb = num_bond[atom1]; + else { + if (molindex[atom1] < 0) continue; + imol = molindex[atom1]; + iatom = molatom[atom1]; + nb = onemols[imol]->num_bond[iatom]; + } + + for (i = 0; i < nb; i++) { + if (molecular == 1) { + btype = bond_type[atom1][i]; + atom2 = atom->map(bond_atom[atom1][i]); + } else { + tagprev = tag[atom1] - iatom - 1; + btype = atom->map(onemols[imol]->bond_type[atom1][i]); + atom2 = atom->map(onemols[imol]->bond_atom[atom1][i]+tagprev); + } + if (atom2 < 0 || !(mask[atom2] & groupbit)) continue; if (newton_bond == 0 && tag[atom1] > tag[atom2]) continue; - if (bond_type[atom1][i] == 0) continue; + if (btype == 0) continue; if (flag) { delx = x[atom1][0] - x[atom2][0]; @@ -149,8 +174,8 @@ int ComputeBondLocal::compute_bonds(int flag) rsq = delx*delx + dely*dely + delz*delz; if (singleflag) { - if (bond_type[atom1][i] > 0) - eng = bond->single(bond_type[atom1][i],rsq,atom1,atom2,fbond); + if (btype > 0) + eng = bond->single(btype,rsq,atom1,atom2,fbond); else eng = fbond = 0.0; } diff --git a/src/compute_dihedral_local.cpp b/src/compute_dihedral_local.cpp index 438f665da6..a43681c8f3 100644 --- a/src/compute_dihedral_local.cpp +++ b/src/compute_dihedral_local.cpp @@ -16,6 +16,7 @@ #include "compute_dihedral_local.h" #include "atom.h" #include "atom_vec.h" +#include "molecule.h" #include "update.h" #include "domain.h" #include "force.h" @@ -107,21 +108,28 @@ void ComputeDihedralLocal::compute_local() int ComputeDihedralLocal::compute_dihedrals(int flag) { - int i,m,n,atom1,atom2,atom3,atom4; + int i,m,n,nd,atom1,atom2,atom3,atom4,imol,iatom; + tagint tagprev; double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z,vb2xm,vb2ym,vb2zm; double ax,ay,az,bx,by,bz,rasq,rbsq,rgsq,rg,rginv,ra2inv,rb2inv,rabinv; double s,c; double *pbuf; double **x = atom->x; + tagint *tag = atom->tag; int *num_dihedral = atom->num_dihedral; tagint **dihedral_atom1 = atom->dihedral_atom1; tagint **dihedral_atom2 = atom->dihedral_atom2; tagint **dihedral_atom3 = atom->dihedral_atom3; tagint **dihedral_atom4 = atom->dihedral_atom4; - tagint *tag = atom->tag; int *mask = atom->mask; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int nlocal = atom->nlocal; + int molecular = atom->molecular; if (flag) { if (nvalues == 1) { @@ -135,13 +143,31 @@ int ComputeDihedralLocal::compute_dihedrals(int flag) m = n = 0; for (atom2 = 0; atom2 < nlocal; atom2++) { if (!(mask[atom2] & groupbit)) continue; - for (i = 0; i < num_dihedral[atom2]; i++) { - if (tag[atom2] != dihedral_atom2[atom2][i]) continue; - atom1 = atom->map(dihedral_atom1[atom2][i]); + + if (molecular == 1) nd = num_dihedral[atom2]; + else { + if (molindex[atom2] < 0) continue; + imol = molindex[atom2]; + iatom = molatom[atom2]; + nd = onemols[imol]->num_dihedral[iatom]; + } + + for (i = 0; i < nd; i++) { + if (molecular == 1) { + if (tag[atom2] != dihedral_atom2[atom2][i]) continue; + atom1 = atom->map(dihedral_atom1[atom2][i]); + atom3 = atom->map(dihedral_atom3[atom2][i]); + atom4 = atom->map(dihedral_atom4[atom2][i]); + } else { + if (tag[atom2] != onemols[imol]->dihedral_atom2[atom2][i]) continue; + tagprev = tag[atom1] - iatom - 1; + atom1 = atom->map(onemols[imol]->dihedral_atom1[atom2][i]+tagprev); + atom3 = atom->map(onemols[imol]->dihedral_atom3[atom2][i]+tagprev); + atom4 = atom->map(onemols[imol]->dihedral_atom4[atom2][i]+tagprev); + } + if (atom1 < 0 || !(mask[atom1] & groupbit)) continue; - atom3 = atom->map(dihedral_atom3[atom2][i]); if (atom3 < 0 || !(mask[atom3] & groupbit)) continue; - atom4 = atom->map(dihedral_atom4[atom2][i]); if (atom4 < 0 || !(mask[atom4] & groupbit)) continue; if (flag) { diff --git a/src/compute_improper_local.cpp b/src/compute_improper_local.cpp index 4e66856df3..7726781439 100644 --- a/src/compute_improper_local.cpp +++ b/src/compute_improper_local.cpp @@ -16,6 +16,7 @@ #include "compute_improper_local.h" #include "atom.h" #include "atom_vec.h" +#include "molecule.h" #include "update.h" #include "domain.h" #include "force.h" @@ -108,21 +109,28 @@ void ComputeImproperLocal::compute_local() int ComputeImproperLocal::compute_impropers(int flag) { - int i,m,n,atom1,atom2,atom3,atom4; + int i,m,n,ni,atom1,atom2,atom3,atom4,imol,iatom; + tagint tagprev; double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z; double ss1,ss2,ss3,r1,r2,r3,c0,c1,c2,s1,s2; double s12,c; double *cbuf; double **x = atom->x; + tagint *tag = atom->tag; int *num_improper = atom->num_improper; tagint **improper_atom1 = atom->improper_atom1; tagint **improper_atom2 = atom->improper_atom2; tagint **improper_atom3 = atom->improper_atom3; tagint **improper_atom4 = atom->improper_atom4; - tagint *tag = atom->tag; int *mask = atom->mask; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int nlocal = atom->nlocal; + int molecular = atom->molecular; if (flag) { if (nvalues == 1) { @@ -136,13 +144,31 @@ int ComputeImproperLocal::compute_impropers(int flag) m = n = 0; for (atom2 = 0; atom2 < nlocal; atom2++) { if (!(mask[atom2] & groupbit)) continue; - for (i = 0; i < num_improper[atom2]; i++) { - if (tag[atom2] != improper_atom2[atom2][i]) continue; - atom1 = atom->map(improper_atom1[atom2][i]); + + if (molecular == 1) ni = num_improper[atom2]; + else { + if (molindex[atom2] < 0) continue; + imol = molindex[atom2]; + iatom = molatom[atom2]; + ni = onemols[imol]->num_improper[iatom]; + } + + for (i = 0; i < ni; i++) { + if (molecular == 1) { + if (tag[atom2] != improper_atom2[atom2][i]) continue; + atom1 = atom->map(improper_atom1[atom2][i]); + atom3 = atom->map(improper_atom3[atom2][i]); + atom4 = atom->map(improper_atom4[atom2][i]); + } else { + if (tag[atom2] != onemols[imol]->improper_atom2[atom2][i]) continue; + tagprev = tag[atom1] - iatom - 1; + atom1 = atom->map(onemols[imol]->improper_atom1[atom2][i]+tagprev); + atom3 = atom->map(onemols[imol]->improper_atom3[atom2][i]+tagprev); + atom4 = atom->map(onemols[imol]->improper_atom4[atom2][i]+tagprev); + } + if (atom1 < 0 || !(mask[atom1] & groupbit)) continue; - atom3 = atom->map(improper_atom3[atom2][i]); if (atom3 < 0 || !(mask[atom3] & groupbit)) continue; - atom4 = atom->map(improper_atom4[atom2][i]); if (atom4 < 0 || !(mask[atom4] & groupbit)) continue; if (flag) { diff --git a/src/compute_property_local.cpp b/src/compute_property_local.cpp index b9fc3ab4d0..675ca7e58c 100644 --- a/src/compute_property_local.cpp +++ b/src/compute_property_local.cpp @@ -212,6 +212,11 @@ ComputePropertyLocal::ComputePropertyLocal(LAMMPS *lmp, int narg, char **arg) : // error check + if (atom->molecular == 2 && (kindflag == BOND || kindflag == ANGLE || + kindflag == DIHEDRAL || kindflag == IMPROPER)) + error->all(FLERR,"Compute property/local does not (yet) work " + "with atom_style template"); + if (kindflag == BOND && atom->avec->bonds_allow == 0) error->all(FLERR, "Compute property/local for property that isn't allocated"); diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 0f6fbe6d56..7a24c5eb09 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -160,11 +160,12 @@ void CreateAtoms::command(int narg, char **arg) error->all(FLERR,"Create_atoms molecule must have coordinates"); if (onemol->typeflag == 0) error->all(FLERR,"Create_atoms molecule must have atom types"); - if (ntype+onemol->maxtype <= 0 || ntype+onemol->maxtype > atom->ntypes) + if (ntype+onemol->ntypes <= 0 || ntype+onemol->ntypes > atom->ntypes) error->all(FLERR,"Invalid atom type in create_atoms mol command"); if (onemol->tag_require && !atom->tag_enable) error->all(FLERR, "Create_atoms molecule has atom IDs, but system does not"); + onemol->check_attributes(0); // create_atoms uses geoemetric center of molecule for insertion @@ -291,6 +292,19 @@ void CreateAtoms::command(int narg, char **arg) int molcreate = (atom->nlocal - nlocal_previous) / onemol->natoms; + // for atom style template systems, increment total bonds,angles,etc + + if (atom->molecular == 2) { + bigint nmolme = molcreate; + bigint nmoltotal; + MPI_Allreduce(&nmolme,&nmoltotal,1,MPI_LMP_BIGINT,MPI_SUM,world); + atom->nbonds += nmoltotal * onemol->nbonds; + atom->nangles += nmoltotal * onemol->nangles; + atom->ndihedrals += nmoltotal * onemol->ndihedrals; + atom->nimpropers += nmoltotal * onemol->nimpropers; + } + + // 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 // including molecules existing before this creation @@ -332,38 +346,44 @@ void CreateAtoms::command(int narg, char **arg) tagint **improper_atom4 = atom->improper_atom4; int **nspecial = atom->nspecial; tagint **special = atom->special; + int molecular = atom->molecular; int ilocal = nlocal_previous; for (int i = 0; i < molcreate; i++) { if (tag) offset = tag[ilocal]-1; for (int m = 0; m < natoms; m++) { - if (molecule) molecule[ilocal] = moloffset + i+1; - if (onemol->bondflag) - for (int j = 0; j < num_bond[ilocal]; j++) - bond_atom[ilocal][j] += offset; - if (onemol->angleflag) - for (int j = 0; j < num_angle[ilocal]; j++) { - angle_atom1[ilocal][j] += offset; - angle_atom2[ilocal][j] += offset; - angle_atom3[ilocal][j] += offset; - } - if (onemol->dihedralflag) - for (int j = 0; j < num_dihedral[ilocal]; j++) { - dihedral_atom1[ilocal][j] += offset; - dihedral_atom2[ilocal][j] += offset; - dihedral_atom3[ilocal][j] += offset; - dihedral_atom4[ilocal][j] += offset; - } - if (onemol->improperflag) - for (int j = 0; j < num_improper[ilocal]; j++) { - improper_atom1[ilocal][j] += offset; - improper_atom2[ilocal][j] += offset; - improper_atom3[ilocal][j] += offset; - improper_atom4[ilocal][j] += offset; - } - if (onemol->specialflag) - for (int j = 0; j < nspecial[ilocal][2]; j++) - special[ilocal][j] += offset; + if (molecular) molecule[ilocal] = moloffset + i+1; + if (molecular == 2) { + atom->molindex[ilocal] = 0; + atom->molatom[ilocal] = m; + } else if (molecular) { + if (onemol->bondflag) + for (int j = 0; j < num_bond[ilocal]; j++) + bond_atom[ilocal][j] += offset; + if (onemol->angleflag) + for (int j = 0; j < num_angle[ilocal]; j++) { + angle_atom1[ilocal][j] += offset; + angle_atom2[ilocal][j] += offset; + angle_atom3[ilocal][j] += offset; + } + if (onemol->dihedralflag) + for (int j = 0; j < num_dihedral[ilocal]; j++) { + dihedral_atom1[ilocal][j] += offset; + dihedral_atom2[ilocal][j] += offset; + dihedral_atom3[ilocal][j] += offset; + dihedral_atom4[ilocal][j] += offset; + } + if (onemol->improperflag) + for (int j = 0; j < num_improper[ilocal]; j++) { + improper_atom1[ilocal][j] += offset; + improper_atom2[ilocal][j] += offset; + improper_atom3[ilocal][j] += offset; + improper_atom4[ilocal][j] += offset; + } + if (onemol->specialflag) + for (int j = 0; j < nspecial[ilocal][2]; j++) + special[ilocal][j] += offset; + } ilocal++; } } @@ -400,11 +420,12 @@ void CreateAtoms::command(int narg, char **arg) } // for MOLECULE mode: - // create special bond lists for molecular systems + // create special bond lists for molecular systems, + // but not for atom style template // only if onemol added bonds but not special info if (mode == MOLECULE) { - if (atom->molecular && onemol->bondflag && !onemol->specialflag) { + if (atom->molecular == 1 && onemol->bondflag && !onemol->specialflag) { Special special(lmp); special.build(); } diff --git a/src/delete_bonds.cpp b/src/delete_bonds.cpp index 9e33b472b0..e8a5809fe7 100644 --- a/src/delete_bonds.cpp +++ b/src/delete_bonds.cpp @@ -41,8 +41,9 @@ void DeleteBonds::command(int narg, char **arg) error->all(FLERR,"Delete_bonds command before simulation box is defined"); if (atom->natoms == 0) error->all(FLERR,"Delete_bonds command with no atoms existing"); - if (atom->molecular == 0) + if (atom->molecular != 1) error->all(FLERR,"Cannot use delete_bonds with non-molecular system"); + if (narg < 2) error->all(FLERR,"Illegal delete_bonds command"); // init entire system since comm->borders is done diff --git a/src/domain.cpp b/src/domain.cpp index 135591b113..24e5786504 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -23,6 +23,8 @@ #include "domain.h" #include "style_region.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "force.h" #include "kspace.h" #include "update.h" @@ -551,7 +553,8 @@ void Domain::pbc() void Domain::image_check() { - int i,j,k; + int i,j,k,n,imol,iatom; + tagint tagprev; // only need to check if system is molecular and some dimension is periodic // if running verlet/split, don't check on KSpace partition since @@ -581,8 +584,15 @@ void Domain::image_check() // flag if any bond component is longer than non-periodic box length // which means image flags in that dimension were different + int molecular = atom->molecular; + int *num_bond = atom->num_bond; tagint **bond_atom = atom->bond_atom; + int **bond_type = atom->bond_type; + tagint *tag = atom->tag; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; double delx,dely,delz; @@ -590,9 +600,25 @@ void Domain::image_check() int nmissing = 0; int flag = 0; - for (i = 0; i < nlocal; i++) - for (j = 0; j < num_bond[i]; j++) { - k = atom->map(bond_atom[i][j]); + for (i = 0; i < nlocal; i++) { + if (molecular == 1) n = num_bond[i]; + else { + if (molindex[i] < 0) continue; + imol = molindex[i]; + iatom = molatom[i]; + n = onemols[imol]->num_bond[iatom]; + } + + for (j = 0; j < n; j++) { + if (molecular == 1) { + if (bond_type[i][j] <= 0) continue; + k = atom->map(bond_atom[i][j]); + } else { + if (onemols[imol]->bond_type[iatom][j] < 0) continue; + tagprev = tag[i] - iatom - 1; + k = atom->map(onemols[imol]->bond_atom[iatom][j]+tagprev); + } + if (k == -1) { nmissing++; if (lostbond == ERROR) @@ -611,6 +637,7 @@ void Domain::image_check() if (!yperiodic && dely > yprd) flag = 1; if (dimension == 3 && !zperiodic && delz > zprd) flag = 1; } + } int flagall; MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_MAX,world); @@ -636,7 +663,8 @@ void Domain::image_check() void Domain::box_too_small_check() { - int i,j,k; + int i,j,k,n,imol,iatom; + tagint tagprev; // only need to check if system is molecular and some dimension is periodic // if running verlet/split, don't check on KSpace partition since @@ -653,10 +681,16 @@ void Domain::box_too_small_check() // in this case, image_check() should warn, // assuming 2 atoms have consistent image flags + int molecular = atom->molecular; + + double **x = atom->x; int *num_bond = atom->num_bond; tagint **bond_atom = atom->bond_atom; int **bond_type = atom->bond_type; - double **x = atom->x; + tagint *tag = atom->tag; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; int nlocal = atom->nlocal; double delx,dely,delz,rsq; @@ -665,16 +699,32 @@ void Domain::box_too_small_check() int lostbond = output->thermo->lostbond; int nmissing = 0; - for (i = 0; i < nlocal; i++) - for (j = 0; j < num_bond[i]; j++) { - if (bond_type[i][j] <= 0) continue; - k = atom->map(bond_atom[i][j]); + for (i = 0; i < nlocal; i++) { + if (molecular == 1) n = num_bond[i]; + else { + if (molindex[i] < 0) continue; + imol = molindex[i]; + iatom = molatom[i]; + n = onemols[imol]->num_bond[iatom]; + } + + for (j = 0; j < n; j++) { + if (molecular == 1) { + if (bond_type[i][j] <= 0) continue; + k = atom->map(bond_atom[i][j]); + } else { + if (onemols[imol]->bond_type[iatom][j] < 0) continue; + tagprev = tag[i] - iatom - 1; + k = atom->map(onemols[imol]->bond_atom[iatom][j]+tagprev); + } + if (k == -1) { nmissing++; if (lostbond == ERROR) error->one(FLERR,"Bond atom missing in box size check"); continue; } + delx = x[i][0] - x[k][0]; dely = x[i][1] - x[k][1]; delz = x[i][2] - x[k][2]; @@ -682,6 +732,7 @@ void Domain::box_too_small_check() rsq = delx*delx + dely*dely + delz*delz; maxbondme = MAX(maxbondme,rsq); } + } if (lostbond == WARN) { int all; diff --git a/src/domain.h b/src/domain.h index 2630f174b2..1d99c36566 100644 --- a/src/domain.h +++ b/src/domain.h @@ -131,8 +131,10 @@ class Domain : protected Pointers { // minimum image convention check // return 1 if any distance > 1/2 of box size + // indicates a special neighbor is actually not in a bond, + // but is a far-away image that should be treated as an unbonded neighbor // inline since called from neighbor build inner loop - + // inline int minimum_image_check(double dx, double dy, double dz) { if (xperiodic && fabs(dx) > xprd_half) return 1; if (yperiodic && fabs(dy) > yprd_half) return 1; diff --git a/src/dump.cpp b/src/dump.cpp index 965aa29a75..5b5321119a 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -106,6 +106,9 @@ Dump::Dump(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) char *ptr; if (ptr = strchr(filename,'%')) { + if (strstr(style,"mpiio")) + error->all(FLERR, + "Dump file MPI-IO output not allowed with '%' in filename"); multiproc = 1; nclusterprocs = 1; filewriter = 1; diff --git a/src/dump_image.cpp b/src/dump_image.cpp index 53f09b02a8..c7bfd868d4 100644 --- a/src/dump_image.cpp +++ b/src/dump_image.cpp @@ -18,6 +18,8 @@ #include "dump_image.h" #include "image.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "domain.h" #include "group.h" #include "force.h" @@ -646,7 +648,8 @@ void DumpImage::view_params() void DumpImage::create_image() { - int i,j,m,itype,atom1,atom2; + int i,j,m,n,itype,atom1,atom2,imol,iatom,btype; + tagint tagprev; double diameter,delx,dely,delz; double *color,*color1,*color2; double xmid[3]; @@ -700,10 +703,14 @@ void DumpImage::create_image() tagint **bond_atom = atom->bond_atom; int **bond_type = atom->bond_type; int *num_bond = atom->num_bond; + int *molindex = atom->molindex; + int *molatom = atom->molatom; int *type = atom->type; int nlocal = atom->nlocal; int nall = atom->nlocal + atom->nghost; int newton_bond = force->newton_bond; + int molecular = atom->molecular; + Molecule **onemols = atom->avec->onemols; // communicate choose flag for ghost atoms to know if they are selected // if bcolor/bdiam = ATOM, setup bufcopy to comm atom color/diam attributes @@ -735,11 +742,27 @@ void DumpImage::create_image() for (i = 0; i < nchoose; i++) { atom1 = clist[i]; - for (m = 0; m < num_bond[atom1]; m++) { - atom2 = atom->map(bond_atom[atom1][m]); + if (molecular == 1) n = num_bond[atom1]; + else { + if (molindex[atom1] < 0) continue; + imol = molindex[atom1]; + iatom = molatom[atom1]; + n = onemols[imol]->num_bond[iatom]; + } + + for (m = 0; m < n; m++) { + if (molecular == 1) { + btype = bond_type[atom1][m]; + atom2 = atom->map(bond_atom[atom1][m]); + } else { + tagprev = tag[i] - iatom - 1; + btype = atom->map(onemols[imol]->bond_type[atom1][m]); + atom2 = atom->map(onemols[imol]->bond_atom[iatom][m]+tagprev); + } + if (atom2 < 0 || !chooseghost[atom2]) continue; if (newton_bond == 0 && tag[atom1] > tag[atom2]) continue; - if (bond_type[atom1][m] == 0) continue; + if (btype == 0) continue; if (bcolor == ATOM) { if (acolor == TYPE) { @@ -753,7 +776,7 @@ void DumpImage::create_image() color2 = image->map_value2color(0,bufcopy[atom2][0]); } } else if (bcolor == TYPE) { - itype = bond_type[atom1][m]; + itype = btype; if (itype < 0) itype = -itype; color = bcolortype[itype]; } @@ -771,7 +794,7 @@ void DumpImage::create_image() diameter = MIN(bufcopy[atom1][1],bufcopy[atom2][1]); } } else if (bdiam == TYPE) { - itype = bond_type[atom1][m]; + itype = btype; if (itype < 0) itype = -itype; diameter = bdiamtype[itype]; } diff --git a/src/finish.cpp b/src/finish.cpp index 6bcd3d4aa4..c63f1377f5 100644 --- a/src/finish.cpp +++ b/src/finish.cpp @@ -19,6 +19,8 @@ #include "timer.h" #include "universe.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "comm.h" #include "force.h" #include "kspace.h" @@ -764,10 +766,26 @@ void Finish::end(int flag) int nspec; double nspec_all; - if (atom->molecular) { - nspec = 0; + if (atom->molecular == 1) { + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) nspec += atom->nspecial[i][2]; + nspec = 0; + for (i = 0; i < nlocal; i++) nspec += nspecial[i][2]; + tmp = nspec; + MPI_Allreduce(&tmp,&nspec_all,1,MPI_DOUBLE,MPI_SUM,world); + } else if (atom->molecular == 2) { + Molecule **onemols = atom->avec->onemols; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + int nlocal = atom->nlocal; + int imol,iatom; + nspec = 0; + for (i = 0; i < nlocal; i++) { + if (molindex[i] < 0) continue; + imol = molindex[i]; + iatom = molatom[i]; + nspec += onemols[imol]->nspecial[iatom][2]; + } tmp = nspec; MPI_Allreduce(&tmp,&nspec_all,1,MPI_DOUBLE,MPI_SUM,world); } diff --git a/src/input.cpp b/src/input.cpp index 3e1b6517ea..c2c2c992d6 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1517,7 +1517,7 @@ void Input::special_bonds() // if simulation box defined and saved values changed, redo special list - if (domain->box_exist && atom->molecular) { + if (domain->box_exist && atom->molecular == 1) { if (lj2 != force->special_lj[2] || lj3 != force->special_lj[3] || coul2 != force->special_coul[2] || coul3 != force->special_coul[3] || angle != force->special_angle || diff --git a/src/molecule.cpp b/src/molecule.cpp index 27a4a1237d..b1a95247a6 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -348,17 +348,6 @@ void Molecule::read(int flag) if (flag == 0) { if (natoms == 0) error->all(FLERR,"No atom count in molecule file"); - - if (nbonds && !atom->avec->bonds_allow) - error->all(FLERR,"Bonds in molecule file not supported by atom style"); - if (nangles && !atom->avec->angles_allow) - error->all(FLERR,"Angles in molecule file not supported by atom style"); - if (ndihedrals && !atom->avec->dihedrals_allow) - error->all(FLERR, - "Dihedrals in molecule file not supported by atom style"); - if (nimpropers && !atom->avec->impropers_allow) - error->all(FLERR, - "Impropers in molecule file not supported by atom style"); } // count = vector for tallying bonds,angles,etc per atom @@ -455,32 +444,6 @@ void Molecule::read(int flag) // error check if (flag == 0) { - if (qflag && !atom->q_flag) - error->all(FLERR,"Molecule file has undefined atom property"); - if (radiusflag && !atom->radius_flag) - error->all(FLERR,"Molecule file has undefined atom property"); - if (rmassflag && !atom->rmass_flag) - error->all(FLERR,"Molecule file has undefined atom property"); - - if (bondflag && !atom->avec->bonds_allow) - error->all(FLERR,"Invalid molecule file section: Bonds"); - if (angleflag && !atom->avec->angles_allow) - error->all(FLERR,"Invalid molecule file section: Angles"); - if (dihedralflag && !atom->avec->dihedrals_allow) - error->all(FLERR,"Invalid molecule file section: Dihedrals"); - if (improperflag && !atom->avec->impropers_allow) - error->all(FLERR,"Invalid molecule file section: Impropers"); - - if (bond_per_atom > atom->bond_per_atom || - angle_per_atom > atom->angle_per_atom || - dihedral_per_atom > atom->dihedral_per_atom || - improper_per_atom > atom->improper_per_atom) - error->all(FLERR,"Molecule file bond/angle/etc counts " - "per atom are too large"); - - // test for maxspecial > atom->maxspecial is done when molecules added - // in Atom::add_molecule_atom() - if ((nspecialflag && !specialflag) || (!nspecialflag && specialflag)) error->all(FLERR,"Molecule file needs both Special Bond sections"); if (specialflag && !bondflag) @@ -512,7 +475,7 @@ void Molecule::coords(char *line) /* ---------------------------------------------------------------------- read types from file - set maxtype = max of any atom type + set ntypes = max of any atom type ------------------------------------------------------------------------- */ void Molecule::types(char *line) @@ -524,11 +487,11 @@ void Molecule::types(char *line) } for (int i = 0; i < natoms; i++) - if (type[i] <= 0 || type[i] > atom->ntypes) + if (type[i] <= 0) error->all(FLERR,"Invalid atom type in molecule file"); for (int i = 0; i < natoms; i++) - maxtype = MAX(maxtype,type[i]); + ntypes = MAX(ntypes,type[i]); } /* ---------------------------------------------------------------------- @@ -580,6 +543,7 @@ void Molecule::masses(char *line) /* ---------------------------------------------------------------------- read bonds from file + set nbondtypes = max type of any bond store each with both atoms if newton_bond = 0 if flag = 0, just count bonds/atom if flag = 1, store them with atoms @@ -602,11 +566,12 @@ void Molecule::bonds(int flag, char *line) if (atom1 <= 0 || atom1 > natoms || atom2 <= 0 || atom2 > natoms) error->one(FLERR,"Invalid atom ID in Bonds section of molecule file"); - if (itype <= 0 || itype > atom->nbondtypes) + if (itype <= 0) error->one(FLERR,"Invalid bond type in Bonds section of molecule file"); if (flag) { m = atom1-1; + nbondtypes = MAX(nbondtypes,itype); bond_type[m][num_bond[m]] = itype; bond_atom[m][num_bond[m]] = atom2; num_bond[m]++; @@ -656,11 +621,12 @@ void Molecule::angles(int flag, char *line) atom2 <= 0 || atom2 > natoms || atom3 <= 0 || atom3 > natoms) error->one(FLERR,"Invalid atom ID in Angles section of molecule file"); - if (itype <= 0 || itype > atom->nangletypes) + if (itype <= 0) error->one(FLERR,"Invalid angle type in Angles section of molecule file"); if (flag) { m = atom2-1; + nangletypes = MAX(nangletypes,itype); angle_type[m][num_angle[m]] = itype; angle_atom1[m][num_angle[m]] = atom1; angle_atom2[m][num_angle[m]] = atom2; @@ -725,12 +691,13 @@ void Molecule::dihedrals(int flag, char *line) atom4 <= 0 || atom4 > natoms) error->one(FLERR, "Invalid atom ID in dihedrals section of molecule file"); - if (itype <= 0 || itype > atom->ndihedraltypes) + if (itype <= 0) error->one(FLERR, "Invalid dihedral type in dihedrals section of molecule file"); if (flag) { m = atom2-1; + ndihedraltypes = MAX(ndihedraltypes,itype); dihedral_type[m][num_dihedral[m]] = itype; dihedral_atom1[m][num_dihedral[m]] = atom1; dihedral_atom2[m][num_dihedral[m]] = atom2; @@ -802,12 +769,13 @@ void Molecule::impropers(int flag, char *line) atom4 <= 0 || atom4 > natoms) error->one(FLERR, "Invalid atom ID in impropers section of molecule file"); - if (itype <= 0 || itype > atom->nimpropertypes) + if (itype <= 0) error->one(FLERR, "Invalid improper type in impropers section of molecule file"); if (flag) { m = atom2-1; + nimpropertypes = MAX(nimpropertypes,itype); improper_type[m][num_improper[m]] = itype; improper_atom1[m][num_improper[m]] = atom1; improper_atom2[m][num_improper[m]] = atom2; @@ -977,14 +945,79 @@ void Molecule::shaketype_read(char *line) int m = shake_flag[i]; if (m == 1) m = 3; for (int j = 0; j < m-1; j++) - if (shake_type[i][j] <= 0 || shake_type[i][j] > atom->nbondtypes) + if (shake_type[i][j] <= 0) error->all(FLERR,"Invalid shake bond type in molecule file"); if (shake_flag[i] == 1) - if (shake_type[i][2] <= 0 || shake_type[i][2] > atom->nangletypes) + if (shake_type[i][2] <= 0) error->all(FLERR,"Invalid shake angle type in molecule file"); } } +/* ---------------------------------------------------------------------- + error check molecule attributes and topology against system settings + flag = 0, just check this molecule + flag = 1, check all molecules in set, this is 1st molecule in set +------------------------------------------------------------------------- */ + +void Molecule::check_attributes(int flag) +{ + int n = 1; + if (flag) n = nset; + int imol = atom->find_molecule(id); + + for (int i = imol; i < imol+n; i++) { + Molecule *onemol = atom->molecules[imol]; + + // check per-atom attributes of molecule + // warn if not a match + + int mismatch = 0; + if (onemol->qflag && !atom->q_flag) mismatch = 1; + if (onemol->radiusflag && !atom->radius_flag) mismatch = 1; + if (onemol->rmassflag && !atom->rmass_flag) mismatch = 1; + + if (mismatch && me == 0) + error->warning(FLERR, + "Molecule attributes do not match system attributes"); + + // for all atom styles, check nbondtype,etc + + mismatch = 0; + if (atom->nbondtypes < onemol->nbondtypes) mismatch = 1; + if (atom->nangletypes < onemol->nangletypes) mismatch = 1; + if (atom->ndihedraltypes < onemol->ndihedraltypes) mismatch = 1; + if (atom->nimpropertypes < onemol->nimpropertypes) mismatch = 1; + + if (mismatch) + error->all(FLERR,"Molecule topology type exceeds system topology type"); + + // for molecular atom styles, check bond_per_atom,etc + maxspecial + // do not check for atom style template, since nothing stored per atom + + if (atom->molecular == 1) { + if (atom->avec->bonds_allow && + atom->bond_per_atom < onemol->bond_per_atom) mismatch = 1; + if (atom->avec->angles_allow && + atom->angle_per_atom < onemol->angle_per_atom) mismatch = 1; + if (atom->avec->dihedrals_allow && + atom->dihedral_per_atom < onemol->dihedral_per_atom) mismatch = 1; + if (atom->avec->impropers_allow && + atom->improper_per_atom < onemol->improper_per_atom) mismatch = 1; + if (atom->maxspecial < onemol->maxspecial) mismatch = 1; + + if (mismatch) + error->all(FLERR,"Molecule toplogy/atom exceeds system topology/atom"); + + } + + // warn if molecule topology defined but no special settings + + if (onemol->bondflag && !onemol->specialflag) + if (me == 0) error->warning(FLERR,"Molecule has bond topology " + "but no special bond settings"); + } +} + /* ---------------------------------------------------------------------- init all data structures to empty ------------------------------------------------------------------------- */ @@ -993,7 +1026,9 @@ void Molecule::initialize() { natoms = 0; nbonds = nangles = ndihedrals = nimpropers = 0; - maxtype = 0; + ntypes = 0; + nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0; + bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; maxspecial = 0; @@ -1040,6 +1075,7 @@ void Molecule::initialize() /* ---------------------------------------------------------------------- allocate all data structures + also initialize values for data structures that are always allocated ------------------------------------------------------------------------- */ void Molecule::allocate() @@ -1049,9 +1085,24 @@ void Molecule::allocate() if (qflag) memory->create(q,natoms,"molecule:q"); if (radiusflag) memory->create(radius,natoms,"molecule:radius"); if (rmassflag) memory->create(rmass,natoms,"molecule:rmass"); - + + // always allocate num_bond,num_angle,etc and nspecial even if not in file + // initialize to 0 even if not in molecule file + // this is so methods that use these arrays don't have to check they exist + + memory->create(num_bond,natoms,"molecule:num_bond"); + for (int i = 0; i < natoms; i++) num_bond[i] = 0; + memory->create(num_angle,natoms,"molecule:num_angle"); + for (int i = 0; i < natoms; i++) num_angle[i] = 0; + memory->create(num_dihedral,natoms,"molecule:num_dihedral"); + for (int i = 0; i < natoms; i++) num_dihedral[i] = 0; + memory->create(num_improper,natoms,"molecule:num_improper"); + for (int i = 0; i < natoms; i++) num_improper[i] = 0; + memory->create(nspecial,natoms,3,"molecule:nspecial"); + for (int i = 0; i < natoms; i++) + nspecial[i][0] = nspecial[i][1] = nspecial[i][2] = 0; + if (bondflag) { - memory->create(num_bond,natoms,"molecule:num_bond"); memory->create(bond_type,natoms,bond_per_atom, "molecule:bond_type"); memory->create(bond_atom,natoms,bond_per_atom, @@ -1059,7 +1110,6 @@ void Molecule::allocate() } if (angleflag) { - memory->create(num_angle,natoms,"molecule:num_angle"); memory->create(angle_type,natoms,angle_per_atom, "molecule:angle_type"); memory->create(angle_atom1,natoms,angle_per_atom, @@ -1071,7 +1121,6 @@ void Molecule::allocate() } if (dihedralflag) { - memory->create(num_dihedral,natoms,"molecule:num_dihedral"); memory->create(dihedral_type,natoms,dihedral_per_atom, "molecule:dihedral_type"); memory->create(dihedral_atom1,natoms,dihedral_per_atom, @@ -1085,7 +1134,6 @@ void Molecule::allocate() } if (improperflag) { - memory->create(num_improper,natoms,"molecule:num_improper"); memory->create(improper_type,natoms,improper_per_atom, "molecule:improper_type"); memory->create(improper_atom1,natoms,improper_per_atom, @@ -1098,8 +1146,6 @@ void Molecule::allocate() "molecule:improper_atom4"); } - if (nspecialflag) - memory->create(nspecial,natoms,3,"molecule:nspecial"); if (specialflag) memory->create(special,natoms,maxspecial,"molecule:special"); diff --git a/src/molecule.h b/src/molecule.h index d5b406f54a..7518e2da15 100644 --- a/src/molecule.h +++ b/src/molecule.h @@ -28,10 +28,11 @@ class Molecule : protected Pointers { int natoms; int nbonds,nangles,ndihedrals,nimpropers; + int ntypes; + int nbondtypes,nangletypes,ndihedraltypes,nimpropertypes; // max bond,angle,etc per atom - int maxtype; int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; int maxspecial; @@ -105,6 +106,7 @@ class Molecule : protected Pointers { void compute_mass(); void compute_com(); void compute_inertia(); + void check_attributes(int); private: int me; diff --git a/src/neigh_bond.cpp b/src/neigh_bond.cpp index 17a6e55fd8..809ea19841 100644 --- a/src/neigh_bond.cpp +++ b/src/neigh_bond.cpp @@ -13,6 +13,8 @@ #include "neighbor.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "force.h" #include "update.h" #include "domain.h" @@ -92,6 +94,78 @@ void Neighbor::bond_all() /* ---------------------------------------------------------------------- */ +void Neighbor::bond_template() +{ + int i,m,atom1; + int imol,iatom; + tagint tagprev; + int *num_bond; + int **bond_atom,**bond_type; + + Molecule **onemols = atom->avec->onemols; + + tagint *tag = atom->tag; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + int nlocal = atom->nlocal; + int newton_bond = force->newton_bond; + + int lostbond = output->thermo->lostbond; + int nmissing = 0; + nbondlist = 0; + + for (i = 0; i < nlocal; i++) { + if (molindex[i] < 0) continue; + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + num_bond = onemols[imol]->num_bond; + bond_atom = onemols[imol]->bond_atom; + bond_type = onemols[imol]->bond_type; + + for (m = 0; m < num_bond[iatom]; m++) { + if (bond_type[iatom][m] <= 0) continue; + atom1 = atom->map(bond_atom[iatom][m]+tagprev); + if (atom1 == -1) { + nmissing++; + if (lostbond == ERROR) { + char str[128]; + sprintf(str,"Bond atoms " TAGINT_FORMAT " " TAGINT_FORMAT + " missing on proc %d at step " BIGINT_FORMAT, + tag[i],bond_atom[iatom][m]+tagprev,me,update->ntimestep); + error->one(FLERR,str); + } + continue; + } + atom1 = domain->closest_image(i,atom1); + if (newton_bond || i < atom1) { + if (nbondlist == maxbond) { + maxbond += BONDDELTA; + memory->grow(bondlist,maxbond,3,"neighbor:bondlist"); + } + bondlist[nbondlist][0] = i; + bondlist[nbondlist][1] = atom1; + bondlist[nbondlist][2] = bond_type[iatom][m]; + nbondlist++; + } + } + } + + if (cluster_check) bond_check(); + if (lostbond == IGNORE) return; + + int all; + MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); + if (all) { + char str[128]; + sprintf(str, + "Bond atoms missing at step " BIGINT_FORMAT,update->ntimestep); + if (me == 0) error->warning(FLERR,str); + } +} + +/* ---------------------------------------------------------------------- */ + void Neighbor::bond_partial() { int i,m,atom1; @@ -240,6 +314,88 @@ void Neighbor::angle_all() /* ---------------------------------------------------------------------- */ +void Neighbor::angle_template() +{ + int i,m,atom1,atom2,atom3; + int imol,iatom; + tagint tagprev; + int *num_angle; + int **angle_atom1,**angle_atom2,**angle_atom3,**angle_type; + + Molecule **onemols = atom->avec->onemols; + + tagint *tag = atom->tag; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + int nlocal = atom->nlocal; + int newton_bond = force->newton_bond; + + int lostbond = output->thermo->lostbond; + int nmissing = 0; + nanglelist = 0; + + for (i = 0; i < nlocal; i++) { + if (molindex[i] < 0) continue; + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + num_angle = onemols[imol]->num_angle; + angle_atom1 = onemols[imol]->angle_atom1; + angle_atom2 = onemols[imol]->angle_atom2; + angle_atom3 = onemols[imol]->angle_atom3; + angle_type = onemols[imol]->angle_type; + + for (m = 0; m < num_angle[iatom]; m++) { + if (angle_type[iatom][m] <= 0) continue; + atom1 = atom->map(angle_atom1[iatom][m]+tagprev); + atom2 = atom->map(angle_atom2[iatom][m]+tagprev); + atom3 = atom->map(angle_atom3[iatom][m]+tagprev); + if (atom1 == -1 || atom2 == -1 || atom3 == -1) { + nmissing++; + if (lostbond == ERROR) { + char str[128]; + sprintf(str,"Angle atoms " + TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT + " missing on proc %d at step " BIGINT_FORMAT, + angle_atom1[iatom][m]+tagprev,angle_atom2[iatom][m]+tagprev, + angle_atom3[iatom][m]+tagprev, + me,update->ntimestep); + error->one(FLERR,str); + } + continue; + } + atom1 = domain->closest_image(i,atom1); + atom2 = domain->closest_image(i,atom2); + atom3 = domain->closest_image(i,atom3); + if (newton_bond || (i <= atom1 && i <= atom2 && i <= atom3)) { + if (nanglelist == maxangle) { + maxangle += BONDDELTA; + memory->grow(anglelist,maxangle,4,"neighbor:anglelist"); + } + anglelist[nanglelist][0] = atom1; + anglelist[nanglelist][1] = atom2; + anglelist[nanglelist][2] = atom3; + anglelist[nanglelist][3] = angle_type[iatom][m]; + nanglelist++; + } + } + } + + if (cluster_check) angle_check(); + if (lostbond == IGNORE) return; + + int all; + MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); + if (all) { + char str[128]; + sprintf(str, + "Angle atoms missing at step " BIGINT_FORMAT,update->ntimestep); + if (me == 0) error->warning(FLERR,str); + } +} + +/* ---------------------------------------------------------------------- */ + void Neighbor::angle_partial() { int i,m,atom1,atom2,atom3; @@ -417,6 +573,96 @@ void Neighbor::dihedral_all() /* ---------------------------------------------------------------------- */ +void Neighbor::dihedral_template() +{ + int i,m,atom1,atom2,atom3,atom4; + int imol,iatom; + tagint tagprev; + int *num_dihedral; + int **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4; + int **dihedral_type; + + Molecule **onemols = atom->avec->onemols; + + tagint *tag = atom->tag; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + int nlocal = atom->nlocal; + int newton_bond = force->newton_bond; + + int lostbond = output->thermo->lostbond; + int nmissing = 0; + ndihedrallist = 0; + + for (i = 0; i < nlocal; i++) { + if (molindex[i] < 0) continue; + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + num_dihedral = onemols[imol]->num_dihedral; + dihedral_atom1 = onemols[imol]->dihedral_atom1; + dihedral_atom2 = onemols[imol]->dihedral_atom2; + dihedral_atom3 = onemols[imol]->dihedral_atom3; + dihedral_atom4 = onemols[imol]->dihedral_atom4; + dihedral_type = onemols[imol]->dihedral_type; + + for (m = 0; m < num_dihedral[iatom]; m++) { + atom1 = atom->map(dihedral_atom1[iatom][m]+tagprev); + atom2 = atom->map(dihedral_atom2[iatom][m]+tagprev); + atom3 = atom->map(dihedral_atom3[iatom][m]+tagprev); + atom4 = atom->map(dihedral_atom4[iatom][m]+tagprev); + if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) { + nmissing++; + if (lostbond == ERROR) { + char str[128]; + sprintf(str,"Dihedral atoms " + TAGINT_FORMAT " " TAGINT_FORMAT " " + TAGINT_FORMAT " " TAGINT_FORMAT + " missing on proc %d at step " BIGINT_FORMAT, + dihedral_atom1[iatom][m]+tagprev, + dihedral_atom2[iatom][m]+tagprev, + dihedral_atom3[iatom][m]+tagprev, + dihedral_atom4[iatom][m]+tagprev, + me,update->ntimestep); + error->one(FLERR,str); + } + continue; + } + atom1 = domain->closest_image(i,atom1); + atom2 = domain->closest_image(i,atom2); + atom3 = domain->closest_image(i,atom3); + atom4 = domain->closest_image(i,atom4); + if (newton_bond || + (i <= atom1 && i <= atom2 && i <= atom3 && i <= atom4)) { + if (ndihedrallist == maxdihedral) { + maxdihedral += BONDDELTA; + memory->grow(dihedrallist,maxdihedral,5,"neighbor:dihedrallist"); + } + dihedrallist[ndihedrallist][0] = atom1; + dihedrallist[ndihedrallist][1] = atom2; + dihedrallist[ndihedrallist][2] = atom3; + dihedrallist[ndihedrallist][3] = atom4; + dihedrallist[ndihedrallist][4] = dihedral_type[iatom][m]; + ndihedrallist++; + } + } + } + + if (cluster_check) dihedral_check(ndihedrallist,dihedrallist); + if (lostbond == IGNORE) return; + + int all; + MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); + if (all) { + char str[128]; + sprintf(str, + "Dihedral atoms missing at step " BIGINT_FORMAT,update->ntimestep); + if (me == 0) error->warning(FLERR,str); + } +} + +/* ---------------------------------------------------------------------- */ + void Neighbor::dihedral_partial() { int i,m,atom1,atom2,atom3,atom4; @@ -618,6 +864,96 @@ void Neighbor::improper_all() /* ---------------------------------------------------------------------- */ +void Neighbor::improper_template() +{ + int i,m,atom1,atom2,atom3,atom4; + int imol,iatom; + tagint tagprev; + int *num_improper; + int **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; + int **improper_type; + + Molecule **onemols = atom->avec->onemols; + + tagint *tag = atom->tag; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + int nlocal = atom->nlocal; + int newton_bond = force->newton_bond; + + int lostbond = output->thermo->lostbond; + int nmissing = 0; + nimproperlist = 0; + + for (i = 0; i < nlocal; i++) { + if (molindex[i] < 0) continue; + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + num_improper = onemols[imol]->num_improper; + improper_atom1 = onemols[imol]->improper_atom1; + improper_atom2 = onemols[imol]->improper_atom2; + improper_atom3 = onemols[imol]->improper_atom3; + improper_atom4 = onemols[imol]->improper_atom4; + improper_type = onemols[imol]->improper_type; + + for (m = 0; m < num_improper[iatom]; m++) { + atom1 = atom->map(improper_atom1[iatom][m]+tagprev); + atom2 = atom->map(improper_atom2[iatom][m]+tagprev); + atom3 = atom->map(improper_atom3[iatom][m]+tagprev); + atom4 = atom->map(improper_atom4[iatom][m]+tagprev); + if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) { + nmissing++; + if (lostbond == ERROR) { + char str[128]; + sprintf(str,"Improper atoms " + TAGINT_FORMAT " " TAGINT_FORMAT " " + TAGINT_FORMAT " " TAGINT_FORMAT + " missing on proc %d at step " BIGINT_FORMAT, + improper_atom1[iatom][m]+tagprev, + improper_atom2[iatom][m]+tagprev, + improper_atom3[iatom][m]+tagprev, + improper_atom4[iatom][m]+tagprev, + me,update->ntimestep); + error->one(FLERR,str); + } + continue; + } + atom1 = domain->closest_image(i,atom1); + atom2 = domain->closest_image(i,atom2); + atom3 = domain->closest_image(i,atom3); + atom4 = domain-> closest_image(i,atom4); + if (newton_bond || + (i <= atom1 && i <= atom2 && i <= atom3 && i <= atom4)) { + if (nimproperlist == maximproper) { + maximproper += BONDDELTA; + memory->grow(improperlist,maximproper,5,"neighbor:improperlist"); + } + improperlist[nimproperlist][0] = atom1; + improperlist[nimproperlist][1] = atom2; + improperlist[nimproperlist][2] = atom3; + improperlist[nimproperlist][3] = atom4; + improperlist[nimproperlist][4] = improper_type[iatom][m]; + nimproperlist++; + } + } + } + + if (cluster_check) dihedral_check(nimproperlist,improperlist); + if (lostbond == IGNORE) return; + + int all; + MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); + if (all) { + char str[128]; + sprintf(str, + "Improper atoms missing at step " BIGINT_FORMAT,update->ntimestep); + if (me == 0) error->warning(FLERR,str); + } +} + +/* ---------------------------------------------------------------------- */ + void Neighbor::improper_partial() { int i,m,atom1,atom2,atom3,atom4; diff --git a/src/neigh_full.cpp b/src/neigh_full.cpp index 6df4bfb512..87dfd1fa09 100644 --- a/src/neigh_full.cpp +++ b/src/neigh_full.cpp @@ -14,6 +14,8 @@ #include "neighbor.h" #include "neigh_list.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "domain.h" #include "my_page.h" #include "group.h" @@ -28,26 +30,32 @@ using namespace LAMMPS_NS; void Neighbor::full_nsq(NeighList *list) { - int i,j,n,itype,jtype,which,bitmask; + int i,j,n,itype,jtype,which,bitmask,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - int molecular = atom->molecular; if (includegroup) { nlocal = atom->nfirst; bitmask = group->bitmask[includegroup]; } + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -66,6 +74,11 @@ void Neighbor::full_nsq(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms, owned and ghost // skip i = j @@ -82,7 +95,13 @@ void Neighbor::full_nsq(NeighList *list) rsq = delx*delx + dely*dely + delz*delz; if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -111,21 +130,27 @@ void Neighbor::full_nsq(NeighList *list) void Neighbor::full_nsq_ghost(NeighList *list) { - int i,j,n,itype,jtype,which; + int i,j,n,itype,jtype,which,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -145,6 +170,11 @@ void Neighbor::full_nsq_ghost(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms, owned and ghost // skip i = j @@ -162,7 +192,13 @@ void Neighbor::full_nsq_ghost(NeighList *list) rsq = delx*delx + dely*dely + delz*delz; if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -204,7 +240,8 @@ void Neighbor::full_nsq_ghost(NeighList *list) void Neighbor::full_bin(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which; + int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -212,18 +249,23 @@ void Neighbor::full_bin(NeighList *list) bin_atoms(); - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - int molecular = atom->molecular; if (includegroup) nlocal = atom->nfirst; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -244,6 +286,11 @@ void Neighbor::full_bin(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in surrounding bins in stencil including self // skip i = j @@ -264,7 +311,13 @@ void Neighbor::full_bin(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -294,7 +347,8 @@ void Neighbor::full_bin(NeighList *list) void Neighbor::full_bin_ghost(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which; + int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int xbin,ybin,zbin,xbin2,ybin2,zbin2; int *neighptr; @@ -303,17 +357,22 @@ void Neighbor::full_bin_ghost(NeighList *list) bin_atoms(); - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -336,6 +395,11 @@ void Neighbor::full_bin_ghost(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in surrounding bins in stencil including self // when i is a ghost atom, must check if stencil bin is out of bounds @@ -358,7 +422,13 @@ void Neighbor::full_bin_ghost(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -413,7 +483,8 @@ void Neighbor::full_bin_ghost(NeighList *list) void Neighbor::full_multi(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which,ns; + int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*s; double *cutsq,*distsq; @@ -422,20 +493,23 @@ void Neighbor::full_multi(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - int molecular = atom->molecular; if (includegroup) nlocal = atom->nfirst; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -447,6 +521,8 @@ void Neighbor::full_multi(NeighList *list) int inum = 0; ipage->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = 0; neighptr = ipage->vget(); @@ -455,6 +531,11 @@ void Neighbor::full_multi(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in other bins in stencil, including self // skip if i,j neighbor cutoff is less than bin distance @@ -480,7 +561,13 @@ void Neighbor::full_multi(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; diff --git a/src/neigh_half_bin.cpp b/src/neigh_half_bin.cpp index 68f7832fa2..7b7fc3833e 100644 --- a/src/neigh_half_bin.cpp +++ b/src/neigh_half_bin.cpp @@ -14,6 +14,8 @@ #include "neighbor.h" #include "neigh_list.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "domain.h" #include "my_page.h" #include "error.h" @@ -29,7 +31,8 @@ using namespace LAMMPS_NS; void Neighbor::half_bin_no_newton(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which; + int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -37,19 +40,22 @@ void Neighbor::half_bin_no_newton(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; if (includegroup) nlocal = atom->nfirst; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -61,6 +67,8 @@ void Neighbor::half_bin_no_newton(NeighList *list) int inum = 0; ipage->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = 0; neighptr = ipage->vget(); @@ -69,6 +77,11 @@ void Neighbor::half_bin_no_newton(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in other bins in stencil including self // only store pair if i < j @@ -91,11 +104,18 @@ void Neighbor::half_bin_no_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); + // OLD: if (which >= 0) neighptr[n++] = j ^ (which << SBBITS); } else neighptr[n++] = j; } } @@ -123,7 +143,8 @@ void Neighbor::half_bin_no_newton(NeighList *list) void Neighbor::half_bin_no_newton_ghost(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which; + int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int xbin,ybin,zbin,xbin2,ybin2,zbin2; int *neighptr; @@ -132,19 +153,23 @@ void Neighbor::half_bin_no_newton_ghost(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; + if (includegroup) nlocal = atom->nfirst; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -157,6 +182,8 @@ void Neighbor::half_bin_no_newton_ghost(NeighList *list) int inum = 0; ipage->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nall; i++) { n = 0; neighptr = ipage->vget(); @@ -165,6 +192,11 @@ void Neighbor::half_bin_no_newton_ghost(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in other bins in stencil including self // when i is a ghost atom, must check if stencil bin is out of bounds @@ -191,7 +223,13 @@ void Neighbor::half_bin_no_newton_ghost(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -246,7 +284,8 @@ void Neighbor::half_bin_no_newton_ghost(NeighList *list) void Neighbor::half_bin_newton(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which; + int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -254,19 +293,22 @@ void Neighbor::half_bin_newton(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; if (includegroup) nlocal = atom->nfirst; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -278,6 +320,8 @@ void Neighbor::half_bin_newton(NeighList *list) int inum = 0; ipage->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = 0; neighptr = ipage->vget(); @@ -286,6 +330,11 @@ void Neighbor::half_bin_newton(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over rest of atoms in i's bin, ghosts are at end of linked list // if j is owned atom, store it, since j is beyond i in linked list @@ -310,7 +359,13 @@ void Neighbor::half_bin_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -335,7 +390,13 @@ void Neighbor::half_bin_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -365,7 +426,8 @@ void Neighbor::half_bin_newton(NeighList *list) void Neighbor::half_bin_newton_tri(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which; + int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -373,19 +435,22 @@ void Neighbor::half_bin_newton_tri(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; if (includegroup) nlocal = atom->nfirst; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -397,6 +462,8 @@ void Neighbor::half_bin_newton_tri(NeighList *list) int inum = 0; ipage->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = 0; neighptr = ipage->vget(); @@ -405,6 +472,11 @@ void Neighbor::half_bin_newton_tri(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in bins in stencil // pairs for atoms j "below" i are excluded @@ -434,7 +506,13 @@ void Neighbor::half_bin_newton_tri(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; diff --git a/src/neigh_half_multi.cpp b/src/neigh_half_multi.cpp index 6dc03a43ef..82eb6afbd6 100644 --- a/src/neigh_half_multi.cpp +++ b/src/neigh_half_multi.cpp @@ -14,6 +14,8 @@ #include "neighbor.h" #include "neigh_list.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "domain.h" #include "my_page.h" #include "error.h" @@ -30,7 +32,8 @@ using namespace LAMMPS_NS; void Neighbor::half_multi_no_newton(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which,ns; + int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*s; double *cutsq,*distsq; @@ -39,20 +42,23 @@ void Neighbor::half_multi_no_newton(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - int molecular = atom->molecular; if (includegroup) nlocal = atom->nfirst; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -64,6 +70,8 @@ void Neighbor::half_multi_no_newton(NeighList *list) int inum = 0; ipage->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = 0; neighptr = ipage->vget(); @@ -72,6 +80,11 @@ void Neighbor::half_multi_no_newton(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in other bins in stencil including self // only store pair if i < j @@ -99,7 +112,13 @@ void Neighbor::half_multi_no_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -129,7 +148,8 @@ void Neighbor::half_multi_no_newton(NeighList *list) void Neighbor::half_multi_newton(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which,ns; + int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*s; double *cutsq,*distsq; @@ -138,20 +158,23 @@ void Neighbor::half_multi_newton(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - int molecular = atom->molecular; if (includegroup) nlocal = atom->nfirst; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -163,6 +186,8 @@ void Neighbor::half_multi_newton(NeighList *list) int inum = 0; ipage->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = 0; neighptr = ipage->vget(); @@ -171,6 +196,11 @@ void Neighbor::half_multi_newton(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over rest of atoms in i's bin, ghosts are at end of linked list // if j is owned atom, store it, since j is beyond i in linked list @@ -195,7 +225,13 @@ void Neighbor::half_multi_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -226,7 +262,13 @@ void Neighbor::half_multi_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -256,7 +298,8 @@ void Neighbor::half_multi_newton(NeighList *list) void Neighbor::half_multi_newton_tri(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which,ns; + int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*s; double *cutsq,*distsq; @@ -265,20 +308,23 @@ void Neighbor::half_multi_newton_tri(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - int molecular = atom->molecular; if (includegroup) nlocal = atom->nfirst; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -290,6 +336,8 @@ void Neighbor::half_multi_newton_tri(NeighList *list) int inum = 0; ipage->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = 0; neighptr = ipage->vget(); @@ -298,6 +346,11 @@ void Neighbor::half_multi_newton_tri(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in bins, including self, in stencil // skip if i,j neighbor cutoff is less than bin distance @@ -334,7 +387,13 @@ void Neighbor::half_multi_newton_tri(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; diff --git a/src/neigh_half_nsq.cpp b/src/neigh_half_nsq.cpp index efdd26a311..f90512f878 100644 --- a/src/neigh_half_nsq.cpp +++ b/src/neigh_half_nsq.cpp @@ -14,6 +14,8 @@ #include "neighbor.h" #include "neigh_list.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "domain.h" #include "group.h" #include "error.h" @@ -28,26 +30,32 @@ using namespace LAMMPS_NS; void Neighbor::half_nsq_no_newton(NeighList *list) { - int i,j,n,itype,jtype,which,bitmask; + int i,j,n,itype,jtype,which,bitmask,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - int molecular = atom->molecular; if (includegroup) { nlocal = atom->nfirst; bitmask = group->bitmask[includegroup]; } + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -66,6 +74,11 @@ void Neighbor::half_nsq_no_newton(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over remaining atoms, owned and ghost // only store pair if i < j @@ -82,7 +95,13 @@ void Neighbor::half_nsq_no_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -112,26 +131,32 @@ void Neighbor::half_nsq_no_newton(NeighList *list) void Neighbor::half_nsq_no_newton_ghost(NeighList *list) { - int i,j,n,itype,jtype,which,bitmask; + int i,j,n,itype,jtype,which,bitmask,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - int molecular = atom->molecular; if (includegroup) { nlocal = atom->nfirst; bitmask = group->bitmask[includegroup]; } + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -150,6 +175,11 @@ void Neighbor::half_nsq_no_newton_ghost(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over remaining atoms, owned and ghost // only store pair if i < j @@ -171,7 +201,13 @@ void Neighbor::half_nsq_no_newton_ghost(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; @@ -215,28 +251,32 @@ void Neighbor::half_nsq_no_newton_ghost(NeighList *list) void Neighbor::half_nsq_newton(NeighList *list) { - int i,j,n,itype,jtype,itag,jtag,which,bitmask; + int i,j,n,itype,jtype,itag,jtag,which,bitmask,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - int molecular = atom->molecular; if (includegroup) { nlocal = atom->nfirst; bitmask = group->bitmask[includegroup]; } + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -245,6 +285,8 @@ void Neighbor::half_nsq_newton(NeighList *list) int inum = 0; ipage->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = 0; neighptr = ipage->vget(); @@ -254,6 +296,11 @@ void Neighbor::half_nsq_newton(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over remaining atoms, owned and ghost // itag = jtag is possible for long cutoffs that include images of self @@ -286,7 +333,13 @@ void Neighbor::half_nsq_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if (domain->minimum_image_check(delx,dely,delz)) neighptr[n++] = j; diff --git a/src/neigh_respa.cpp b/src/neigh_respa.cpp index 1e7bc78a1d..bbf24fa551 100644 --- a/src/neigh_respa.cpp +++ b/src/neigh_respa.cpp @@ -14,6 +14,8 @@ #include "neighbor.h" #include "neigh_list.h" #include "atom.h" +#include "atom_vec.h" +#include "molecule.h" #include "domain.h" #include "group.h" #include "my_page.h" @@ -30,28 +32,32 @@ using namespace LAMMPS_NS; void Neighbor::respa_nsq_no_newton(NeighList *list) { - int i,j,n,itype,jtype,n_inner,n_middle,bitmask; + int i,j,n,itype,jtype,n_inner,n_middle,bitmask,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - int molecular = atom->molecular; if (includegroup) { nlocal = atom->nfirst; bitmask = group->bitmask[includegroup]; } + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -82,6 +88,8 @@ void Neighbor::respa_nsq_no_newton(NeighList *list) ipage_inner->reset(); if (respamiddle) ipage_middle->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = n_inner = 0; neighptr = ipage->vget(); @@ -95,6 +103,11 @@ void Neighbor::respa_nsq_no_newton(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over remaining atoms, owned and ghost @@ -110,7 +123,13 @@ void Neighbor::respa_nsq_no_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; @@ -174,27 +193,32 @@ void Neighbor::respa_nsq_no_newton(NeighList *list) void Neighbor::respa_nsq_newton(NeighList *list) { int i,j,n,itype,jtype,itag,jtag,n_inner,n_middle,bitmask; + int imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - int molecular = atom->molecular; if (includegroup) { nlocal = atom->nfirst; bitmask = group->bitmask[includegroup]; } + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -225,6 +249,8 @@ void Neighbor::respa_nsq_newton(NeighList *list) ipage_inner->reset(); if (respamiddle) ipage_middle->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = n_inner = 0; neighptr = ipage->vget(); @@ -239,6 +265,11 @@ void Neighbor::respa_nsq_newton(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over remaining atoms, owned and ghost @@ -270,7 +301,13 @@ void Neighbor::respa_nsq_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; @@ -334,7 +371,8 @@ void Neighbor::respa_nsq_newton(NeighList *list) void Neighbor::respa_bin_no_newton(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,n_inner,n_middle; + int i,j,k,n,itype,jtype,ibin,n_inner,n_middle,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; @@ -342,20 +380,23 @@ void Neighbor::respa_bin_no_newton(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - int molecular = atom->molecular; if (includegroup) nlocal = atom->nfirst; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -388,6 +429,8 @@ void Neighbor::respa_bin_no_newton(NeighList *list) ipage_inner->reset(); if (respamiddle) ipage_middle->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = n_inner = 0; neighptr = ipage->vget(); @@ -402,6 +445,11 @@ void Neighbor::respa_bin_no_newton(NeighList *list) ytmp = x[i][1]; ztmp = x[i][2]; ibin = coord2bin(x[i]); + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in surrounding bins in stencil including self // only store pair if i < j @@ -422,7 +470,13 @@ void Neighbor::respa_bin_no_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; @@ -487,7 +541,8 @@ void Neighbor::respa_bin_no_newton(NeighList *list) void Neighbor::respa_bin_newton(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,n_inner,n_middle; + int i,j,k,n,itype,jtype,ibin,n_inner,n_middle,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; @@ -495,20 +550,23 @@ void Neighbor::respa_bin_newton(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - int molecular = atom->molecular; if (includegroup) nlocal = atom->nfirst; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -541,6 +599,8 @@ void Neighbor::respa_bin_newton(NeighList *list) ipage_inner->reset(); if (respamiddle) ipage_middle->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = n_inner = 0; neighptr = ipage->vget(); @@ -554,6 +614,11 @@ void Neighbor::respa_bin_newton(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over rest of atoms in i's bin, ghosts are at end of linked list // if j is owned atom, store it, since j is beyond i in linked list @@ -578,7 +643,13 @@ void Neighbor::respa_bin_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; @@ -616,7 +687,13 @@ void Neighbor::respa_bin_newton(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; @@ -681,7 +758,8 @@ void Neighbor::respa_bin_newton(NeighList *list) void Neighbor::respa_bin_newton_tri(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,n_inner,n_middle; + int i,j,k,n,itype,jtype,ibin,n_inner,n_middle,imol,iatom,moltemplate; + tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; @@ -689,20 +767,23 @@ void Neighbor::respa_bin_newton_tri(NeighList *list) bin_atoms(); - // loop over each atom, storing neighbors - - tagint **special = atom->special; - int **nspecial = atom->nspecial; - tagint *tag = atom->tag; - double **x = atom->x; int *type = atom->type; int *mask = atom->mask; - tagint *molecule = atom->molecule; + int *tag = atom->tag; + int *molecule = atom->molecule; + int **special = atom->special; + int **nspecial = atom->nspecial; int nlocal = atom->nlocal; - int molecular = atom->molecular; if (includegroup) nlocal = atom->nfirst; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + int molecular = atom->molecular; + if (molecular == 2) moltemplate = 1; + else moltemplate = 0; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -735,6 +816,8 @@ void Neighbor::respa_bin_newton_tri(NeighList *list) ipage_inner->reset(); if (respamiddle) ipage_middle->reset(); + // loop over each atom, storing neighbors + for (i = 0; i < nlocal; i++) { n = n_inner = 0; neighptr = ipage->vget(); @@ -748,6 +831,11 @@ void Neighbor::respa_bin_newton_tri(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } // loop over all atoms in bins in stencil // pairs for atoms j "below" i are excluded @@ -777,7 +865,13 @@ void Neighbor::respa_bin_newton_tri(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) { if (molecular) { - which = find_special(special[i],nspecial[i],tag[j]); + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which == 0; if (which == 0) neighptr[n++] = j; else if ((minchange = domain->minimum_image_check(delx,dely,delz))) neighptr[n++] = j; diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 11c11001d3..731278a87e 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -758,6 +758,7 @@ void Neighbor::init() } // set flags that determine which topology neighboring routines to use + // bonds,etc can only be broken for atom->molecular = 1, not 2 // SHAKE sets bonds and angles negative // bond_quartic sets bonds to 0 // delete_bonds sets all interactions negative @@ -769,7 +770,7 @@ void Neighbor::init() bond_off = angle_off = 1; if (force->bond && force->bond_match("quartic")) bond_off = 1; - if (atom->avec->bonds_allow) { + if (atom->avec->bonds_allow && atom->molecular == 1) { for (i = 0; i < atom->nlocal; i++) { if (bond_off) break; for (m = 0; m < atom->num_bond[i]; m++) @@ -777,7 +778,7 @@ void Neighbor::init() } } - if (atom->avec->angles_allow) { + if (atom->avec->angles_allow && atom->molecular == 1) { for (i = 0; i < atom->nlocal; i++) { if (angle_off) break; for (m = 0; m < atom->num_angle[i]; m++) @@ -786,7 +787,7 @@ void Neighbor::init() } int dihedral_off = 0; - if (atom->avec->dihedrals_allow) { + if (atom->avec->dihedrals_allow && atom->molecular == 1) { for (i = 0; i < atom->nlocal; i++) { if (dihedral_off) break; for (m = 0; m < atom->num_dihedral[i]; m++) @@ -795,7 +796,7 @@ void Neighbor::init() } int improper_off = 0; - if (atom->avec->impropers_allow) { + if (atom->avec->impropers_allow && atom->molecular == 1) { for (i = 0; i < atom->nlocal; i++) { if (improper_off) break; for (m = 0; m < atom->num_improper[i]; m++) @@ -817,15 +818,19 @@ void Neighbor::init() // set ptrs to topology build functions if (bond_off) bond_build = &Neighbor::bond_partial; + else if (atom->molecular == 2) bond_build = &Neighbor::bond_template; else bond_build = &Neighbor::bond_all; if (angle_off) angle_build = &Neighbor::angle_partial; + else if (atom->molecular == 2) angle_build = &Neighbor::angle_template; else angle_build = &Neighbor::angle_all; if (dihedral_off) dihedral_build = &Neighbor::dihedral_partial; + else if (atom->molecular == 2) dihedral_build = &Neighbor::dihedral_template; else dihedral_build = &Neighbor::dihedral_all; if (improper_off) improper_build = &Neighbor::improper_partial; + else if (atom->molecular == 2) improper_build = &Neighbor::improper_template; else improper_build = &Neighbor::improper_all; // set topology neighbor list counts to 0 @@ -914,7 +919,7 @@ void Neighbor::choose_build(int index, NeighRequest *rq) else pb = &Neighbor::half_bin_no_newton_ghost; } else if (triclinic == 0) { pb = &Neighbor::half_bin_newton; - } else if (triclinic == 1) + } else if (triclinic == 1) pb = &Neighbor::half_bin_newton_tri; } else if (rq->newton == 1) { if (triclinic == 0) pb = &Neighbor::half_bin_newton; @@ -1319,7 +1324,7 @@ int Neighbor::check_distance() /* ---------------------------------------------------------------------- build all perpetual neighbor lists every few timesteps pairwise & topology lists are created as needed - topology lists only built if topoflag = 1 + topology lists only built if topoflag = 1, USER-CUDA calls with topoflag = 0 ------------------------------------------------------------------------- */ void Neighbor::build(int topoflag) diff --git a/src/neighbor.h b/src/neighbor.h index 2bf33d22e1..8812aa5455 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -260,21 +260,25 @@ class Neighbor : protected Pointers { BondPtr bond_build; // ptr to bond list functions void bond_all(); // bond list with all bonds + void bond_template(); // bond list with templated bonds void bond_partial(); // exclude certain bonds void bond_check(); BondPtr angle_build; // ptr to angle list functions void angle_all(); // angle list with all angles + void angle_template(); // angle list with templated bonds void angle_partial(); // exclude certain angles void angle_check(); BondPtr dihedral_build; // ptr to dihedral list functions void dihedral_all(); // dihedral list with all dihedrals + void dihedral_template(); // dihedral list with templated bonds void dihedral_partial(); // exclude certain dihedrals void dihedral_check(int, int **); BondPtr improper_build; // ptr to improper list functions void improper_all(); // improper list with all impropers + void improper_template(); // improper list with templated bonds void improper_partial(); // exclude certain impropers // find_special: determine if atom j is in special list of atom i diff --git a/src/read_data.cpp b/src/read_data.cpp index 2a512350fe..d6959ae9d5 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -23,6 +23,7 @@ #include "atom_vec_ellipsoid.h" #include "atom_vec_line.h" #include "atom_vec_tri.h" +#include "molecule.h" #include "comm.h" #include "update.h" #include "modify.h" @@ -269,25 +270,25 @@ void ReadData::command(int narg, char **arg) } else if (strcmp(keyword,"Bonds") == 0) { topoflag = bondflag = 1; - if (atom->avec->bonds_allow == 0) + if (atom->nbonds == 0) error->all(FLERR,"Invalid data file section: Bonds"); if (atomflag == 0) error->all(FLERR,"Must read Atoms before Bonds"); bonds(firstpass); } else if (strcmp(keyword,"Angles") == 0) { topoflag = angleflag = 1; - if (atom->avec->angles_allow == 0) + if (atom->nangles == 0) error->all(FLERR,"Invalid data file section: Angles"); if (atomflag == 0) error->all(FLERR,"Must read Atoms before Angles"); angles(firstpass); } else if (strcmp(keyword,"Dihedrals") == 0) { topoflag = dihedralflag = 1; - if (atom->avec->dihedrals_allow == 0) + if (atom->ndihedrals == 0) error->all(FLERR,"Invalid data file section: Dihedrals"); if (atomflag == 0) error->all(FLERR,"Must read Atoms before Dihedrals"); dihedrals(firstpass); } else if (strcmp(keyword,"Impropers") == 0) { topoflag = improperflag = 1; - if (atom->avec->impropers_allow == 0) + if (atom->nimpropers == 0) error->all(FLERR,"Invalid data file section: Impropers"); if (atomflag == 0) error->all(FLERR,"Must read Atoms before Impropers"); impropers(firstpass); @@ -538,10 +539,83 @@ void ReadData::command(int narg, char **arg) // create special bond lists for molecular systems - if (atom->molecular) { + if (atom->molecular == 1) { Special special(lmp); special.build(); } + + // for atom style template systems, count total bonds,angles,etc + + if (atom->molecular == 2) { + Molecule **onemols = atom->avec->onemols; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + int nlocal = atom->nlocal; + + int imol,iatom; + bigint nbonds,nangles,ndihedrals,nimpropers; + nbonds = nangles = ndihedrals = nimpropers = 0; + + for (int i = 0; i < nlocal; i++) { + imol = molindex[i]; + iatom = molatom[i]; + nbonds += onemols[imol]->num_bond[iatom]; + nangles += onemols[imol]->num_angle[iatom]; + ndihedrals += onemols[imol]->num_dihedral[iatom]; + nimpropers += onemols[imol]->num_improper[iatom]; + } + + MPI_Allreduce(&nbonds,&atom->nbonds,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&nangles,&atom->nangles,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&ndihedrals,&atom->ndihedrals,1,MPI_LMP_BIGINT,MPI_SUM,world); + MPI_Allreduce(&nimpropers,&atom->nimpropers,1,MPI_LMP_BIGINT,MPI_SUM,world); + + if (!force->newton_bond) { + atom->nbonds /= 2; + atom->nangles /= 3; + atom->ndihedrals /= 4; + atom->nimpropers /= 4; + } + + if (me == 0) { + if (atom->nbonds) { + if (screen) + fprintf(screen," " BIGINT_FORMAT " template bonds\n",atom->nbonds); + if (logfile) + fprintf(logfile," " BIGINT_FORMAT " template bonds\n",atom->nbonds); + } + if (atom->nangles) { + if (screen) + fprintf(screen," " BIGINT_FORMAT " template angles\n", + atom->nangles); + if (logfile) + fprintf(logfile," " BIGINT_FORMAT " template angles\n", + atom->nangles); + } + if (atom->ndihedrals) { + if (screen) + fprintf(screen," " BIGINT_FORMAT " template dihedrals\n", + atom->nbonds); + if (logfile) + fprintf(logfile," " BIGINT_FORMAT " template bonds\n", + atom->ndihedrals); + } + if (atom->nimpropers) { + if (screen) + fprintf(screen," " BIGINT_FORMAT " template impropers\n", + atom->nimpropers); + if (logfile) + fprintf(logfile," " BIGINT_FORMAT " template impropers\n", + atom->nimpropers); + } + } + } + + // for atom style template systems + // insure nbondtypes,etc are still consistent with template molecules, + // in case data file re-defined them + + if (atom->molecular == 2) atom->avec->onemols[0]->check_attributes(1); } /* ---------------------------------------------------------------------- @@ -626,20 +700,20 @@ void ReadData::header() // otherwise "triangles" will be matched as "angles" } else if (strstr(line,"ellipsoids")) { - if (!avec_ellipsoid && me == 0) - error->one(FLERR,"No ellipsoids allowed with this atom style"); + if (!avec_ellipsoid) + error->all(FLERR,"No ellipsoids allowed with this atom style"); sscanf(line,BIGINT_FORMAT,&nellipsoids); } else if (strstr(line,"lines")) { - if (!avec_line && me == 0) - error->one(FLERR,"No lines allowed with this atom style"); + if (!avec_line) + error->all(FLERR,"No lines allowed with this atom style"); sscanf(line,BIGINT_FORMAT,&nlines); } else if (strstr(line,"triangles")) { - if (!avec_tri && me == 0) - error->one(FLERR,"No triangles allowed with this atom style"); + if (!avec_tri) + error->all(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"); + if (!avec_body) + error->all(FLERR,"No bodies allowed with this atom style"); sscanf(line,BIGINT_FORMAT,&nbodies); } @@ -687,44 +761,49 @@ void ReadData::header() atom->nbonds < 0 || atom->nbonds >= MAXBIGINT || atom->nangles < 0 || atom->nangles >= MAXBIGINT || atom->ndihedrals < 0 || atom->ndihedrals >= MAXBIGINT || - atom->nimpropers < 0 || atom->nimpropers >= MAXBIGINT) { - if (me == 0) error->one(FLERR,"System in data file is too big"); - } + atom->nimpropers < 0 || atom->nimpropers >= MAXBIGINT) + error->all(FLERR,"System in data file is too big"); // check that exiting string is a valid section keyword parse_keyword(1); for (n = 0; n < NSECTIONS; n++) if (strcmp(keyword,section_keywords[n]) == 0) break; - if (n == NSECTIONS && me == 0) { + if (n == NSECTIONS) { char str[128]; sprintf(str,"Unknown identifier in data file: %s",keyword); - error->one(FLERR,str); + error->all(FLERR,str); } - // error check on consistency of header values + // error checks on header values + // must be consistent with atom style and other header values if ((atom->nbonds || atom->nbondtypes) && - atom->avec->bonds_allow == 0 && me == 0) - error->one(FLERR,"No bonds allowed with this atom style"); + atom->avec->bonds_allow == 0) + error->all(FLERR,"No bonds allowed with this atom style"); if ((atom->nangles || atom->nangletypes) && - atom->avec->angles_allow == 0 && me == 0) - error->one(FLERR,"No angles allowed with this atom style"); + atom->avec->angles_allow == 0) + error->all(FLERR,"No angles allowed with this atom style"); if ((atom->ndihedrals || atom->ndihedraltypes) && - atom->avec->dihedrals_allow == 0 && me == 0) - error->one(FLERR,"No dihedrals allowed with this atom style"); + atom->avec->dihedrals_allow == 0) + error->all(FLERR,"No dihedrals allowed with this atom style"); if ((atom->nimpropers || atom->nimpropertypes) && - atom->avec->impropers_allow == 0 && me == 0) - error->one(FLERR,"No impropers allowed with this atom style"); + atom->avec->impropers_allow == 0) + error->all(FLERR,"No impropers allowed with this atom style"); + + if (atom->nbonds > 0 && atom->nbondtypes <= 0) + error->all(FLERR,"Bonds defined but no bond types"); + if (atom->nangles > 0 && atom->nangletypes <= 0) + error->all(FLERR,"Angles defined but no angle types"); + if (atom->ndihedrals > 0 && atom->ndihedraltypes <= 0) + error->all(FLERR,"Dihedrals defined but no dihedral types"); + if (atom->nimpropers > 0 && atom->nimpropertypes <= 0) + error->all(FLERR,"Impropers defined but no improper types"); - if (atom->nbonds > 0 && atom->nbondtypes <= 0 && me == 0) - error->one(FLERR,"Bonds defined but no bond types"); - if (atom->nangles > 0 && atom->nangletypes <= 0 && me == 0) - error->one(FLERR,"Angles defined but no angle types"); - if (atom->ndihedrals > 0 && atom->ndihedraltypes <= 0 && me == 0) - error->one(FLERR,"Dihedrals defined but no dihedral types"); - if (atom->nimpropers > 0 && atom->nimpropertypes <= 0 && me == 0) - error->one(FLERR,"Impropers defined but no improper types"); + if (atom->molecular == 2) { + if (atom->nbonds || atom->nangles || atom->ndihedrals || atom->nimpropers) + error->all(FLERR,"No molecule topology allowed with atom style template"); + } } /* ---------------------------------------------------------------------- @@ -870,7 +949,7 @@ void ReadData::bonds(int firstpass) if (screen) fprintf(screen," %d = max bonds/atom\n",maxall); if (logfile) fprintf(logfile," %d = max bonds/atom\n",maxall); } - atom->bond_per_atom = maxall; + atom->bond_per_atom = maxall + atom->extra_bond_per_atom; memory->destroy(count); return; } @@ -944,7 +1023,7 @@ void ReadData::angles(int firstpass) if (screen) fprintf(screen," %d = max angles/atom\n",maxall); if (logfile) fprintf(logfile," %d = max angles/atom\n",maxall); } - atom->angle_per_atom = maxall; + atom->angle_per_atom = maxall + atom->extra_angle_per_atom; memory->destroy(count); return; } @@ -1018,7 +1097,7 @@ void ReadData::dihedrals(int firstpass) if (screen) fprintf(screen," %d = max dihedrals/atom\n",maxall); if (logfile) fprintf(logfile," %d = max dihedrals/atom\n",maxall); } - atom->dihedral_per_atom = maxall; + atom->dihedral_per_atom = maxall + atom->extra_dihedral_per_atom; memory->destroy(count); return; } @@ -1092,7 +1171,7 @@ void ReadData::impropers(int firstpass) if (screen) fprintf(screen," %d = max impropers/atom\n",maxall); if (logfile) fprintf(logfile," %d = max impropers/atom\n",maxall); } - atom->improper_per_atom = maxall; + atom->improper_per_atom = maxall + atom->extra_improper_per_atom; memory->destroy(count); return; } @@ -1162,7 +1241,7 @@ void ReadData::bonus(bigint nbonus, AtomVec *ptr, const char *type) void ReadData::bodies(int firstpass) { - int i,m,nchunk,nmax,ninteger,ndouble,tmp,onebody; + int i,m,nchunk,nline,nmax,ninteger,ndouble,tmp,onebody; char *eof; int mapflag = 0; @@ -1184,10 +1263,10 @@ void ReadData::bodies(int firstpass) if (me == 0) { nchunk = 0; - nlines = 0; + nline = 0; m = 0; - while (nchunk < nmax && nlines <= CHUNK-MAXBODY) { + while (nchunk < nmax && nline <= 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); @@ -1207,7 +1286,7 @@ void ReadData::bodies(int firstpass) } nchunk++; - nlines += onebody+1; + nline += onebody+1; } if (buffer[m-1] != '\n') strcpy(&buffer[m++],"\n"); @@ -1401,11 +1480,11 @@ void ReadData::fix(int ifix, char *keyword) { int nchunk,eof; - bigint nlines = modify->fix[ifix]->read_data_skip_lines(keyword); + bigint nline = modify->fix[ifix]->read_data_skip_lines(keyword); bigint nread = 0; - while (nread < nlines) { - nchunk = MIN(nlines-nread,CHUNK); + while (nread < nline) { + nchunk = MIN(nline-nread,CHUNK); eof = comm->read_lines_from_file(fp,nchunk,MAXLINE,buffer); if (eof) error->all(FLERR,"Unexpected end of data file"); modify->fix[ifix]->read_data_section(keyword,nchunk,buffer); diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 2d6db0ec87..13795b0c43 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -510,7 +510,7 @@ void ReadRestart::command(int narg, char **arg) // create special bond lists for molecular systems - if (atom->molecular) { + if (atom->molecular == 1) { Special special(lmp); special.build(); } @@ -764,26 +764,17 @@ void ReadRestart::header(int incompatible) domain->nonperiodic = 2; } - // create new AtomVec class - // if style = hybrid, read additional sub-class arguments + // create new AtomVec class using any stored args } else if (flag == ATOM_STYLE) { char *style = read_string(); - - int nwords = 0; - char **words = NULL; - - if (strcmp(style,"hybrid") == 0) { - nwords = read_int(); - words = new char*[nwords]; - for (int i = 0; i < nwords; i++) words[i] = read_string(); - } - - atom->create_avec(style,nwords,words); - atom->avec->read_restart_settings(fp); - - for (int i = 0; i < nwords; i++) delete [] words[i]; - delete [] words; + int nargcopy = read_int(); + char **argcopy = new char*[nargcopy]; + for (int i = 0; i < nargcopy; i++) + argcopy[i] = read_string(); + atom->create_avec(style,nargcopy,argcopy); + for (int i = 0; i < nargcopy; i++) delete [] argcopy[i]; + delete [] argcopy; delete [] style; } else if (flag == NATOMS) { @@ -933,10 +924,10 @@ void ReadRestart::file_layout() error->all(FLERR,"Restart file is not a MPI-IO file"); if (mpiioflag) { - long *nproc_chunk_offsets; + bigint *nproc_chunk_offsets; memory->create(nproc_chunk_offsets,nprocs, "write_restart:nproc_chunk_offsets"); - long *nproc_chunk_sizes; + bigint *nproc_chunk_sizes; memory->create(nproc_chunk_sizes,nprocs, "write_restart:nproc_chunk_sizes"); @@ -966,7 +957,7 @@ void ReadRestart::file_layout() } int all_written_send_sizes_index = 0; - long current_offset = 0; + bigint current_offset = 0; for (int i=0;idestroy(nproc_chunk_sizes); memory->destroy(nproc_chunk_offsets); @@ -1004,7 +995,7 @@ void ReadRestart::file_layout() if (mpiioflag) { if (me == 0) headerOffset = ftell(fp); - MPI_Bcast(&headerOffset,1,MPI_LONG,0,world); + MPI_Bcast(&headerOffset,1,MPI_LMP_BIGINT,0,world); } } diff --git a/src/read_restart.h b/src/read_restart.h index f0032aa7aa..2af94c5a87 100644 --- a/src/read_restart.h +++ b/src/read_restart.h @@ -43,7 +43,7 @@ class ReadRestart : protected Pointers { int mpiioflag; // 1 for MPIIO output, else 0 class RestartMPIIO *mpiio; // MPIIO for restart file input int numChunksAssigned; - long assignedChunkSize; + bigint assignedChunkSize; MPI_Offset assignedChunkOffset,headerOffset; void file_search(char *, char *); diff --git a/src/replicate.cpp b/src/replicate.cpp index b31506d6c1..b50d676561 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -110,20 +110,11 @@ void Replicate::command(int narg, char **arg) // old = original atom class // atom = new replicated atom class - // if old atom style was hybrid, pass sub-style names to create_avec Atom *old = atom; atom = new Atom(lmp); atom->settings(old); - - int nstyles = 0; - char **keywords = NULL; - if (strcmp(old->atom_style,"hybrid") == 0) { - AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) old->avec; - nstyles = avec_hybrid->nstyles; - keywords = avec_hybrid->keywords; - } - atom->create_avec(old->atom_style,nstyles,keywords); + atom->create_avec(old->atom_style,old->avec->nargcopy,old->avec->argcopy); // check that new system will not be too large // new tags cannot exceed MAXTAGINT @@ -313,32 +304,34 @@ void Replicate::command(int narg, char **arg) atom->tag[i] += atom_offset; atom->image[i] = image; - if (atom->molecule_flag) { + if (atom->molecular) { if (atom->molecule[i] > 0) atom->molecule[i] += mol_offset; - if (atom->avec->bonds_allow) - for (j = 0; j < atom->num_bond[i]; j++) - atom->bond_atom[i][j] += atom_offset; - if (atom->avec->angles_allow) - for (j = 0; j < atom->num_angle[i]; j++) { - atom->angle_atom1[i][j] += atom_offset; - atom->angle_atom2[i][j] += atom_offset; - atom->angle_atom3[i][j] += atom_offset; - } - if (atom->avec->dihedrals_allow) - for (j = 0; j < atom->num_dihedral[i]; j++) { - atom->dihedral_atom1[i][j] += atom_offset; - atom->dihedral_atom2[i][j] += atom_offset; - atom->dihedral_atom3[i][j] += atom_offset; - atom->dihedral_atom4[i][j] += atom_offset; - } - if (atom->avec->impropers_allow) - for (j = 0; j < atom->num_improper[i]; j++) { - atom->improper_atom1[i][j] += atom_offset; - atom->improper_atom2[i][j] += atom_offset; - atom->improper_atom3[i][j] += atom_offset; - atom->improper_atom4[i][j] += atom_offset; - } + if (atom->molecular == 1) { + if (atom->avec->bonds_allow) + for (j = 0; j < atom->num_bond[i]; j++) + atom->bond_atom[i][j] += atom_offset; + if (atom->avec->angles_allow) + for (j = 0; j < atom->num_angle[i]; j++) { + atom->angle_atom1[i][j] += atom_offset; + atom->angle_atom2[i][j] += atom_offset; + atom->angle_atom3[i][j] += atom_offset; + } + if (atom->avec->dihedrals_allow) + for (j = 0; j < atom->num_dihedral[i]; j++) { + atom->dihedral_atom1[i][j] += atom_offset; + atom->dihedral_atom2[i][j] += atom_offset; + atom->dihedral_atom3[i][j] += atom_offset; + atom->dihedral_atom4[i][j] += atom_offset; + } + if (atom->avec->impropers_allow) + for (j = 0; j < atom->num_improper[i]; j++) { + atom->improper_atom1[i][j] += atom_offset; + atom->improper_atom2[i][j] += atom_offset; + atom->improper_atom3[i][j] += atom_offset; + atom->improper_atom4[i][j] += atom_offset; + } + } } } else m += static_cast (buf[m]); } @@ -404,7 +397,7 @@ void Replicate::command(int narg, char **arg) // create special bond lists for molecular systems - if (atom->molecular) { + if (atom->molecular == 1) { Special special(lmp); special.build(); } diff --git a/src/set.cpp b/src/set.cpp index 108aecc239..c221fbc3e0 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -845,6 +845,11 @@ void Set::topology(int keyword) { int m,atom1,atom2,atom3,atom4; + // error check + + if (atom->molecular == 2) + error->all(FLERR,"Cannot set bond topology types for atom style template"); + // border swap to acquire ghost atom info // enforce PBC before in case atoms are outside box // init entire system since comm->exchange is done diff --git a/src/variable.cpp b/src/variable.cpp index 1cc4b0d24b..124adb0597 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -3554,7 +3554,7 @@ void Variable::atom_vector(char *word, Tree **tree, error->one(FLERR,"Variable uses atom property that isn't allocated"); if (sizeof(tagint) == sizeof(smallint)) { newtree->type = INTARRAY; - newtree->iarray = (int *)atom->molecule; + newtree->iarray = (int *) atom->molecule; } else { newtree->type = BIGINTARRAY; newtree->barray = (bigint *) atom->molecule; diff --git a/src/version.h b/src/version.h index cc9d03c9b9..6df31a52ed 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "27 Jan 2014" +#define LAMMPS_VERSION "29 Jan 2014" diff --git a/src/write_data.cpp b/src/write_data.cpp index a07c280e4a..41d35c31ca 100644 --- a/src/write_data.cpp +++ b/src/write_data.cpp @@ -152,11 +152,11 @@ void WriteData::write(char *file) // sum up bond,angle counts // may be different than atom->nbonds,nangles if broken/turned-off - if (atom->nbonds || atom->nbondtypes) { + if (atom->molecular == 1 && atom->nbonds || atom->nbondtypes) { nbonds_local = atom->avec->pack_bond(NULL); MPI_Allreduce(&nbonds_local,&nbonds,1,MPI_LMP_BIGINT,MPI_SUM,world); } - if (atom->nangles || atom->nangletypes) { + if (atom->molecular == 1 && atom->nangles || atom->nangletypes) { nangles_local = atom->avec->pack_angle(NULL); MPI_Allreduce(&nangles_local,&nangles,1,MPI_LMP_BIGINT,MPI_SUM,world); } @@ -181,13 +181,16 @@ void WriteData::write(char *file) } // per atom info + // do not write molecular topology for atom_style template if (natoms) atoms(); if (natoms) velocities(); - if (atom->nbonds && nbonds) bonds(); - if (atom->nangles && nangles) angles(); - if (atom->ndihedrals) dihedrals(); - if (atom->nimpropers) impropers(); + if (atom->molecular == 1) { + if (atom->nbonds && nbonds) bonds(); + if (atom->nangles && nangles) angles(); + if (atom->ndihedrals) dihedrals(); + if (atom->nimpropers) impropers(); + } // extra sections managed by fixes @@ -276,21 +279,19 @@ void WriteData::force_fields() force->pair->write_data_all(fp); } } - if (atom->avec->bonds_allow && force->bond && force->bond->writedata) { + if (force->bond && force->bond->writedata) { fprintf(fp,"\nBond Coeffs # %s\n\n", force->bond_style); force->bond->write_data(fp); } - if (atom->avec->angles_allow && force->angle && force->angle->writedata) { + if (force->angle && force->angle->writedata) { fprintf(fp,"\nAngle Coeffs # %s\n\n", force->angle_style); force->angle->write_data(fp); } - if (atom->avec->dihedrals_allow && force->dihedral && - force->dihedral->writedata) { + if (force->dihedral && force->dihedral->writedata) { fprintf(fp,"\nDihedral Coeffs # %s\n\n", force->dihedral_style); force->dihedral->write_data(fp); } - if (atom->avec->impropers_allow && force->improper && - force->improper->writedata) { + if (force->improper && force->improper->writedata) { fprintf(fp,"\nImproper Coeffs # %s\n\n", force->improper_style); force->improper->write_data(fp); } diff --git a/src/write_restart.cpp b/src/write_restart.cpp index ca5c5fcd96..18390b7d35 100644 --- a/src/write_restart.cpp +++ b/src/write_restart.cpp @@ -449,25 +449,15 @@ void WriteRestart::header() write_int(ZPERIODIC,domain->zperiodic); write_int_vec(BOUNDARY,6,&domain->boundary[0][0]); - // 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 atom_style and its args write_string(ATOM_STYLE,atom->atom_style); - - if (strcmp(atom->atom_style,"hybrid") == 0) { - AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) atom->avec; - int nstyles = avec_hybrid->nstyles; - char **keywords = avec_hybrid->keywords; - fwrite(&nstyles,sizeof(int),1,fp); - for (int i = 0; i < nstyles; i++) { - int n = strlen(keywords[i]) + 1; - fwrite(&n,sizeof(int),1,fp); - fwrite(keywords[i],sizeof(char),n,fp); - } + fwrite(&atom->avec->nargcopy,sizeof(int),1,fp); + for (int i = 0; i < atom->avec->nargcopy; i++) { + int n = strlen(atom->avec->argcopy[i]) + 1; + fwrite(&n,sizeof(int),1,fp); + fwrite(atom->avec->argcopy[i],sizeof(char),n,fp); } - atom->avec->write_restart_settings(fp); write_bigint(NATOMS,natoms); write_int(NTYPES,atom->ntypes); @@ -579,7 +569,7 @@ void WriteRestart::file_layout(int send_size) if (mpiioflag) { if (me == 0) headerOffset = ftell(fp); - MPI_Bcast(&headerOffset,1,MPI_LONG,0,world); + MPI_Bcast(&headerOffset,1,MPI_LMP_BIGINT,0,world); } }