changes to start to make atom style hybrid work
This commit is contained in:
@ -55,16 +55,12 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp)
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
modify what the default AtomVec::data_atom() just initialized
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecDipole::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
void AtomVecDipole::data_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::data_atom(coord,imagetmp,values);
|
||||
|
||||
int ilocal = atom->nlocal-1;
|
||||
double mu = atom->mu[ilocal];
|
||||
double *mu = atom->mu[ilocal];
|
||||
mu[3] = sqrt(mu[0]*mu[0] + mu[1]*mu[1] + mu[2]*mu[2]);
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ namespace LAMMPS_NS {
|
||||
class AtomVecDipole : public AtomVec {
|
||||
public:
|
||||
AtomVecDipole(class LAMMPS *);
|
||||
void data_atom(double *, imageint, char **);
|
||||
void data_atom_post(int);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -67,11 +67,10 @@ AtomVecAngle::~AtomVecAngle()
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file
|
||||
modify/unmodify values for default AtomVec::pack_restart() to pack
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::pack_restart(int i, double *buf)
|
||||
void AtomVecAngle::pack_restart_pre(int i)
|
||||
{
|
||||
// insure negative vectors are needed length
|
||||
|
||||
@ -110,51 +109,49 @@ int AtomVecAngle::pack_restart(int i, double *buf)
|
||||
any_angle_negative = 1;
|
||||
} else angle_negative[m] = 0;
|
||||
}
|
||||
|
||||
// perform the pack with adjusted values
|
||||
|
||||
int n = AtomVec::pack_restart(i,buf);
|
||||
|
||||
// restore the flagged types to their negative values
|
||||
|
||||
if (any_bond_negative) {
|
||||
for (int m = 0; m < num_bond[i]; m++)
|
||||
if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m];
|
||||
}
|
||||
if (any_angle_negative) {
|
||||
for (int m = 0; m < num_angle[i]; m++)
|
||||
if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m];
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
initialize other atom quantities
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::unpack_restart(double *buf)
|
||||
void AtomVecAngle::pack_restart_post(int i)
|
||||
{
|
||||
AtomVec::unpack_restart(buf);
|
||||
int ilocal = atom->nlocal-1;
|
||||
// restore the flagged types to their negative values
|
||||
|
||||
if (any_bond_negative) {
|
||||
int *num_bond = atom->num_bond;
|
||||
int **bond_type = atom->bond_type;
|
||||
for (int m = 0; m < num_bond[i]; m++)
|
||||
if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m];
|
||||
}
|
||||
|
||||
if (any_angle_negative) {
|
||||
int *num_angle = atom->num_angle;
|
||||
int **angle_type = atom->angle_type;
|
||||
for (int m = 0; m < num_angle[i]; m++)
|
||||
if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize other atom quantities after AtomVec::unpack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::unpack_restart_init(int ilocal)
|
||||
{
|
||||
atom->nspecial[ilocal][0] = 0;
|
||||
atom->nspecial[ilocal][1] = 0;
|
||||
atom->nspecial[ilocal][2] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
modify what default AtomVec::data_atom() just unpacked
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
void AtomVecAngle::data_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::data_atom(coord,imagetmp,values);
|
||||
int ilocal = atom->nlocal-1;
|
||||
|
||||
atom->num_bond[ilocal] = 0;
|
||||
atom->num_angle[ilocal] = 0;
|
||||
atom->nspecial[ilocal][0] = 0;
|
||||
|
||||
@ -28,11 +28,13 @@ class AtomVecAngle : public AtomVec {
|
||||
public:
|
||||
AtomVecAngle(class LAMMPS *);
|
||||
~AtomVecAngle();
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void data_atom(double *, imageint, char **);
|
||||
void pack_restart_pre(int);
|
||||
void pack_restart_post(int);
|
||||
void unpack_restart_init(int);
|
||||
void data_atom_post(int);
|
||||
|
||||
private:
|
||||
int any_bond_negative,any_angle_negative;
|
||||
int bond_per_atom,angle_per_atom;
|
||||
int *bond_negative,*angle_negative;
|
||||
};
|
||||
|
||||
@ -61,11 +61,10 @@ AtomVecBond::~AtomVecBond()
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file
|
||||
modify/unmodify values for default AtomVec::pack_restart() to pack
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::pack_restart(int i, double *buf)
|
||||
void AtomVecBond::pack_restart_pre(int i)
|
||||
{
|
||||
// insure bond_negative vector is needed length
|
||||
|
||||
@ -80,7 +79,7 @@ int AtomVecBond::pack_restart(int i, double *buf)
|
||||
int *num_bond = atom->num_bond;
|
||||
int **bond_type = atom->bond_type;
|
||||
|
||||
int any_bond_negative = 0;
|
||||
any_bond_negative = 0;
|
||||
for (int m = 0; m < num_bond[i]; m++) {
|
||||
if (bond_type[i][m] < 0) {
|
||||
bond_negative[m] = 1;
|
||||
@ -88,47 +87,42 @@ int AtomVecBond::pack_restart(int i, double *buf)
|
||||
any_bond_negative = 1;
|
||||
} else bond_negative[m] = 0;
|
||||
}
|
||||
|
||||
// perform the pack with adjusted values
|
||||
|
||||
int n = AtomVec::pack_restart(i,buf);
|
||||
|
||||
// restore the flagged types to their negative values
|
||||
|
||||
if (any_bond_negative) {
|
||||
for (int m = 0; m < num_bond[i]; m++)
|
||||
if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m];
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
initialize other atom quantities
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::unpack_restart(double *buf)
|
||||
void AtomVecBond::pack_restart_post(int i)
|
||||
{
|
||||
AtomVec::unpack_restart(buf);
|
||||
int ilocal = atom->nlocal-1;
|
||||
// restore the flagged types to their negative values
|
||||
|
||||
if (any_bond_negative) {
|
||||
int *num_bond = atom->num_bond;
|
||||
int **bond_type = atom->bond_type;
|
||||
for (int m = 0; m < num_bond[i]; m++)
|
||||
if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize other atom quantities after AtomVec::unpack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::unpack_restart_init(int ilocal)
|
||||
{
|
||||
atom->nspecial[ilocal][0] = 0;
|
||||
atom->nspecial[ilocal][1] = 0;
|
||||
atom->nspecial[ilocal][2] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
modify what default AtomVec::data_atom() just unpacked
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
void AtomVecBond::data_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::data_atom(coord,imagetmp,values);
|
||||
int ilocal = atom->nlocal-1;
|
||||
|
||||
atom->num_bond[ilocal] = 0;
|
||||
atom->nspecial[ilocal][0] = 0;
|
||||
atom->nspecial[ilocal][1] = 0;
|
||||
|
||||
@ -28,11 +28,13 @@ class AtomVecBond : public AtomVec {
|
||||
public:
|
||||
AtomVecBond(class LAMMPS *);
|
||||
~AtomVecBond();
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void data_atom(double *, imageint, char **);
|
||||
void pack_restart_pre(int);
|
||||
void pack_restart_post(int);
|
||||
void unpack_restart_init(int);
|
||||
void data_atom_post(int);
|
||||
|
||||
private:
|
||||
int any_bond_negative;
|
||||
int bond_per_atom;
|
||||
int *bond_negative;
|
||||
};
|
||||
|
||||
@ -89,11 +89,10 @@ AtomVecFull::~AtomVecFull()
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file
|
||||
modify/unmodify values for default AtomVec::pack_restart() to pack
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecFull::pack_restart(int i, double *buf)
|
||||
void AtomVecFull::pack_restart_pre(int i)
|
||||
{
|
||||
// insure negative vectors are needed length
|
||||
|
||||
@ -164,59 +163,63 @@ int AtomVecFull::pack_restart(int i, double *buf)
|
||||
any_improper_negative = 1;
|
||||
} else improper_negative[m] = 0;
|
||||
}
|
||||
|
||||
// perform the pack with adjusted values
|
||||
|
||||
int n = AtomVec::pack_restart(i,buf);
|
||||
|
||||
// restore the flagged types to their negative values
|
||||
|
||||
if (any_bond_negative) {
|
||||
for (int m = 0; m < num_bond[i]; m++)
|
||||
if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m];
|
||||
}
|
||||
if (any_angle_negative) {
|
||||
for (int m = 0; m < num_angle[i]; m++)
|
||||
if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m];
|
||||
}
|
||||
if (any_dihedral_negative) {
|
||||
for (int m = 0; m < num_dihedral[i]; m++)
|
||||
if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m];
|
||||
}
|
||||
if (any_improper_negative) {
|
||||
for (int m = 0; m < num_improper[i]; m++)
|
||||
if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m];
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
initialize other atom quantities
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecFull::unpack_restart(double *buf)
|
||||
void AtomVecFull::pack_restart_post(int i)
|
||||
{
|
||||
AtomVec::unpack_restart(buf);
|
||||
int ilocal = atom->nlocal-1;
|
||||
// restore the flagged types to their negative values
|
||||
|
||||
if (any_bond_negative) {
|
||||
int *num_bond = atom->num_bond;
|
||||
int **bond_type = atom->bond_type;
|
||||
for (int m = 0; m < num_bond[i]; m++)
|
||||
if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m];
|
||||
}
|
||||
|
||||
if (any_angle_negative) {
|
||||
int *num_angle = atom->num_angle;
|
||||
int **angle_type = atom->angle_type;
|
||||
for (int m = 0; m < num_angle[i]; m++)
|
||||
if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m];
|
||||
}
|
||||
|
||||
if (any_dihedral_negative) {
|
||||
int *num_dihedral = atom->num_dihedral;
|
||||
int **dihedral_type = atom->dihedral_type;
|
||||
for (int m = 0; m < num_dihedral[i]; m++)
|
||||
if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m];
|
||||
}
|
||||
|
||||
if (any_improper_negative) {
|
||||
int *num_improper = atom->num_improper;
|
||||
int **improper_type = atom->improper_type;
|
||||
for (int m = 0; m < num_improper[i]; m++)
|
||||
if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize other atom quantities after AtomVec::unpack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecFull::unpack_restart_init(int ilocal)
|
||||
{
|
||||
atom->nspecial[ilocal][0] = 0;
|
||||
atom->nspecial[ilocal][1] = 0;
|
||||
atom->nspecial[ilocal][2] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
modify what default AtomVec::data_atom() just unpacked
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecFull::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
void AtomVecFull::data_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::data_atom(coord,imagetmp,values);
|
||||
int ilocal = atom->nlocal-1;
|
||||
|
||||
atom->num_bond[ilocal] = 0;
|
||||
atom->num_angle[ilocal] = 0;
|
||||
atom->num_dihedral[ilocal] = 0;
|
||||
|
||||
@ -28,11 +28,14 @@ class AtomVecFull : public AtomVec {
|
||||
public:
|
||||
AtomVecFull(class LAMMPS *);
|
||||
~AtomVecFull();
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void data_atom(double *, imageint, char **);
|
||||
void pack_restart_pre(int);
|
||||
void pack_restart_post(int);
|
||||
void unpack_restart_init(int);
|
||||
void data_atom_post(int);
|
||||
|
||||
private:
|
||||
int any_bond_negative,any_angle_negative,
|
||||
any_dihedral_negative,any_improper_negative;
|
||||
int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom;
|
||||
int *bond_negative,*angle_negative,*dihedral_negative,*improper_negative;
|
||||
};
|
||||
|
||||
@ -89,11 +89,10 @@ AtomVecMolecular::~AtomVecMolecular()
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file
|
||||
modify/unmodify values for default AtomVec::pack_restart() to pack
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::pack_restart(int i, double *buf)
|
||||
void AtomVecMolecular::pack_restart_pre(int i)
|
||||
{
|
||||
// insure negative vectors are needed length
|
||||
|
||||
@ -164,59 +163,63 @@ int AtomVecMolecular::pack_restart(int i, double *buf)
|
||||
any_improper_negative = 1;
|
||||
} else improper_negative[m] = 0;
|
||||
}
|
||||
|
||||
// perform the pack with adjusted values
|
||||
|
||||
int n = AtomVec::pack_restart(i,buf);
|
||||
|
||||
// restore the flagged types to their negative values
|
||||
|
||||
if (any_bond_negative) {
|
||||
for (int m = 0; m < num_bond[i]; m++)
|
||||
if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m];
|
||||
}
|
||||
if (any_angle_negative) {
|
||||
for (int m = 0; m < num_angle[i]; m++)
|
||||
if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m];
|
||||
}
|
||||
if (any_dihedral_negative) {
|
||||
for (int m = 0; m < num_dihedral[i]; m++)
|
||||
if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m];
|
||||
}
|
||||
if (any_improper_negative) {
|
||||
for (int m = 0; m < num_improper[i]; m++)
|
||||
if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m];
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
initialize other atom quantities
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::unpack_restart(double *buf)
|
||||
void AtomVecMolecular::pack_restart_post(int i)
|
||||
{
|
||||
AtomVec::unpack_restart(buf);
|
||||
int ilocal = atom->nlocal-1;
|
||||
// restore the flagged types to their negative values
|
||||
|
||||
if (any_bond_negative) {
|
||||
int *num_bond = atom->num_bond;
|
||||
int **bond_type = atom->bond_type;
|
||||
for (int m = 0; m < num_bond[i]; m++)
|
||||
if (bond_negative[m]) bond_type[i][m] = -bond_type[i][m];
|
||||
}
|
||||
|
||||
if (any_angle_negative) {
|
||||
int *num_angle = atom->num_angle;
|
||||
int **angle_type = atom->angle_type;
|
||||
for (int m = 0; m < num_angle[i]; m++)
|
||||
if (angle_negative[m]) angle_type[i][m] = -angle_type[i][m];
|
||||
}
|
||||
|
||||
if (any_dihedral_negative) {
|
||||
int *num_dihedral = atom->num_dihedral;
|
||||
int **dihedral_type = atom->dihedral_type;
|
||||
for (int m = 0; m < num_dihedral[i]; m++)
|
||||
if (dihedral_negative[m]) dihedral_type[i][m] = -dihedral_type[i][m];
|
||||
}
|
||||
|
||||
if (any_improper_negative) {
|
||||
int *num_improper = atom->num_improper;
|
||||
int **improper_type = atom->improper_type;
|
||||
for (int m = 0; m < num_improper[i]; m++)
|
||||
if (improper_negative[m]) improper_type[i][m] = -improper_type[i][m];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize other atom quantities after AtomVec::unpack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::unpack_restart_init(int ilocal)
|
||||
{
|
||||
atom->nspecial[ilocal][0] = 0;
|
||||
atom->nspecial[ilocal][1] = 0;
|
||||
atom->nspecial[ilocal][2] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
modify what default AtomVec::data_atom() just unpacked
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
void AtomVecMolecular::data_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::data_atom(coord,imagetmp,values);
|
||||
int ilocal = atom->nlocal-1;
|
||||
|
||||
atom->num_bond[ilocal] = 0;
|
||||
atom->num_angle[ilocal] = 0;
|
||||
atom->num_dihedral[ilocal] = 0;
|
||||
|
||||
@ -28,11 +28,14 @@ class AtomVecMolecular : public AtomVec {
|
||||
public:
|
||||
AtomVecMolecular(class LAMMPS *);
|
||||
~AtomVecMolecular();
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void data_atom(double *, imageint, char **);
|
||||
void pack_restart_pre(int);
|
||||
void pack_restart_post(int);
|
||||
void unpack_restart_init(int);
|
||||
void data_atom_post(int);
|
||||
|
||||
private:
|
||||
int any_bond_negative,any_angle_negative,
|
||||
any_dihedral_negative,any_improper_negative;
|
||||
int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom;
|
||||
int *bond_negative,*angle_negative,*dihedral_negative,*improper_negative;
|
||||
};
|
||||
|
||||
@ -97,29 +97,22 @@ void AtomVecTemplate::process_args(int narg, char **arg)
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one atom of itype at coord
|
||||
modify what default AtomVec::create_atom() just created
|
||||
initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecTemplate::create_atom(int itype, double *coord)
|
||||
void AtomVecTemplate::create_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::create_atom(itype,coord);
|
||||
|
||||
int ilocal = atom->nlocal-1;
|
||||
atom->molindex[ilocal] = -1;
|
||||
atom->molatom[ilocal] = -1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
error check what default AtomVec::data_atom() just unpacked
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecTemplate::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
void AtomVecTemplate::data_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::data_atom(coord,imagetmp,values);
|
||||
|
||||
int ilocal = atom->nlocal-1;
|
||||
int molindex = atom->molindex[ilocal];
|
||||
int molatom = atom->molatom[ilocal];
|
||||
|
||||
|
||||
@ -28,8 +28,8 @@ class AtomVecTemplate : public AtomVec {
|
||||
public:
|
||||
AtomVecTemplate(class LAMMPS *);
|
||||
void process_args(int, char **);
|
||||
void create_atom(int, double *);
|
||||
void data_atom(double *, imageint, char **);
|
||||
void create_atom_post(int);
|
||||
void data_atom_post(int);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -88,20 +88,16 @@ void AtomVecPeri::create_atom(int itype, double *coord)
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
modify what default AtomVec::data_atom() just unpacked
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecPeri::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
void AtomVecPeri::data_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::data_atom(coord,imagetmp,values);
|
||||
int ilocal = atom->nlocal-1;
|
||||
|
||||
atom->s0[ilocal] = DBL_MAX;
|
||||
atom->x0[ilocal][0] = coord[0];
|
||||
atom->x0[ilocal][1] = coord[1];
|
||||
atom->x0[ilocal][2] = coord[2];
|
||||
atom->x0[ilocal][0] = atom->x[ilocal][0];
|
||||
atom->x0[ilocal][1] = atom->x[ilocal][1];
|
||||
atom->x0[ilocal][2] = atom->x[ilocal][2];
|
||||
|
||||
if (atom->rmass[ilocal] <= 0.0)
|
||||
error->one(FLERR,"Invalid mass in Atoms section of data file");
|
||||
|
||||
@ -28,7 +28,7 @@ class AtomVecPeri : public AtomVec {
|
||||
public:
|
||||
AtomVecPeri(class LAMMPS *);
|
||||
void create_atom(int, double *);
|
||||
void data_atom(double *, imageint, char **);
|
||||
void data_atom_post(int);
|
||||
int property_atom(char *);
|
||||
void pack_property_atom(int, double *, int, int);
|
||||
};
|
||||
|
||||
@ -62,25 +62,7 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp)
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
modify what default AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSpin::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
{
|
||||
AtomVec::data_atom(coord,imagetmp,values);
|
||||
int ilocal = atom->nlocal-1;
|
||||
|
||||
double *sp = atom->sp[ilocal];
|
||||
double inorm = 1.0/sqrt(sp[0]*sp[0] + sp[1]*sp[1] + sp[2]*sp[2]);
|
||||
sp[0] *= inorm;
|
||||
sp[1] *= inorm;
|
||||
sp[2] *= inorm;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
clear all forces (mech and mag)
|
||||
clear all forces (mechanical and magnetic)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSpin::force_clear(int /*n*/, size_t nbytes)
|
||||
@ -89,3 +71,17 @@ void AtomVecSpin::force_clear(int /*n*/, size_t nbytes)
|
||||
memset(&atom->fm[0][0],0,3*nbytes);
|
||||
memset(&atom->fm_long[0][0],0,3*nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSpin::data_atom_post(int ilocal)
|
||||
{
|
||||
double *sp = atom->sp[ilocal];
|
||||
double inorm = 1.0/sqrt(sp[0]*sp[0] + sp[1]*sp[1] + sp[2]*sp[2]);
|
||||
sp[0] *= inorm;
|
||||
sp[1] *= inorm;
|
||||
sp[2] *= inorm;
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ namespace LAMMPS_NS {
|
||||
class AtomVecSpin : public AtomVec {
|
||||
public:
|
||||
AtomVecSpin(class LAMMPS *);
|
||||
void data_atom(double *, imageint, char **);
|
||||
void force_clear(int, size_t);
|
||||
void data_atom_post(int);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -2498,3 +2498,4 @@ bigint Atom::memory_usage()
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
490
src/atom_vec.cpp
490
src/atom_vec.cpp
@ -145,223 +145,6 @@ void AtomVec::init()
|
||||
error->all(FLERR,"KOKKOS package requires a kokkos enabled atom_style");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
process field strings to initialize data structs for all other methods
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::setup_fields()
|
||||
{
|
||||
int n,cols;
|
||||
|
||||
if (!fields_data_atom)
|
||||
error->all(FLERR,"Atom style requires fields_data_atom");
|
||||
|
||||
// process field strings
|
||||
// return # of fields and matching index into atom->peratom (in Method struct)
|
||||
|
||||
ngrow = process_fields(fields_grow,default_grow,&mgrow);
|
||||
ncopy = process_fields(fields_copy,default_copy,&mcopy);
|
||||
ncomm = process_fields(fields_comm,default_comm,&mcomm);
|
||||
ncomm_vel = process_fields(fields_comm_vel,default_comm_vel,&mcomm_vel);
|
||||
nreverse = process_fields(fields_reverse,default_reverse,&mreverse);
|
||||
nborder = process_fields(fields_border,default_border,&mborder);
|
||||
nborder_vel = process_fields(fields_border_vel,default_border_vel,&mborder_vel);
|
||||
nexchange = process_fields(fields_exchange,default_exchange,&mexchange);
|
||||
nrestart = process_fields(fields_restart,default_restart,&mrestart);
|
||||
ncreate = process_fields(fields_create,default_create,&mcreate);
|
||||
ndata_atom = process_fields(fields_data_atom,default_data_atom,&mdata_atom);
|
||||
ndata_vel = process_fields(fields_data_vel,default_data_vel,&mdata_vel);
|
||||
|
||||
// populate field-based data struct for each method to use
|
||||
|
||||
create_method(ngrow,&mgrow);
|
||||
create_method(ncopy,&mcopy);
|
||||
create_method(ncomm,&mcomm);
|
||||
create_method(ncomm_vel,&mcomm_vel);
|
||||
create_method(nreverse,&mreverse);
|
||||
create_method(nborder,&mborder);
|
||||
create_method(nborder_vel,&mborder_vel);
|
||||
create_method(nexchange,&mexchange);
|
||||
create_method(nrestart,&mrestart);
|
||||
create_method(ncreate,&mcreate);
|
||||
create_method(ndata_atom,&mdata_atom);
|
||||
create_method(ndata_vel,&mdata_vel);
|
||||
|
||||
// create threads data struct for grow and memory_usage to use
|
||||
|
||||
threads = new int[ngrow];
|
||||
for (int i = 0; i < ngrow; i++) {
|
||||
Atom::PerAtom *field = &atom->peratom[mgrow.index[i]];
|
||||
if (field->threadflag) threads[i] = nthreads;
|
||||
else threads[i] = 1;
|
||||
}
|
||||
|
||||
// set style-specific variables
|
||||
// NOTE: check for others vars in atom_vec.cpp/h ??
|
||||
|
||||
if (ncomm == 0) comm_x_only = 1;
|
||||
else comm_x_only = 0;
|
||||
|
||||
if (nreverse == 0) comm_f_only = 1;
|
||||
else comm_f_only = 0;
|
||||
|
||||
size_forward = 3;
|
||||
for (n = 0; n < ncomm; n++) {
|
||||
cols = mcomm.cols[n];
|
||||
if (cols == 0) size_forward++;
|
||||
else size_forward += cols;
|
||||
}
|
||||
|
||||
size_reverse = 3;
|
||||
for (n = 0; n < nreverse; n++) {
|
||||
cols = mreverse.cols[n];
|
||||
if (cols == 0) size_reverse++;
|
||||
else size_reverse += cols;
|
||||
}
|
||||
|
||||
size_border = 6;
|
||||
for (n = 0; n < nborder; n++) {
|
||||
cols = mborder.cols[n];
|
||||
if (cols == 0) size_border++;
|
||||
else size_border += cols;
|
||||
}
|
||||
|
||||
size_velocity = 3;
|
||||
for (n = 0; n < ncomm_vel; n++) {
|
||||
cols = mcomm_vel.cols[n];
|
||||
if (cols == 0) size_velocity++;
|
||||
else size_velocity += cols;
|
||||
}
|
||||
|
||||
size_data_atom = 0;
|
||||
for (n = 0; n < ndata_atom; n++) {
|
||||
cols = mdata_atom.cols[n];
|
||||
if (strcmp(atom->peratom[mdata_atom.index[n]].name,"x") == 0)
|
||||
xcol_data = size_data_atom + 1;
|
||||
if (cols == 0) size_data_atom++;
|
||||
else size_data_atom += cols;
|
||||
}
|
||||
|
||||
size_data_vel = 4;
|
||||
for (n = 0; n < ndata_vel; n++) {
|
||||
cols = mdata_vel.cols[n];
|
||||
if (cols == 0) size_data_vel++;
|
||||
else size_data_vel += cols;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
process a single field string
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVec::process_fields(char *list, const char *default_list, Method *method)
|
||||
{
|
||||
int i,n;
|
||||
char match[128];
|
||||
|
||||
if (list == NULL) {
|
||||
method->index = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// make copy of list of fields so can tokenize it
|
||||
|
||||
n = strlen(list) + 1;
|
||||
char *copy = new char[n];
|
||||
strcpy(copy,list);
|
||||
|
||||
int nfield = atom->count_words(copy);
|
||||
int *index = new int[nfield];
|
||||
|
||||
Atom::PerAtom *peratom = atom->peratom;
|
||||
int nperatom = atom->nperatom;
|
||||
|
||||
nfield = 0;
|
||||
char *field = strtok(copy," ");
|
||||
while (field) {
|
||||
|
||||
// find field in master Atom::peratom list
|
||||
|
||||
for (i = 0; i < nperatom; i++)
|
||||
if (strcmp(field,peratom[i].name) == 0) break;
|
||||
if (i == nperatom) error->all(FLERR,"Atom_style unrecognized peratom field");
|
||||
index[nfield++] = i;
|
||||
|
||||
// error if field is in default list or appears multiple times
|
||||
|
||||
sprintf(match," %s ",field);
|
||||
if (strstr(default_list,match))
|
||||
error->all(FLERR,"Atom_style repeat of default peratom field");
|
||||
|
||||
for (i = 0; i < nfield-1; i++)
|
||||
if (index[i] == index[nfield-1])
|
||||
error->all(FLERR,"Atom_style duplicated peratom field");
|
||||
|
||||
field = strtok(NULL," ");
|
||||
}
|
||||
|
||||
delete [] copy;
|
||||
|
||||
method->index = index;
|
||||
return nfield;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create a method data structs for processing fields
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::create_method(int nfield, Method *method)
|
||||
{
|
||||
method->pdata = new void*[nfield];
|
||||
method->datatype = new int[nfield];
|
||||
method->cols = new int[nfield];
|
||||
method->maxcols = new int*[nfield];
|
||||
method->collength = new int[nfield];
|
||||
method->plength = new void*[nfield];
|
||||
|
||||
for (int i = 0; i < nfield; i++) {
|
||||
Atom::PerAtom *field = &atom->peratom[method->index[i]];
|
||||
method->pdata[i] = (void *) field->address;
|
||||
method->datatype[i] = field->datatype;
|
||||
method->cols[i] = field->cols;
|
||||
if (method->cols[i] < 0) {
|
||||
method->maxcols[i] = field->address_maxcols;
|
||||
method->collength[i] = field->collength;
|
||||
method->plength[i] = field->address_length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
free memory in a method data structs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::init_method(Method *method)
|
||||
{
|
||||
method->pdata = NULL;
|
||||
method->datatype = NULL;
|
||||
method->cols = NULL;
|
||||
method->maxcols = NULL;
|
||||
method->collength = NULL;
|
||||
method->plength = NULL;
|
||||
method->index = NULL;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
free memory in a method data structs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::destroy_method(Method *method)
|
||||
{
|
||||
delete [] method->pdata;
|
||||
delete [] method->datatype;
|
||||
delete [] method->cols;
|
||||
delete [] method->maxcols;
|
||||
delete [] method->collength;
|
||||
delete [] method->plength;
|
||||
delete [] method->index;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grow nmax so it is a multiple of DELTA
|
||||
------------------------------------------------------------------------- */
|
||||
@ -446,18 +229,6 @@ void AtomVec::grow(int n)
|
||||
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
reset local array ptrs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::grow_reset()
|
||||
{
|
||||
// NOTE: is this method needed anymore
|
||||
tag = atom->tag; type = atom->type;
|
||||
mask = atom->mask; image = atom->image;
|
||||
x = atom->x; v = atom->v; f = atom->f;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
copy atom I info to atom J
|
||||
------------------------------------------------------------------------- */
|
||||
@ -1614,6 +1385,10 @@ int AtomVec::pack_restart(int i, double *buf)
|
||||
int mm,nn,datatype,cols,collength,ncols;
|
||||
void *pdata,*plength;
|
||||
|
||||
// if needed, change values before packing
|
||||
|
||||
pack_restart_pre(i);
|
||||
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
@ -1684,6 +1459,12 @@ int AtomVec::pack_restart(int i, double *buf)
|
||||
}
|
||||
}
|
||||
|
||||
// if needed, restore values after packing
|
||||
|
||||
pack_restart_post(i);
|
||||
|
||||
// invoke fixes which store peratom restart info
|
||||
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
|
||||
|
||||
@ -1777,6 +1558,12 @@ int AtomVec::unpack_restart(double *buf)
|
||||
}
|
||||
}
|
||||
|
||||
// if needed, initialize other peratom values
|
||||
|
||||
unpack_restart_init(nlocal);
|
||||
|
||||
// store extra restart info which fixes can unpack when instantiated
|
||||
|
||||
double **extra = atom->extra;
|
||||
if (atom->nextra_store) {
|
||||
int size = static_cast<int> (buf[0]) - m;
|
||||
@ -1812,7 +1599,7 @@ void AtomVec::create_atom(int itype, double *coord)
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
|
||||
// special-case initialization for some fields
|
||||
// initialization additional fields
|
||||
|
||||
for (n = 0; n < ncreate; n++) {
|
||||
pdata = mcreate.pdata[n];
|
||||
@ -1848,12 +1635,16 @@ void AtomVec::create_atom(int itype, double *coord)
|
||||
}
|
||||
}
|
||||
|
||||
// if needed, initialize other peratom values
|
||||
|
||||
create_atom_post(nlocal);
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
initialize other atom quantities
|
||||
initialize other peratom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
@ -1919,6 +1710,10 @@ void AtomVec::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
if (atom->type[nlocal] <= 0 || atom->type[nlocal] > atom->ntypes)
|
||||
error->one(FLERR,"Invalid atom type in Atoms section of data file");
|
||||
|
||||
// if needed, modify unpacked values or initialize other peratom values
|
||||
|
||||
data_atom_post(nlocal);
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
@ -1933,6 +1728,11 @@ void AtomVec::pack_data(double **buf)
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
|
||||
// if needed, change values before packing
|
||||
|
||||
pack_data_pre(i);
|
||||
|
||||
j = 0;
|
||||
for (n = 0; n < ndata_atom; n++) {
|
||||
pdata = mdata_atom.pdata[n];
|
||||
@ -1971,6 +1771,10 @@ void AtomVec::pack_data(double **buf)
|
||||
buf[i][j++] = ubuf((image[i] & IMGMASK) - IMGMAX).d;
|
||||
buf[i][j++] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d;
|
||||
buf[i][j++] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d;
|
||||
|
||||
// if needed, restore values after packing
|
||||
|
||||
pack_data_post(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2493,3 +2297,227 @@ bigint AtomVec::memory_usage()
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// internal methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
process field strings to initialize data structs for all other methods
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::setup_fields()
|
||||
{
|
||||
int n,cols;
|
||||
|
||||
if (!fields_data_atom)
|
||||
error->all(FLERR,"Atom style requires fields_data_atom");
|
||||
if (strstr(fields_data_atom,"id ") != fields_data_atom)
|
||||
error->all(FLERR,"Atom style fields_data_atom must have id as first field");
|
||||
|
||||
// process field strings
|
||||
// return # of fields and matching index into atom->peratom (in Method struct)
|
||||
|
||||
ngrow = process_fields(fields_grow,default_grow,&mgrow);
|
||||
ncopy = process_fields(fields_copy,default_copy,&mcopy);
|
||||
ncomm = process_fields(fields_comm,default_comm,&mcomm);
|
||||
ncomm_vel = process_fields(fields_comm_vel,default_comm_vel,&mcomm_vel);
|
||||
nreverse = process_fields(fields_reverse,default_reverse,&mreverse);
|
||||
nborder = process_fields(fields_border,default_border,&mborder);
|
||||
nborder_vel = process_fields(fields_border_vel,default_border_vel,&mborder_vel);
|
||||
nexchange = process_fields(fields_exchange,default_exchange,&mexchange);
|
||||
nrestart = process_fields(fields_restart,default_restart,&mrestart);
|
||||
ncreate = process_fields(fields_create,default_create,&mcreate);
|
||||
ndata_atom = process_fields(fields_data_atom,default_data_atom,&mdata_atom);
|
||||
ndata_vel = process_fields(fields_data_vel,default_data_vel,&mdata_vel);
|
||||
|
||||
// populate field-based data struct for each method to use
|
||||
|
||||
create_method(ngrow,&mgrow);
|
||||
create_method(ncopy,&mcopy);
|
||||
create_method(ncomm,&mcomm);
|
||||
create_method(ncomm_vel,&mcomm_vel);
|
||||
create_method(nreverse,&mreverse);
|
||||
create_method(nborder,&mborder);
|
||||
create_method(nborder_vel,&mborder_vel);
|
||||
create_method(nexchange,&mexchange);
|
||||
create_method(nrestart,&mrestart);
|
||||
create_method(ncreate,&mcreate);
|
||||
create_method(ndata_atom,&mdata_atom);
|
||||
create_method(ndata_vel,&mdata_vel);
|
||||
|
||||
// create threads data struct for grow and memory_usage to use
|
||||
|
||||
threads = new int[ngrow];
|
||||
for (int i = 0; i < ngrow; i++) {
|
||||
Atom::PerAtom *field = &atom->peratom[mgrow.index[i]];
|
||||
if (field->threadflag) threads[i] = nthreads;
|
||||
else threads[i] = 1;
|
||||
}
|
||||
|
||||
// set style-specific variables
|
||||
// NOTE: check for others vars in atom_vec.cpp/h ??
|
||||
// NOTE: need to set maxexchange, e.g for style hybrid?
|
||||
|
||||
if (ncomm == 0) comm_x_only = 1;
|
||||
else comm_x_only = 0;
|
||||
|
||||
if (nreverse == 0) comm_f_only = 1;
|
||||
else comm_f_only = 0;
|
||||
|
||||
size_forward = 3;
|
||||
for (n = 0; n < ncomm; n++) {
|
||||
cols = mcomm.cols[n];
|
||||
if (cols == 0) size_forward++;
|
||||
else size_forward += cols;
|
||||
}
|
||||
|
||||
size_reverse = 3;
|
||||
for (n = 0; n < nreverse; n++) {
|
||||
cols = mreverse.cols[n];
|
||||
if (cols == 0) size_reverse++;
|
||||
else size_reverse += cols;
|
||||
}
|
||||
|
||||
size_border = 6;
|
||||
for (n = 0; n < nborder; n++) {
|
||||
cols = mborder.cols[n];
|
||||
if (cols == 0) size_border++;
|
||||
else size_border += cols;
|
||||
}
|
||||
|
||||
size_velocity = 3;
|
||||
for (n = 0; n < ncomm_vel; n++) {
|
||||
cols = mcomm_vel.cols[n];
|
||||
if (cols == 0) size_velocity++;
|
||||
else size_velocity += cols;
|
||||
}
|
||||
|
||||
size_data_atom = 0;
|
||||
for (n = 0; n < ndata_atom; n++) {
|
||||
cols = mdata_atom.cols[n];
|
||||
if (strcmp(atom->peratom[mdata_atom.index[n]].name,"x") == 0)
|
||||
xcol_data = size_data_atom + 1;
|
||||
if (cols == 0) size_data_atom++;
|
||||
else size_data_atom += cols;
|
||||
}
|
||||
|
||||
size_data_vel = 4;
|
||||
for (n = 0; n < ndata_vel; n++) {
|
||||
cols = mdata_vel.cols[n];
|
||||
if (cols == 0) size_data_vel++;
|
||||
else size_data_vel += cols;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
process a single field string
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVec::process_fields(char *list, const char *default_list, Method *method)
|
||||
{
|
||||
int i,n;
|
||||
char match[128];
|
||||
|
||||
if (list == NULL) {
|
||||
method->index = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// make copy of list of fields so can tokenize it
|
||||
|
||||
n = strlen(list) + 1;
|
||||
char *copy = new char[n];
|
||||
strcpy(copy,list);
|
||||
|
||||
int nfield = atom->count_words(copy);
|
||||
int *index = new int[nfield];
|
||||
|
||||
Atom::PerAtom *peratom = atom->peratom;
|
||||
int nperatom = atom->nperatom;
|
||||
|
||||
nfield = 0;
|
||||
char *field = strtok(copy," ");
|
||||
while (field) {
|
||||
|
||||
// find field in master Atom::peratom list
|
||||
|
||||
for (i = 0; i < nperatom; i++)
|
||||
if (strcmp(field,peratom[i].name) == 0) break;
|
||||
if (i == nperatom) error->all(FLERR,"Atom_style unrecognized peratom field");
|
||||
index[nfield++] = i;
|
||||
|
||||
// error if field is in default list or appears multiple times
|
||||
|
||||
sprintf(match," %s ",field);
|
||||
if (strstr(default_list,match))
|
||||
error->all(FLERR,"Atom_style repeat of default peratom field");
|
||||
|
||||
for (i = 0; i < nfield-1; i++)
|
||||
if (index[i] == index[nfield-1])
|
||||
error->all(FLERR,"Atom_style duplicated peratom field");
|
||||
|
||||
field = strtok(NULL," ");
|
||||
}
|
||||
|
||||
delete [] copy;
|
||||
|
||||
method->index = index;
|
||||
return nfield;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create a method data structs for processing fields
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::create_method(int nfield, Method *method)
|
||||
{
|
||||
method->pdata = new void*[nfield];
|
||||
method->datatype = new int[nfield];
|
||||
method->cols = new int[nfield];
|
||||
method->maxcols = new int*[nfield];
|
||||
method->collength = new int[nfield];
|
||||
method->plength = new void*[nfield];
|
||||
|
||||
for (int i = 0; i < nfield; i++) {
|
||||
Atom::PerAtom *field = &atom->peratom[method->index[i]];
|
||||
method->pdata[i] = (void *) field->address;
|
||||
method->datatype[i] = field->datatype;
|
||||
method->cols[i] = field->cols;
|
||||
if (method->cols[i] < 0) {
|
||||
method->maxcols[i] = field->address_maxcols;
|
||||
method->collength[i] = field->collength;
|
||||
method->plength[i] = field->address_length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
free memory in a method data structs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::init_method(Method *method)
|
||||
{
|
||||
method->pdata = NULL;
|
||||
method->datatype = NULL;
|
||||
method->cols = NULL;
|
||||
method->maxcols = NULL;
|
||||
method->collength = NULL;
|
||||
method->plength = NULL;
|
||||
method->index = NULL;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
free memory in a method data structs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::destroy_method(Method *method)
|
||||
{
|
||||
delete [] method->pdata;
|
||||
delete [] method->datatype;
|
||||
delete [] method->cols;
|
||||
delete [] method->maxcols;
|
||||
delete [] method->collength;
|
||||
delete [] method->plength;
|
||||
delete [] method->index;
|
||||
}
|
||||
|
||||
@ -49,60 +49,68 @@ class AtomVec : protected Pointers {
|
||||
int nargcopy; // copy of command-line args for atom_style command
|
||||
char **argcopy; // used when AtomVec is realloced (restart,replicate)
|
||||
|
||||
// additional list of peratom fields operated on by different methods
|
||||
// set by child styles
|
||||
|
||||
char *fields_grow,*fields_copy;
|
||||
char *fields_comm,*fields_comm_vel,*fields_reverse;
|
||||
char *fields_border,*fields_border_vel;
|
||||
char *fields_exchange,*fields_restart;
|
||||
char *fields_create,*fields_data_atom,*fields_data_vel;
|
||||
|
||||
// methods
|
||||
|
||||
AtomVec(class LAMMPS *);
|
||||
virtual ~AtomVec();
|
||||
void store_args(int, char **);
|
||||
virtual void process_args(int, char **);
|
||||
virtual void init();
|
||||
|
||||
virtual void force_clear(int, size_t) {}
|
||||
|
||||
void grow(int);
|
||||
void grow_reset();
|
||||
void copy(int, int, int);
|
||||
void clear_bonus() {}
|
||||
void force_clear(int, size_t) {}
|
||||
|
||||
int pack_comm(int, int *, double *, int, int *);
|
||||
int pack_comm_vel(int, int *, double *, int, int *);
|
||||
int pack_comm_hybrid(int, int *, double *) {return 0;}
|
||||
void unpack_comm(int, int, double *);
|
||||
void unpack_comm_vel(int, int, double *);
|
||||
int unpack_comm_hybrid(int, int, double *) {return 0;}
|
||||
|
||||
int pack_reverse(int, int, double *);
|
||||
int pack_reverse_hybrid(int, int, double *) {return 0;}
|
||||
void unpack_reverse(int, int *, double *);
|
||||
int unpack_reverse_hybrid(int, int *, double *) {return 0;}
|
||||
|
||||
int pack_border(int, int *, double *, int, int *);
|
||||
int pack_border_vel(int, int *, double *, int, int *);
|
||||
int pack_border_hybrid(int, int *, double *) {return 0;}
|
||||
void unpack_border(int, int, double *);
|
||||
void unpack_border_vel(int, int, double *);
|
||||
int unpack_border_hybrid(int, int, double *) {return 0;}
|
||||
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(double *);
|
||||
|
||||
int size_restart();
|
||||
virtual int pack_restart(int, double *);
|
||||
virtual int unpack_restart(double *);
|
||||
virtual void pack_restart_pre(int) {}
|
||||
int pack_restart(int, double *);
|
||||
virtual void pack_restart_post(int) {}
|
||||
int unpack_restart(double *);
|
||||
virtual void unpack_restart_init(int) {}
|
||||
|
||||
virtual void create_atom(int, double *);
|
||||
void create_atom(int, double *);
|
||||
virtual void create_atom_post(int) {}
|
||||
|
||||
void data_atom(double *, imageint, char **);
|
||||
virtual void data_atom_post(int) {}
|
||||
|
||||
virtual void data_atom(double *, imageint, char **);
|
||||
void data_atom_bonus(int, char **) {}
|
||||
int data_atom_hybrid(int, char **) {return 0;}
|
||||
void data_vel(int, char **);
|
||||
int data_vel_hybrid(int, char **) {return 0;}
|
||||
|
||||
virtual void pack_data_pre(int) {}
|
||||
void pack_data(double **);
|
||||
virtual void pack_data_post(int) {}
|
||||
int pack_data_hybrid(int, double *) {return 0;}
|
||||
void write_data(FILE *, int, double **);
|
||||
int write_data_hybrid(FILE *, double *) {return 0;}
|
||||
void pack_vel(double **);
|
||||
int pack_vel_hybrid(int, double *) {return 0;}
|
||||
void write_vel(FILE *, int, double **);
|
||||
int write_vel_hybrid(FILE *, double *) {return 0;}
|
||||
|
||||
int pack_bond(tagint **);
|
||||
void write_bond(FILE *, int, tagint **, int);
|
||||
@ -129,18 +137,15 @@ class AtomVec : protected Pointers {
|
||||
imageint *image;
|
||||
double **x,**v,**f;
|
||||
|
||||
// standard list of peratom fields always operated on by different methods
|
||||
// common to all styles, so not listed in field strings
|
||||
|
||||
const char *default_grow,*default_copy;
|
||||
const char *default_comm,*default_comm_vel,*default_reverse;
|
||||
const char *default_border,*default_border_vel;
|
||||
const char *default_exchange,*default_restart;
|
||||
const char *default_create,*default_data_atom,*default_data_vel;
|
||||
|
||||
char *fields_grow,*fields_copy;
|
||||
char *fields_comm,*fields_comm_vel,*fields_reverse;
|
||||
char *fields_border,*fields_border_vel;
|
||||
char *fields_exchange,*fields_restart;
|
||||
char *fields_create,*fields_data_atom,*fields_data_vel;
|
||||
|
||||
struct Method {
|
||||
void **pdata;
|
||||
int *datatype;
|
||||
|
||||
@ -35,6 +35,15 @@ AtomVecHybrid::~AtomVecHybrid()
|
||||
delete [] styles;
|
||||
for (int k = 0; k < nstyles; k++) delete [] keywords[k];
|
||||
delete [] keywords;
|
||||
|
||||
// these strings will be concatenated from sub-style strings
|
||||
// fields_data_atom must start with fields common to all styles
|
||||
|
||||
fields_grow = fields_copy = fields_comm = fields_comm_vel = NULL;
|
||||
fields_reverse = fields_border = fields_border_vel = NULL;
|
||||
fields_exchange = fields_restart = fields_create = NULL;
|
||||
fields_data_atom = (char *) "id type x";
|
||||
fields_data_vel = NULL;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -81,51 +90,49 @@ void AtomVecHybrid::process_args(int narg, char **arg)
|
||||
for (int i = 0; i < nallstyles; i++) delete [] allstyles[i];
|
||||
delete [] allstyles;
|
||||
|
||||
// hybrid settings are MAX or MIN of sub-style settings
|
||||
// hybrid sizes are minimal values plus extra values for each sub-style
|
||||
// concatenate field strings from all sub-styles
|
||||
|
||||
molecular = 0;
|
||||
comm_x_only = comm_f_only = 1;
|
||||
concatenate_fields();
|
||||
|
||||
size_forward = 3;
|
||||
size_reverse = 3;
|
||||
size_border = 6;
|
||||
size_data_atom = 5;
|
||||
size_data_vel = 4;
|
||||
xcol_data = 3;
|
||||
maxexchange = 0;
|
||||
// parent AtomVec will now operate on concatenated fields
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::concatenate_fields()
|
||||
{
|
||||
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);
|
||||
impropers_allow = MAX(impropers_allow,styles[k]->impropers_allow);
|
||||
mass_type = MAX(mass_type,styles[k]->mass_type);
|
||||
dipole_type = MAX(dipole_type,styles[k]->dipole_type);
|
||||
forceclearflag = MAX(forceclearflag,styles[k]->forceclearflag);
|
||||
|
||||
if (styles[k]->molecular == 2) onemols = styles[k]->onemols;
|
||||
|
||||
comm_x_only = MIN(comm_x_only,styles[k]->comm_x_only);
|
||||
comm_f_only = MIN(comm_f_only,styles[k]->comm_f_only);
|
||||
size_forward += styles[k]->size_forward - 3;
|
||||
size_reverse += styles[k]->size_reverse - 3;
|
||||
size_border += styles[k]->size_border - 6;
|
||||
size_data_atom += styles[k]->size_data_atom - 5;
|
||||
size_data_vel += styles[k]->size_data_vel - 4;
|
||||
|
||||
maxexchange += styles[k]->maxexchange;
|
||||
concatenate(fields_grow,styles[k]->fields_grow);
|
||||
concatenate(fields_copy,styles[k]->fields_copy);
|
||||
concatenate(fields_comm,styles[k]->fields_comm);
|
||||
concatenate(fields_comm_vel,styles[k]->fields_comm_vel);
|
||||
concatenate(fields_reverse,styles[k]->fields_reverse);
|
||||
concatenate(fields_border,styles[k]->fields_border);
|
||||
concatenate(fields_border_vel,styles[k]->fields_border_vel);
|
||||
concatenate(fields_exchange,styles[k]->fields_exchange);
|
||||
concatenate(fields_restart,styles[k]->fields_restart);
|
||||
concatenate(fields_create,styles[k]->fields_create);
|
||||
concatenate(fields_data_atom,styles[k]->fields_data_atom);
|
||||
concatenate(fields_data_vel,styles[k]->fields_data_vel);
|
||||
}
|
||||
}
|
||||
|
||||
size_velocity = 3;
|
||||
if (atom->omega_flag) size_velocity += 3;
|
||||
if (atom->angmom_flag) size_velocity += 3;
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::concatenate(char *&root, char *add)
|
||||
{
|
||||
/*
|
||||
char **rootwords,**addwords;
|
||||
int nroot = parse(root,rootwords);
|
||||
int nadd = parse(add,addwords);
|
||||
|
||||
for (int iadd = 0; iadd < nadd; iadd++) {
|
||||
if (check(addwords[iadd],nroot,rootwords)) continue;
|
||||
addone(addwords[iadd],nroot,rootwords);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -136,76 +143,6 @@ void AtomVecHybrid::init()
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->init();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grow atom arrays
|
||||
n = 0 grows arrays by a chunk
|
||||
n > 0 allocates arrays to size n
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::grow(int n)
|
||||
{
|
||||
if (n == 0) grow_nmax();
|
||||
else nmax = n;
|
||||
atom->nmax = nmax;
|
||||
if (nmax < 0 || nmax > MAXSMALLINT)
|
||||
error->one(FLERR,"Per-processor system is too big");
|
||||
|
||||
// sub-styles perform all reallocation
|
||||
// turn off nextra_grow so hybrid can do that once below
|
||||
|
||||
int tmp = atom->nextra_grow;
|
||||
atom->nextra_grow = 0;
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->grow(nmax);
|
||||
atom->nextra_grow = tmp;
|
||||
|
||||
// insure hybrid local ptrs and sub-style ptrs are up to date
|
||||
// for sub-styles, do this in case
|
||||
// multiple sub-style reallocs of same array occurred
|
||||
|
||||
grow_reset();
|
||||
|
||||
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 AtomVecHybrid::grow_reset()
|
||||
{
|
||||
tag = atom->tag; type = atom->type;
|
||||
mask = atom->mask; image = atom->image;
|
||||
x = atom->x; v = atom->v; f = atom->f;
|
||||
omega = atom->omega; angmom = atom->angmom;
|
||||
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->grow_reset();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
copy atom I info to atom J for all sub-styles
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::copy(int i, int j, int delflag)
|
||||
{
|
||||
int tmp = atom->nextra_grow;
|
||||
atom->nextra_grow = 0;
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->copy(i,j,delflag);
|
||||
atom->nextra_grow = tmp;
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j,delflag);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::clear_bonus()
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) styles[k]->clear_bonus();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::force_clear(int n, size_t nbytes)
|
||||
@ -214,799 +151,6 @@ void AtomVecHybrid::force_clear(int n, size_t nbytes)
|
||||
if (styles[k]->forceclearflag) styles[k]->force_clear(n,nbytes);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_comm(int n, int *list, double *buf,
|
||||
int pbc_flag, int *pbc)
|
||||
{
|
||||
int i,j,k,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;
|
||||
}
|
||||
}
|
||||
|
||||
// pack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->pack_comm_hybrid(n,list,&buf[m]);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_comm_vel(int n, int *list, double *buf,
|
||||
int pbc_flag, int *pbc)
|
||||
{
|
||||
int i,j,k,m;
|
||||
double dx,dy,dz,dvx,dvy,dvz;
|
||||
int omega_flag = atom->omega_flag;
|
||||
int angmom_flag = atom->angmom_flag;
|
||||
|
||||
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];
|
||||
if (omega_flag) {
|
||||
buf[m++] = omega[j][0];
|
||||
buf[m++] = omega[j][1];
|
||||
buf[m++] = omega[j][2];
|
||||
}
|
||||
if (angmom_flag) {
|
||||
buf[m++] = angmom[j][0];
|
||||
buf[m++] = angmom[j][1];
|
||||
buf[m++] = angmom[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];
|
||||
if (omega_flag) {
|
||||
buf[m++] = omega[j][0];
|
||||
buf[m++] = omega[j][1];
|
||||
buf[m++] = omega[j][2];
|
||||
}
|
||||
if (angmom_flag) {
|
||||
buf[m++] = angmom[j][0];
|
||||
buf[m++] = angmom[j][1];
|
||||
buf[m++] = angmom[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];
|
||||
}
|
||||
if (omega_flag) {
|
||||
buf[m++] = omega[j][0];
|
||||
buf[m++] = omega[j][1];
|
||||
buf[m++] = omega[j][2];
|
||||
}
|
||||
if (angmom_flag) {
|
||||
buf[m++] = angmom[j][0];
|
||||
buf[m++] = angmom[j][1];
|
||||
buf[m++] = angmom[j][2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->pack_comm_hybrid(n,list,&buf[m]);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,k,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++];
|
||||
}
|
||||
|
||||
// unpack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->unpack_comm_hybrid(n,first,&buf[m]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_comm_vel(int n, int first, double *buf)
|
||||
{
|
||||
int i,k,m,last;
|
||||
int omega_flag = atom->omega_flag;
|
||||
int angmom_flag = atom->angmom_flag;
|
||||
|
||||
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++];
|
||||
if (omega_flag) {
|
||||
omega[i][0] = buf[m++];
|
||||
omega[i][1] = buf[m++];
|
||||
omega[i][2] = buf[m++];
|
||||
}
|
||||
if (angmom_flag) {
|
||||
angmom[i][0] = buf[m++];
|
||||
angmom[i][1] = buf[m++];
|
||||
angmom[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
// unpack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->unpack_comm_hybrid(n,first,&buf[m]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_reverse(int n, int first, double *buf)
|
||||
{
|
||||
int i,k,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];
|
||||
}
|
||||
|
||||
// pack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->pack_reverse_hybrid(n,first,&buf[m]);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_reverse(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,k,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++];
|
||||
}
|
||||
|
||||
// unpack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->unpack_reverse_hybrid(n,list,&buf[m]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_border(int n, int *list, double *buf,
|
||||
int pbc_flag, int *pbc)
|
||||
{
|
||||
int i,j,k,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;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
// pack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->pack_border_hybrid(n,list,&buf[m]);
|
||||
|
||||
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 AtomVecHybrid::pack_border_vel(int n, int *list, double *buf,
|
||||
int pbc_flag, int *pbc)
|
||||
{
|
||||
int i,j,k,m;
|
||||
double dx,dy,dz,dvx,dvy,dvz;
|
||||
int omega_flag = atom->omega_flag;
|
||||
int angmom_flag = atom->angmom_flag;
|
||||
|
||||
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++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
if (omega_flag) {
|
||||
buf[m++] = omega[j][0];
|
||||
buf[m++] = omega[j][1];
|
||||
buf[m++] = omega[j][2];
|
||||
}
|
||||
if (angmom_flag) {
|
||||
buf[m++] = angmom[j][0];
|
||||
buf[m++] = angmom[j][1];
|
||||
buf[m++] = angmom[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++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
if (omega_flag) {
|
||||
buf[m++] = omega[j][0];
|
||||
buf[m++] = omega[j][1];
|
||||
buf[m++] = omega[j][2];
|
||||
}
|
||||
if (angmom_flag) {
|
||||
buf[m++] = angmom[j][0];
|
||||
buf[m++] = angmom[j][1];
|
||||
buf[m++] = angmom[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;
|
||||
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 (omega_flag) {
|
||||
buf[m++] = omega[j][0];
|
||||
buf[m++] = omega[j][1];
|
||||
buf[m++] = omega[j][2];
|
||||
}
|
||||
if (angmom_flag) {
|
||||
buf[m++] = angmom[j][0];
|
||||
buf[m++] = angmom[j][1];
|
||||
buf[m++] = angmom[j][2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->pack_border_hybrid(n,list,&buf[m]);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_border(int n, int first, double *buf)
|
||||
{
|
||||
int i,k,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;
|
||||
}
|
||||
|
||||
// unpack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->unpack_border_hybrid(n,first,&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]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_border_vel(int n, int first, double *buf)
|
||||
{
|
||||
int i,k,m,last;
|
||||
int omega_flag = atom->omega_flag;
|
||||
int angmom_flag = atom->angmom_flag;
|
||||
|
||||
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;
|
||||
v[i][0] = buf[m++];
|
||||
v[i][1] = buf[m++];
|
||||
v[i][2] = buf[m++];
|
||||
if (omega_flag) {
|
||||
omega[i][0] = buf[m++];
|
||||
omega[i][1] = buf[m++];
|
||||
omega[i][2] = buf[m++];
|
||||
}
|
||||
if (angmom_flag) {
|
||||
angmom[i][0] = buf[m++];
|
||||
angmom[i][1] = buf[m++];
|
||||
angmom[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
// unpack sub-style contributions as contiguous chunks
|
||||
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->unpack_border_hybrid(n,first,&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]);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data for atom I for sending to another proc
|
||||
pack each sub-style one after the other
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_exchange(int i, double *buf)
|
||||
{
|
||||
int k,m;
|
||||
|
||||
int tmp = atom->nextra_grow;
|
||||
atom->nextra_grow = 0;
|
||||
|
||||
m = 0;
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->pack_exchange(i,&buf[m]);
|
||||
|
||||
atom->nextra_grow = tmp;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for single atom received from another proc
|
||||
unpack each sub-style one after the other
|
||||
grow() occurs here so arrays for all sub-styles are grown
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::unpack_exchange(double *buf)
|
||||
{
|
||||
int k,m;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
int tmp = atom->nextra_grow;
|
||||
atom->nextra_grow = 0;
|
||||
|
||||
m = 0;
|
||||
for (k = 0; k < nstyles; k++) {
|
||||
m += styles[k]->unpack_exchange(&buf[m]);
|
||||
atom->nlocal--;
|
||||
}
|
||||
|
||||
atom->nextra_grow = tmp;
|
||||
|
||||
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 AtomVecHybrid::size_restart()
|
||||
{
|
||||
int tmp = atom->nextra_restart;
|
||||
atom->nextra_restart = 0;
|
||||
|
||||
int n = 0;
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
n += styles[k]->size_restart();
|
||||
|
||||
atom->nextra_restart = tmp;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
for (int 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
|
||||
pack each sub-style one after the other
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_restart(int i, double *buf)
|
||||
{
|
||||
int tmp = atom->nextra_restart;
|
||||
atom->nextra_restart = 0;
|
||||
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
m += styles[k]->pack_restart(i,&buf[m]);
|
||||
|
||||
atom->nextra_restart = tmp;
|
||||
|
||||
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
|
||||
unpack each sub-style one after the other
|
||||
grow() occurs here so arrays for all sub-styles are grown
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::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 tmp = atom->nextra_store;
|
||||
atom->nextra_store = 0;
|
||||
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
m += styles[k]->unpack_restart(&buf[m]);
|
||||
atom->nlocal--;
|
||||
}
|
||||
atom->nextra_store = tmp;
|
||||
|
||||
double **extra = atom->extra;
|
||||
if (atom->nextra_store) {
|
||||
int size = static_cast<int> (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
|
||||
create each sub-style one after the other
|
||||
grow() occurs here so arrays for all sub-styles are grown
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::create_atom(int itype, double *coord)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
styles[k]->create_atom(itype,coord);
|
||||
atom->nlocal--;
|
||||
}
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
grow() occurs here so arrays for all sub-styles are grown
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = utils::tnumeric(FLERR,values[0],true,lmp);
|
||||
type[nlocal] = utils::inumeric(FLERR,values[1],true,lmp);
|
||||
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;
|
||||
if (atom->omega_flag) {
|
||||
omega[nlocal][0] = 0.0;
|
||||
omega[nlocal][1] = 0.0;
|
||||
omega[nlocal][2] = 0.0;
|
||||
}
|
||||
if (atom->angmom_flag) {
|
||||
angmom[nlocal][0] = 0.0;
|
||||
angmom[nlocal][1] = 0.0;
|
||||
angmom[nlocal][2] = 0.0;
|
||||
}
|
||||
|
||||
// each sub-style parses sub-style specific values
|
||||
|
||||
int m = 5;
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
m += styles[k]->data_atom_hybrid(nlocal,&values[m]);
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Velocities section of data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::data_vel(int m, char **values)
|
||||
{
|
||||
v[m][0] = utils::numeric(FLERR,values[0],true,lmp);
|
||||
v[m][1] = utils::numeric(FLERR,values[1],true,lmp);
|
||||
v[m][2] = utils::numeric(FLERR,values[2],true,lmp);
|
||||
|
||||
// each sub-style parses sub-style specific values
|
||||
|
||||
int n = 3;
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
n += styles[k]->data_vel_hybrid(m,&values[n]);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom info for data file including 3 image flags
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_data(double **buf)
|
||||
{
|
||||
int k,m;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
buf[i][0] = ubuf(tag[i]).d;
|
||||
buf[i][1] = ubuf(type[i]).d;
|
||||
buf[i][2] = x[i][0];
|
||||
buf[i][3] = x[i][1];
|
||||
buf[i][4] = x[i][2];
|
||||
|
||||
m = 5;
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->pack_data_hybrid(i,&buf[i][m]);
|
||||
|
||||
buf[i][m] = ubuf((image[i] & IMGMASK) - IMGMAX).d;
|
||||
buf[i][m+1] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d;
|
||||
buf[i][m+2] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
write atom info to data file including 3 image flags
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::write_data(FILE *fp, int n, double **buf)
|
||||
{
|
||||
int k,m;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
fprintf(fp,TAGINT_FORMAT " %d %-1.16e %-1.16e %-1.16e",
|
||||
(tagint) ubuf(buf[i][0]).i,(int) ubuf(buf[i][1]).i,
|
||||
buf[i][2],buf[i][3],buf[i][4]);
|
||||
|
||||
m = 5;
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->write_data_hybrid(fp,&buf[i][m]);
|
||||
|
||||
fprintf(fp," %d %d %d\n",
|
||||
(int) ubuf(buf[i][m]).i,(int) ubuf(buf[i][m+1]).i,
|
||||
(int) ubuf(buf[i][m+2]).i);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack velocity info for data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_vel(double **buf)
|
||||
{
|
||||
int k,m;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
buf[i][0] = ubuf(tag[i]).d;
|
||||
buf[i][1] = v[i][0];
|
||||
buf[i][2] = v[i][1];
|
||||
buf[i][3] = v[i][2];
|
||||
|
||||
m = 4;
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->pack_vel_hybrid(i,&buf[i][m]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
write velocity info to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::write_vel(FILE *fp, int n, double **buf)
|
||||
{
|
||||
int k,m;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
fprintf(fp,TAGINT_FORMAT " %g %g %g",
|
||||
(tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]);
|
||||
|
||||
m = 4;
|
||||
for (k = 0; k < nstyles; k++)
|
||||
m += styles[k]->write_vel_hybrid(fp,&buf[i][m]);
|
||||
|
||||
fprintf(fp,"\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
assign an index to named atom property and return index
|
||||
returned value encodes which sub-style and index returned by sub-style
|
||||
@ -1073,14 +217,3 @@ int AtomVecHybrid::known_style(char *str)
|
||||
if (strcmp(str,allstyles[i]) == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return # of bytes of allocated memory
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
bigint AtomVecHybrid::memory_usage()
|
||||
{
|
||||
bigint bytes = 0;
|
||||
for (int k = 0; k < nstyles; k++) bytes += styles[k]->memory_usage();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -34,48 +34,16 @@ class AtomVecHybrid : public AtomVec {
|
||||
~AtomVecHybrid();
|
||||
void process_args(int, char **);
|
||||
void init();
|
||||
void grow(int);
|
||||
void grow_reset();
|
||||
void copy(int, int, int);
|
||||
void clear_bonus();
|
||||
void force_clear(int, size_t);
|
||||
int pack_comm(int, int *, double *, int, int *);
|
||||
int pack_comm_vel(int, int *, double *, int, int *);
|
||||
void unpack_comm(int, int, double *);
|
||||
void unpack_comm_vel(int, int, double *);
|
||||
int pack_reverse(int, int, double *);
|
||||
void unpack_reverse(int, int *, double *);
|
||||
int pack_border(int, int *, double *, int, int *);
|
||||
int pack_border_vel(int, int *, double *, int, int *);
|
||||
void unpack_border(int, int, double *);
|
||||
void unpack_border_vel(int, int, double *);
|
||||
int pack_exchange(int, double *);
|
||||
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 *, imageint, char **);
|
||||
int data_atom_hybrid(int, char **) {return 0;}
|
||||
void data_vel(int, char **);
|
||||
void pack_data(double **);
|
||||
void write_data(FILE *, int, double **);
|
||||
void pack_vel(double **);
|
||||
void write_vel(FILE *, int, double **);
|
||||
int property_atom(char *);
|
||||
void pack_property_atom(int, double *, int, int);
|
||||
bigint memory_usage();
|
||||
|
||||
private:
|
||||
tagint *tag;
|
||||
int *type,*mask;
|
||||
imageint *image;
|
||||
double **x,**v,**f;
|
||||
double **omega,**angmom;
|
||||
|
||||
int nallstyles;
|
||||
char **allstyles;
|
||||
|
||||
void concatenate_fields();
|
||||
void concatenate(char *&, char *);
|
||||
void build_styles();
|
||||
int known_style(char *);
|
||||
};
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "fix_adapt.h"
|
||||
#include "math_const.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
@ -54,58 +55,61 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
process sub-style args
|
||||
optional arg = 0/1 for static/dynamic particle radii
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSphere::process_args(int narg, char **arg)
|
||||
{
|
||||
if (narg == 0) return;
|
||||
if (narg != 1) error->all(FLERR,"Illegal atom_style sphere command");
|
||||
|
||||
radvary = utils::numeric(FLERR,arg[0],true,lmp);
|
||||
if (radvary < 0 || radvary > 1)
|
||||
error->all(FLERR,"Illegal atom_style sphere command");
|
||||
if (radvary == 0) return;
|
||||
|
||||
// dynamic particle radius and mass must be communicated every step
|
||||
|
||||
fields_comm = (char *) "radius rmass";
|
||||
fields_comm_vel = (char *) "radius rmass omega";
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSphere::init()
|
||||
{
|
||||
AtomVec::init();
|
||||
|
||||
// set radvary if particle diameters are time-varying due to fix adapt
|
||||
// NOTE: change this to a atom_style sphere optional arg
|
||||
|
||||
radvary = 0;
|
||||
//comm_x_only = 1;
|
||||
//size_forward = 3;
|
||||
// check if optional radvary setting should have been set to 1
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (strcmp(modify->fix[i]->style,"adapt") == 0) {
|
||||
FixAdapt *fix = (FixAdapt *) modify->fix[i];
|
||||
if (fix->diamflag) {
|
||||
radvary = 1;
|
||||
comm_x_only = 0;
|
||||
size_forward = 5;
|
||||
if (fix->diamflag && radvary == 0)
|
||||
error->all(FLERR,"Fix adapt changes particle radii "
|
||||
"but atom_style sphere is not dynamic");
|
||||
}
|
||||
}
|
||||
|
||||
//fields_comm = (char *) "radius rmass";
|
||||
//fields_comm_vel = (char *) "radius rmass";
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one atom of itype at coord
|
||||
modify what default AtomVec::create_atom() just created
|
||||
initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSphere::create_atom(int itype, double *coord)
|
||||
void AtomVecSphere::create_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::create_atom(itype,coord);
|
||||
int ilocal = atom->nlocal-1;
|
||||
|
||||
atom->radius[ilocal] = 0.5;
|
||||
atom->rmass[ilocal] = 4.0*MY_PI/3.0 * 0.5*0.5*0.5;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
modify what default AtomVec::data_atom() just unpacked
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSphere::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
void AtomVecSphere::data_atom_post(int ilocal)
|
||||
{
|
||||
AtomVec::data_atom(coord,imagetmp,values);
|
||||
int ilocal = atom->nlocal-1;
|
||||
|
||||
double radius = 0.5 * atom->radius[ilocal];
|
||||
atom->radius[ilocal] = radius;
|
||||
if (radius > 0.0)
|
||||
@ -115,3 +119,27 @@ void AtomVecSphere::data_atom(double *coord, imageint imagetmp, char **values)
|
||||
if (atom->rmass[ilocal] <= 0.0)
|
||||
error->one(FLERR,"Invalid mass in Atoms section of data file");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify values for AtomVec::pack_data() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSphere::pack_data_pre(int ilocal)
|
||||
{
|
||||
radius = atom->radius[ilocal];
|
||||
rmass = atom->rmass[ilocal];
|
||||
|
||||
atom->radius[ilocal] *= 2.0;
|
||||
if (radius == 0.0)
|
||||
atom->rmass[ilocal] = rmass / (4.0*MY_PI/3.0 * radius*radius*radius);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unmodify values packed by AtomVec::pack_data()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecSphere::pack_data_post(int ilocal)
|
||||
{
|
||||
atom->radius[ilocal] = radius;
|
||||
atom->rmass[ilocal] = rmass;
|
||||
}
|
||||
|
||||
@ -27,12 +27,16 @@ namespace LAMMPS_NS {
|
||||
class AtomVecSphere : public AtomVec {
|
||||
public:
|
||||
AtomVecSphere(class LAMMPS *);
|
||||
void process_args(int, char **);
|
||||
void init();
|
||||
void create_atom(int, double *);
|
||||
void data_atom(double *, imageint, char **);
|
||||
void create_atom_post(int);
|
||||
void data_atom_post(int);
|
||||
void pack_data_pre(int);
|
||||
void pack_data_post(int);
|
||||
|
||||
private:
|
||||
int radvary;
|
||||
double radius,rmass;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -715,7 +715,6 @@ void Special::combine()
|
||||
memory->create(atom->special,atom->nmax,atom->maxspecial,"atom:special");
|
||||
}
|
||||
|
||||
atom->avec->grow_reset();
|
||||
tagint **special = atom->special;
|
||||
|
||||
// ----------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user