Merge branch 'master' into feature-cnt
This commit is contained in:
504
src/atom.cpp
504
src/atom.cpp
@ -44,9 +44,11 @@ using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
#define DELTA 1
|
||||
#define DELTA_MEMSTR 1024
|
||||
#define DELTA_PERATOM 64
|
||||
#define EPSILON 1.0e-6
|
||||
|
||||
enum{DOUBLE,INT,BIGINT};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
@ -66,66 +68,31 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
binhead = NULL;
|
||||
next = permute = NULL;
|
||||
|
||||
// initialize atom arrays
|
||||
// customize by adding new array
|
||||
// data structure with info on per-atom vectors/arrays
|
||||
|
||||
nperatom = maxperatom = 0;
|
||||
peratom = NULL;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// 1st customization section: customize by adding new per-atom variables
|
||||
|
||||
tag = NULL;
|
||||
type = mask = NULL;
|
||||
image = NULL;
|
||||
x = v = f = NULL;
|
||||
|
||||
molecule = NULL;
|
||||
molindex = molatom = NULL;
|
||||
// charged and dipolar particles
|
||||
|
||||
q = NULL;
|
||||
mu = NULL;
|
||||
|
||||
// finite-size particles
|
||||
|
||||
omega = angmom = torque = NULL;
|
||||
radius = rmass = NULL;
|
||||
ellipsoid = line = tri = body = NULL;
|
||||
|
||||
vfrac = s0 = NULL;
|
||||
x0 = NULL;
|
||||
|
||||
spin = NULL;
|
||||
eradius = ervel = erforce = NULL;
|
||||
cs = csforce = vforce = ervelforce = NULL;
|
||||
etag = NULL;
|
||||
|
||||
rho = drho = e = de = cv = NULL;
|
||||
vest = NULL;
|
||||
|
||||
// SPIN package
|
||||
|
||||
sp = fm = fm_long = NULL;
|
||||
|
||||
// USER-DPD
|
||||
|
||||
uCond = uMech = uChem = uCG = uCGnew = NULL;
|
||||
duChem = NULL;
|
||||
dpdTheta = NULL;
|
||||
|
||||
// USER-MESO
|
||||
|
||||
cc = cc_flux = NULL;
|
||||
edpd_temp = edpd_flux = edpd_cv = NULL;
|
||||
|
||||
// USER-MESONT package
|
||||
|
||||
mesont_flag = 0;
|
||||
length = NULL;
|
||||
buckling = NULL;
|
||||
bond_nt = NULL;
|
||||
|
||||
// USER-SMD
|
||||
|
||||
contact_radius = NULL;
|
||||
smd_data_9 = NULL;
|
||||
smd_stress = NULL;
|
||||
eff_plastic_strain = NULL;
|
||||
eff_plastic_strain_rate = NULL;
|
||||
damage = NULL;
|
||||
|
||||
// molecular info
|
||||
|
||||
// molecular systems
|
||||
bond_per_atom = extra_bond_per_atom = 0;
|
||||
num_bond = NULL;
|
||||
bond_type = NULL;
|
||||
@ -150,6 +117,57 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
nspecial = NULL;
|
||||
special = NULL;
|
||||
|
||||
// PERI package
|
||||
|
||||
vfrac = s0 = NULL;
|
||||
x0 = NULL;
|
||||
|
||||
// SPIN package
|
||||
|
||||
sp = fm = fm_long = NULL;
|
||||
|
||||
// USER-EFF and USER-AWPMD packages
|
||||
|
||||
spin = NULL;
|
||||
eradius = ervel = erforce = NULL;
|
||||
ervelforce = NULL;
|
||||
cs = csforce = vforce = NULL;
|
||||
etag = NULL;
|
||||
|
||||
// USER-DPD package
|
||||
|
||||
uCond = uMech = uChem = uCG = uCGnew = NULL;
|
||||
duChem = dpdTheta = NULL;
|
||||
|
||||
// USER-MESO package
|
||||
|
||||
cc = cc_flux = NULL;
|
||||
edpd_temp = edpd_flux = edpd_cv = NULL;
|
||||
|
||||
// USER-MESONT package
|
||||
|
||||
mesont_flag = 0;
|
||||
length = NULL;
|
||||
buckling = NULL;
|
||||
bond_nt = NULL;
|
||||
|
||||
// USER-SMD package
|
||||
|
||||
contact_radius = NULL;
|
||||
smd_data_9 = NULL;
|
||||
smd_stress = NULL;
|
||||
eff_plastic_strain = NULL;
|
||||
eff_plastic_strain_rate = NULL;
|
||||
damage = NULL;
|
||||
|
||||
// USER-SPH package
|
||||
|
||||
rho = drho = esph = desph = cv = NULL;
|
||||
vest = NULL;
|
||||
|
||||
// end of customization section
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// user-defined molecules
|
||||
|
||||
nmolecule = 0;
|
||||
@ -163,44 +181,12 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
iname = dname = NULL;
|
||||
|
||||
// initialize atom style and array existence flags
|
||||
// customize by adding new flag
|
||||
|
||||
sphere_flag = peri_flag = electron_flag = 0;
|
||||
wavepacket_flag = sph_flag = 0;
|
||||
set_atomflag_defaults();
|
||||
|
||||
molecule_flag = 0;
|
||||
q_flag = mu_flag = 0;
|
||||
omega_flag = torque_flag = angmom_flag = 0;
|
||||
radius_flag = rmass_flag = 0;
|
||||
ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
|
||||
// initialize peratom data structure
|
||||
|
||||
// magnetic flags
|
||||
|
||||
sp_flag = 0;
|
||||
|
||||
vfrac_flag = 0;
|
||||
spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0;
|
||||
cs_flag = csforce_flag = vforce_flag = etag_flag = 0;
|
||||
|
||||
// USER-SPH, USER-MESO, and USER-DPD flags
|
||||
|
||||
rho_flag = e_flag = cv_flag = vest_flag = 0;
|
||||
dpd_flag = edpd_flag = tdpd_flag = 0;
|
||||
|
||||
// USER-SMD
|
||||
|
||||
smd_flag = 0;
|
||||
contact_radius_flag = 0;
|
||||
smd_data_9_flag = 0;
|
||||
smd_stress_flag = 0;
|
||||
x0_flag = 0;
|
||||
eff_plastic_strain_flag = 0;
|
||||
eff_plastic_strain_rate_flag = 0;
|
||||
damage_flag = 0;
|
||||
|
||||
// Peridynamic scale factor
|
||||
|
||||
pdscale = 1.0;
|
||||
peratom_create();
|
||||
|
||||
// ntype-length arrays
|
||||
|
||||
@ -254,8 +240,15 @@ Atom::~Atom()
|
||||
memory->destroy(next);
|
||||
memory->destroy(permute);
|
||||
|
||||
// delete peratom data struct
|
||||
|
||||
for (int i = 0; i < nperatom; i++)
|
||||
delete [] peratom[i].name;
|
||||
memory->sfree(peratom);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// 2nd customization section: customize by adding new per-atom variables
|
||||
// delete atom arrays
|
||||
// customize by adding new array
|
||||
|
||||
memory->destroy(tag);
|
||||
memory->destroy(type);
|
||||
@ -301,8 +294,8 @@ Atom::~Atom()
|
||||
|
||||
memory->destroy(rho);
|
||||
memory->destroy(drho);
|
||||
memory->destroy(e);
|
||||
memory->destroy(de);
|
||||
memory->destroy(esph);
|
||||
memory->destroy(desph);
|
||||
memory->destroy(cv);
|
||||
memory->destroy(vest);
|
||||
|
||||
@ -354,6 +347,9 @@ Atom::~Atom()
|
||||
memory->destroy(improper_atom3);
|
||||
memory->destroy(improper_atom4);
|
||||
|
||||
// end of customization section
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// delete custom atom arrays
|
||||
|
||||
for (int i = 0; i < nivector; i++) {
|
||||
@ -418,6 +414,277 @@ void Atom::settings(Atom *old)
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
one-time creation of peratom data structure
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::peratom_create()
|
||||
{
|
||||
for (int i = 0; i < nperatom; i++)
|
||||
delete [] peratom[i].name;
|
||||
memory->sfree(peratom);
|
||||
|
||||
peratom = NULL;
|
||||
nperatom = maxperatom = 0;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// 3rd customization section: add peratom variables here, order does not matter
|
||||
// register tagint & imageint variables as INT or BIGINT
|
||||
|
||||
int tagintsize = INT;
|
||||
if (sizeof(tagint) == 8) tagintsize = BIGINT;
|
||||
int imageintsize = INT;
|
||||
if (sizeof(imageint) == 8) imageintsize = BIGINT;
|
||||
|
||||
add_peratom("id",&tag,tagintsize,0);
|
||||
add_peratom("type",&type,INT,0);
|
||||
add_peratom("mask",&mask,INT,0);
|
||||
add_peratom("image",&image,imageintsize,0);
|
||||
|
||||
add_peratom("x",&x,DOUBLE,3);
|
||||
add_peratom("v",&v,DOUBLE,3);
|
||||
add_peratom("f",&f,DOUBLE,3,1); // set per-thread flag
|
||||
|
||||
add_peratom("rmass",&rmass,DOUBLE,0);
|
||||
add_peratom("q",&q,DOUBLE,0);
|
||||
add_peratom("mu",&mu,DOUBLE,4);
|
||||
add_peratom("mu3",&mu,DOUBLE,3); // just first 3 values of mu[4]
|
||||
|
||||
// finite size particles
|
||||
|
||||
add_peratom("radius",&radius,DOUBLE,0);
|
||||
add_peratom("omega",&omega,DOUBLE,3);
|
||||
add_peratom("torque",&torque,DOUBLE,3,1); // set per-thread flag
|
||||
add_peratom("angmom",&angmom,DOUBLE,3);
|
||||
|
||||
add_peratom("ellipsoid",&ellipsoid,INT,0);
|
||||
add_peratom("line",&line,INT,0);
|
||||
add_peratom("tri",&tri,INT,0);
|
||||
add_peratom("body",&body,INT,0);
|
||||
|
||||
// MOLECULE package
|
||||
|
||||
add_peratom("molecule",&molecule,tagintsize,0);
|
||||
add_peratom("molindex",&molindex,INT,0);
|
||||
add_peratom("molatom",&molatom,INT,0);
|
||||
|
||||
add_peratom("nspecial",&nspecial,INT,3);
|
||||
add_peratom_vary("special",&special,tagintsize,&maxspecial,&nspecial,3);
|
||||
|
||||
add_peratom("num_bond",&num_bond,INT,0);
|
||||
add_peratom_vary("bond_type",&bond_type,INT,&bond_per_atom,&num_bond);
|
||||
add_peratom_vary("bond_atom",&bond_atom,tagintsize,&bond_per_atom,&num_bond);
|
||||
|
||||
add_peratom("num_angle",&num_angle,INT,0);
|
||||
add_peratom_vary("angle_type",&angle_type,INT,&angle_per_atom,&num_angle);
|
||||
add_peratom_vary("angle_atom1",&angle_atom1,tagintsize,
|
||||
&angle_per_atom,&num_angle);
|
||||
add_peratom_vary("angle_atom2",&angle_atom2,tagintsize,
|
||||
&angle_per_atom,&num_angle);
|
||||
add_peratom_vary("angle_atom3",&angle_atom3,tagintsize,
|
||||
&angle_per_atom,&num_angle);
|
||||
|
||||
add_peratom("num_dihedral",&num_dihedral,INT,0);
|
||||
add_peratom_vary("dihedral_type",&dihedral_type,INT,
|
||||
&dihedral_per_atom,&num_dihedral);
|
||||
add_peratom_vary("dihedral_atom1",&dihedral_atom1,tagintsize,
|
||||
&dihedral_per_atom,&num_dihedral);
|
||||
add_peratom_vary("dihedral_atom2",&dihedral_atom2,tagintsize,
|
||||
&dihedral_per_atom,&num_dihedral);
|
||||
add_peratom_vary("dihedral_atom3",&dihedral_atom3,tagintsize,
|
||||
&dihedral_per_atom,&num_dihedral);
|
||||
add_peratom_vary("dihedral_atom4",&dihedral_atom4,tagintsize,
|
||||
&dihedral_per_atom,&num_dihedral);
|
||||
|
||||
add_peratom("num_improper",&num_improper,INT,0);
|
||||
add_peratom_vary("improper_type",&improper_type,INT,
|
||||
&improper_per_atom,&num_improper);
|
||||
add_peratom_vary("improper_atom1",&improper_atom1,tagintsize,
|
||||
&improper_per_atom,&num_improper);
|
||||
add_peratom_vary("improper_atom2",&improper_atom2,tagintsize,
|
||||
&improper_per_atom,&num_improper);
|
||||
add_peratom_vary("improper_atom3",&improper_atom3,tagintsize,
|
||||
&improper_per_atom,&num_improper);
|
||||
add_peratom_vary("improper_atom4",&improper_atom4,tagintsize,
|
||||
&improper_per_atom,&num_improper);
|
||||
|
||||
// PERI package
|
||||
|
||||
add_peratom("vfrac",&vfrac,DOUBLE,0);
|
||||
add_peratom("s0",&s0,DOUBLE,0);
|
||||
add_peratom("x0",&x0,DOUBLE,3);
|
||||
|
||||
// SPIN package
|
||||
|
||||
add_peratom("sp",&sp,DOUBLE,4);
|
||||
add_peratom("fm",&fm,DOUBLE,3,1);
|
||||
add_peratom("fm_long",&fm_long,DOUBLE,3,1);
|
||||
|
||||
// USER-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
|
||||
|
||||
add_peratom("cs",&cs,DOUBLE,2);
|
||||
add_peratom("csforce",&csforce,DOUBLE,2);
|
||||
add_peratom("vforce",&vforce,DOUBLE,3);
|
||||
add_peratom("ervelforce",&ervelforce,DOUBLE,0);
|
||||
add_peratom("etag",&etag,INT,0);
|
||||
|
||||
// USER-DPD package
|
||||
|
||||
add_peratom("dpdTheta",&dpdTheta,DOUBLE,0);
|
||||
add_peratom("uCond",&uCond,DOUBLE,0);
|
||||
add_peratom("uMech",&uMech,DOUBLE,0);
|
||||
add_peratom("uChem",&uChem,DOUBLE,0);
|
||||
add_peratom("uCG",&uCG,DOUBLE,0);
|
||||
add_peratom("uCGnew",&uCGnew,DOUBLE,0);
|
||||
add_peratom("duChem",&duChem,DOUBLE,0);
|
||||
|
||||
// USER-MESO package
|
||||
|
||||
add_peratom("edpd_cv",&edpd_cv,DOUBLE,0);
|
||||
add_peratom("edpd_temp",&edpd_temp,DOUBLE,0);
|
||||
add_peratom("vest_temp",&vest_temp,DOUBLE,0);
|
||||
add_peratom("edpd_flux",&edpd_flux,DOUBLE,0,1); // set per-thread flag
|
||||
add_peratom("cc",&cc,DOUBLE,1);
|
||||
add_peratom("cc_flux",&cc_flux,DOUBLE,1,1); // set per-thread flag
|
||||
|
||||
// USER-SPH package
|
||||
|
||||
add_peratom("rho",&rho,DOUBLE,0);
|
||||
add_peratom("drho",&drho,DOUBLE,0,1); // set per-thread flag
|
||||
add_peratom("esph",&esph,DOUBLE,0);
|
||||
add_peratom("desph",&desph,DOUBLE,0,1); // set per-thread flag
|
||||
add_peratom("vest",&vest,DOUBLE,3);
|
||||
add_peratom("cv",&cv,DOUBLE,0);
|
||||
|
||||
// USER-SMD package
|
||||
|
||||
add_peratom("contact_radius",&contact_radius,DOUBLE,0);
|
||||
add_peratom("smd_data_9",&smd_data_9,DOUBLE,1);
|
||||
add_peratom("smd_stress",&smd_stress,DOUBLE,1);
|
||||
add_peratom("eff_plastic_strain",&eff_plastic_strain,DOUBLE,0);
|
||||
add_peratom("eff_plastic_strain_rate",&eff_plastic_strain_rate,DOUBLE,0);
|
||||
add_peratom("damage",&damage,DOUBLE,0);
|
||||
|
||||
// end of customization section
|
||||
// --------------------------------------------------------------------
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
add info for a single per-atom vector/array to PerAtom data struct
|
||||
cols = 0: per-atom vector
|
||||
cols = N: static per-atom array with N columns
|
||||
use add_peratom_vary() when column count varies per atom
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::add_peratom(const char *name, void *address,
|
||||
int datatype, int cols, int threadflag)
|
||||
{
|
||||
if (nperatom == maxperatom) {
|
||||
maxperatom += DELTA_PERATOM;
|
||||
peratom = (PerAtom *)
|
||||
memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom");
|
||||
}
|
||||
|
||||
int n = strlen(name) + 1;
|
||||
peratom[nperatom].name = new char[n];
|
||||
strcpy(peratom[nperatom].name,name);
|
||||
peratom[nperatom].address = address;
|
||||
peratom[nperatom].datatype = datatype;
|
||||
peratom[nperatom].cols = cols;
|
||||
peratom[nperatom].threadflag = threadflag;
|
||||
peratom[nperatom].address_length = NULL;
|
||||
|
||||
nperatom++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
change the column count of an existing peratom array entry
|
||||
allows atom_style to specify column count as an argument
|
||||
see atom_style tdpd as an example
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::add_peratom_change_columns(const char *name, int cols)
|
||||
{
|
||||
for (int i = 0; i < nperatom; i++) {
|
||||
if (strcmp(name,peratom[i].name) == 0) {
|
||||
peratom[i].cols = cols;
|
||||
return;
|
||||
}
|
||||
}
|
||||
error->all(FLERR,"Could not find name of peratom array for column change");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
add info for a single per-atom array to PerAtom data struct
|
||||
cols = address of int variable with max columns per atom
|
||||
for collength = 0:
|
||||
length = address of peratom vector with column count per atom
|
||||
e.g. num_bond
|
||||
for collength = N:
|
||||
length = address of peratom array with column count per atom
|
||||
collength = index of column (1 to N) in peratom array with count
|
||||
e.g. nspecial
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::add_peratom_vary(const char *name, void *address,
|
||||
int datatype, int *cols, void *length, int collength)
|
||||
{
|
||||
if (nperatom == maxperatom) {
|
||||
maxperatom += DELTA_PERATOM;
|
||||
peratom = (PerAtom *)
|
||||
memory->srealloc(peratom,maxperatom*sizeof(PerAtom),"atom:peratom");
|
||||
}
|
||||
|
||||
int n = strlen(name) + 1;
|
||||
peratom[nperatom].name = new char[n];
|
||||
strcpy(peratom[nperatom].name,name);
|
||||
peratom[nperatom].address = address;
|
||||
peratom[nperatom].datatype = datatype;
|
||||
peratom[nperatom].cols = -1;
|
||||
peratom[nperatom].threadflag = 0;
|
||||
peratom[nperatom].address_maxcols = cols;
|
||||
peratom[nperatom].address_length = length;
|
||||
peratom[nperatom].collength = collength;
|
||||
|
||||
nperatom++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
add info for a single per-atom array to PerAtom data struct
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::set_atomflag_defaults()
|
||||
{
|
||||
// --------------------------------------------------------------------
|
||||
// 4th customization section: customize by adding new flag
|
||||
// identical list as 2nd customization in atom.h
|
||||
|
||||
sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
|
||||
peri_flag = electron_flag = 0;
|
||||
wavepacket_flag = sph_flag = 0;
|
||||
molecule_flag = molindex_flag = molatom_flag = 0;
|
||||
q_flag = mu_flag = 0;
|
||||
rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0;
|
||||
vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0;
|
||||
cs_flag = csforce_flag = vforce_flag = ervelforce_flag = etag_flag = 0;
|
||||
rho_flag = esph_flag = cv_flag = vest_flag = 0;
|
||||
dpd_flag = edpd_flag = tdpd_flag = 0;
|
||||
sp_flag = 0;
|
||||
x0_flag = 0;
|
||||
smd_flag = damage_flag = 0;
|
||||
contact_radius_flag = smd_data_9_flag = smd_stress_flag = 0;
|
||||
eff_plastic_strain_flag = eff_plastic_strain_rate_flag = 0;
|
||||
|
||||
pdscale = 1.0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create an AtomVec style
|
||||
called from lammps.cpp, input script, restart file, replicate
|
||||
@ -432,26 +699,8 @@ void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix)
|
||||
|
||||
// unset atom style and array existence flags
|
||||
// may have been set by old avec
|
||||
// customize by adding new flag
|
||||
|
||||
sphere_flag = peri_flag = electron_flag = 0;
|
||||
wavepacket_flag = sph_flag = 0;
|
||||
|
||||
molecule_flag = 0;
|
||||
q_flag = mu_flag = 0;
|
||||
omega_flag = torque_flag = angmom_flag = 0;
|
||||
radius_flag = rmass_flag = 0;
|
||||
ellipsoid_flag = line_flag = tri_flag = body_flag = 0;
|
||||
|
||||
// magnetic flags
|
||||
|
||||
sp_flag = 0;
|
||||
|
||||
vfrac_flag = 0;
|
||||
spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0;
|
||||
cs_flag = csforce_flag = vforce_flag = etag_flag = 0;
|
||||
|
||||
rho_flag = e_flag = cv_flag = vest_flag = 0;
|
||||
set_atomflag_defaults();
|
||||
|
||||
// create instance of AtomVec
|
||||
// use grow() to initialize atom-based arrays to length 1
|
||||
@ -535,6 +784,7 @@ AtomVec *Atom::avec_creator(LAMMPS *lmp)
|
||||
return new T(lmp);
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void Atom::init()
|
||||
@ -1434,8 +1684,7 @@ void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus, tagint id_offset)
|
||||
call style-specific routine to parse line
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::data_bodies(int n, char *buf, AtomVecBody *avec_body,
|
||||
tagint id_offset)
|
||||
void Atom::data_bodies(int n, char *buf, AtomVec *avec_body, tagint id_offset)
|
||||
{
|
||||
int j,m,nvalues,tagdata,ninteger,ndouble;
|
||||
|
||||
@ -2241,11 +2490,13 @@ void Atom::remove_custom(int flag, int index)
|
||||
/* ----------------------------------------------------------------------
|
||||
return a pointer to a named internal variable
|
||||
if don't recognize name, return NULL
|
||||
customize by adding names
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void *Atom::extract(char *name)
|
||||
{
|
||||
// --------------------------------------------------------------------
|
||||
// 5th customization section: customize by adding new variable name
|
||||
|
||||
if (strcmp(name,"mass") == 0) return (void *) mass;
|
||||
|
||||
if (strcmp(name,"id") == 0) return (void *) tag;
|
||||
@ -2283,8 +2534,8 @@ void *Atom::extract(char *name)
|
||||
|
||||
if (strcmp(name,"rho") == 0) return (void *) rho;
|
||||
if (strcmp(name,"drho") == 0) return (void *) drho;
|
||||
if (strcmp(name,"e") == 0) return (void *) e;
|
||||
if (strcmp(name,"de") == 0) return (void *) de;
|
||||
if (strcmp(name,"esph") == 0) return (void *) esph;
|
||||
if (strcmp(name,"desph") == 0) return (void *) desph;
|
||||
if (strcmp(name,"cv") == 0) return (void *) cv;
|
||||
if (strcmp(name,"vest") == 0) return (void *) vest;
|
||||
|
||||
@ -2316,11 +2567,7 @@ void *Atom::extract(char *name)
|
||||
|
||||
bigint Atom::memory_usage()
|
||||
{
|
||||
memlength = DELTA_MEMSTR;
|
||||
memory->create(memstr,memlength,"atom:memstr");
|
||||
memstr[0] = '\0';
|
||||
bigint bytes = avec->memory_usage();
|
||||
memory->destroy(memstr);
|
||||
|
||||
bytes += max_same*sizeof(int);
|
||||
if (map_style == 1)
|
||||
@ -2337,30 +2584,3 @@ bigint Atom::memory_usage()
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
accumulate per-atom vec names in memstr, padded by spaces
|
||||
return 1 if padded str is not already in memlist, else 0
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int Atom::memcheck(const char *str)
|
||||
{
|
||||
int n = strlen(str) + 3;
|
||||
char *padded = new char[n];
|
||||
strcpy(padded," ");
|
||||
strcat(padded,str);
|
||||
strcat(padded," ");
|
||||
|
||||
if (strstr(memstr,padded)) {
|
||||
delete [] padded;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((int)strlen(memstr) + n >= memlength) {
|
||||
memlength += DELTA_MEMSTR;
|
||||
memory->grow(memstr,memlength,"atom:memstr");
|
||||
}
|
||||
|
||||
strcat(memstr,padded);
|
||||
delete [] padded;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user