Merge branch 'master' of https://github.com/lammps/lammps into lammps-master2

This commit is contained in:
Jacob Gissinger
2021-08-20 10:53:04 -04:00
4453 changed files with 106551 additions and 73942 deletions

View File

@ -39,7 +39,7 @@
#include <cmath>
#include <cstring>
#ifdef LMP_USER_INTEL
#ifdef LMP_INTEL
#include "neigh_request.h"
#endif
@ -162,7 +162,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
sp = fm = fm_long = nullptr;
// USER-EFF and USER-AWPMD packages
// EFF and AWPMD packages
spin = nullptr;
eradius = ervel = erforce = nullptr;
@ -170,23 +170,27 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
cs = csforce = vforce = nullptr;
etag = nullptr;
// USER-DPD package
// CG-DNA package
id5p = nullptr;
// DPD-REACT package
uCond = uMech = uChem = uCG = uCGnew = nullptr;
duChem = dpdTheta = nullptr;
// USER-MESO package
// MESO package
cc = cc_flux = nullptr;
edpd_temp = edpd_flux = edpd_cv = nullptr;
// USER-MESONT package
// MESONT package
length = nullptr;
buckling = nullptr;
bond_nt = nullptr;
// USER-SMD package
// MACHDYN package
contact_radius = nullptr;
smd_data_9 = nullptr;
@ -195,11 +199,15 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
eff_plastic_strain_rate = nullptr;
damage = nullptr;
// USER-SPH package
// SPH package
rho = drho = esph = desph = cv = nullptr;
vest = nullptr;
// DIELECTRIC package
area = ed = em = epsilon = curvature = q_unscaled = nullptr;
// end of customization section
// --------------------------------------------------------------------
@ -215,10 +223,13 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
// custom atom arrays
nivector = ndvector = 0;
nivector = ndvector = niarray = ndarray = 0;
ivector = nullptr;
dvector = nullptr;
iname = dname = nullptr;
iarray = nullptr;
darray = nullptr;
icols = dcols = nullptr;
ivname = dvname = ianame = daname = nullptr;
// initialize atom style and array existence flags
@ -299,20 +310,33 @@ Atom::~Atom()
// delete custom atom arrays
for (int i = 0; i < nivector; i++) {
delete [] iname[i];
delete [] ivname[i];
memory->destroy(ivector[i]);
}
if (dvector != nullptr) {
for (int i = 0; i < ndvector; i++) {
delete [] dname[i];
for (int i = 0; i < ndvector; i++) {
delete [] dvname[i];
if (dvector) // (needed for Kokkos)
memory->destroy(dvector[i]);
}
}
for (int i = 0; i < niarray; i++) {
delete [] ianame[i];
memory->destroy(iarray[i]);
}
for (int i = 0; i < ndarray; i++) {
delete [] daname[i];
memory->destroy(darray[i]);
}
memory->sfree(iname);
memory->sfree(dname);
memory->sfree(ivname);
memory->sfree(dvname);
memory->sfree(ianame);
memory->sfree(daname);
memory->sfree(ivector);
memory->sfree(dvector);
memory->sfree(iarray);
memory->sfree(darray);
memory->sfree(icols);
memory->sfree(dcols);
// delete user-defined molecules
@ -464,14 +488,14 @@ void Atom::peratom_create()
add_peratom("fm",&fm,DOUBLE,3,1);
add_peratom("fm_long",&fm_long,DOUBLE,3,1);
// USER-EFF package
// EFF package
add_peratom("spin",&spin,INT,0);
add_peratom("eradius",&eradius,DOUBLE,0);
add_peratom("ervel",&ervel,DOUBLE,0);
add_peratom("erforce",&erforce,DOUBLE,0,1); // set per-thread flag
// USER-AWPMD package
// AWPMD package
add_peratom("cs",&cs,DOUBLE,2);
add_peratom("csforce",&csforce,DOUBLE,2);
@ -479,7 +503,11 @@ void Atom::peratom_create()
add_peratom("ervelforce",&ervelforce,DOUBLE,0);
add_peratom("etag",&etag,INT,0);
// USER-DPD package
// CG-DNA package
add_peratom("id5p",&id5p,tagintsize,0);
// DPD-REACT package
add_peratom("dpdTheta",&dpdTheta,DOUBLE,0);
add_peratom("uCond",&uCond,DOUBLE,0);
@ -489,7 +517,7 @@ void Atom::peratom_create()
add_peratom("uCGnew",&uCGnew,DOUBLE,0);
add_peratom("duChem",&duChem,DOUBLE,0);
// USER-MESO package
// MESO package
add_peratom("edpd_cv",&edpd_cv,DOUBLE,0);
add_peratom("edpd_temp",&edpd_temp,DOUBLE,0);
@ -498,13 +526,13 @@ void Atom::peratom_create()
add_peratom("cc",&cc,DOUBLE,1);
add_peratom("cc_flux",&cc_flux,DOUBLE,1,1); // set per-thread flag
// USER-MESONT package
// MESONT package
add_peratom("length",&length,DOUBLE,0);
add_peratom("buckling",&buckling,INT,0);
add_peratom("bond_nt",&bond_nt,tagintsize,2);
// USER-SPH package
// SPH package
add_peratom("rho",&rho,DOUBLE,0);
add_peratom("drho",&drho,DOUBLE,0,1); // set per-thread flag
@ -513,7 +541,7 @@ void Atom::peratom_create()
add_peratom("vest",&vest,DOUBLE,3);
add_peratom("cv",&cv,DOUBLE,0);
// USER-SMD package
// MACHDYN package
add_peratom("contact_radius",&contact_radius,DOUBLE,0);
add_peratom("smd_data_9",&smd_data_9,DOUBLE,1);
@ -522,6 +550,15 @@ void Atom::peratom_create()
add_peratom("eff_plastic_strain_rate",&eff_plastic_strain_rate,DOUBLE,0);
add_peratom("damage",&damage,DOUBLE,0);
// DIELECTRIC package
add_peratom("area",&area,DOUBLE,0);
add_peratom("ed",&ed,DOUBLE,0);
add_peratom("em",&em,DOUBLE,0);
add_peratom("epsilon",&epsilon,DOUBLE,0);
add_peratom("curvature",&curvature,DOUBLE,0);
add_peratom("q_unscaled",&q_unscaled,DOUBLE,0);
// end of customization section
// --------------------------------------------------------------------
}
@ -1282,6 +1319,7 @@ void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset,
bond_type[m][num_bond[m]] = itype;
bond_atom[m][num_bond[m]] = atom2;
num_bond[m]++;
avec->data_bonds_post(m, num_bond[m], atom1, atom2, id_offset);
}
}
if (newton_bond == 0) {
@ -1291,6 +1329,7 @@ void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset,
bond_type[m][num_bond[m]] = itype;
bond_atom[m][num_bond[m]] = atom1;
num_bond[m]++;
avec->data_bonds_post(m, num_bond[m], atom1, atom2, id_offset);
}
}
}
@ -2249,7 +2288,7 @@ void Atom::setup_sort_bins()
bininvy = nbiny / (bboxhi[1]-bboxlo[1]);
bininvz = nbinz / (bboxhi[2]-bboxlo[2]);
#ifdef LMP_USER_INTEL
#ifdef LMP_INTEL
int intel_neigh = 0;
if (neighbor->nrequest) {
if (neighbor->requests[0]->intel) intel_neigh = 1;
@ -2453,92 +2492,143 @@ void Atom::update_callback(int ifix)
/* ----------------------------------------------------------------------
find custom per-atom vector with name
return index if found, and flag = 0/1 for int/double
return -1 if not found
return index if found, -1 if not found
lists of names can have NULL entries if previously removed
return flag = 0/1 for int/double
return cols = 0/N for vector/array where N = # of columns
------------------------------------------------------------------------- */
int Atom::find_custom(const char *name, int &flag)
int Atom::find_custom(const char *name, int &flag, int &cols)
{
if (name == nullptr) return -1;
for (int i = 0; i < nivector; i++)
if (iname[i] && strcmp(iname[i],name) == 0) {
if (ivname[i] && strcmp(ivname[i],name) == 0) {
flag = 0;
cols = 0;
return i;
}
for (int i = 0; i < ndvector; i++)
if (dname[i] && strcmp(dname[i],name) == 0) {
if (dvname[i] && strcmp(dvname[i],name) == 0) {
flag = 1;
cols = 0;
return i;
}
for (int i = 0; i < niarray; i++)
if (ianame[i] && strcmp(ianame[i],name) == 0) {
flag = 0;
cols = icols[i];
return i;
}
for (int i = 0; i < ndarray; i++)
if (daname[i] && strcmp(daname[i],name) == 0) {
flag = 1;
cols = dcols[i];
return i;
}
return -1;
}
/** \brief Add a custom per-atom property with the given name and type
/** \brief Add a custom per-atom property with the given name and type and size
\verbatim embed:rst
This function will add a custom per-atom property with the name "name"
as either list of int or double to the list of custom properties. This
function is called, e.g. from :doc:`fix property/atom <fix_property_atom>`.
This function will add a custom per-atom property with one or more values
with the name "name" to the list of custom properties.
This function is called, e.g. from :doc:`fix property/atom <fix_property_atom>`.
\endverbatim
* \param name Name of the property (w/o a "d_" or "i_" prefix)
* \param name Name of the property (w/o a "i_" or "d_" or "i2_" or "d2_" prefix)
* \param flag Data type of property: 0 for int, 1 for double
* \return Index of property in the respective list of properties
* \param cols Number of values: 0 for a single value, 1 or more for a vector of values
* \return index of property in the respective list of properties
*/
int Atom::add_custom(const char *name, int flag)
int Atom::add_custom(const char *name, int flag, int cols)
{
int index;
if (flag == 0) {
if ((flag == 0) && (cols == 0)) {
index = nivector;
nivector++;
iname = (char **) memory->srealloc(iname,nivector*sizeof(char *),
"atom:iname");
iname[index] = utils::strdup(name);
ivector = (int **) memory->srealloc(ivector,nivector*sizeof(int *),
"atom:ivector");
ivname = (char **) memory->srealloc(ivname,nivector*sizeof(char *),"atom:ivname");
ivname[index] = utils::strdup(name);
ivector = (int **) memory->srealloc(ivector,nivector*sizeof(int *),"atom:ivector");
memory->create(ivector[index],nmax,"atom:ivector");
} else {
} else if ((flag == 1) && (cols == 0)) {
index = ndvector;
ndvector++;
dname = (char **) memory->srealloc(dname,ndvector*sizeof(char *),
"atom:dname");
dname[index] = utils::strdup(name);
dvector = (double **) memory->srealloc(dvector,ndvector*sizeof(double *),
"atom:dvector");
dvname = (char **) memory->srealloc(dvname,ndvector*sizeof(char *),"atom:dvname");
dvname[index] = utils::strdup(name);
dvector = (double **) memory->srealloc(dvector,ndvector*sizeof(double *),"atom:dvector");
memory->create(dvector[index],nmax,"atom:dvector");
} else if ((flag == 0) && (cols > 0)) {
index = niarray;
niarray++;
ianame = (char **) memory->srealloc(ianame,niarray*sizeof(char *),"atom:ianame");
ianame[index] = utils::strdup(name);
iarray = (int ***) memory->srealloc(iarray,niarray*sizeof(int **),"atom:iarray");
memory->create(iarray[index],nmax,cols,"atom:iarray");
icols = (int *) memory->srealloc(icols,niarray*sizeof(int),"atom:icols");
icols[index] = cols;
} else if ((flag == 1) && (cols > 0)) {
index = ndarray;
ndarray++;
daname = (char **) memory->srealloc(daname,ndarray*sizeof(char *),"atom:daname");
daname[index] = utils::strdup(name);
darray = (double ***) memory->srealloc(darray,ndarray*sizeof(double **),"atom:darray");
memory->create(darray[index],nmax,cols,"atom:darray");
dcols = (int *) memory->srealloc(dcols,ndarray*sizeof(int),"atom:dcols");
dcols[index] = cols;
}
return index;
}
/*! \brief Remove a custom per-atom property of a given type
/*! \brief Remove a custom per-atom property of a given type and size
*
\verbatim embed:rst
This will remove a property that was requested e.g. by the
This will remove a property that was requested, e.g. by the
:doc:`fix property/atom <fix_property_atom>` command. It frees the
allocated memory and sets the pointer to ``nullptr`` to the entry in
the list can be reused. The lists of those pointers will never be
compacted or never shrink, so that index to name mappings remain valid.
allocated memory and sets the pointer to ``nullptr`` for the entry in
the list so it can be reused. The lists of these pointers are never
compacted or shrink, so that indices to name mappings remain valid.
\endverbatim
*
* \param flag whether the property is integer (=0) or double (=1)
* \param index of that property in the respective list.
* \param index Index of property in the respective list of properties
* \param flag Data type of property: 0 for int, 1 for double
* \param cols Number of values: 0 for a single value, 1 or more for a vector of values
*/
void Atom::remove_custom(int flag, int index)
void Atom::remove_custom(int index, int flag, int cols)
{
if (flag == 0) {
if (flag == 0 && cols == 0) {
memory->destroy(ivector[index]);
ivector[index] = nullptr;
delete [] iname[index];
iname[index] = nullptr;
} else {
ivector[index] = NULL;
delete [] ivname[index];
ivname[index] = NULL;
} else if (flag == 1 && cols == 0) {
memory->destroy(dvector[index]);
dvector[index] = nullptr;
delete [] dname[index];
dname[index] = nullptr;
dvector[index] = NULL;
delete [] dvname[index];
dvname[index] = NULL;
} else if (flag == 0 && cols) {
memory->destroy(iarray[index]);
iarray[index] = NULL;
delete [] ianame[index];
ianame[index] = NULL;
} else if (flag == 1 && cols) {
memory->destroy(darray[index]);
darray[index] = NULL;
delete [] daname[index];
daname[index] = NULL;
}
}
@ -2646,6 +2736,22 @@ length of the data area, and a short description.
- int
- 1
- 1 if the particle is a body particle, 0 if not
* - i_name
- int
- 1
- single integer value defined by fix property/atom vector name
* - d_name
- double
- 1
- single double value defined by fix property/atom vector name
* - i2_name
- int
- n
- N integer values defined by fix property/atom array name
* - d2_name
- double
- n
- N double values defined by fix property/atom array name
*See also*
:cpp:func:`lammps_extract_atom`
@ -2662,10 +2768,8 @@ void *Atom::extract(const char *name)
{
// --------------------------------------------------------------------
// 4th customization section: customize by adding new variable name
// please see the following function to set the type of the data
// so that programs can detect it dynamically at run time.
// if new variable is from a package, add package comment
/* NOTE: this array is only of length ntypes+1 */
if (strcmp(name,"mass") == 0) return (void *) mass;
if (strcmp(name,"id") == 0) return (void *) tag;
@ -2709,11 +2813,14 @@ void *Atom::extract(const char *name)
if (strcmp(name,"cv") == 0) return (void *) cv;
if (strcmp(name,"vest") == 0) return (void *) vest;
// USER-MESONT package
// MESONT package
if (strcmp(name,"length") == 0) return (void *) length;
if (strcmp(name,"buckling") == 0) return (void *) buckling;
if (strcmp(name,"bond_nt") == 0) return (void *) bond_nt;
// MACHDYN package
if (strcmp(name, "contact_radius") == 0) return (void *) contact_radius;
if (strcmp(name, "smd_data_9") == 0) return (void *) smd_data_9;
if (strcmp(name, "smd_stress") == 0) return (void *) smd_stress;
@ -2723,16 +2830,50 @@ void *Atom::extract(const char *name)
return (void *) eff_plastic_strain_rate;
if (strcmp(name, "damage") == 0) return (void *) damage;
// DPD-REACT pakage
if (strcmp(name,"dpdTheta") == 0) return (void *) dpdTheta;
// DPD-MESO package
if (strcmp(name,"edpd_temp") == 0) return (void *) edpd_temp;
// DIELECTRIC package
if (strcmp(name,"area") == 0) return (void *) area;
if (strcmp(name,"ed") == 0) return (void *) ed;
if (strcmp(name,"em") == 0) return (void *) em;
if (strcmp(name,"epsilon") == 0) return (void *) epsilon;
if (strcmp(name,"curvature") == 0) return (void *) curvature;
if (strcmp(name,"q_unscaled") == 0) return (void *) q_unscaled;
// end of customization section
// --------------------------------------------------------------------
// custom vectors and arrays
if (utils::strmatch(name,"^[id]2?_")) {
int which = 0, array = 0;
if (name[0] == 'd') which = 1;
if (name[1] == '2') array = 1;
int index,flag,cols;
if (!array) index = find_custom(&name[2],flag,cols);
else index = find_custom(&name[3],flag,cols);
if (index < 0) return NULL;
if (which != flag) return NULL;
if ((!array && cols) || (array && !cols)) return NULL;
if (!which && !array) return (void *) ivector[index];
if (which && !array) return (void *) dvector[index];
if (!which && array) return (void *) iarray[index];
if (which && array) return (void *) darray[index];
}
return nullptr;
}
/** Provide data type info about internal data of the Atom class
*
\verbatim embed:rst
@ -2794,11 +2935,14 @@ int Atom::extract_datatype(const char *name)
if (strcmp(name,"cv") == 0) return LAMMPS_DOUBLE;
if (strcmp(name,"vest") == 0) return LAMMPS_DOUBLE_2D;
// USER-MESONT package
// MESONT package
if (strcmp(name,"length") == 0) return LAMMPS_DOUBLE;
if (strcmp(name,"buckling") == 0) return LAMMPS_INT;
if (strcmp(name,"bond_nt") == 0) return LAMMPS_TAGINT_2D;
// MACHDYN package
if (strcmp(name, "contact_radius") == 0) return LAMMPS_DOUBLE;
if (strcmp(name, "smd_data_9") == 0) return LAMMPS_DOUBLE_2D;
if (strcmp(name, "smd_stress") == 0) return LAMMPS_DOUBLE_2D;
@ -2806,12 +2950,45 @@ int Atom::extract_datatype(const char *name)
if (strcmp(name, "eff_plastic_strain_rate") == 0) return LAMMPS_DOUBLE;
if (strcmp(name, "damage") == 0) return LAMMPS_DOUBLE;
// DPD-REACT package
if (strcmp(name,"dpdTheta") == 0) return LAMMPS_DOUBLE;
// DPD-MESO package
if (strcmp(name,"edpd_temp") == 0) return LAMMPS_DOUBLE;
// DIELECTRIC package
if (strcmp(name,"area") == 0) return LAMMPS_DOUBLE;
if (strcmp(name,"ed") == 0) return LAMMPS_DOUBLE;
if (strcmp(name,"em") == 0) return LAMMPS_DOUBLE;
if (strcmp(name,"epsilon") == 0) return LAMMPS_DOUBLE;
if (strcmp(name,"curvature") == 0) return LAMMPS_DOUBLE;
if (strcmp(name,"q_unscaled") == 0) return LAMMPS_DOUBLE;
// end of customization section
// --------------------------------------------------------------------
// custom vectors and arrays
if (utils::strmatch(name,"^[id]2?_")) {
int which = 0, array = 0;
if (name[0] == 'd') which = 1;
if (name[1] == '2') array = 1;
int index,flag,cols;
if (!array) index = find_custom(&name[2],flag,cols);
else index = find_custom(&name[3],flag,cols);
if (index < 0) return -1;
if (which != flag) return -1;
if ((!array && cols) || (array && !cols)) return -1;
if (which == 0) return LAMMPS_INT;
else return LAMMPS_DOUBLE;
}
return -1;
}