changes to enable atom_style hybrid to work
This commit is contained in:
@ -35,21 +35,21 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "q mu";
|
||||
fields_copy = (char *) "q mu";
|
||||
fields_comm = (char *) "mu3";
|
||||
fields_comm_vel = (char *) "mu3";
|
||||
fields_reverse = NULL;
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "q mu";
|
||||
fields_border_vel = (char *) "q mu";
|
||||
fields_exchange = (char *) "q mu";
|
||||
fields_restart = (char *) "q mu";
|
||||
fields_create = (char *) "q mu";
|
||||
fields_data_atom = (char *) "id type q x mu3";
|
||||
fields_data_vel = NULL;
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -28,8 +28,8 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
@ -37,9 +37,9 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_copy = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3 nspecial special";
|
||||
fields_comm = NULL;
|
||||
fields_comm_vel = NULL;
|
||||
fields_reverse = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "molecule";
|
||||
fields_border_vel = (char *) "molecule";
|
||||
fields_exchange = (char *)
|
||||
@ -50,7 +50,7 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp)
|
||||
"num_angle angle_type angle_atom1 angle_atom2 angle_atom3";
|
||||
fields_create = (char *) "molecule num_bond num_angle nspecial";
|
||||
fields_data_atom = (char *) "id molecule type x";
|
||||
fields_data_vel = NULL;
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
setup_fields();
|
||||
|
||||
@ -70,7 +70,7 @@ AtomVecAngle::~AtomVecAngle()
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::pack_restart_pre(int i)
|
||||
void AtomVecAngle::pack_restart_pre(int ilocal)
|
||||
{
|
||||
// insure negative vectors are needed length
|
||||
|
||||
@ -93,19 +93,19 @@ void AtomVecAngle::pack_restart_pre(int i)
|
||||
int **angle_type = atom->angle_type;
|
||||
|
||||
int any_bond_negative = 0;
|
||||
for (int m = 0; m < num_bond[i]; m++) {
|
||||
if (bond_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_bond[ilocal]; m++) {
|
||||
if (bond_type[ilocal][m] < 0) {
|
||||
bond_negative[m] = 1;
|
||||
bond_type[i][m] = -bond_type[i][m];
|
||||
bond_type[ilocal][m] = -bond_type[ilocal][m];
|
||||
any_bond_negative = 1;
|
||||
} else bond_negative[m] = 0;
|
||||
}
|
||||
|
||||
int any_angle_negative = 0;
|
||||
for (int m = 0; m < num_angle[i]; m++) {
|
||||
if (angle_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_angle[ilocal]; m++) {
|
||||
if (angle_type[ilocal][m] < 0) {
|
||||
angle_negative[m] = 1;
|
||||
angle_type[i][m] = -angle_type[i][m];
|
||||
angle_type[ilocal][m] = -angle_type[ilocal][m];
|
||||
any_angle_negative = 1;
|
||||
} else angle_negative[m] = 0;
|
||||
}
|
||||
@ -115,22 +115,22 @@ void AtomVecAngle::pack_restart_pre(int i)
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::pack_restart_post(int i)
|
||||
void AtomVecAngle::pack_restart_post(int ilocal)
|
||||
{
|
||||
// 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];
|
||||
for (int m = 0; m < num_bond[ilocal]; m++)
|
||||
if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][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];
|
||||
for (int m = 0; m < num_angle[ilocal]; m++)
|
||||
if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -28,16 +28,16 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"molecule num_bond bond_type bond_atom nspecial special";
|
||||
fields_copy = (char *)
|
||||
"molecule num_bond bond_type bond_atom nspecial special";
|
||||
fields_comm = NULL;
|
||||
fields_comm_vel = NULL;
|
||||
fields_reverse = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "molecule";
|
||||
fields_border_vel = (char *) "molecule";
|
||||
fields_exchange = (char *)
|
||||
@ -45,7 +45,7 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_restart = (char *) "molecule num_bond bond_type bond_atom";
|
||||
fields_create = (char *) "molecule num_bond nspecial";
|
||||
fields_data_atom = (char *) "id molecule type x";
|
||||
fields_data_vel = NULL;
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
setup_fields();
|
||||
|
||||
@ -64,7 +64,7 @@ AtomVecBond::~AtomVecBond()
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::pack_restart_pre(int i)
|
||||
void AtomVecBond::pack_restart_pre(int ilocal)
|
||||
{
|
||||
// insure bond_negative vector is needed length
|
||||
|
||||
@ -80,10 +80,10 @@ void AtomVecBond::pack_restart_pre(int i)
|
||||
int **bond_type = atom->bond_type;
|
||||
|
||||
any_bond_negative = 0;
|
||||
for (int m = 0; m < num_bond[i]; m++) {
|
||||
if (bond_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_bond[ilocal]; m++) {
|
||||
if (bond_type[ilocal][m] < 0) {
|
||||
bond_negative[m] = 1;
|
||||
bond_type[i][m] = -bond_type[i][m];
|
||||
bond_type[ilocal][m] = -bond_type[ilocal][m];
|
||||
any_bond_negative = 1;
|
||||
} else bond_negative[m] = 0;
|
||||
}
|
||||
@ -93,15 +93,15 @@ void AtomVecBond::pack_restart_pre(int i)
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::pack_restart_post(int i)
|
||||
void AtomVecBond::pack_restart_post(int ilocal)
|
||||
{
|
||||
// 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];
|
||||
for (int m = 0; m < num_bond[ilocal]; m++)
|
||||
if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -28,8 +28,8 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"q molecule num_bond bond_type bond_atom "
|
||||
@ -47,9 +47,9 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp)
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special";
|
||||
fields_comm = NULL;
|
||||
fields_comm_vel = NULL;
|
||||
fields_reverse = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "q molecule";
|
||||
fields_border_vel = (char *) "q molecule";
|
||||
fields_exchange = (char *)
|
||||
@ -70,7 +70,7 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_create = (char *)
|
||||
"q molecule num_bond num_angle num_dihedral num_improper nspecial";
|
||||
fields_data_atom = (char *) "id molecule type q x";
|
||||
fields_data_vel = NULL;
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
setup_fields();
|
||||
|
||||
@ -92,7 +92,7 @@ AtomVecFull::~AtomVecFull()
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecFull::pack_restart_pre(int i)
|
||||
void AtomVecFull::pack_restart_pre(int ilocal)
|
||||
{
|
||||
// insure negative vectors are needed length
|
||||
|
||||
@ -129,37 +129,37 @@ void AtomVecFull::pack_restart_pre(int i)
|
||||
int **improper_type = atom->improper_type;
|
||||
|
||||
int any_bond_negative = 0;
|
||||
for (int m = 0; m < num_bond[i]; m++) {
|
||||
if (bond_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_bond[ilocal]; m++) {
|
||||
if (bond_type[ilocal][m] < 0) {
|
||||
bond_negative[m] = 1;
|
||||
bond_type[i][m] = -bond_type[i][m];
|
||||
bond_type[ilocal][m] = -bond_type[ilocal][m];
|
||||
any_bond_negative = 1;
|
||||
} else bond_negative[m] = 0;
|
||||
}
|
||||
|
||||
int any_angle_negative = 0;
|
||||
for (int m = 0; m < num_angle[i]; m++) {
|
||||
if (angle_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_angle[ilocal]; m++) {
|
||||
if (angle_type[ilocal][m] < 0) {
|
||||
angle_negative[m] = 1;
|
||||
angle_type[i][m] = -angle_type[i][m];
|
||||
angle_type[ilocal][m] = -angle_type[ilocal][m];
|
||||
any_angle_negative = 1;
|
||||
} else angle_negative[m] = 0;
|
||||
}
|
||||
|
||||
int any_dihedral_negative = 0;
|
||||
for (int m = 0; m < num_dihedral[i]; m++) {
|
||||
if (dihedral_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_dihedral[ilocal]; m++) {
|
||||
if (dihedral_type[ilocal][m] < 0) {
|
||||
dihedral_negative[m] = 1;
|
||||
dihedral_type[i][m] = -dihedral_type[i][m];
|
||||
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
|
||||
any_dihedral_negative = 1;
|
||||
} else dihedral_negative[m] = 0;
|
||||
}
|
||||
|
||||
int any_improper_negative = 0;
|
||||
for (int m = 0; m < num_improper[i]; m++) {
|
||||
if (improper_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_improper[ilocal]; m++) {
|
||||
if (improper_type[ilocal][m] < 0) {
|
||||
improper_negative[m] = 1;
|
||||
improper_type[i][m] = -improper_type[i][m];
|
||||
improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
any_improper_negative = 1;
|
||||
} else improper_negative[m] = 0;
|
||||
}
|
||||
@ -169,36 +169,38 @@ void AtomVecFull::pack_restart_pre(int i)
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecFull::pack_restart_post(int i)
|
||||
void AtomVecFull::pack_restart_post(int ilocal)
|
||||
{
|
||||
// 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];
|
||||
for (int m = 0; m < num_bond[ilocal]; m++)
|
||||
if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][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];
|
||||
for (int m = 0; m < num_angle[ilocal]; m++)
|
||||
if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][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];
|
||||
for (int m = 0; m < num_dihedral[ilocal]; m++)
|
||||
if (dihedral_negative[m])
|
||||
dihedral_type[ilocal][m] = -dihedral_type[ilocal][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];
|
||||
for (int m = 0; m < num_improper[ilocal]; m++)
|
||||
if (improper_negative[m])
|
||||
improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -28,8 +28,8 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *)
|
||||
"molecule num_bond bond_type bond_atom "
|
||||
@ -47,9 +47,9 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp)
|
||||
"num_improper improper_type improper_atom1 improper_atom2 "
|
||||
"improper_atom3 improper_atom4 "
|
||||
"nspecial special";
|
||||
fields_comm = NULL;
|
||||
fields_comm_vel = NULL;
|
||||
fields_reverse = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "molecule";
|
||||
fields_border_vel = (char *) "molecule";
|
||||
fields_exchange = (char *)
|
||||
@ -70,7 +70,7 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_create = (char *)
|
||||
"molecule num_bond num_angle num_dihedral num_improper nspecial";
|
||||
fields_data_atom = (char *) "id molecule type x";
|
||||
fields_data_vel = NULL;
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
setup_fields();
|
||||
|
||||
@ -92,7 +92,7 @@ AtomVecMolecular::~AtomVecMolecular()
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::pack_restart_pre(int i)
|
||||
void AtomVecMolecular::pack_restart_pre(int ilocal)
|
||||
{
|
||||
// insure negative vectors are needed length
|
||||
|
||||
@ -129,37 +129,37 @@ void AtomVecMolecular::pack_restart_pre(int i)
|
||||
int **improper_type = atom->improper_type;
|
||||
|
||||
int any_bond_negative = 0;
|
||||
for (int m = 0; m < num_bond[i]; m++) {
|
||||
if (bond_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_bond[ilocal]; m++) {
|
||||
if (bond_type[ilocal][m] < 0) {
|
||||
bond_negative[m] = 1;
|
||||
bond_type[i][m] = -bond_type[i][m];
|
||||
bond_type[ilocal][m] = -bond_type[ilocal][m];
|
||||
any_bond_negative = 1;
|
||||
} else bond_negative[m] = 0;
|
||||
}
|
||||
|
||||
int any_angle_negative = 0;
|
||||
for (int m = 0; m < num_angle[i]; m++) {
|
||||
if (angle_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_angle[ilocal]; m++) {
|
||||
if (angle_type[ilocal][m] < 0) {
|
||||
angle_negative[m] = 1;
|
||||
angle_type[i][m] = -angle_type[i][m];
|
||||
angle_type[ilocal][m] = -angle_type[ilocal][m];
|
||||
any_angle_negative = 1;
|
||||
} else angle_negative[m] = 0;
|
||||
}
|
||||
|
||||
int any_dihedral_negative = 0;
|
||||
for (int m = 0; m < num_dihedral[i]; m++) {
|
||||
if (dihedral_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_dihedral[ilocal]; m++) {
|
||||
if (dihedral_type[ilocal][m] < 0) {
|
||||
dihedral_negative[m] = 1;
|
||||
dihedral_type[i][m] = -dihedral_type[i][m];
|
||||
dihedral_type[ilocal][m] = -dihedral_type[ilocal][m];
|
||||
any_dihedral_negative = 1;
|
||||
} else dihedral_negative[m] = 0;
|
||||
}
|
||||
|
||||
int any_improper_negative = 0;
|
||||
for (int m = 0; m < num_improper[i]; m++) {
|
||||
if (improper_type[i][m] < 0) {
|
||||
for (int m = 0; m < num_improper[ilocal]; m++) {
|
||||
if (improper_type[ilocal][m] < 0) {
|
||||
improper_negative[m] = 1;
|
||||
improper_type[i][m] = -improper_type[i][m];
|
||||
improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
any_improper_negative = 1;
|
||||
} else improper_negative[m] = 0;
|
||||
}
|
||||
@ -169,36 +169,38 @@ void AtomVecMolecular::pack_restart_pre(int i)
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::pack_restart_post(int i)
|
||||
void AtomVecMolecular::pack_restart_post(int ilocal)
|
||||
{
|
||||
// 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];
|
||||
for (int m = 0; m < num_bond[ilocal]; m++)
|
||||
if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][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];
|
||||
for (int m = 0; m < num_angle[ilocal]; m++)
|
||||
if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][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];
|
||||
for (int m = 0; m < num_dihedral[ilocal]; m++)
|
||||
if (dihedral_negative[m])
|
||||
dihedral_type[ilocal][m] = -dihedral_type[ilocal][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];
|
||||
for (int m = 0; m < num_improper[ilocal]; m++)
|
||||
if (improper_negative[m])
|
||||
improper_type[ilocal][m] = -improper_type[ilocal][m];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,16 +40,16 @@ AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
fields_grow = (char *) "molecule molindex molatom";
|
||||
fields_copy = (char *) "molecule molindex molatom";
|
||||
fields_comm = NULL;
|
||||
fields_comm_vel = NULL;
|
||||
fields_reverse = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "molecule molindex molatom";
|
||||
fields_border_vel = (char *) "molecule molindex molatom";
|
||||
fields_exchange = (char *) "molecule molindex molatom";
|
||||
fields_restart = (char *) "molecule molindex molatom";
|
||||
fields_create = (char *) "molecule molindex molatom";
|
||||
fields_data_atom = (char *) "id molecule molindex molatom type x";
|
||||
fields_data_vel = NULL;
|
||||
fields_data_vel = (char *) "";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -50,21 +50,21 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "rmass vfrac s0 x0";
|
||||
fields_copy = (char *) "rmass vfrac s0 x0";
|
||||
fields_comm = (char *) "s0";
|
||||
fields_comm_vel = (char *) "s0";
|
||||
fields_reverse = NULL;
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "rmass vfrac s0 x0";
|
||||
fields_border_vel = (char *) "rmass vfrac s0 x0";
|
||||
fields_exchange = (char *) "rmass vfrac s0 x0";
|
||||
fields_restart = (char *) "rmass vfrac s0 x0";
|
||||
fields_create = (char *) "rmass vfrac s0 x0";
|
||||
fields_data_atom = (char *) "id type vfrac rmass x";
|
||||
fields_data_vel = (char *) "omega";
|
||||
fields_data_vel = (char *) "id v omega";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -42,8 +42,8 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "sp fm fm_long";
|
||||
fields_copy = (char *) "sp";
|
||||
@ -56,7 +56,7 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_restart = (char *) "sp";
|
||||
fields_create = (char *) "sp";
|
||||
fields_data_atom = (char *) "id type x sp";
|
||||
fields_data_vel = (char *) "omega";
|
||||
fields_data_vel = (char *) "id v omega";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -33,21 +33,21 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem";
|
||||
fields_copy = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
|
||||
fields_comm = (char *) "dpdTheta uCond uMech uChem";
|
||||
fields_comm_vel = (char *) "dpdTheta uCond uMech uChem";
|
||||
fields_reverse = NULL;
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
|
||||
fields_border_vel = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
|
||||
fields_exchange = (char *) "dpdTheta uCond uMech uChem uCG uCGnew";
|
||||
fields_restart = (char *) "dpdTheta uCond uMech uChem";
|
||||
fields_create = (char *) "rho dpdTheta uCond uMech uChem uCG uCGnew duChem";
|
||||
fields_data_atom = (char *) "id type dpdTheta x";
|
||||
fields_data_vel = (char *) "omega";
|
||||
fields_data_vel = (char *) "id v omega";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -56,8 +56,8 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "q spin eradius ervel erforce";
|
||||
fields_copy = (char *) "q spin eradius ervel";
|
||||
@ -70,7 +70,7 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_restart = (char *) "q spin eradius ervel";
|
||||
fields_create = (char *) "q spin eradius ervel";
|
||||
fields_data_atom = (char *) "id type q spin eradius x";
|
||||
fields_data_vel = (char *) "ervel";
|
||||
fields_data_vel = (char *) "id v ervel";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -41,8 +41,8 @@ AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "edpd_cv edpd_temp edpd_flux vest";
|
||||
fields_copy = (char *) "edpd_cv edpd_temp edpd_flux vest";
|
||||
@ -55,7 +55,7 @@ AtomVecEDPD::AtomVecEDPD(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_restart = (char * ) "edpd_cv edpd_temp vest";
|
||||
fields_create = (char *) "edpd_cv edpd_temp edpd_flux vest";
|
||||
fields_data_atom = (char *) "id type edpd_temp edpd_cv x";
|
||||
fields_data_vel = NULL;
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
323
src/atom_vec.cpp
323
src/atom_vec.cpp
@ -55,20 +55,19 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp)
|
||||
|
||||
// peratom variables auto-included in corresponding child style fields string
|
||||
// these fields cannot be specified in the fields string
|
||||
// leading/trailing whitespace just facilitates matching in process_args()
|
||||
|
||||
default_grow = " id type mask image x v f ";
|
||||
default_copy = " id type mask image x v ";
|
||||
default_comm = " x ";
|
||||
default_comm_vel = " x v ";
|
||||
default_reverse = " f ";
|
||||
default_border = " id type mask x ";
|
||||
default_border_vel = " id type mask x v ";
|
||||
default_exchange = " id type mask image x v ";
|
||||
default_restart = " id type mask image x v ";
|
||||
default_create = " id type mask image x v ";
|
||||
default_grow = "id type mask image x v f";
|
||||
default_copy = "id type mask image x v";
|
||||
default_comm = "x";
|
||||
default_comm_vel = "x v";
|
||||
default_reverse = "f";
|
||||
default_border = "id type mask x";
|
||||
default_border_vel = "id type mask x v";
|
||||
default_exchange = "id type mask image x v";
|
||||
default_restart = "id type mask image x v";
|
||||
default_create = "id type mask image x v";
|
||||
default_data_atom = "";
|
||||
default_data_vel = " v ";
|
||||
default_data_vel = "";
|
||||
|
||||
// initializations
|
||||
|
||||
@ -1757,6 +1756,7 @@ void AtomVec::pack_data(double **buf)
|
||||
void *pdata;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
|
||||
// if needed, change values before packing
|
||||
@ -1877,37 +1877,39 @@ void AtomVec::data_vel(int ilocal, char **values)
|
||||
v[ilocal][1] = utils::numeric(FLERR,values[1],true,lmp);
|
||||
v[ilocal][2] = utils::numeric(FLERR,values[2],true,lmp);
|
||||
|
||||
int ivalue = 3;
|
||||
for (n = 0; n < ndata_vel; n++) {
|
||||
pdata = mdata_vel.pdata[n];
|
||||
datatype = mdata_vel.datatype[n];
|
||||
cols = mdata_vel.cols[n];
|
||||
if (datatype == DOUBLE) {
|
||||
if (cols == 0) {
|
||||
double *vec = *((double **) pdata);
|
||||
vec[ilocal] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
} else {
|
||||
double **array = *((double ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
array[ilocal][m] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
}
|
||||
} else if (datatype == INT) {
|
||||
if (cols == 0) {
|
||||
int *vec = *((int **) pdata);
|
||||
vec[ilocal] = utils::inumeric(FLERR,values[ivalue++],true,lmp);
|
||||
} else {
|
||||
int **array = *((int ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
array[ilocal][m] = utils::inumeric(FLERR,values[ivalue++],true,lmp);
|
||||
}
|
||||
} else if (datatype == BIGINT) {
|
||||
if (cols == 0) {
|
||||
bigint *vec = *((bigint **) pdata);
|
||||
vec[ilocal] = utils::bnumeric(FLERR,values[ivalue++],true,lmp);
|
||||
} else {
|
||||
bigint **array = *((bigint ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
array[ilocal][m] = utils::bnumeric(FLERR,values[ivalue++],true,lmp);
|
||||
if (ndata_vel) {
|
||||
int ivalue = 3;
|
||||
for (n = 0; n < ndata_vel; n++) {
|
||||
pdata = mdata_vel.pdata[n];
|
||||
datatype = mdata_vel.datatype[n];
|
||||
cols = mdata_vel.cols[n];
|
||||
if (datatype == DOUBLE) {
|
||||
if (cols == 0) {
|
||||
double *vec = *((double **) pdata);
|
||||
vec[ilocal] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
} else {
|
||||
double **array = *((double ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
array[ilocal][m] = utils::numeric(FLERR,values[ivalue++],true,lmp);
|
||||
}
|
||||
} else if (datatype == INT) {
|
||||
if (cols == 0) {
|
||||
int *vec = *((int **) pdata);
|
||||
vec[ilocal] = utils::inumeric(FLERR,values[ivalue++],true,lmp);
|
||||
} else {
|
||||
int **array = *((int ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
array[ilocal][m] = utils::inumeric(FLERR,values[ivalue++],true,lmp);
|
||||
}
|
||||
} else if (datatype == BIGINT) {
|
||||
if (cols == 0) {
|
||||
bigint *vec = *((bigint **) pdata);
|
||||
vec[ilocal] = utils::bnumeric(FLERR,values[ivalue++],true,lmp);
|
||||
} else {
|
||||
bigint **array = *((bigint ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
array[ilocal][m] = utils::bnumeric(FLERR,values[ivalue++],true,lmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1922,49 +1924,40 @@ void AtomVec::pack_vel(double **buf)
|
||||
int i,j,m,n,datatype,cols;
|
||||
void *pdata;
|
||||
|
||||
double **v = atom->v;
|
||||
tagint *tag = atom->tag;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (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];
|
||||
|
||||
j = 4;
|
||||
if (ndata_vel) {
|
||||
for (n = 0; n < ndata_vel; n++) {
|
||||
pdata = mdata_vel.pdata[n];
|
||||
datatype = mdata_vel.datatype[n];
|
||||
cols = mdata_vel.cols[n];
|
||||
if (datatype == DOUBLE) {
|
||||
if (cols == 0) {
|
||||
double *vec = *((double **) pdata);
|
||||
buf[i][j++] = vec[i];
|
||||
} else {
|
||||
double **array = *((double ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
buf[i][j++] = array[i][m];
|
||||
}
|
||||
} else if (datatype == INT) {
|
||||
if (cols == 0) {
|
||||
int *vec = *((int **) pdata);
|
||||
buf[i][j++] = ubuf(vec[i]).d;
|
||||
} else {
|
||||
int **array = *((int ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
buf[i][j++] = ubuf(array[i][m]).d;
|
||||
}
|
||||
} else if (datatype == BIGINT) {
|
||||
if (cols == 0) {
|
||||
bigint *vec = *((bigint **) pdata);
|
||||
buf[i][j++] = ubuf(vec[i]).d;
|
||||
} else {
|
||||
bigint **array = *((bigint ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
buf[i][j++] = ubuf(array[i][m]).d;
|
||||
}
|
||||
j = 0;
|
||||
for (n = 0; n < ndata_vel; n++) {
|
||||
pdata = mdata_vel.pdata[n];
|
||||
datatype = mdata_vel.datatype[n];
|
||||
cols = mdata_vel.cols[n];
|
||||
if (datatype == DOUBLE) {
|
||||
if (cols == 0) {
|
||||
double *vec = *((double **) pdata);
|
||||
buf[i][j++] = vec[i];
|
||||
} else {
|
||||
double **array = *((double ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
buf[i][j++] = array[i][m];
|
||||
}
|
||||
} else if (datatype == INT) {
|
||||
if (cols == 0) {
|
||||
int *vec = *((int **) pdata);
|
||||
buf[i][j++] = ubuf(vec[i]).d;
|
||||
} else {
|
||||
int **array = *((int ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
buf[i][j++] = ubuf(array[i][m]).d;
|
||||
}
|
||||
} else if (datatype == BIGINT) {
|
||||
if (cols == 0) {
|
||||
bigint *vec = *((bigint **) pdata);
|
||||
buf[i][j++] = ubuf(vec[i]).d;
|
||||
} else {
|
||||
bigint **array = *((bigint ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
buf[i][j++] = ubuf(array[i][m]).d;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1985,37 +1978,39 @@ void AtomVec::write_vel(FILE *fp, int n, double **buf)
|
||||
fprintf(fp,TAGINT_FORMAT " %-1.16e %-1.16e %-1.16e\n",
|
||||
(tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]);
|
||||
|
||||
j = 4;
|
||||
for (nn = 0; nn < ndata_vel; nn++) {
|
||||
pdata = mdata_vel.pdata[nn];
|
||||
datatype = mdata_vel.datatype[nn];
|
||||
cols = mdata_vel.cols[nn];
|
||||
if (datatype == DOUBLE) {
|
||||
if (cols == 0) {
|
||||
double *vec = *((double **) pdata);
|
||||
fprintf(fp," %-1.16e",buf[i][j++]);
|
||||
} else {
|
||||
double **array = *((double ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
if (ndata_vel) {
|
||||
j = 4;
|
||||
for (nn = 0; nn < ndata_vel; nn++) {
|
||||
pdata = mdata_vel.pdata[nn];
|
||||
datatype = mdata_vel.datatype[nn];
|
||||
cols = mdata_vel.cols[nn];
|
||||
if (datatype == DOUBLE) {
|
||||
if (cols == 0) {
|
||||
double *vec = *((double **) pdata);
|
||||
fprintf(fp," %-1.16e",buf[i][j++]);
|
||||
}
|
||||
} else if (datatype == INT) {
|
||||
if (cols == 0) {
|
||||
int *vec = *((int **) pdata);
|
||||
fprintf(fp," %d",(int) ubuf(buf[i][j++]).i);
|
||||
} else {
|
||||
int **array = *((int ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
} else {
|
||||
double **array = *((double ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
fprintf(fp," %-1.16e",buf[i][j++]);
|
||||
}
|
||||
} else if (datatype == INT) {
|
||||
if (cols == 0) {
|
||||
int *vec = *((int **) pdata);
|
||||
fprintf(fp," %d",(int) ubuf(buf[i][j++]).i);
|
||||
}
|
||||
} else if (datatype == BIGINT) {
|
||||
if (cols == 0) {
|
||||
bigint *vec = *((bigint **) pdata);
|
||||
fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i);
|
||||
} else {
|
||||
bigint **array = *((bigint ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
} else {
|
||||
int **array = *((int ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
fprintf(fp," %d",(int) ubuf(buf[i][j++]).i);
|
||||
}
|
||||
} else if (datatype == BIGINT) {
|
||||
if (cols == 0) {
|
||||
bigint *vec = *((bigint **) pdata);
|
||||
fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i);
|
||||
} else {
|
||||
bigint **array = *((bigint ***) pdata);
|
||||
for (m = 0; m < cols; m++)
|
||||
fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2342,10 +2337,11 @@ 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");
|
||||
if (strstr(fields_data_vel,"id v") != fields_data_vel)
|
||||
error->all(FLERR,"Atom style fields_data_vel must have "
|
||||
"'id v' as first fields");
|
||||
|
||||
// process field strings
|
||||
// return # of fields and matching index into atom->peratom (in Method struct)
|
||||
@ -2387,7 +2383,7 @@ void AtomVec::setup_fields()
|
||||
else threads[i] = 1;
|
||||
}
|
||||
|
||||
// set style-specific variables
|
||||
// set style-specific sizes
|
||||
// NOTE: check for others vars in atom_vec.cpp/h ??
|
||||
// NOTE: need to set maxexchange, e.g for style hybrid?
|
||||
|
||||
@ -2437,7 +2433,7 @@ void AtomVec::setup_fields()
|
||||
else size_data_atom += cols;
|
||||
}
|
||||
|
||||
size_data_vel = 4;
|
||||
size_data_vel = 0;
|
||||
for (n = 0; n < ndata_vel; n++) {
|
||||
cols = mdata_vel.cols[n];
|
||||
if (cols == 0) size_data_vel++;
|
||||
@ -2449,61 +2445,96 @@ void AtomVec::setup_fields()
|
||||
process a single field string
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVec::process_fields(char *list, const char *default_list, Method *method)
|
||||
int AtomVec::process_fields(char *str, const char *default_str, Method *method)
|
||||
{
|
||||
int i,n;
|
||||
char match[128];
|
||||
|
||||
if (list == NULL) {
|
||||
if (str == NULL) {
|
||||
method->index = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// make copy of list of fields so can tokenize it
|
||||
// tokenize words in both strings
|
||||
|
||||
n = strlen(list) + 1;
|
||||
char *copy = new char[n];
|
||||
strcpy(copy,list);
|
||||
|
||||
int nfield = atom->count_words(copy);
|
||||
int *index = new int[nfield];
|
||||
char *copy1,*copy2;
|
||||
char **words,**defwords;
|
||||
int nfield = tokenize(str,words,copy1);
|
||||
int ndef = tokenize((char *) default_str,defwords,copy2);
|
||||
|
||||
// process fields one by one, add to index vector
|
||||
|
||||
Atom::PerAtom *peratom = atom->peratom;
|
||||
int nperatom = atom->nperatom;
|
||||
|
||||
nfield = 0;
|
||||
char *field = strtok(copy," ");
|
||||
while (field) {
|
||||
|
||||
int *index = new int[nfield];
|
||||
int match;
|
||||
|
||||
for (int i = 0; i < nfield; i++) {
|
||||
|
||||
// find field in master Atom::peratom list
|
||||
|
||||
for (i = 0; i < nperatom; i++)
|
||||
if (strcmp(field,peratom[i].name) == 0) break;
|
||||
if (i == nperatom) {
|
||||
printf("FIELD %s\n",field);
|
||||
error->all(FLERR,"Atom_style unrecognized peratom field");
|
||||
for (match = 0; match < nperatom; match++)
|
||||
if (strcmp(words[i],peratom[match].name) == 0) break;
|
||||
if (match == nperatom) {
|
||||
char str[128];
|
||||
sprintf(str,"Peratom field %s not recognized",words[i]);
|
||||
error->all(FLERR,str);
|
||||
}
|
||||
index[nfield++] = i;
|
||||
index[i] = match;
|
||||
|
||||
// error if field is in default list or appears multiple times
|
||||
// error if field appears multiple times
|
||||
|
||||
sprintf(match," %s ",field);
|
||||
if (strstr(default_list,match))
|
||||
error->all(FLERR,"Atom_style repeat of default peratom field");
|
||||
for (match = 0; match < i; match++)
|
||||
if (index[i] == index[match]) {
|
||||
char str[128];
|
||||
sprintf(str,"Peratom field %s is repeated",words[i]);
|
||||
error->all(FLERR,str);
|
||||
}
|
||||
|
||||
for (i = 0; i < nfield-1; i++)
|
||||
if (index[i] == index[nfield-1])
|
||||
error->all(FLERR,"Atom_style duplicated peratom field");
|
||||
// error if field is in default str
|
||||
|
||||
for (match = 0; match < ndef; match++)
|
||||
if (strcmp(words[i],defwords[match]) == 0) {
|
||||
char str[128];
|
||||
sprintf(str,"Peratom field %s is a default",words[i]);
|
||||
error->all(FLERR,str);
|
||||
}
|
||||
|
||||
field = strtok(NULL," ");
|
||||
}
|
||||
|
||||
delete [] copy;
|
||||
delete [] copy1;
|
||||
delete [] copy2;
|
||||
delete [] words;
|
||||
delete [] defwords;
|
||||
|
||||
method->index = index;
|
||||
return nfield;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
tokenize str into white-space separated words
|
||||
return nwords = number of words
|
||||
return words = vector of ptrs to each word
|
||||
also return copystr since words points into it, caller will delete copystr
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVec::tokenize(char *str, char **&words, char *©str)
|
||||
{
|
||||
int n = strlen(str) + 1;
|
||||
copystr = new char[n];
|
||||
strcpy(copystr,str);
|
||||
|
||||
int nword = atom->count_words(copystr);
|
||||
words = new char*[nword];
|
||||
|
||||
nword = 0;
|
||||
char *word = strtok(copystr," ");
|
||||
while (word) {
|
||||
words[nword++] = word;
|
||||
word = strtok(NULL," ");
|
||||
}
|
||||
|
||||
return nword;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create a method data structs for processing fields
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -55,7 +55,7 @@ class AtomVec : protected Pointers {
|
||||
char **argcopy; // used when AtomVec is realloced (restart,replicate)
|
||||
|
||||
// additional list of peratom fields operated on by different methods
|
||||
// set by child styles
|
||||
// set or created by child styles
|
||||
|
||||
char *fields_grow,*fields_copy;
|
||||
char *fields_comm,*fields_comm_vel,*fields_reverse;
|
||||
@ -220,6 +220,7 @@ class AtomVec : protected Pointers {
|
||||
int grow_nmax_bonus(int);
|
||||
void setup_fields();
|
||||
int process_fields(char *, const char *, Method *);
|
||||
int tokenize(char *, char **&, char *&);
|
||||
void create_method(int, Method *);
|
||||
void init_method(Method *);
|
||||
void destroy_method(Method *);
|
||||
|
||||
@ -24,21 +24,21 @@ AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = NULL;
|
||||
fields_copy = NULL;
|
||||
fields_comm = NULL;
|
||||
fields_comm_vel = NULL;
|
||||
fields_reverse = NULL;
|
||||
fields_border = NULL;
|
||||
fields_border_vel = NULL;
|
||||
fields_exchange = NULL;
|
||||
fields_restart = NULL;
|
||||
fields_create = NULL;
|
||||
fields_grow = (char *) "";
|
||||
fields_copy = (char *) "";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "";
|
||||
fields_border_vel = (char *) "";
|
||||
fields_exchange = (char *) "";
|
||||
fields_restart = (char *) "";
|
||||
fields_create = (char *) "";
|
||||
fields_data_atom = (char *) "id type x";
|
||||
fields_data_vel = NULL;
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -60,12 +60,12 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "radius rmass angmom torque body";
|
||||
fields_copy = (char *) "radius rmass angmom";
|
||||
fields_comm = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "angmom";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "radius rmass";
|
||||
@ -74,7 +74,7 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_restart = (char *) "radius rmass angmom";
|
||||
fields_create = (char *) "radius rmass angmom tri";
|
||||
fields_data_atom = (char *) "id type body rmass x";
|
||||
fields_data_vel = (char *) "angmom";
|
||||
fields_data_vel = (char *) "id v angmom";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -47,7 +47,6 @@ class AtomVecBody : public AtomVec {
|
||||
void clear_bonus();
|
||||
int pack_comm_bonus(int, int *, double *);
|
||||
void unpack_comm_bonus(int, int, double *);
|
||||
int pack_reverse_bonus(int, int, double *);
|
||||
int pack_border_bonus(int, int *, double *);
|
||||
int unpack_border_bonus(int, int, double *);
|
||||
int pack_exchange_bonus(int, double *);
|
||||
|
||||
@ -27,21 +27,21 @@ AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "q";
|
||||
fields_copy = (char *) "q";
|
||||
fields_comm = NULL;
|
||||
fields_comm_vel = NULL;
|
||||
fields_reverse = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "q";
|
||||
fields_border_vel = (char *) "q";
|
||||
fields_exchange = (char *) "q";
|
||||
fields_restart = (char *) "q";
|
||||
fields_create = (char *) "q";
|
||||
fields_data_atom = (char *) "id type q x";
|
||||
fields_data_vel = NULL;
|
||||
fields_data_atom = (char *) "id type q x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -49,12 +49,12 @@ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "rmass angmom torque ellipsoid";
|
||||
fields_copy = (char *) "rmass angmom";
|
||||
fields_comm = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "angmom";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "rmass";
|
||||
@ -63,7 +63,7 @@ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_restart = (char *) "rmass angmom";
|
||||
fields_create = (char *) "rmass angmom ellipsoid";
|
||||
fields_data_atom = (char *) "id type ellipsoid rmass x";
|
||||
fields_data_vel = (char *) "angmom";
|
||||
fields_data_vel = (char *) "id v angmom";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -40,7 +40,6 @@ class AtomVecEllipsoid : public AtomVec {
|
||||
void clear_bonus();
|
||||
int pack_comm_bonus(int, int *, double *);
|
||||
void unpack_comm_bonus(int, int, double *);
|
||||
int pack_reverse_bonus(int, int, double *);
|
||||
int pack_border_bonus(int, int *, double *);
|
||||
int unpack_border_bonus(int, int, double *);
|
||||
int pack_exchange_bonus(int, double *);
|
||||
|
||||
@ -14,18 +14,39 @@
|
||||
#include "atom_vec_hybrid.h"
|
||||
#include <cstring>
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "comm.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define NFIELDSTRINGS 12 // # of field strings
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) {}
|
||||
AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp)
|
||||
{
|
||||
nstyles = 0;
|
||||
styles = NULL;
|
||||
keywords = NULL;
|
||||
fieldstrings = NULL;
|
||||
|
||||
nstyles_bonus = 0;
|
||||
styles_bonus = NULL;
|
||||
|
||||
// NOTE: set bonus_flag if any substyle does
|
||||
// set nstyles_bonus, styles_bonus
|
||||
// NOTE: call method in each sub-style to set q_flag ??
|
||||
|
||||
// these strings will be concatenated from sub-style strings
|
||||
// fields_data_atom & fields_data_vel start with fields common to all styles
|
||||
|
||||
fields_grow = fields_copy = fields_comm = fields_comm_vel = (char *) "";
|
||||
fields_reverse = fields_border = fields_border_vel = (char *) "";
|
||||
fields_exchange = fields_restart = fields_create = (char *) "";
|
||||
fields_data_atom = (char *) "id type x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -36,14 +57,23 @@ AtomVecHybrid::~AtomVecHybrid()
|
||||
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
|
||||
// NOTE: need to check these have actually been allocated
|
||||
|
||||
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;
|
||||
delete [] fields_grow;
|
||||
delete [] fields_copy;
|
||||
delete [] fields_comm;
|
||||
delete [] fields_comm_vel;
|
||||
delete [] fields_reverse;
|
||||
delete [] fields_border;
|
||||
delete [] fields_border_vel;
|
||||
delete [] fields_exchange;
|
||||
delete [] fields_restart;
|
||||
delete [] fields_create;
|
||||
delete [] fields_data_atom;
|
||||
delete [] fields_data_vel;
|
||||
|
||||
for (int k = 0; k < nstyles; k++) delete [] fieldstrings[k].fstr;
|
||||
delete [] fieldstrings;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -52,7 +82,7 @@ AtomVecHybrid::~AtomVecHybrid()
|
||||
|
||||
void AtomVecHybrid::process_args(int narg, char **arg)
|
||||
{
|
||||
// build list of all known atom styles
|
||||
// create list of all known atom styles
|
||||
|
||||
build_styles();
|
||||
|
||||
@ -85,58 +115,120 @@ void AtomVecHybrid::process_args(int narg, char **arg)
|
||||
nstyles++;
|
||||
}
|
||||
|
||||
// hybrid settings are MAX or MIN of sub-style settings
|
||||
// check for both mass_type = 0 and 1, so can warn
|
||||
|
||||
molecular = 0;
|
||||
maxexchange = 0;
|
||||
|
||||
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;
|
||||
|
||||
// NOTE: need to sum this one?
|
||||
maxexchange += styles[k]->maxexchange;
|
||||
}
|
||||
|
||||
// issue a warning if both per-type mass and per-atom rmass are defined
|
||||
|
||||
int mass_pertype = 0;
|
||||
int mass_peratom = 0;
|
||||
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (styles[k]->mass_type == 0) mass_peratom = 1;
|
||||
if (styles[k]->mass_type == 1) mass_pertype = 1;
|
||||
}
|
||||
|
||||
if (mass_pertype && mass_peratom && comm->me == 0)
|
||||
error->warning(FLERR,
|
||||
"Atom_style hybrid defines both pertype and peratom masses "
|
||||
"- both must be set, only peratom masses will be used");
|
||||
|
||||
// free allstyles created by build_styles()
|
||||
|
||||
for (int i = 0; i < nallstyles; i++) delete [] allstyles[i];
|
||||
delete [] allstyles;
|
||||
|
||||
// concatenate field strings from all sub-styles
|
||||
// set field strings from all substyles
|
||||
|
||||
concatenate_fields();
|
||||
fieldstrings = new FieldStrings[nstyles];
|
||||
|
||||
// parent AtomVec will now operate on concatenated fields
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
fieldstrings[k].fstr = new char*[NFIELDSTRINGS];
|
||||
fieldstrings[k].fstr[0] = styles[k]->fields_grow;
|
||||
fieldstrings[k].fstr[1] = styles[k]->fields_copy;
|
||||
fieldstrings[k].fstr[2] = styles[k]->fields_comm;
|
||||
fieldstrings[k].fstr[3] = styles[k]->fields_comm_vel;
|
||||
fieldstrings[k].fstr[4] = styles[k]->fields_reverse;
|
||||
fieldstrings[k].fstr[5] = styles[k]->fields_border;
|
||||
fieldstrings[k].fstr[6] = styles[k]->fields_border_vel;
|
||||
fieldstrings[k].fstr[7] = styles[k]->fields_exchange;
|
||||
fieldstrings[k].fstr[8] = styles[k]->fields_restart;
|
||||
fieldstrings[k].fstr[9] = styles[k]->fields_create;
|
||||
fieldstrings[k].fstr[10] = styles[k]->fields_data_atom;
|
||||
fieldstrings[k].fstr[11] = styles[k]->fields_data_vel;
|
||||
}
|
||||
|
||||
// merge field strings from all sub-styles
|
||||
// save concat_grow to check for duplicates of special-case fields
|
||||
|
||||
char *concat_grow;;
|
||||
char *null = NULL;
|
||||
|
||||
fields_grow = merge_fields(0,fields_grow,1,concat_grow);
|
||||
fields_copy = merge_fields(1,fields_copy,0,null);
|
||||
fields_comm = merge_fields(2,fields_comm,0,null);
|
||||
fields_comm_vel = merge_fields(3,fields_comm_vel,0,null);
|
||||
fields_reverse = merge_fields(4,fields_reverse,0,null);
|
||||
fields_border = merge_fields(5,fields_border,0,null);
|
||||
fields_border_vel = merge_fields(6,fields_border_vel,0,null);
|
||||
fields_exchange = merge_fields(7,fields_exchange,0,null);
|
||||
fields_restart = merge_fields(8,fields_restart,0,null);
|
||||
fields_create = merge_fields(9,fields_create,0,null);
|
||||
fields_data_atom = merge_fields(10,fields_data_atom,0,null);
|
||||
fields_data_vel = merge_fields(11,fields_data_vel,0,null);
|
||||
|
||||
// check concat_grow for multiple special-case fields
|
||||
// may cause issues with style-specific create_atom() and data_atom() methods
|
||||
// issue warnings if appear in multiple sub-styles
|
||||
|
||||
const char *dupfield[] = {"radius","rmass"};
|
||||
int ndupfield = 2;
|
||||
char *ptr;
|
||||
|
||||
for (int idup = 0; idup < ndupfield; idup++) {
|
||||
char *dup = (char *) dupfield[idup];
|
||||
ptr = strstr(concat_grow,dup);
|
||||
if (strstr(ptr+1,dup)) {
|
||||
char str[128];
|
||||
sprintf(str,"Peratom %s is in multiple sub-styles - "
|
||||
"must be used consistently",dup);
|
||||
if (comm->me == 0) error->warning(FLERR,str);
|
||||
}
|
||||
}
|
||||
|
||||
delete [] concat_grow;
|
||||
|
||||
// parent AtomVec can now operate on merged fields
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::concatenate_fields()
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
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);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::init()
|
||||
{
|
||||
AtomVec::init();
|
||||
@ -151,6 +243,185 @@ void AtomVecHybrid::force_clear(int n, size_t nbytes)
|
||||
if (styles[k]->forceclearflag) styles[k]->force_clear(n,nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify values for AtomVec::pack_restart() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_restart_pre(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_restart_pre(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unmodify values packed by AtomVec::pack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_restart_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_restart_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize other atom quantities after AtomVec::unpack_restart()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_restart_init(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->unpack_restart_init(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize non-zero atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::create_atom_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->create_atom_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::data_atom_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->data_atom_post(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify values for AtomVec::pack_data() to pack
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_data_pre(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_data_pre(ilocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unmodify values packed by AtomVec::pack_data()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::pack_data_post(int ilocal)
|
||||
{
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
styles[k]->pack_data_post(ilocal);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::copy_bonus(int i, int j, int delflag)
|
||||
{
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
styles_bonus[k]->copy_bonus(i,j,delflag);
|
||||
}
|
||||
|
||||
// NOTE: need a clear_bonus() ?
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_comm_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->pack_comm_bonus(n,list,buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_comm_bonus(int n, int first, double *buf)
|
||||
{
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
styles_bonus[k]->unpack_comm_bonus(n,first,buf);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_border_bonus(int n, int *list, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->pack_border_bonus(n,list,buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::unpack_border_bonus(int n, int first, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->unpack_border_bonus(n,first,buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_exchange_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->pack_exchange_bonus(i,buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::unpack_exchange_bonus(int ilocal, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->unpack_exchange_bonus(ilocal,buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::size_restart_bonus()
|
||||
{
|
||||
int n = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
n += styles_bonus[k]->size_restart_bonus();
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_restart_bonus(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->pack_restart_bonus(i,buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::unpack_restart_bonus(int ilocal, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
m += styles_bonus[k]->unpack_restart_bonus(ilocal,buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
bigint AtomVecHybrid::memory_usage_bonus()
|
||||
{
|
||||
bigint bytes = 0;
|
||||
for (int k = 0; k < nstyles_bonus; k++)
|
||||
bytes += styles_bonus[k]->memory_usage_bonus();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
assign an index to named atom property and return index
|
||||
returned value encodes which sub-style and index returned by sub-style
|
||||
@ -179,6 +450,75 @@ void AtomVecHybrid::pack_property_atom(int multiindex, double *buf,
|
||||
styles[k]->pack_property_atom(index,buf,nvalues,groupbit);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// internal methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
merge fields and remove duplicate fields
|
||||
concat = root + Inum fields string from all substyles
|
||||
return dedup = concat with duplicate fields removed
|
||||
if concat_flag set, also return concat (w/ duplicates)
|
||||
so caller can check for problematic fields, call will free it
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
char *AtomVecHybrid::merge_fields(int inum, char *root,
|
||||
int concat_flag, char *&concat_str)
|
||||
{
|
||||
// create concatenated string of length size from root + all substyles
|
||||
|
||||
int size = strlen(root) + 1;
|
||||
for (int k = 0; k < nstyles; k++)
|
||||
size += strlen(fieldstrings[k].fstr[inum]) + 1;
|
||||
|
||||
char *concat = new char[size];
|
||||
strcpy(concat,root);
|
||||
|
||||
for (int k = 0; k < nstyles; k++) {
|
||||
if (strlen(concat)) strcat(concat," ");
|
||||
strcat(concat,fieldstrings[k].fstr[inum]);
|
||||
}
|
||||
|
||||
// identify unique words in concatenated string
|
||||
|
||||
char *copystr;
|
||||
char **words;
|
||||
int nwords = tokenize(concat,words,copystr);
|
||||
int *unique = new int[nwords];
|
||||
|
||||
for (int i = 0; i < nwords; i++) {
|
||||
unique[i] = 1;
|
||||
for (int j = 0; j < i; j++)
|
||||
if (strcmp(words[i],words[j]) == 0) unique[i] = 0;
|
||||
}
|
||||
|
||||
// construct a new deduped string
|
||||
|
||||
char *dedup = new char[size];
|
||||
dedup[0] = '\0';
|
||||
|
||||
for (int i = 0; i < nwords; i++) {
|
||||
if (!unique[i]) continue;
|
||||
strcat(dedup,words[i]);
|
||||
if (i < nwords-1) strcat(dedup," ");
|
||||
}
|
||||
|
||||
// clean up or return concat
|
||||
|
||||
if (concat_flag) concat_str = concat;
|
||||
else delete [] concat;
|
||||
|
||||
// clean up
|
||||
|
||||
delete [] copystr;
|
||||
delete [] words;
|
||||
delete [] unique;
|
||||
|
||||
// return final concatenated, deduped string
|
||||
|
||||
return dedup;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
allstyles = list of all atom styles in this LAMMPS executable
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -35,6 +35,33 @@ class AtomVecHybrid : public AtomVec {
|
||||
void process_args(int, char **);
|
||||
void init();
|
||||
void force_clear(int, size_t);
|
||||
|
||||
void copy_bonus(int, int, int);
|
||||
void clear_bonus() {}
|
||||
int pack_comm_bonus(int, int *, double *);
|
||||
void unpack_comm_bonus(int, int, double *);
|
||||
int pack_border_bonus(int, int *, double *);
|
||||
int unpack_border_bonus(int, int, double *);
|
||||
int pack_exchange_bonus(int, double *);
|
||||
int unpack_exchange_bonus(int, double *);
|
||||
int size_restart_bonus();
|
||||
int pack_restart_bonus(int, double *);
|
||||
int unpack_restart_bonus(int, double *);
|
||||
bigint memory_usage_bonus();
|
||||
|
||||
void pack_restart_pre(int);
|
||||
void pack_restart_post(int);
|
||||
void unpack_restart_init(int);
|
||||
void create_atom_post(int);
|
||||
void data_atom_post(int);
|
||||
void pack_data_pre(int);
|
||||
void pack_data_post(int);
|
||||
|
||||
//void create_atom_post(int);
|
||||
//void data_atom_post(int);
|
||||
//void pack_data_pre(int);
|
||||
//void pack_data_post(int);
|
||||
|
||||
int property_atom(char *);
|
||||
void pack_property_atom(int, double *, int, int);
|
||||
|
||||
@ -42,8 +69,15 @@ class AtomVecHybrid : public AtomVec {
|
||||
int nallstyles;
|
||||
char **allstyles;
|
||||
|
||||
void concatenate_fields();
|
||||
void concatenate(char *&, char *);
|
||||
struct FieldStrings {
|
||||
char **fstr;
|
||||
};
|
||||
FieldStrings *fieldstrings;
|
||||
|
||||
int nstyles_bonus;
|
||||
class AtomVec **styles_bonus;
|
||||
|
||||
char *merge_fields(int, char *, int, char *&);
|
||||
void build_styles();
|
||||
int known_style(char *);
|
||||
};
|
||||
|
||||
@ -50,12 +50,12 @@ AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "molecule radius rmass omega torque line";
|
||||
fields_copy = (char *) "molecule radius rmass omega";
|
||||
fields_comm = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "omega";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "molecule radius rmass";
|
||||
@ -64,7 +64,7 @@ AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_restart = (char *) "molecule radius rmass omega";
|
||||
fields_create = (char *) "molecule radius rmass omega line";
|
||||
fields_data_atom = (char *) "id molecule type line rmass x";
|
||||
fields_data_vel = (char *) "omega";
|
||||
fields_data_vel = (char *) "id v omega";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -40,7 +40,6 @@ class AtomVecLine : public AtomVec {
|
||||
void clear_bonus();
|
||||
int pack_comm_bonus(int, int *, double *);
|
||||
void unpack_comm_bonus(int, int, double *);
|
||||
int pack_reverse_bonus(int, int, double *);
|
||||
int pack_border_bonus(int, int *, double *);
|
||||
int unpack_border_bonus(int, int, double *);
|
||||
int pack_exchange_bonus(int, double *);
|
||||
|
||||
@ -36,12 +36,12 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "radius rmass omega torque";
|
||||
fields_copy = (char *) "radius rmass omega";
|
||||
fields_comm = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "omega";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "radius rmass";
|
||||
@ -50,7 +50,7 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_restart = (char *) "radius rmass omega";
|
||||
fields_create = (char *) "radius rmass omega";
|
||||
fields_data_atom = (char *) "id type radius rmass x";
|
||||
fields_data_vel = (char *) "omega";
|
||||
fields_data_vel = (char *) "id v omega";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -52,12 +52,12 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp)
|
||||
|
||||
// strings with peratom variables to include in each AtomVec method
|
||||
// strings cannot contain fields in corresponding AtomVec default strings
|
||||
// order of fields in the string does not matter
|
||||
// except fields_data_atom and fields_data_vel which must match data file
|
||||
// order of fields in a string does not matter
|
||||
// except: fields_data_atom & fields_data_vel must match data file
|
||||
|
||||
fields_grow = (char *) "molecule radius rmass omega angmom torque tri";
|
||||
fields_copy = (char *) "molecule radius rmass omega angmom";
|
||||
fields_comm = NULL;
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "omega angmom";
|
||||
fields_reverse = (char *) "torque";
|
||||
fields_border = (char *) "molecule radius rmass";
|
||||
@ -66,7 +66,7 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp)
|
||||
fields_restart = (char *) "molecule radius rmass omega angmom";
|
||||
fields_create = (char *) "molecule radius rmass omega angmom line";
|
||||
fields_data_atom = (char *) "id molecule type tri rmass x";
|
||||
fields_data_vel = (char *) "omega angmom";
|
||||
fields_data_vel = (char *) "id v omega angmom";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@ class AtomVecTri : public AtomVec {
|
||||
void clear_bonus();
|
||||
int pack_comm_bonus(int, int *, double *);
|
||||
void unpack_comm_bonus(int, int, double *);
|
||||
int pack_reverse_bonus(int, int, double *);
|
||||
int pack_border_bonus(int, int *, double *);
|
||||
int unpack_border_bonus(int, int, double *);
|
||||
int pack_exchange_bonus(int, double *);
|
||||
|
||||
Reference in New Issue
Block a user