programming style and format updates
This commit is contained in:
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifdef ATOM_CLASS
|
#ifdef ATOM_CLASS
|
||||||
// clang-format off
|
// clang-format off
|
||||||
AtomStyle(bpm/sphere,AtomVecBPMSphere)
|
AtomStyle(bpm/sphere,AtomVecBPMSphere);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -39,13 +39,12 @@ class AtomVecBPMSphere : public AtomVec {
|
|||||||
void pack_data_pre(int) override;
|
void pack_data_pre(int) override;
|
||||||
void pack_data_post(int) override;
|
void pack_data_post(int) override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int *num_bond;
|
int *num_bond;
|
||||||
int **bond_type;
|
int **bond_type;
|
||||||
int **nspecial;
|
int **nspecial;
|
||||||
|
|
||||||
double *radius,*rmass;
|
double *radius, *rmass;
|
||||||
double **omega, **torque, **quat;
|
double **omega, **torque, **quat;
|
||||||
|
|
||||||
int any_bond_negative;
|
int any_bond_negative;
|
||||||
@ -53,7 +52,7 @@ class AtomVecBPMSphere : public AtomVec {
|
|||||||
int *bond_negative;
|
int *bond_negative;
|
||||||
|
|
||||||
int radvary;
|
int radvary;
|
||||||
double radius_one,rmass_one;
|
double radius_one, rmass_one;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LAMMPS_NS
|
} // namespace LAMMPS_NS
|
||||||
|
|||||||
@ -67,7 +67,7 @@ BondBPM::BondBPM(LAMMPS *lmp) : Bond(lmp)
|
|||||||
|
|
||||||
BondBPM::~BondBPM()
|
BondBPM::~BondBPM()
|
||||||
{
|
{
|
||||||
delete [] pack_choice;
|
delete[] pack_choice;
|
||||||
|
|
||||||
if (id_fix_dummy) modify->delete_fix(id_fix_dummy);
|
if (id_fix_dummy) modify->delete_fix(id_fix_dummy);
|
||||||
if (id_fix_dummy2) modify->delete_fix(id_fix_dummy2);
|
if (id_fix_dummy2) modify->delete_fix(id_fix_dummy2);
|
||||||
@ -76,12 +76,12 @@ BondBPM::~BondBPM()
|
|||||||
if (id_fix_store_local) modify->delete_fix(id_fix_store_local);
|
if (id_fix_store_local) modify->delete_fix(id_fix_store_local);
|
||||||
if (id_fix_prop_atom) modify->delete_fix(id_fix_prop_atom);
|
if (id_fix_prop_atom) modify->delete_fix(id_fix_prop_atom);
|
||||||
|
|
||||||
delete [] id_fix_dummy;
|
delete[] id_fix_dummy;
|
||||||
delete [] id_fix_dummy2;
|
delete[] id_fix_dummy2;
|
||||||
delete [] id_fix_update;
|
delete[] id_fix_update;
|
||||||
delete [] id_fix_bond_history;
|
delete[] id_fix_bond_history;
|
||||||
delete [] id_fix_store_local;
|
delete[] id_fix_store_local;
|
||||||
delete [] id_fix_prop_atom;
|
delete[] id_fix_prop_atom;
|
||||||
|
|
||||||
memory->destroy(output_data);
|
memory->destroy(output_data);
|
||||||
}
|
}
|
||||||
@ -90,13 +90,12 @@ BondBPM::~BondBPM()
|
|||||||
|
|
||||||
void BondBPM::init_style()
|
void BondBPM::init_style()
|
||||||
{
|
{
|
||||||
int ifix;
|
|
||||||
if (id_fix_store_local) {
|
if (id_fix_store_local) {
|
||||||
ifix = modify->find_fix(id_fix_store_local);
|
auto ifix = modify->get_fix_by_id(id_fix_store_local);
|
||||||
if (ifix < 0) error->all(FLERR, "Cannot find fix store/local");
|
if (!ifix) error->all(FLERR, "Cannot find fix store/local");
|
||||||
if (strcmp(modify->fix[ifix]->style, "STORE_LOCAL") != 0)
|
if (strcmp(ifix->style, "STORE_LOCAL") != 0)
|
||||||
error->all(FLERR, "Incorrect fix style matched, not store/local");
|
error->all(FLERR, "Incorrect fix style matched, not store/local");
|
||||||
fix_store_local = (FixStoreLocal *) modify->fix[ifix];
|
fix_store_local = dynamic_cast<FixStoreLocal *>(ifix);
|
||||||
fix_store_local->nvalues = nvalues;
|
fix_store_local->nvalues = nvalues;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +106,7 @@ void BondBPM::init_style()
|
|||||||
"require special_bonds weight of 1.0 for first neighbors");
|
"require special_bonds weight of 1.0 for first neighbors");
|
||||||
if (id_fix_update) {
|
if (id_fix_update) {
|
||||||
modify->delete_fix(id_fix_update);
|
modify->delete_fix(id_fix_update);
|
||||||
delete [] id_fix_update;
|
delete[] id_fix_update;
|
||||||
id_fix_update = nullptr;
|
id_fix_update = nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -127,19 +126,17 @@ void BondBPM::init_style()
|
|||||||
|
|
||||||
if (id_fix_dummy) {
|
if (id_fix_dummy) {
|
||||||
id_fix_update = utils::strdup("BPM_UPDATE_SPECIAL_BONDS");
|
id_fix_update = utils::strdup("BPM_UPDATE_SPECIAL_BONDS");
|
||||||
fix_update_special_bonds = (FixUpdateSpecialBonds *) modify->replace_fix(id_fix_dummy,
|
fix_update_special_bonds = dynamic_cast<FixUpdateSpecialBonds *>(modify->replace_fix(
|
||||||
fmt::format("{} all UPDATE_SPECIAL_BONDS", id_fix_update),1);
|
id_fix_dummy,fmt::format("{} all UPDATE_SPECIAL_BONDS", id_fix_update),1));
|
||||||
delete [] id_fix_dummy;
|
delete[] id_fix_dummy;
|
||||||
id_fix_dummy = nullptr;
|
id_fix_dummy = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force->angle || force->dihedral || force->improper)
|
if (force->angle || force->dihedral || force->improper)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Bond style bpm cannot be used with 3,4-body interactions");
|
||||||
"Bond style bpm cannot be used with 3,4-body interactions");
|
|
||||||
if (atom->molecular == 2)
|
if (atom->molecular == 2)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Bond style bpm cannot be used with atom style template");
|
||||||
"Bond style bpm cannot be used with atom style template");
|
|
||||||
|
|
||||||
// special 1-3 and 1-4 weights must be 1 to prevent building 1-3 and 1-4 special bond lists
|
// special 1-3 and 1-4 weights must be 1 to prevent building 1-3 and 1-4 special bond lists
|
||||||
if (force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0 ||
|
if (force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0 ||
|
||||||
@ -205,17 +202,15 @@ void BondBPM::settings(int narg, char **arg)
|
|||||||
|
|
||||||
if (id_fix_store_local) {
|
if (id_fix_store_local) {
|
||||||
|
|
||||||
if (nvalues == 0) error->all(FLERR,
|
if (nvalues == 0)
|
||||||
"Storing local data must include at least one value to output");
|
error->all(FLERR, "Storing local data must include at least one value to output");
|
||||||
memory->create(output_data, nvalues, "bond/bpm:output_data");
|
memory->create(output_data, nvalues, "bond/bpm:output_data");
|
||||||
|
|
||||||
int ifix = modify->find_fix(id_fix_store_local);
|
auto ifix = modify->get_fix_by_id(id_fix_store_local);
|
||||||
if (ifix < 0) {
|
if (!ifix)
|
||||||
modify->add_fix(fmt::format("{} all STORE_LOCAL {} {}",
|
ifix = modify->add_fix(fmt::format("{} all STORE_LOCAL {} {}",
|
||||||
id_fix_store_local, store_local_freq, nvalues));
|
id_fix_store_local, store_local_freq, nvalues));
|
||||||
ifix = modify->find_fix(id_fix_store_local);
|
fix_store_local = dynamic_cast<FixStoreLocal *>(ifix);
|
||||||
}
|
|
||||||
fix_store_local = (FixStoreLocal *) modify->fix[ifix];
|
|
||||||
|
|
||||||
// Use property/atom to save reference positions as it can transfer to ghost atoms
|
// Use property/atom to save reference positions as it can transfer to ghost atoms
|
||||||
// This won't work for instances where bonds are added (e.g. fix pour) but in those cases
|
// This won't work for instances where bonds are added (e.g. fix pour) but in those cases
|
||||||
@ -227,12 +222,10 @@ void BondBPM::settings(int narg, char **arg)
|
|||||||
char *y_ref_id = utils::strdup("BPM_Y_REF");
|
char *y_ref_id = utils::strdup("BPM_Y_REF");
|
||||||
char *z_ref_id = utils::strdup("BPM_Z_REF");
|
char *z_ref_id = utils::strdup("BPM_Z_REF");
|
||||||
|
|
||||||
ifix = modify->find_fix(id_fix_prop_atom);
|
ifix = modify->get_fix_by_id(id_fix_prop_atom);
|
||||||
if (ifix < 0) {
|
if (!ifix)
|
||||||
modify->add_fix(fmt::format("{} all property/atom {} {} {} ghost yes",
|
ifix = modify->add_fix(fmt::format("{} all property/atom {} {} {} ghost yes",
|
||||||
id_fix_prop_atom, x_ref_id, y_ref_id, z_ref_id));
|
id_fix_prop_atom, x_ref_id, y_ref_id, z_ref_id));
|
||||||
ifix = modify->find_fix(id_fix_prop_atom);
|
|
||||||
}
|
|
||||||
|
|
||||||
int type_flag;
|
int type_flag;
|
||||||
int col_flag;
|
int col_flag;
|
||||||
@ -240,12 +233,12 @@ void BondBPM::settings(int narg, char **arg)
|
|||||||
index_y_ref = atom->find_custom(y_ref_id, type_flag, col_flag);
|
index_y_ref = atom->find_custom(y_ref_id, type_flag, col_flag);
|
||||||
index_z_ref = atom->find_custom(z_ref_id, type_flag, col_flag);
|
index_z_ref = atom->find_custom(z_ref_id, type_flag, col_flag);
|
||||||
|
|
||||||
delete [] x_ref_id;
|
delete[] x_ref_id;
|
||||||
delete [] y_ref_id;
|
delete[] y_ref_id;
|
||||||
delete [] z_ref_id;
|
delete[] z_ref_id;
|
||||||
|
|
||||||
if (modify->fix[ifix]->restart_reset) {
|
if (ifix->restart_reset) {
|
||||||
modify->fix[ifix]->restart_reset = 0;
|
ifix->restart_reset = 0;
|
||||||
} else {
|
} else {
|
||||||
double *x_ref = atom->dvector[index_x_ref];
|
double *x_ref = atom->dvector[index_x_ref];
|
||||||
double *y_ref = atom->dvector[index_y_ref];
|
double *y_ref = atom->dvector[index_y_ref];
|
||||||
@ -266,7 +259,7 @@ void BondBPM::settings(int narg, char **arg)
|
|||||||
used to check bond communiction cutoff - not perfect, estimates based on local-local only
|
used to check bond communiction cutoff - not perfect, estimates based on local-local only
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
double BondBPM::equilibrium_distance(int i)
|
double BondBPM::equilibrium_distance(int /*i*/)
|
||||||
{
|
{
|
||||||
// Ghost atoms may not yet be communicated, this may only be an estimate
|
// Ghost atoms may not yet be communicated, this may only be an estimate
|
||||||
if (r0_max_estimate == 0) {
|
if (r0_max_estimate == 0) {
|
||||||
@ -363,7 +356,7 @@ void BondBPM::process_broken(int i, int j)
|
|||||||
the atom property is packed into array or vector
|
the atom property is packed into array or vector
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void BondBPM::pack_id1(int n, int i, int j)
|
void BondBPM::pack_id1(int n, int i, int /*j*/)
|
||||||
{
|
{
|
||||||
tagint *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
output_data[n] = tag[i];
|
output_data[n] = tag[i];
|
||||||
@ -371,7 +364,7 @@ void BondBPM::pack_id1(int n, int i, int j)
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void BondBPM::pack_id2(int n, int i, int j)
|
void BondBPM::pack_id2(int n, int /*i*/, int j)
|
||||||
{
|
{
|
||||||
tagint *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
output_data[n] = tag[j];
|
output_data[n] = tag[j];
|
||||||
@ -379,7 +372,7 @@ void BondBPM::pack_id2(int n, int i, int j)
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void BondBPM::pack_time(int n, int i, int j)
|
void BondBPM::pack_time(int n, int /*i*/, int /*j*/)
|
||||||
{
|
{
|
||||||
bigint time = update->ntimestep;
|
bigint time = update->ntimestep;
|
||||||
output_data[n] = time;
|
output_data[n] = time;
|
||||||
|
|||||||
@ -23,10 +23,10 @@ namespace LAMMPS_NS {
|
|||||||
class BondBPM : public Bond {
|
class BondBPM : public Bond {
|
||||||
public:
|
public:
|
||||||
BondBPM(class LAMMPS *);
|
BondBPM(class LAMMPS *);
|
||||||
virtual ~BondBPM() override;
|
~BondBPM() override;
|
||||||
virtual void compute(int, int) override = 0;
|
void compute(int, int) override = 0;
|
||||||
virtual void coeff(int, char **) override = 0;
|
void coeff(int, char **) override = 0;
|
||||||
virtual void init_style() override;
|
void init_style() override;
|
||||||
void settings(int, char **) override;
|
void settings(int, char **) override;
|
||||||
double equilibrium_distance(int) override;
|
double equilibrium_distance(int) override;
|
||||||
void write_restart(FILE *) override {};
|
void write_restart(FILE *) override {};
|
||||||
|
|||||||
@ -89,7 +89,6 @@ double BondBPMRotational::acos_limit(double c)
|
|||||||
|
|
||||||
double BondBPMRotational::store_bond(int n,int i,int j)
|
double BondBPMRotational::store_bond(int n,int i,int j)
|
||||||
{
|
{
|
||||||
int m,k;
|
|
||||||
double delx, dely, delz, r, rinv;
|
double delx, dely, delz, r, rinv;
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
tagint *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
@ -114,7 +113,7 @@ double BondBPMRotational::store_bond(int n,int i,int j)
|
|||||||
bondstore[n][3] = delz*rinv;
|
bondstore[n][3] = delz*rinv;
|
||||||
|
|
||||||
if (i < atom->nlocal) {
|
if (i < atom->nlocal) {
|
||||||
for (m = 0; m < atom->num_bond[i]; m ++) {
|
for (int m = 0; m < atom->num_bond[i]; m ++) {
|
||||||
if (atom->bond_atom[i][m] == tag[j]) {
|
if (atom->bond_atom[i][m] == tag[j]) {
|
||||||
fix_bond_history->update_atom_value(i, m, 0, r);
|
fix_bond_history->update_atom_value(i, m, 0, r);
|
||||||
fix_bond_history->update_atom_value(i, m, 1, delx*rinv);
|
fix_bond_history->update_atom_value(i, m, 1, delx*rinv);
|
||||||
@ -125,7 +124,7 @@ double BondBPMRotational::store_bond(int n,int i,int j)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (j < atom->nlocal) {
|
if (j < atom->nlocal) {
|
||||||
for (m = 0; m < atom->num_bond[j]; m ++) {
|
for (int m = 0; m < atom->num_bond[j]; m ++) {
|
||||||
if (atom->bond_atom[j][m] == tag[i]) {
|
if (atom->bond_atom[j][m] == tag[i]) {
|
||||||
fix_bond_history->update_atom_value(j, m, 0, r);
|
fix_bond_history->update_atom_value(j, m, 0, r);
|
||||||
fix_bond_history->update_atom_value(j, m, 1, delx*rinv);
|
fix_bond_history->update_atom_value(j, m, 1, delx*rinv);
|
||||||
@ -193,11 +192,11 @@ void BondBPMRotational::store_data()
|
|||||||
2) P. Mora & Y. Wang Advances in Geomcomputing 2009
|
2) P. Mora & Y. Wang Advances in Geomcomputing 2009
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
|
|
||||||
double BondBPMRotational::elastic_forces(int i1, int i2, int type, double& Fr,
|
double BondBPMRotational::elastic_forces(int i1, int i2, int type, double &Fr, double r_mag,
|
||||||
double r_mag, double r0_mag, double r_mag_inv, double* rhat, double* r,
|
double r0_mag, double r_mag_inv, double * /*rhat*/,
|
||||||
double* r0, double* force1on2, double* torque1on2, double* torque2on1)
|
double *r, double *r0, double *force1on2,
|
||||||
|
double *torque1on2, double *torque2on1)
|
||||||
{
|
{
|
||||||
int m;
|
|
||||||
double breaking, temp, r0_dot_rb, c, gamma;
|
double breaking, temp, r0_dot_rb, c, gamma;
|
||||||
double psi, theta, cos_phi, sin_phi;
|
double psi, theta, cos_phi, sin_phi;
|
||||||
double mag_in_plane, mag_out_plane;
|
double mag_in_plane, mag_out_plane;
|
||||||
@ -336,7 +335,7 @@ double BondBPMRotational::elastic_forces(int i1, int i2, int type, double& Fr,
|
|||||||
|
|
||||||
MathExtra::quatrotvec(mq, Fsp, Ftmp);
|
MathExtra::quatrotvec(mq, Fsp, Ftmp);
|
||||||
MathExtra::quatrotvec(mq, Tsp, Ttmp);
|
MathExtra::quatrotvec(mq, Tsp, Ttmp);
|
||||||
for (m = 0; m < 3; m++) {
|
for (int m = 0; m < 3; m++) {
|
||||||
Fs[m] += Ftmp[m];
|
Fs[m] += Ftmp[m];
|
||||||
Ts[m] += Ttmp[m];
|
Ts[m] += Ttmp[m];
|
||||||
}
|
}
|
||||||
@ -462,7 +461,7 @@ void BondBPMRotational::compute(int eflag, int vflag)
|
|||||||
|
|
||||||
int i1,i2,itmp,n,type;
|
int i1,i2,itmp,n,type;
|
||||||
double r[3], r0[3], rhat[3];
|
double r[3], r0[3], rhat[3];
|
||||||
double delx, dely, delz, rsq, r0_mag, r_mag, r_mag_inv;
|
double rsq, r0_mag, r_mag, r_mag_inv;
|
||||||
double Fr, breaking, smooth;
|
double Fr, breaking, smooth;
|
||||||
double force1on2[3], torque1on2[3], torque2on1[3];
|
double force1on2[3], torque1on2[3], torque2on1[3];
|
||||||
|
|
||||||
@ -471,7 +470,6 @@ void BondBPMRotational::compute(int eflag, int vflag)
|
|||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double **f = atom->f;
|
double **f = atom->f;
|
||||||
double **torque = atom->torque;
|
double **torque = atom->torque;
|
||||||
double *radius = atom->radius;
|
|
||||||
tagint *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
int **bondlist = neighbor->bondlist;
|
int **bondlist = neighbor->bondlist;
|
||||||
int nbondlist = neighbor->nbondlist;
|
int nbondlist = neighbor->nbondlist;
|
||||||
@ -657,9 +655,9 @@ void BondBPMRotational::init_style()
|
|||||||
|
|
||||||
if (!id_fix_bond_history) {
|
if (!id_fix_bond_history) {
|
||||||
id_fix_bond_history = utils::strdup("HISTORY_BPM_ROTATIONAL");
|
id_fix_bond_history = utils::strdup("HISTORY_BPM_ROTATIONAL");
|
||||||
fix_bond_history = (FixBondHistory *) modify->replace_fix(id_fix_dummy2,
|
fix_bond_history = dynamic_cast<FixBondHistory *>(modify->replace_fix(id_fix_dummy2,
|
||||||
fmt::format("{} all BOND_HISTORY 0 4", id_fix_bond_history),1);
|
fmt::format("{} all BOND_HISTORY 0 4", id_fix_bond_history),1));
|
||||||
delete [] id_fix_dummy2;
|
delete[] id_fix_dummy2;
|
||||||
id_fix_dummy2 = nullptr;
|
id_fix_dummy2 = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -671,7 +669,7 @@ void BondBPMRotational::settings(int narg, char **arg)
|
|||||||
BondBPM::settings(narg, arg);
|
BondBPM::settings(narg, arg);
|
||||||
|
|
||||||
int iarg;
|
int iarg;
|
||||||
for (int i = 0; i < leftover_iarg.size(); i++) {
|
for (std::size_t i = 0; i < leftover_iarg.size(); i++) {
|
||||||
iarg = leftover_iarg[i];
|
iarg = leftover_iarg[i];
|
||||||
if (strcmp(arg[iarg], "smooth") == 0) {
|
if (strcmp(arg[iarg], "smooth") == 0) {
|
||||||
if (iarg+1 > narg) error->all(FLERR,"Illegal bond bpm command");
|
if (iarg+1 > narg) error->all(FLERR,"Illegal bond bpm command");
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifdef BOND_CLASS
|
#ifdef BOND_CLASS
|
||||||
// clang-format off
|
// clang-format off
|
||||||
BondStyle(bpm/rotational,BondBPMRotational)
|
BondStyle(bpm/rotational,BondBPMRotational);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -27,8 +27,8 @@ namespace LAMMPS_NS {
|
|||||||
class BondBPMRotational : public BondBPM {
|
class BondBPMRotational : public BondBPM {
|
||||||
public:
|
public:
|
||||||
BondBPMRotational(class LAMMPS *);
|
BondBPMRotational(class LAMMPS *);
|
||||||
virtual ~BondBPMRotational() override;
|
~BondBPMRotational() override;
|
||||||
virtual void compute(int, int) override;
|
void compute(int, int) override;
|
||||||
void coeff(int, char **) override;
|
void coeff(int, char **) override;
|
||||||
void init_style() override;
|
void init_style() override;
|
||||||
void settings(int, char **) override;
|
void settings(int, char **) override;
|
||||||
@ -44,10 +44,9 @@ class BondBPMRotational : public BondBPM {
|
|||||||
|
|
||||||
double acos_limit(double);
|
double acos_limit(double);
|
||||||
|
|
||||||
double elastic_forces(int, int, int, double &, double, double, double,
|
double elastic_forces(int, int, int, double &, double, double, double, double *, double *,
|
||||||
double*, double*, double*, double*, double*, double*);
|
double *, double *, double *, double *);
|
||||||
void damping_forces(int, int, int, double &, double*, double*, double*,
|
void damping_forces(int, int, int, double &, double *, double *, double *, double *, double *);
|
||||||
double*, double*);
|
|
||||||
|
|
||||||
void allocate();
|
void allocate();
|
||||||
void store_data();
|
void store_data();
|
||||||
|
|||||||
@ -57,7 +57,6 @@ BondBPMSpring::~BondBPMSpring()
|
|||||||
|
|
||||||
double BondBPMSpring::store_bond(int n,int i,int j)
|
double BondBPMSpring::store_bond(int n,int i,int j)
|
||||||
{
|
{
|
||||||
int m,k;
|
|
||||||
double delx, dely, delz, r;
|
double delx, dely, delz, r;
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double **bondstore = fix_bond_history->bondstore;
|
double **bondstore = fix_bond_history->bondstore;
|
||||||
@ -71,7 +70,7 @@ double BondBPMSpring::store_bond(int n,int i,int j)
|
|||||||
bondstore[n][0] = r;
|
bondstore[n][0] = r;
|
||||||
|
|
||||||
if (i < atom->nlocal) {
|
if (i < atom->nlocal) {
|
||||||
for (m = 0; m < atom->num_bond[i]; m ++) {
|
for (int m = 0; m < atom->num_bond[i]; m ++) {
|
||||||
if (atom->bond_atom[i][m] == tag[j]) {
|
if (atom->bond_atom[i][m] == tag[j]) {
|
||||||
fix_bond_history->update_atom_value(i, m, 0, r);
|
fix_bond_history->update_atom_value(i, m, 0, r);
|
||||||
}
|
}
|
||||||
@ -79,7 +78,7 @@ double BondBPMSpring::store_bond(int n,int i,int j)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (j < atom->nlocal) {
|
if (j < atom->nlocal) {
|
||||||
for (m = 0; m < atom->num_bond[j]; m ++) {
|
for (int m = 0; m < atom->num_bond[j]; m ++) {
|
||||||
if (atom->bond_atom[j][m] == tag[i]) {
|
if (atom->bond_atom[j][m] == tag[i]) {
|
||||||
fix_bond_history->update_atom_value(j, m, 0, r);
|
fix_bond_history->update_atom_value(j, m, 0, r);
|
||||||
}
|
}
|
||||||
@ -136,7 +135,7 @@ void BondBPMSpring::compute(int eflag, int vflag)
|
|||||||
store_data();
|
store_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
int i1,i2,itmp,m,n,type,itype,jtype;
|
int i1,i2,itmp,n,type;
|
||||||
double delx, dely, delz, delvx, delvy, delvz;
|
double delx, dely, delz, delvx, delvy, delvz;
|
||||||
double e, rsq, r, r0, rinv, smooth, fbond, dot;
|
double e, rsq, r, r0, rinv, smooth, fbond, dot;
|
||||||
|
|
||||||
@ -283,9 +282,9 @@ void BondBPMSpring::init_style()
|
|||||||
|
|
||||||
if (!id_fix_bond_history) {
|
if (!id_fix_bond_history) {
|
||||||
id_fix_bond_history = utils::strdup("HISTORY_BPM_SPRING");
|
id_fix_bond_history = utils::strdup("HISTORY_BPM_SPRING");
|
||||||
fix_bond_history = (FixBondHistory *) modify->replace_fix(id_fix_dummy2,
|
fix_bond_history = dynamic_cast<FixBondHistory *>(modify->replace_fix(id_fix_dummy2,
|
||||||
fmt::format("{} all BOND_HISTORY 0 1", id_fix_bond_history),1);
|
fmt::format("{} all BOND_HISTORY 0 1", id_fix_bond_history),1));
|
||||||
delete [] id_fix_dummy2;
|
delete[] id_fix_dummy2;
|
||||||
id_fix_dummy2 = nullptr;
|
id_fix_dummy2 = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,7 +296,7 @@ void BondBPMSpring::settings(int narg, char **arg)
|
|||||||
BondBPM::settings(narg, arg);
|
BondBPM::settings(narg, arg);
|
||||||
|
|
||||||
int iarg;
|
int iarg;
|
||||||
for (int i = 0; i < leftover_iarg.size(); i++) {
|
for (std::size_t i = 0; i < leftover_iarg.size(); i++) {
|
||||||
iarg = leftover_iarg[i];
|
iarg = leftover_iarg[i];
|
||||||
if (strcmp(arg[iarg], "smooth") == 0) {
|
if (strcmp(arg[iarg], "smooth") == 0) {
|
||||||
if (iarg+1 > narg) error->all(FLERR,"Illegal bond bpm command");
|
if (iarg+1 > narg) error->all(FLERR,"Illegal bond bpm command");
|
||||||
@ -366,7 +365,6 @@ double BondBPMSpring::single(int type, double rsq, int i, int j,
|
|||||||
|
|
||||||
double r = sqrt(rsq);
|
double r = sqrt(rsq);
|
||||||
double rinv = 1.0/r;
|
double rinv = 1.0/r;
|
||||||
double e = (r - r0)/r0;
|
|
||||||
fforce = k[type]*(r0-r);
|
fforce = k[type]*(r0-r);
|
||||||
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifdef BOND_CLASS
|
#ifdef BOND_CLASS
|
||||||
// clang-format off
|
// clang-format off
|
||||||
BondStyle(bpm/spring,BondBPMSpring)
|
BondStyle(bpm/spring,BondBPMSpring);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -27,8 +27,8 @@ namespace LAMMPS_NS {
|
|||||||
class BondBPMSpring : public BondBPM {
|
class BondBPMSpring : public BondBPM {
|
||||||
public:
|
public:
|
||||||
BondBPMSpring(class LAMMPS *);
|
BondBPMSpring(class LAMMPS *);
|
||||||
virtual ~BondBPMSpring() override;
|
~BondBPMSpring() override;
|
||||||
virtual void compute(int, int) override;
|
void compute(int, int) override;
|
||||||
void coeff(int, char **) override;
|
void coeff(int, char **) override;
|
||||||
void init_style() override;
|
void init_style() override;
|
||||||
void settings(int, char **) override;
|
void settings(int, char **) override;
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifdef COMPUTE_CLASS
|
#ifdef COMPUTE_CLASS
|
||||||
// clang-format off
|
// clang-format off
|
||||||
ComputeStyle(nbond/atom,ComputeNBondAtom)
|
ComputeStyle(nbond/atom,ComputeNBondAtom);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifdef FIX_CLASS
|
#ifdef FIX_CLASS
|
||||||
// clang-format off
|
// clang-format off
|
||||||
FixStyle(nve/bpm/sphere,FixNVEBPMSphere)
|
FixStyle(nve/bpm/sphere,FixNVEBPMSphere);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -19,8 +18,8 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "neighbor.h"
|
|
||||||
#include "neigh_list.h"
|
#include "neigh_list.h"
|
||||||
|
#include "neighbor.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -49,26 +48,22 @@ PairBPMSpring::~PairBPMSpring()
|
|||||||
|
|
||||||
void PairBPMSpring::compute(int eflag, int vflag)
|
void PairBPMSpring::compute(int eflag, int vflag)
|
||||||
{
|
{
|
||||||
int i,j,m,ii,jj,inum,jnum,itype,jtype;
|
int i, j, ii, jj, inum, jnum, itype, jtype;
|
||||||
tagint tagi, tagj;
|
double xtmp, ytmp, ztmp, delx, dely, delz, evdwl, fpair;
|
||||||
int bond_flag;
|
double r, rsq, rinv, factor_lj;
|
||||||
double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair;
|
int *ilist, *jlist, *numneigh, **firstneigh;
|
||||||
double r,rsq,rinv,r2inv,factor_lj;
|
double vxtmp, vytmp, vztmp, delvx, delvy, delvz, dot, smooth;
|
||||||
int *ilist,*jlist,*numneigh,**firstneigh;
|
|
||||||
double vxtmp,vytmp,vztmp,delvx,delvy,delvz,dot,smooth;
|
|
||||||
|
|
||||||
evdwl = 0.0;
|
evdwl = 0.0;
|
||||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
if (eflag || vflag)
|
||||||
else evflag = vflag_fdotr = 0;
|
ev_setup(eflag, vflag);
|
||||||
|
else
|
||||||
|
evflag = vflag_fdotr = 0;
|
||||||
|
|
||||||
tagint *tag = atom->tag;
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double **v = atom->v;
|
double **v = atom->v;
|
||||||
double **f = atom->f;
|
double **f = atom->f;
|
||||||
int *type = atom->type;
|
int *type = atom->type;
|
||||||
int **bond_type = atom->bond_type;
|
|
||||||
int *num_bond = atom->num_bond;
|
|
||||||
tagint **bond_atom = atom->bond_atom;
|
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
int newton_pair = force->newton_pair;
|
int newton_pair = force->newton_pair;
|
||||||
double *special_lj = force->special_lj;
|
double *special_lj = force->special_lj;
|
||||||
@ -82,7 +77,6 @@ void PairBPMSpring::compute(int eflag, int vflag)
|
|||||||
|
|
||||||
for (ii = 0; ii < inum; ii++) {
|
for (ii = 0; ii < inum; ii++) {
|
||||||
i = ilist[ii];
|
i = ilist[ii];
|
||||||
tagi = tag[i];
|
|
||||||
xtmp = x[i][0];
|
xtmp = x[i][0];
|
||||||
ytmp = x[i][1];
|
ytmp = x[i][1];
|
||||||
ztmp = x[i][2];
|
ztmp = x[i][2];
|
||||||
@ -104,40 +98,39 @@ void PairBPMSpring::compute(int eflag, int vflag)
|
|||||||
delx = xtmp - x[j][0];
|
delx = xtmp - x[j][0];
|
||||||
dely = ytmp - x[j][1];
|
dely = ytmp - x[j][1];
|
||||||
delz = ztmp - x[j][2];
|
delz = ztmp - x[j][2];
|
||||||
rsq = delx*delx + dely*dely + delz*delz;
|
rsq = delx * delx + dely * dely + delz * delz;
|
||||||
jtype = type[j];
|
jtype = type[j];
|
||||||
|
|
||||||
if (rsq < cutsq[itype][jtype]) {
|
if (rsq < cutsq[itype][jtype]) {
|
||||||
r = sqrt(rsq);
|
r = sqrt(rsq);
|
||||||
|
|
||||||
rinv = 1.0/r;
|
rinv = 1.0 / r;
|
||||||
fpair = k[itype][jtype]*(cut[itype][jtype]-r);
|
fpair = k[itype][jtype] * (cut[itype][jtype] - r);
|
||||||
|
|
||||||
smooth = rsq/cutsq[itype][jtype];
|
smooth = rsq / cutsq[itype][jtype];
|
||||||
smooth *= smooth;
|
smooth *= smooth;
|
||||||
smooth *= smooth;
|
smooth *= smooth;
|
||||||
smooth = 1.0 - smooth;
|
smooth = 1.0 - smooth;
|
||||||
delvx = vxtmp - v[j][0];
|
delvx = vxtmp - v[j][0];
|
||||||
delvy = vytmp - v[j][1];
|
delvy = vytmp - v[j][1];
|
||||||
delvz = vztmp - v[j][2];
|
delvz = vztmp - v[j][2];
|
||||||
dot = delx*delvx + dely*delvy + delz*delvz;
|
dot = delx * delvx + dely * delvy + delz * delvz;
|
||||||
fpair -= gamma[itype][jtype]*dot*smooth*rinv;
|
fpair -= gamma[itype][jtype] * dot * smooth * rinv;
|
||||||
|
|
||||||
fpair *= factor_lj*rinv;
|
fpair *= factor_lj * rinv;
|
||||||
if (eflag) evdwl = 0.0;
|
if (eflag) evdwl = 0.0;
|
||||||
|
|
||||||
f[i][0] += delx*fpair;
|
f[i][0] += delx * fpair;
|
||||||
f[i][1] += dely*fpair;
|
f[i][1] += dely * fpair;
|
||||||
f[i][2] += delz*fpair;
|
f[i][2] += delz * fpair;
|
||||||
|
|
||||||
if (newton_pair || j < nlocal) {
|
if (newton_pair || j < nlocal) {
|
||||||
f[j][0] -= delx*fpair;
|
f[j][0] -= delx * fpair;
|
||||||
f[j][1] -= dely*fpair;
|
f[j][1] -= dely * fpair;
|
||||||
f[j][2] -= delz*fpair;
|
f[j][2] -= delz * fpair;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evflag) ev_tally(i,j,nlocal,newton_pair,
|
if (evflag) ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, delx, dely, delz);
|
||||||
evdwl,0.0,fpair,delx,dely,delz);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,27 +145,26 @@ void PairBPMSpring::compute(int eflag, int vflag)
|
|||||||
void PairBPMSpring::allocate()
|
void PairBPMSpring::allocate()
|
||||||
{
|
{
|
||||||
allocated = 1;
|
allocated = 1;
|
||||||
int n = atom->ntypes;
|
const int np1 = atom->ntypes;
|
||||||
|
|
||||||
memory->create(setflag,n+1,n+1,"pair:setflag");
|
memory->create(setflag, np1, np1, "pair:setflag");
|
||||||
for (int i = 1; i <= n; i++)
|
for (int i = 1; i < np1; i++)
|
||||||
for (int j = i; j <= n; j++)
|
for (int j = i; j < np1; j++) setflag[i][j] = 0;
|
||||||
setflag[i][j] = 0;
|
|
||||||
|
|
||||||
memory->create(cutsq,n+1,n+1,"pair:cutsq");
|
memory->create(cutsq, np1, np1, "pair:cutsq");
|
||||||
|
|
||||||
memory->create(k,n+1,n+1,"pair:k");
|
memory->create(k, np1, np1, "pair:k");
|
||||||
memory->create(cut,n+1,n+1,"pair:cut");
|
memory->create(cut, np1, np1, "pair:cut");
|
||||||
memory->create(gamma,n+1,n+1,"pair:gamma");
|
memory->create(gamma, np1, np1, "pair:gamma");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
global settings
|
global settings
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void PairBPMSpring::settings(int narg, char **arg)
|
void PairBPMSpring::settings(int narg, char ** /*arg*/)
|
||||||
{
|
{
|
||||||
if (narg != 0) error->all(FLERR,"Illegal pair_style command");
|
if (narg != 0) error->all(FLERR, "Illegal pair_style command");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -181,23 +173,22 @@ void PairBPMSpring::settings(int narg, char **arg)
|
|||||||
|
|
||||||
void PairBPMSpring::coeff(int narg, char **arg)
|
void PairBPMSpring::coeff(int narg, char **arg)
|
||||||
{
|
{
|
||||||
if (narg != 5)
|
if (narg != 5) error->all(FLERR, "Incorrect args for pair coefficients");
|
||||||
error->all(FLERR,"Incorrect args for pair coefficients");
|
|
||||||
if (!allocated) allocate();
|
if (!allocated) allocate();
|
||||||
|
|
||||||
int ilo,ihi,jlo,jhi;
|
int ilo, ihi, jlo, jhi;
|
||||||
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
|
utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error);
|
||||||
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
|
utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error);
|
||||||
|
|
||||||
double k_one = utils::numeric(FLERR,arg[2],false,lmp);
|
double k_one = utils::numeric(FLERR, arg[2], false, lmp);
|
||||||
double cut_one = utils::numeric(FLERR,arg[3],false,lmp);
|
double cut_one = utils::numeric(FLERR, arg[3], false, lmp);
|
||||||
double gamma_one = utils::numeric(FLERR,arg[4],false,lmp);
|
double gamma_one = utils::numeric(FLERR, arg[4], false, lmp);
|
||||||
|
|
||||||
if (cut_one <= 0.0) error->all(FLERR,"Incorrect args for pair coefficients");
|
if (cut_one <= 0.0) error->all(FLERR, "Incorrect args for pair coefficients");
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = ilo; i <= ihi; i++) {
|
for (int i = ilo; i <= ihi; i++) {
|
||||||
for (int j = MAX(jlo,i); j <= jhi; j++) {
|
for (int j = MAX(jlo, i); j <= jhi; j++) {
|
||||||
k[i][j] = k_one;
|
k[i][j] = k_one;
|
||||||
cut[i][j] = cut_one;
|
cut[i][j] = cut_one;
|
||||||
gamma[i][j] = gamma_one;
|
gamma[i][j] = gamma_one;
|
||||||
@ -207,7 +198,7 @@ void PairBPMSpring::coeff(int narg, char **arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
|
if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -217,11 +208,9 @@ void PairBPMSpring::coeff(int narg, char **arg)
|
|||||||
double PairBPMSpring::init_one(int i, int j)
|
double PairBPMSpring::init_one(int i, int j)
|
||||||
{
|
{
|
||||||
if (setflag[i][j] == 0) {
|
if (setflag[i][j] == 0) {
|
||||||
cut[i][j] = mix_distance(cut[i][i],cut[j][j]);
|
cut[i][j] = mix_distance(cut[i][i], cut[j][j]);
|
||||||
k[i][j] = mix_energy(k[i][i],k[j][j],
|
k[i][j] = mix_energy(k[i][i], k[j][j], cut[i][i], cut[j][j]);
|
||||||
cut[i][i],cut[j][j]);
|
gamma[i][j] = mix_energy(gamma[i][i], gamma[j][j], cut[i][i], cut[j][j]);
|
||||||
gamma[i][j] = mix_energy(gamma[i][i],gamma[j][j],
|
|
||||||
cut[i][i],cut[j][j]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cut[j][i] = cut[i][j];
|
cut[j][i] = cut[i][j];
|
||||||
@ -239,14 +228,14 @@ void PairBPMSpring::write_restart(FILE *fp)
|
|||||||
{
|
{
|
||||||
write_restart_settings(fp);
|
write_restart_settings(fp);
|
||||||
|
|
||||||
int i,j;
|
int i, j;
|
||||||
for (i = 1; i <= atom->ntypes; i++)
|
for (i = 1; i <= atom->ntypes; i++)
|
||||||
for (j = i; j <= atom->ntypes; j++) {
|
for (j = i; j <= atom->ntypes; j++) {
|
||||||
fwrite(&setflag[i][j],sizeof(int),1,fp);
|
fwrite(&setflag[i][j], sizeof(int), 1, fp);
|
||||||
if (setflag[i][j]) {
|
if (setflag[i][j]) {
|
||||||
fwrite(&k[i][j],sizeof(double),1,fp);
|
fwrite(&k[i][j], sizeof(double), 1, fp);
|
||||||
fwrite(&cut[i][j],sizeof(double),1,fp);
|
fwrite(&cut[i][j], sizeof(double), 1, fp);
|
||||||
fwrite(&gamma[i][j],sizeof(double),1,fp);
|
fwrite(&gamma[i][j], sizeof(double), 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,21 +249,21 @@ void PairBPMSpring::read_restart(FILE *fp)
|
|||||||
read_restart_settings(fp);
|
read_restart_settings(fp);
|
||||||
allocate();
|
allocate();
|
||||||
|
|
||||||
int i,j;
|
int i, j;
|
||||||
int me = comm->me;
|
int me = comm->me;
|
||||||
for (i = 1; i <= atom->ntypes; i++)
|
for (i = 1; i <= atom->ntypes; i++)
|
||||||
for (j = i; j <= atom->ntypes; j++) {
|
for (j = i; j <= atom->ntypes; j++) {
|
||||||
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp);
|
if (me == 0) fread(&setflag[i][j], sizeof(int), 1, fp);
|
||||||
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
|
MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world);
|
||||||
if (setflag[i][j]) {
|
if (setflag[i][j]) {
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fread(&k[i][j],sizeof(double),1,fp);
|
fread(&k[i][j], sizeof(double), 1, fp);
|
||||||
fread(&cut[i][j],sizeof(double),1,fp);
|
fread(&cut[i][j], sizeof(double), 1, fp);
|
||||||
fread(&gamma[i][j],sizeof(double),1,fp);
|
fread(&gamma[i][j], sizeof(double), 1, fp);
|
||||||
}
|
}
|
||||||
MPI_Bcast(&k[i][j],1,MPI_DOUBLE,0,world);
|
MPI_Bcast(&k[i][j], 1, MPI_DOUBLE, 0, world);
|
||||||
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
|
MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world);
|
||||||
MPI_Bcast(&gamma[i][j],1,MPI_DOUBLE,0,world);
|
MPI_Bcast(&gamma[i][j], 1, MPI_DOUBLE, 0, world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,7 +275,7 @@ void PairBPMSpring::read_restart(FILE *fp)
|
|||||||
void PairBPMSpring::write_data(FILE *fp)
|
void PairBPMSpring::write_data(FILE *fp)
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= atom->ntypes; i++)
|
for (int i = 1; i <= atom->ntypes; i++)
|
||||||
fprintf(fp,"%d %g %g %g\n",i,k[i][i],cut[i][i],gamma[i][i]);
|
fprintf(fp, "%d %g %g %g\n", i, k[i][i], cut[i][i], gamma[i][i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -297,30 +286,28 @@ void PairBPMSpring::write_data_all(FILE *fp)
|
|||||||
{
|
{
|
||||||
for (int i = 1; i <= atom->ntypes; i++)
|
for (int i = 1; i <= atom->ntypes; i++)
|
||||||
for (int j = i; j <= atom->ntypes; j++)
|
for (int j = i; j <= atom->ntypes; j++)
|
||||||
fprintf(fp,"%d %d %g %g %g\n",i,j,
|
fprintf(fp, "%d %d %g %g %g\n", i, j, k[i][j], cut[i][j], gamma[i][j]);
|
||||||
k[i][j],cut[i][j],gamma[i][j]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
double PairBPMSpring::single(int i, int j, int itype, int jtype, double rsq,
|
double PairBPMSpring::single(int i, int j, int itype, int jtype, double rsq, double /*factor_coul*/,
|
||||||
double factor_coul, double factor_lj,
|
double factor_lj, double &fforce)
|
||||||
double &fforce)
|
|
||||||
{
|
{
|
||||||
double fpair,r,rinv;
|
double fpair, r, rinv;
|
||||||
double delx, dely, delz, delvx, delvy, delvz, dot, smooth;
|
double delx, dely, delz, delvx, delvy, delvz, dot, smooth;
|
||||||
|
|
||||||
if(rsq > cutsq[itype][jtype]) return 0.0;
|
if (rsq > cutsq[itype][jtype]) return 0.0;
|
||||||
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double **v = atom->v;
|
double **v = atom->v;
|
||||||
|
|
||||||
r = sqrt(rsq);
|
r = sqrt(rsq);
|
||||||
rinv = 1.0/r;
|
rinv = 1.0 / r;
|
||||||
|
|
||||||
fpair = k[itype][jtype]*(cut[itype][jtype]-r);
|
fpair = k[itype][jtype] * (cut[itype][jtype] - r);
|
||||||
|
|
||||||
smooth = rsq/cutsq[itype][jtype];
|
smooth = rsq / cutsq[itype][jtype];
|
||||||
smooth *= smooth;
|
smooth *= smooth;
|
||||||
smooth = 1.0 - smooth;
|
smooth = 1.0 - smooth;
|
||||||
delx = x[i][0] - x[j][0];
|
delx = x[i][0] - x[j][0];
|
||||||
@ -329,8 +316,8 @@ double PairBPMSpring::single(int i, int j, int itype, int jtype, double rsq,
|
|||||||
delvx = v[i][0] - v[j][0];
|
delvx = v[i][0] - v[j][0];
|
||||||
delvy = v[i][1] - v[j][1];
|
delvy = v[i][1] - v[j][1];
|
||||||
delvz = v[i][2] - v[j][2];
|
delvz = v[i][2] - v[j][2];
|
||||||
dot = delx*delvx + dely*delvy + delz*delvz;
|
dot = delx * delvx + dely * delvy + delz * delvz;
|
||||||
fpair -= gamma[itype][jtype]*dot*rinv*smooth;
|
fpair -= gamma[itype][jtype] * dot * rinv * smooth;
|
||||||
|
|
||||||
fpair *= factor_lj;
|
fpair *= factor_lj;
|
||||||
fforce = fpair;
|
fforce = fpair;
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifdef PAIR_CLASS
|
#ifdef PAIR_CLASS
|
||||||
// clang-format off
|
// clang-format off
|
||||||
PairStyle(bpm/spring,PairBPMSpring)
|
PairStyle(bpm/spring,PairBPMSpring);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -27,8 +27,8 @@ namespace LAMMPS_NS {
|
|||||||
class PairBPMSpring : public Pair {
|
class PairBPMSpring : public Pair {
|
||||||
public:
|
public:
|
||||||
PairBPMSpring(class LAMMPS *);
|
PairBPMSpring(class LAMMPS *);
|
||||||
virtual ~PairBPMSpring() override;
|
~PairBPMSpring() override;
|
||||||
virtual void compute(int, int) override;
|
void compute(int, int) override;
|
||||||
void settings(int, char **) override;
|
void settings(int, char **) override;
|
||||||
void coeff(int, char **) override;
|
void coeff(int, char **) override;
|
||||||
double init_one(int, int) override;
|
double init_one(int, int) override;
|
||||||
@ -39,12 +39,12 @@ class PairBPMSpring : public Pair {
|
|||||||
double single(int, int, int, int, double, double, double, double &) override;
|
double single(int, int, int, int, double, double, double, double &) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double **k,**cut,**gamma;
|
double **k, **cut, **gamma;
|
||||||
|
|
||||||
void allocate();
|
void allocate();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LAMMPS_NS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -301,11 +301,11 @@ void FixBondBreak::post_integrate()
|
|||||||
bond_type[i][k] = bond_type[i][k+1];
|
bond_type[i][k] = bond_type[i][k+1];
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->shift_history(i,k,k+1);
|
dynamic_cast<FixBondHistory *>(ihistory)->shift_history(i,k,k+1);
|
||||||
}
|
}
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->delete_history(i,num_bond[i]-1);
|
dynamic_cast<FixBondHistory *>(ihistory)->delete_history(i,num_bond[i]-1);
|
||||||
num_bond[i]--;
|
num_bond[i]--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,21 +17,15 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "fix_bond_create_angle.h"
|
#include "fix_bond_create_angle.h"
|
||||||
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixBondCreateAngle::FixBondCreateAngle(LAMMPS *lmp, int narg, char **arg) :
|
|
||||||
FixBondCreate(lmp, narg, arg)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int FixBondCreateAngle::constrain(int i, int j, double amin, double amax)
|
int FixBondCreateAngle::constrain(int i, int j, double amin, double amax)
|
||||||
{
|
{
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace LAMMPS_NS {
|
|||||||
|
|
||||||
class FixBondCreateAngle : public FixBondCreate {
|
class FixBondCreateAngle : public FixBondCreate {
|
||||||
public:
|
public:
|
||||||
FixBondCreateAngle(class LAMMPS *, int, char **);
|
FixBondCreateAngle(LAMMPS *_lmp, int narg, char **arg) : FixBondCreate(_lmp, narg, arg) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int constrain(int, int, double, double) override;
|
int constrain(int, int, double, double) override;
|
||||||
|
|||||||
@ -461,28 +461,28 @@ void FixBondSwap::post_integrate()
|
|||||||
if (bond_atom[i][ibond] == tag[inext]) {
|
if (bond_atom[i][ibond] == tag[inext]) {
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->delete_history(i,ibond);
|
dynamic_cast<FixBondHistory *>(ihistory)->delete_history(i,ibond);
|
||||||
bond_atom[i][ibond] = tag[jnext];
|
bond_atom[i][ibond] = tag[jnext];
|
||||||
}
|
}
|
||||||
for (jbond = 0; jbond < num_bond[j]; jbond++)
|
for (jbond = 0; jbond < num_bond[j]; jbond++)
|
||||||
if (bond_atom[j][jbond] == tag[jnext]) {
|
if (bond_atom[j][jbond] == tag[jnext]) {
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->delete_history(j,jbond);
|
dynamic_cast<FixBondHistory *>(ihistory)->delete_history(j,jbond);
|
||||||
bond_atom[j][jbond] = tag[inext];
|
bond_atom[j][jbond] = tag[inext];
|
||||||
}
|
}
|
||||||
for (ibond = 0; ibond < num_bond[inext]; ibond++)
|
for (ibond = 0; ibond < num_bond[inext]; ibond++)
|
||||||
if (bond_atom[inext][ibond] == tag[i]) {
|
if (bond_atom[inext][ibond] == tag[i]) {
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->delete_history(inext,ibond);
|
dynamic_cast<FixBondHistory *>(ihistory)->delete_history(inext,ibond);
|
||||||
bond_atom[inext][ibond] = tag[j];
|
bond_atom[inext][ibond] = tag[j];
|
||||||
}
|
}
|
||||||
for (jbond = 0; jbond < num_bond[jnext]; jbond++)
|
for (jbond = 0; jbond < num_bond[jnext]; jbond++)
|
||||||
if (bond_atom[jnext][jbond] == tag[j]) {
|
if (bond_atom[jnext][jbond] == tag[j]) {
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->delete_history(jnext,jbond);
|
dynamic_cast<FixBondHistory *>(ihistory)->delete_history(jnext,jbond);
|
||||||
bond_atom[jnext][jbond] = tag[i];
|
bond_atom[jnext][jbond] = tag[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3111,9 +3111,9 @@ void FixBondReact::update_everything()
|
|||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories) {
|
for (auto &ihistory: histories) {
|
||||||
for (int n = 0; n < num_bond[atom->map(update_mega_glove[jj+1][i])]; n++)
|
for (int n = 0; n < num_bond[atom->map(update_mega_glove[jj+1][i])]; n++)
|
||||||
((FixBondHistory *) ihistory)->cache_history(atom->map(update_mega_glove[jj+1][i]), n);
|
dynamic_cast<FixBondHistory *>(ihistory)->cache_history(atom->map(update_mega_glove[jj+1][i]), n);
|
||||||
for (int n = 0; n < num_bond[atom->map(update_mega_glove[jj+1][i])]; n++)
|
for (int n = 0; n < num_bond[atom->map(update_mega_glove[jj+1][i])]; n++)
|
||||||
((FixBondHistory *) ihistory)->delete_history(atom->map(update_mega_glove[jj+1][i]), 0);
|
dynamic_cast<FixBondHistory *>(ihistory)->delete_history(atom->map(update_mega_glove[jj+1][i]), 0);
|
||||||
}
|
}
|
||||||
num_bond[atom->map(update_mega_glove[jj+1][i])] = 0;
|
num_bond[atom->map(update_mega_glove[jj+1][i])] = 0;
|
||||||
}
|
}
|
||||||
@ -3125,17 +3125,17 @@ void FixBondReact::update_everything()
|
|||||||
// Cache history information, shift history, then delete final element
|
// Cache history information, shift history, then delete final element
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->cache_history(atom->map(update_mega_glove[jj+1][i]), p);
|
dynamic_cast<FixBondHistory *>(ihistory)->cache_history(atom->map(update_mega_glove[jj+1][i]), p);
|
||||||
for (int m = p; m < num_bond[atom->map(update_mega_glove[jj+1][i])]-1; m++) {
|
for (int m = p; m < num_bond[atom->map(update_mega_glove[jj+1][i])]-1; m++) {
|
||||||
bond_type[atom->map(update_mega_glove[jj+1][i])][m] = bond_type[atom->map(update_mega_glove[jj+1][i])][m+1];
|
bond_type[atom->map(update_mega_glove[jj+1][i])][m] = bond_type[atom->map(update_mega_glove[jj+1][i])][m+1];
|
||||||
bond_atom[atom->map(update_mega_glove[jj+1][i])][m] = bond_atom[atom->map(update_mega_glove[jj+1][i])][m+1];
|
bond_atom[atom->map(update_mega_glove[jj+1][i])][m] = bond_atom[atom->map(update_mega_glove[jj+1][i])][m+1];
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->shift_history(atom->map(update_mega_glove[jj+1][i]),m,m+1);
|
dynamic_cast<FixBondHistory *>(ihistory)->shift_history(atom->map(update_mega_glove[jj+1][i]),m,m+1);
|
||||||
}
|
}
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->delete_history(atom->map(update_mega_glove[jj+1][i]),
|
dynamic_cast<FixBondHistory *>(ihistory)->delete_history(atom->map(update_mega_glove[jj+1][i]),
|
||||||
num_bond[atom->map(update_mega_glove[jj+1][i])]-1);
|
num_bond[atom->map(update_mega_glove[jj+1][i])]-1);
|
||||||
num_bond[atom->map(update_mega_glove[jj+1][i])]--;
|
num_bond[atom->map(update_mega_glove[jj+1][i])]--;
|
||||||
delta_bonds--;
|
delta_bonds--;
|
||||||
@ -3158,7 +3158,7 @@ void FixBondReact::update_everything()
|
|||||||
// Check cached history data to see if bond regenerated
|
// Check cached history data to see if bond regenerated
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->check_cache(atom->map(update_mega_glove[jj+1][i]), p);
|
dynamic_cast<FixBondHistory *>(ihistory)->check_cache(atom->map(update_mega_glove[jj+1][i]), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (landlocked_atoms[j][rxnID] == 0) {
|
if (landlocked_atoms[j][rxnID] == 0) {
|
||||||
@ -3170,7 +3170,7 @@ void FixBondReact::update_everything()
|
|||||||
// Check cached history data to see if bond regenerated
|
// Check cached history data to see if bond regenerated
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->check_cache(atom->map(update_mega_glove[jj+1][i]), insert_num);
|
dynamic_cast<FixBondHistory *>(ihistory)->check_cache(atom->map(update_mega_glove[jj+1][i]), insert_num);
|
||||||
num_bond[atom->map(update_mega_glove[jj+1][i])]++;
|
num_bond[atom->map(update_mega_glove[jj+1][i])]++;
|
||||||
if (num_bond[atom->map(update_mega_glove[jj+1][i])] > atom->bond_per_atom)
|
if (num_bond[atom->map(update_mega_glove[jj+1][i])] > atom->bond_per_atom)
|
||||||
error->one(FLERR,"Bond/react topology/atom exceed system topology/atom");
|
error->one(FLERR,"Bond/react topology/atom exceed system topology/atom");
|
||||||
@ -3184,7 +3184,7 @@ void FixBondReact::update_everything()
|
|||||||
|
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories)
|
for (auto &ihistory: histories)
|
||||||
((FixBondHistory *) ihistory)->clear_cache();
|
dynamic_cast<FixBondHistory *>(ihistory)->clear_cache();
|
||||||
|
|
||||||
// Angles! First let's delete all angle info:
|
// Angles! First let's delete all angle info:
|
||||||
if (force->angle && twomol->angleflag) {
|
if (force->angle && twomol->angleflag) {
|
||||||
|
|||||||
@ -427,6 +427,8 @@ void Atom::peratom_create()
|
|||||||
add_peratom("tri",&tri,INT,0);
|
add_peratom("tri",&tri,INT,0);
|
||||||
add_peratom("body",&body,INT,0);
|
add_peratom("body",&body,INT,0);
|
||||||
|
|
||||||
|
// BPM package
|
||||||
|
|
||||||
add_peratom("quat",&quat,DOUBLE,4);
|
add_peratom("quat",&quat,DOUBLE,4);
|
||||||
|
|
||||||
// MOLECULE package
|
// MOLECULE package
|
||||||
|
|||||||
@ -491,8 +491,7 @@ void CommBrick::setup()
|
|||||||
return how many procs away are needed to encompass cutghost away from loc
|
return how many procs away are needed to encompass cutghost away from loc
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int CommBrick::updown(int dim, int dir, int loc,
|
int CommBrick::updown(int dim, int dir, int loc, double prd, int periodicity, double *split)
|
||||||
double prd, int periodicity, double *split)
|
|
||||||
{
|
{
|
||||||
int index,count;
|
int index,count;
|
||||||
double frac,delta;
|
double frac,delta;
|
||||||
@ -553,19 +552,15 @@ void CommBrick::forward_comm(int /*dummy*/)
|
|||||||
if (comm_x_only) {
|
if (comm_x_only) {
|
||||||
if (size_forward_recv[iswap]) {
|
if (size_forward_recv[iswap]) {
|
||||||
buf = x[firstrecv[iswap]];
|
buf = x[firstrecv[iswap]];
|
||||||
MPI_Irecv(buf,size_forward_recv[iswap],MPI_DOUBLE,
|
MPI_Irecv(buf,size_forward_recv[iswap],MPI_DOUBLE,recvproc[iswap],0,world,&request);
|
||||||
recvproc[iswap],0,world,&request);
|
|
||||||
}
|
}
|
||||||
n = avec->pack_comm(sendnum[iswap],sendlist[iswap],
|
n = avec->pack_comm(sendnum[iswap],sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
buf_send,pbc_flag[iswap],pbc[iswap]);
|
|
||||||
if (n) MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
if (n) MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
||||||
if (size_forward_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (size_forward_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
} else if (ghost_velocity) {
|
} else if (ghost_velocity) {
|
||||||
if (size_forward_recv[iswap])
|
if (size_forward_recv[iswap])
|
||||||
MPI_Irecv(buf_recv,size_forward_recv[iswap],MPI_DOUBLE,
|
MPI_Irecv(buf_recv,size_forward_recv[iswap],MPI_DOUBLE,recvproc[iswap],0,world,&request);
|
||||||
recvproc[iswap],0,world,&request);
|
n = avec->pack_comm_vel(sendnum[iswap],sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
n = avec->pack_comm_vel(sendnum[iswap],sendlist[iswap],
|
|
||||||
buf_send,pbc_flag[iswap],pbc[iswap]);
|
|
||||||
if (n) MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
if (n) MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
||||||
if (size_forward_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (size_forward_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
avec->unpack_comm_vel(recvnum[iswap],firstrecv[iswap],buf_recv);
|
avec->unpack_comm_vel(recvnum[iswap],firstrecv[iswap],buf_recv);
|
||||||
@ -573,8 +568,7 @@ void CommBrick::forward_comm(int /*dummy*/)
|
|||||||
if (size_forward_recv[iswap])
|
if (size_forward_recv[iswap])
|
||||||
MPI_Irecv(buf_recv,size_forward_recv[iswap],MPI_DOUBLE,
|
MPI_Irecv(buf_recv,size_forward_recv[iswap],MPI_DOUBLE,
|
||||||
recvproc[iswap],0,world,&request);
|
recvproc[iswap],0,world,&request);
|
||||||
n = avec->pack_comm(sendnum[iswap],sendlist[iswap],
|
n = avec->pack_comm(sendnum[iswap],sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
buf_send,pbc_flag[iswap],pbc[iswap]);
|
|
||||||
if (n) MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
if (n) MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
||||||
if (size_forward_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (size_forward_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
avec->unpack_comm(recvnum[iswap],firstrecv[iswap],buf_recv);
|
avec->unpack_comm(recvnum[iswap],firstrecv[iswap],buf_recv);
|
||||||
@ -586,12 +580,10 @@ void CommBrick::forward_comm(int /*dummy*/)
|
|||||||
avec->pack_comm(sendnum[iswap],sendlist[iswap],
|
avec->pack_comm(sendnum[iswap],sendlist[iswap],
|
||||||
x[firstrecv[iswap]],pbc_flag[iswap],pbc[iswap]);
|
x[firstrecv[iswap]],pbc_flag[iswap],pbc[iswap]);
|
||||||
} else if (ghost_velocity) {
|
} else if (ghost_velocity) {
|
||||||
avec->pack_comm_vel(sendnum[iswap],sendlist[iswap],
|
avec->pack_comm_vel(sendnum[iswap],sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
buf_send,pbc_flag[iswap],pbc[iswap]);
|
|
||||||
avec->unpack_comm_vel(recvnum[iswap],firstrecv[iswap],buf_send);
|
avec->unpack_comm_vel(recvnum[iswap],firstrecv[iswap],buf_send);
|
||||||
} else {
|
} else {
|
||||||
avec->pack_comm(sendnum[iswap],sendlist[iswap],
|
avec->pack_comm(sendnum[iswap],sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
buf_send,pbc_flag[iswap],pbc[iswap]);
|
|
||||||
avec->unpack_comm(recvnum[iswap],firstrecv[iswap],buf_send);
|
avec->unpack_comm(recvnum[iswap],firstrecv[iswap],buf_send);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -619,18 +611,15 @@ void CommBrick::reverse_comm()
|
|||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (comm_f_only) {
|
if (comm_f_only) {
|
||||||
if (size_reverse_recv[iswap])
|
if (size_reverse_recv[iswap])
|
||||||
MPI_Irecv(buf_recv,size_reverse_recv[iswap],MPI_DOUBLE,
|
MPI_Irecv(buf_recv,size_reverse_recv[iswap],MPI_DOUBLE,sendproc[iswap],0,world,&request);
|
||||||
sendproc[iswap],0,world,&request);
|
|
||||||
if (size_reverse_send[iswap]) {
|
if (size_reverse_send[iswap]) {
|
||||||
buf = f[firstrecv[iswap]];
|
buf = f[firstrecv[iswap]];
|
||||||
MPI_Send(buf,size_reverse_send[iswap],MPI_DOUBLE,
|
MPI_Send(buf,size_reverse_send[iswap],MPI_DOUBLE,recvproc[iswap],0,world);
|
||||||
recvproc[iswap],0,world);
|
|
||||||
}
|
}
|
||||||
if (size_reverse_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (size_reverse_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
} else {
|
} else {
|
||||||
if (size_reverse_recv[iswap])
|
if (size_reverse_recv[iswap])
|
||||||
MPI_Irecv(buf_recv,size_reverse_recv[iswap],MPI_DOUBLE,
|
MPI_Irecv(buf_recv,size_reverse_recv[iswap],MPI_DOUBLE,sendproc[iswap],0,world,&request);
|
||||||
sendproc[iswap],0,world,&request);
|
|
||||||
n = avec->pack_reverse(recvnum[iswap],firstrecv[iswap],buf_send);
|
n = avec->pack_reverse(recvnum[iswap],firstrecv[iswap],buf_send);
|
||||||
if (n) MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
if (n) MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
||||||
if (size_reverse_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (size_reverse_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -640,8 +629,7 @@ void CommBrick::reverse_comm()
|
|||||||
} else {
|
} else {
|
||||||
if (comm_f_only) {
|
if (comm_f_only) {
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
avec->unpack_reverse(sendnum[iswap],sendlist[iswap],
|
avec->unpack_reverse(sendnum[iswap],sendlist[iswap],f[firstrecv[iswap]]);
|
||||||
f[firstrecv[iswap]]);
|
|
||||||
} else {
|
} else {
|
||||||
avec->pack_reverse(recvnum[iswap],firstrecv[iswap],buf_send);
|
avec->pack_reverse(recvnum[iswap],firstrecv[iswap],buf_send);
|
||||||
avec->unpack_reverse(sendnum[iswap],sendlist[iswap],buf_send);
|
avec->unpack_reverse(sendnum[iswap],sendlist[iswap],buf_send);
|
||||||
@ -734,25 +722,21 @@ void CommBrick::exchange()
|
|||||||
if (procgrid[dim] == 1) nrecv = 0;
|
if (procgrid[dim] == 1) nrecv = 0;
|
||||||
else {
|
else {
|
||||||
MPI_Sendrecv(&nsend,1,MPI_INT,procneigh[dim][0],0,
|
MPI_Sendrecv(&nsend,1,MPI_INT,procneigh[dim][0],0,
|
||||||
&nrecv1,1,MPI_INT,procneigh[dim][1],0,world,
|
&nrecv1,1,MPI_INT,procneigh[dim][1],0,world,MPI_STATUS_IGNORE);
|
||||||
MPI_STATUS_IGNORE);
|
|
||||||
nrecv = nrecv1;
|
nrecv = nrecv1;
|
||||||
if (procgrid[dim] > 2) {
|
if (procgrid[dim] > 2) {
|
||||||
MPI_Sendrecv(&nsend,1,MPI_INT,procneigh[dim][1],0,
|
MPI_Sendrecv(&nsend,1,MPI_INT,procneigh[dim][1],0,
|
||||||
&nrecv2,1,MPI_INT,procneigh[dim][0],0,world,
|
&nrecv2,1,MPI_INT,procneigh[dim][0],0,world,MPI_STATUS_IGNORE);
|
||||||
MPI_STATUS_IGNORE);
|
|
||||||
nrecv += nrecv2;
|
nrecv += nrecv2;
|
||||||
}
|
}
|
||||||
if (nrecv > maxrecv) grow_recv(nrecv);
|
if (nrecv > maxrecv) grow_recv(nrecv);
|
||||||
|
|
||||||
MPI_Irecv(buf_recv,nrecv1,MPI_DOUBLE,procneigh[dim][1],0,
|
MPI_Irecv(buf_recv,nrecv1,MPI_DOUBLE,procneigh[dim][1],0,world,&request);
|
||||||
world,&request);
|
|
||||||
MPI_Send(buf_send,nsend,MPI_DOUBLE,procneigh[dim][0],0,world);
|
MPI_Send(buf_send,nsend,MPI_DOUBLE,procneigh[dim][0],0,world);
|
||||||
MPI_Wait(&request,MPI_STATUS_IGNORE);
|
MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
|
|
||||||
if (procgrid[dim] > 2) {
|
if (procgrid[dim] > 2) {
|
||||||
MPI_Irecv(&buf_recv[nrecv1],nrecv2,MPI_DOUBLE,procneigh[dim][0],0,
|
MPI_Irecv(&buf_recv[nrecv1],nrecv2,MPI_DOUBLE,procneigh[dim][0],0,world,&request);
|
||||||
world,&request);
|
|
||||||
MPI_Send(buf_send,nsend,MPI_DOUBLE,procneigh[dim][1],0,world);
|
MPI_Send(buf_send,nsend,MPI_DOUBLE,procneigh[dim][1],0,world);
|
||||||
MPI_Wait(&request,MPI_STATUS_IGNORE);
|
MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
}
|
}
|
||||||
@ -926,11 +910,9 @@ void CommBrick::borders()
|
|||||||
|
|
||||||
if (nsend*size_border > maxsend) grow_send(nsend*size_border,0);
|
if (nsend*size_border > maxsend) grow_send(nsend*size_border,0);
|
||||||
if (ghost_velocity)
|
if (ghost_velocity)
|
||||||
n = avec->pack_border_vel(nsend,sendlist[iswap],buf_send,
|
n = avec->pack_border_vel(nsend,sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
pbc_flag[iswap],pbc[iswap]);
|
|
||||||
else
|
else
|
||||||
n = avec->pack_border(nsend,sendlist[iswap],buf_send,
|
n = avec->pack_border(nsend,sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
pbc_flag[iswap],pbc[iswap]);
|
|
||||||
|
|
||||||
// swap atoms with other proc
|
// swap atoms with other proc
|
||||||
// no MPI calls except SendRecv if nsend/nrecv = 0
|
// no MPI calls except SendRecv if nsend/nrecv = 0
|
||||||
@ -939,8 +921,7 @@ void CommBrick::borders()
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
MPI_Sendrecv(&nsend,1,MPI_INT,sendproc[iswap],0,
|
MPI_Sendrecv(&nsend,1,MPI_INT,sendproc[iswap],0,
|
||||||
&nrecv,1,MPI_INT,recvproc[iswap],0,world,
|
&nrecv,1,MPI_INT,recvproc[iswap],0,world,MPI_STATUS_IGNORE);
|
||||||
MPI_STATUS_IGNORE);
|
|
||||||
if (nrecv*size_border > maxrecv) grow_recv(nrecv*size_border);
|
if (nrecv*size_border > maxrecv) grow_recv(nrecv*size_border);
|
||||||
if (nrecv) MPI_Irecv(buf_recv,nrecv*size_border,MPI_DOUBLE,
|
if (nrecv) MPI_Irecv(buf_recv,nrecv*size_border,MPI_DOUBLE,
|
||||||
recvproc[iswap],0,world,&request);
|
recvproc[iswap],0,world,&request);
|
||||||
@ -1014,16 +995,14 @@ void CommBrick::forward_comm(Pair *pair)
|
|||||||
|
|
||||||
// pack buffer
|
// pack buffer
|
||||||
|
|
||||||
n = pair->pack_forward_comm(sendnum[iswap],sendlist[iswap],
|
n = pair->pack_forward_comm(sendnum[iswap],sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
buf_send,pbc_flag[iswap],pbc[iswap]);
|
|
||||||
|
|
||||||
// exchange with another proc
|
// exchange with another proc
|
||||||
// if self, set recv buffer to send buffer
|
// if self, set recv buffer to send buffer
|
||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,
|
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,world,&request);
|
||||||
recvproc[iswap],0,world,&request);
|
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
||||||
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1060,8 +1039,7 @@ void CommBrick::reverse_comm(Pair *pair)
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,
|
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
||||||
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1091,16 +1069,14 @@ void CommBrick::forward_comm(Bond *bond)
|
|||||||
|
|
||||||
// pack buffer
|
// pack buffer
|
||||||
|
|
||||||
n = bond->pack_forward_comm(sendnum[iswap],sendlist[iswap],
|
n = bond->pack_forward_comm(sendnum[iswap],sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
buf_send,pbc_flag[iswap],pbc[iswap]);
|
|
||||||
|
|
||||||
// exchange with another proc
|
// exchange with another proc
|
||||||
// if self, set recv buffer to send buffer
|
// if self, set recv buffer to send buffer
|
||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,
|
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,world,&request);
|
||||||
recvproc[iswap],0,world,&request);
|
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
||||||
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1137,8 +1113,7 @@ void CommBrick::reverse_comm(Bond *bond)
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,
|
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
||||||
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1173,16 +1148,14 @@ void CommBrick::forward_comm(Fix *fix, int size)
|
|||||||
|
|
||||||
// pack buffer
|
// pack buffer
|
||||||
|
|
||||||
n = fix->pack_forward_comm(sendnum[iswap],sendlist[iswap],
|
n = fix->pack_forward_comm(sendnum[iswap],sendlist[iswap],buf_send,pbc_flag[iswap],pbc[iswap]);
|
||||||
buf_send,pbc_flag[iswap],pbc[iswap]);
|
|
||||||
|
|
||||||
// exchange with another proc
|
// exchange with another proc
|
||||||
// if self, set recv buffer to send buffer
|
// if self, set recv buffer to send buffer
|
||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,
|
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
||||||
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1224,8 +1197,7 @@ void CommBrick::reverse_comm(Fix *fix, int size)
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,
|
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
||||||
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1263,13 +1235,11 @@ void CommBrick::reverse_comm_variable(Fix *fix)
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
MPI_Sendrecv(&nsend,1,MPI_INT,recvproc[iswap],0,
|
MPI_Sendrecv(&nsend,1,MPI_INT,recvproc[iswap],0,
|
||||||
&nrecv,1,MPI_INT,sendproc[iswap],0,world,
|
&nrecv,1,MPI_INT,sendproc[iswap],0,world,MPI_STATUS_IGNORE);
|
||||||
MPI_STATUS_IGNORE);
|
|
||||||
|
|
||||||
if (sendnum[iswap]) {
|
if (sendnum[iswap]) {
|
||||||
if (nrecv > maxrecv) grow_recv(nrecv);
|
if (nrecv > maxrecv) grow_recv(nrecv);
|
||||||
MPI_Irecv(buf_recv,maxrecv,MPI_DOUBLE,sendproc[iswap],0,
|
MPI_Irecv(buf_recv,maxrecv,MPI_DOUBLE,sendproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
}
|
}
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Send(buf_send,nsend,MPI_DOUBLE,recvproc[iswap],0,world);
|
MPI_Send(buf_send,nsend,MPI_DOUBLE,recvproc[iswap],0,world);
|
||||||
@ -1308,8 +1278,7 @@ void CommBrick::forward_comm(Compute *compute)
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,
|
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
||||||
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1346,8 +1315,7 @@ void CommBrick::reverse_comm(Compute *compute)
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,
|
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
||||||
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1385,8 +1353,7 @@ void CommBrick::forward_comm(Dump *dump)
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,
|
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
|
||||||
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1423,8 +1390,7 @@ void CommBrick::reverse_comm(Dump *dump)
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,
|
MPI_Irecv(buf_recv,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
|
||||||
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
@ -1472,11 +1438,9 @@ void CommBrick::forward_comm_array(int nsize, double **array)
|
|||||||
|
|
||||||
if (sendproc[iswap] != me) {
|
if (sendproc[iswap] != me) {
|
||||||
if (recvnum[iswap])
|
if (recvnum[iswap])
|
||||||
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,
|
MPI_Irecv(buf_recv,nsize*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,world,&request);
|
||||||
world,&request);
|
|
||||||
if (sendnum[iswap])
|
if (sendnum[iswap])
|
||||||
MPI_Send(buf_send,nsize*sendnum[iswap],MPI_DOUBLE,
|
MPI_Send(buf_send,nsize*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,world);
|
||||||
sendproc[iswap],0,world);
|
|
||||||
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
if (recvnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
buf = buf_recv;
|
buf = buf_recv;
|
||||||
} else buf = buf_send;
|
} else buf = buf_send;
|
||||||
@ -1522,21 +1486,18 @@ int CommBrick::exchange_variable(int n, double *inbuf, double *&outbuf)
|
|||||||
nrecv += nrecv1;
|
nrecv += nrecv1;
|
||||||
if (procgrid[dim] > 2) {
|
if (procgrid[dim] > 2) {
|
||||||
MPI_Sendrecv(&nsend,1,MPI_INT,procneigh[dim][1],0,
|
MPI_Sendrecv(&nsend,1,MPI_INT,procneigh[dim][1],0,
|
||||||
&nrecv2,1,MPI_INT,procneigh[dim][0],0,world,
|
&nrecv2,1,MPI_INT,procneigh[dim][0],0,world,MPI_STATUS_IGNORE);
|
||||||
MPI_STATUS_IGNORE);
|
|
||||||
nrecv += nrecv2;
|
nrecv += nrecv2;
|
||||||
} else nrecv2 = 0;
|
} else nrecv2 = 0;
|
||||||
|
|
||||||
if (nrecv > maxrecv) grow_recv(nrecv);
|
if (nrecv > maxrecv) grow_recv(nrecv);
|
||||||
|
|
||||||
MPI_Irecv(&buf_recv[nsend],nrecv1,MPI_DOUBLE,procneigh[dim][1],0,
|
MPI_Irecv(&buf_recv[nsend],nrecv1,MPI_DOUBLE,procneigh[dim][1],0,world,&request);
|
||||||
world,&request);
|
|
||||||
MPI_Send(buf_recv,nsend,MPI_DOUBLE,procneigh[dim][0],0,world);
|
MPI_Send(buf_recv,nsend,MPI_DOUBLE,procneigh[dim][0],0,world);
|
||||||
MPI_Wait(&request,MPI_STATUS_IGNORE);
|
MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
|
|
||||||
if (procgrid[dim] > 2) {
|
if (procgrid[dim] > 2) {
|
||||||
MPI_Irecv(&buf_recv[nsend+nrecv1],nrecv2,MPI_DOUBLE,procneigh[dim][0],0,
|
MPI_Irecv(&buf_recv[nsend+nrecv1],nrecv2,MPI_DOUBLE,procneigh[dim][0],0,world,&request);
|
||||||
world,&request);
|
|
||||||
MPI_Send(buf_recv,nsend,MPI_DOUBLE,procneigh[dim][1],0,world);
|
MPI_Send(buf_recv,nsend,MPI_DOUBLE,procneigh[dim][1],0,world);
|
||||||
MPI_Wait(&request,MPI_STATUS_IGNORE);
|
MPI_Wait(&request,MPI_STATUS_IGNORE);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -513,16 +513,14 @@ void CommTiled::setup()
|
|||||||
MIN(sbox_multi[3+idim]+cutghostmulti[icollection][idim],subhi[idim]);
|
MIN(sbox_multi[3+idim]+cutghostmulti[icollection][idim],subhi[idim]);
|
||||||
else
|
else
|
||||||
sbox_multi[3+idim] =
|
sbox_multi[3+idim] =
|
||||||
MIN(sbox_multi[3+idim]-prd[idim]+cutghostmulti[icollection][idim],
|
MIN(sbox_multi[3+idim]-prd[idim]+cutghostmulti[icollection][idim],subhi[idim]);
|
||||||
subhi[idim]);
|
|
||||||
} else {
|
} else {
|
||||||
if (i < noverlap1)
|
if (i < noverlap1)
|
||||||
sbox_multi[idim] =
|
sbox_multi[idim] =
|
||||||
MAX(sbox_multi[idim]-cutghostmulti[icollection][idim],sublo[idim]);
|
MAX(sbox_multi[idim]-cutghostmulti[icollection][idim],sublo[idim]);
|
||||||
else
|
else
|
||||||
sbox_multi[idim] =
|
sbox_multi[idim] =
|
||||||
MAX(sbox_multi[idim]+prd[idim]-cutghostmulti[icollection][idim],
|
MAX(sbox_multi[idim]+prd[idim]-cutghostmulti[icollection][idim],sublo[idim]);
|
||||||
sublo[idim]);
|
|
||||||
sbox_multi[3+idim] = subhi[idim];
|
sbox_multi[3+idim] = subhi[idim];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,16 +587,14 @@ void CommTiled::setup()
|
|||||||
MIN(sbox_multiold[3+idim]+cutghostmultiold[itype][idim],subhi[idim]);
|
MIN(sbox_multiold[3+idim]+cutghostmultiold[itype][idim],subhi[idim]);
|
||||||
else
|
else
|
||||||
sbox_multiold[3+idim] =
|
sbox_multiold[3+idim] =
|
||||||
MIN(sbox_multiold[3+idim]-prd[idim]+cutghostmultiold[itype][idim],
|
MIN(sbox_multiold[3+idim]-prd[idim]+cutghostmultiold[itype][idim],subhi[idim]);
|
||||||
subhi[idim]);
|
|
||||||
} else {
|
} else {
|
||||||
if (i < noverlap1)
|
if (i < noverlap1)
|
||||||
sbox_multiold[idim] =
|
sbox_multiold[idim] =
|
||||||
MAX(sbox_multiold[idim]-cutghostmultiold[itype][idim],sublo[idim]);
|
MAX(sbox_multiold[idim]-cutghostmultiold[itype][idim],sublo[idim]);
|
||||||
else
|
else
|
||||||
sbox_multiold[idim] =
|
sbox_multiold[idim] =
|
||||||
MAX(sbox_multiold[idim]+prd[idim]-cutghostmultiold[itype][idim],
|
MAX(sbox_multiold[idim]+prd[idim]-cutghostmultiold[itype][idim],sublo[idim]);
|
||||||
sublo[idim]);
|
|
||||||
sbox_multiold[3+idim] = subhi[idim];
|
sbox_multiold[3+idim] = subhi[idim];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,8 +744,7 @@ void CommTiled::forward_comm(int /*dummy*/)
|
|||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
avec->pack_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
avec->pack_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
x[firstrecv[iswap][nrecv]],pbc_flag[iswap][nsend],
|
x[firstrecv[iswap][nrecv]],pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
pbc[iswap][nsend]);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) MPI_Waitall(nrecv,requests,MPI_STATUS_IGNORE);
|
if (recvother[iswap]) MPI_Waitall(nrecv,requests,MPI_STATUS_IGNORE);
|
||||||
|
|
||||||
@ -757,8 +752,7 @@ void CommTiled::forward_comm(int /*dummy*/)
|
|||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++)
|
for (i = 0; i < nrecv; i++)
|
||||||
MPI_Irecv(&buf_recv[size_forward*forward_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[size_forward*forward_recv_offset[iswap][i]],
|
||||||
size_forward_recv[iswap][i],
|
size_forward_recv[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
||||||
MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
@ -770,15 +764,13 @@ void CommTiled::forward_comm(int /*dummy*/)
|
|||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
avec->pack_comm_vel(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
avec->pack_comm_vel(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
avec->unpack_comm_vel(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
avec->unpack_comm_vel(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
avec->unpack_comm_vel(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
avec->unpack_comm_vel(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
||||||
&buf_recv[size_forward*
|
&buf_recv[size_forward*forward_recv_offset[iswap][irecv]]);
|
||||||
forward_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,8 +778,7 @@ void CommTiled::forward_comm(int /*dummy*/)
|
|||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++)
|
for (i = 0; i < nrecv; i++)
|
||||||
MPI_Irecv(&buf_recv[size_forward*forward_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[size_forward*forward_recv_offset[iswap][i]],
|
||||||
size_forward_recv[iswap][i],
|
size_forward_recv[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
||||||
MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
@ -799,15 +790,13 @@ void CommTiled::forward_comm(int /*dummy*/)
|
|||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
avec->pack_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
avec->pack_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
avec->unpack_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
avec->unpack_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
avec->unpack_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
avec->unpack_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
||||||
&buf_recv[size_forward*
|
&buf_recv[size_forward*forward_recv_offset[iswap][irecv]]);
|
||||||
forward_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -840,8 +829,7 @@ void CommTiled::reverse_comm()
|
|||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
MPI_Irecv(&buf_recv[size_reverse*reverse_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[size_reverse*reverse_recv_offset[iswap][i]],
|
||||||
size_reverse_recv[iswap][i],MPI_DOUBLE,
|
size_reverse_recv[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world,&requests[i]);
|
||||||
sendproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
@ -857,8 +845,7 @@ void CommTiled::reverse_comm()
|
|||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
avec->unpack_reverse(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
avec->unpack_reverse(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
||||||
&buf_recv[size_reverse*
|
&buf_recv[size_reverse*reverse_recv_offset[iswap][irecv]]);
|
||||||
reverse_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,28 +853,23 @@ void CommTiled::reverse_comm()
|
|||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++)
|
for (i = 0; i < nsend; i++)
|
||||||
MPI_Irecv(&buf_recv[size_reverse*reverse_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[size_reverse*reverse_recv_offset[iswap][i]],
|
||||||
size_reverse_recv[iswap][i],MPI_DOUBLE,
|
size_reverse_recv[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world,&requests[i]);
|
||||||
sendproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
n = avec->pack_reverse(recvnum[iswap][i],firstrecv[iswap][i],
|
n = avec->pack_reverse(recvnum[iswap][i],firstrecv[iswap][i],buf_send);
|
||||||
buf_send);
|
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
avec->pack_reverse(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
avec->pack_reverse(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
buf_send);
|
avec->unpack_reverse(sendnum[iswap][nsend],sendlist[iswap][nsend],buf_send);
|
||||||
avec->unpack_reverse(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
avec->unpack_reverse(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
avec->unpack_reverse(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
||||||
&buf_recv[size_reverse*
|
&buf_recv[size_reverse*reverse_recv_offset[iswap][irecv]]);
|
||||||
reverse_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -990,8 +972,7 @@ void CommTiled::exchange()
|
|||||||
if (!nexch) continue;
|
if (!nexch) continue;
|
||||||
|
|
||||||
for (m = 0; m < nexch; m++)
|
for (m = 0; m < nexch; m++)
|
||||||
MPI_Irecv(&exchnum[dim][m],1,MPI_INT,
|
MPI_Irecv(&exchnum[dim][m],1,MPI_INT,exchproc[dim][m],0,world,&requests[m]);
|
||||||
exchproc[dim][m],0,world,&requests[m]);
|
|
||||||
for (m = 0; m < nexch; m++)
|
for (m = 0; m < nexch; m++)
|
||||||
MPI_Send(&nsend,1,MPI_INT,exchproc[dim][m],0,world);
|
MPI_Send(&nsend,1,MPI_INT,exchproc[dim][m],0,world);
|
||||||
MPI_Waitall(nexch,requests,MPI_STATUS_IGNORE);
|
MPI_Waitall(nexch,requests,MPI_STATUS_IGNORE);
|
||||||
@ -1002,8 +983,7 @@ void CommTiled::exchange()
|
|||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
for (m = 0; m < nexch; m++) {
|
for (m = 0; m < nexch; m++) {
|
||||||
MPI_Irecv(&buf_recv[offset],exchnum[dim][m],
|
MPI_Irecv(&buf_recv[offset],exchnum[dim][m],MPI_DOUBLE,exchproc[dim][m],0,world,&requests[m]);
|
||||||
MPI_DOUBLE,exchproc[dim][m],0,world,&requests[m]);
|
|
||||||
offset += exchnum[dim][m];
|
offset += exchnum[dim][m];
|
||||||
}
|
}
|
||||||
for (m = 0; m < nexch; m++)
|
for (m = 0; m < nexch; m++)
|
||||||
@ -1234,8 +1214,7 @@ void CommTiled::borders()
|
|||||||
|
|
||||||
if (recvother[iswap])
|
if (recvother[iswap])
|
||||||
for (m = 0; m < nrecv; m++)
|
for (m = 0; m < nrecv; m++)
|
||||||
MPI_Irecv(&recvnum[iswap][m],1,MPI_INT,
|
MPI_Irecv(&recvnum[iswap][m],1,MPI_INT,recvproc[iswap][m],0,world,&requests[m]);
|
||||||
recvproc[iswap][m],0,world,&requests[m]);
|
|
||||||
if (sendother[iswap])
|
if (sendother[iswap])
|
||||||
for (m = 0; m < nsend; m++)
|
for (m = 0; m < nsend; m++)
|
||||||
MPI_Send(&sendnum[iswap][m],1,MPI_INT,sendproc[iswap][m],0,world);
|
MPI_Send(&sendnum[iswap][m],1,MPI_INT,sendproc[iswap][m],0,world);
|
||||||
@ -1295,17 +1274,14 @@ void CommTiled::borders()
|
|||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
avec->pack_border_vel(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
avec->pack_border_vel(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
buf_send,pbc_flag[iswap][nsend],
|
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
pbc[iswap][nsend]);
|
avec->unpack_border_vel(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
avec->unpack_border_vel(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
MPI_Waitany(nrecv,requests,&m,MPI_STATUS_IGNORE);
|
MPI_Waitany(nrecv,requests,&m,MPI_STATUS_IGNORE);
|
||||||
avec->unpack_border_vel(recvnum[iswap][m],firstrecv[iswap][m],
|
avec->unpack_border_vel(recvnum[iswap][m],firstrecv[iswap][m],
|
||||||
&buf_recv[size_border*
|
&buf_recv[size_border*forward_recv_offset[iswap][m]]);
|
||||||
forward_recv_offset[iswap][m]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1326,15 +1302,13 @@ void CommTiled::borders()
|
|||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
avec->pack_border(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
avec->pack_border(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
avec->unpack_border(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
avec->unpack_border(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
MPI_Waitany(nrecv,requests,&m,MPI_STATUS_IGNORE);
|
MPI_Waitany(nrecv,requests,&m,MPI_STATUS_IGNORE);
|
||||||
avec->unpack_border(recvnum[iswap][m],firstrecv[iswap][m],
|
avec->unpack_border(recvnum[iswap][m],firstrecv[iswap][m],
|
||||||
&buf_recv[size_border*
|
&buf_recv[size_border*forward_recv_offset[iswap][m]]);
|
||||||
forward_recv_offset[iswap][m]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1352,10 +1326,8 @@ void CommTiled::borders()
|
|||||||
// For molecular systems we lose some bits for local atom indices due
|
// For molecular systems we lose some bits for local atom indices due
|
||||||
// to encoding of special pairs in neighbor lists. Check for overflows.
|
// to encoding of special pairs in neighbor lists. Check for overflows.
|
||||||
|
|
||||||
if ((atom->molecular != Atom::ATOMIC)
|
if ((atom->molecular != Atom::ATOMIC) && ((atom->nlocal + atom->nghost) > NEIGHMASK))
|
||||||
&& ((atom->nlocal + atom->nghost) > NEIGHMASK))
|
error->one(FLERR,"Per-processor number of atoms is too large for molecular neighbor lists");
|
||||||
error->one(FLERR,"Per-processor number of atoms is too large for "
|
|
||||||
"molecular neighbor lists");
|
|
||||||
|
|
||||||
// insure send/recv buffers are long enough for all forward & reverse comm
|
// insure send/recv buffers are long enough for all forward & reverse comm
|
||||||
// send buf is for one forward or reverse sends to one proc
|
// send buf is for one forward or reverse sends to one proc
|
||||||
@ -1389,8 +1361,7 @@ void CommTiled::forward_comm(Pair *pair)
|
|||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++)
|
for (i = 0; i < nrecv; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
||||||
nsize*recvnum[iswap][i],
|
nsize*recvnum[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
||||||
MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
@ -1403,17 +1374,14 @@ void CommTiled::forward_comm(Pair *pair)
|
|||||||
|
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
pair->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
pair->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
buf_send,pbc_flag[iswap][nsend],
|
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
pbc[iswap][nsend]);
|
pair->unpack_forward_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
pair->unpack_forward_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
pair->unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
pair->unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*forward_recv_offset[iswap][irecv]]);
|
||||||
forward_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1437,28 +1405,23 @@ void CommTiled::reverse_comm(Pair *pair)
|
|||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++)
|
for (i = 0; i < nsend; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
||||||
nsize*sendnum[iswap][i],MPI_DOUBLE,
|
nsize*sendnum[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world,&requests[i]);
|
||||||
sendproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
n = pair->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],
|
n = pair->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],buf_send);
|
||||||
buf_send);
|
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
pair->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
pair->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
buf_send);
|
pair->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],buf_send);
|
||||||
pair->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
pair->unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
pair->unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*reverse_recv_offset[iswap][irecv]]);
|
||||||
reverse_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1482,8 +1445,7 @@ void CommTiled::forward_comm(Bond *bond)
|
|||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++)
|
for (i = 0; i < nrecv; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
||||||
nsize*recvnum[iswap][i],
|
nsize*recvnum[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
||||||
MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
@ -1496,17 +1458,14 @@ void CommTiled::forward_comm(Bond *bond)
|
|||||||
|
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
bond->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
bond->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
buf_send,pbc_flag[iswap][nsend],
|
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
pbc[iswap][nsend]);
|
bond->unpack_forward_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
bond->unpack_forward_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
bond->unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
bond->unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*forward_recv_offset[iswap][irecv]]);
|
||||||
forward_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1530,28 +1489,23 @@ void CommTiled::reverse_comm(Bond *bond)
|
|||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++)
|
for (i = 0; i < nsend; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
||||||
nsize*sendnum[iswap][i],MPI_DOUBLE,
|
nsize*sendnum[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world,&requests[i]);
|
||||||
sendproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
n = bond->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],
|
n = bond->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],buf_send);
|
||||||
buf_send);
|
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
bond->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
bond->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
buf_send);
|
bond->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],buf_send);
|
||||||
bond->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
bond->unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
bond->unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*reverse_recv_offset[iswap][irecv]]);
|
||||||
reverse_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1580,8 +1534,7 @@ void CommTiled::forward_comm(Fix *fix, int size)
|
|||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++)
|
for (i = 0; i < nrecv; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
||||||
nsize*recvnum[iswap][i],
|
nsize*recvnum[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
||||||
MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
@ -1592,17 +1545,14 @@ void CommTiled::forward_comm(Fix *fix, int size)
|
|||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
fix->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
fix->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
buf_send,pbc_flag[iswap][nsend],
|
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
pbc[iswap][nsend]);
|
fix->unpack_forward_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
fix->unpack_forward_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
fix->unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
fix->unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*forward_recv_offset[iswap][irecv]]);
|
||||||
forward_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1631,28 +1581,23 @@ void CommTiled::reverse_comm(Fix *fix, int size)
|
|||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++)
|
for (i = 0; i < nsend; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
||||||
nsize*sendnum[iswap][i],MPI_DOUBLE,
|
nsize*sendnum[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world,&requests[i]);
|
||||||
sendproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
n = fix->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],
|
n = fix->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],buf_send);
|
||||||
buf_send);
|
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
fix->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
fix->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
buf_send);
|
fix->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],buf_send);
|
||||||
fix->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
fix->unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
fix->unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*reverse_recv_offset[iswap][irecv]]);
|
||||||
reverse_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1688,31 +1633,26 @@ void CommTiled::forward_comm(Compute *compute)
|
|||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++)
|
for (i = 0; i < nrecv; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
||||||
nsize*recvnum[iswap][i],
|
nsize*recvnum[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
||||||
MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
n = compute->pack_forward_comm(sendnum[iswap][i],sendlist[iswap][i],
|
n = compute->pack_forward_comm(sendnum[iswap][i],sendlist[iswap][i],
|
||||||
buf_send,pbc_flag[iswap][i],
|
buf_send,pbc_flag[iswap][i],pbc[iswap][i]);
|
||||||
pbc[iswap][i]);
|
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap][i],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap][i],0,world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
compute->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
compute->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
buf_send,pbc_flag[iswap][nsend],
|
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
pbc[iswap][nsend]);
|
compute->unpack_forward_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
compute->unpack_forward_comm(recvnum[iswap][nrecv],
|
|
||||||
firstrecv[iswap][nrecv],buf_send);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
compute->
|
compute->
|
||||||
unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*forward_recv_offset[iswap][irecv]]);
|
||||||
forward_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1736,29 +1676,24 @@ void CommTiled::reverse_comm(Compute *compute)
|
|||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++)
|
for (i = 0; i < nsend; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
||||||
nsize*sendnum[iswap][i],MPI_DOUBLE,
|
nsize*sendnum[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world,&requests[i]);
|
||||||
sendproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
n = compute->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],
|
n = compute->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],buf_send);
|
||||||
buf_send);
|
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
compute->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
compute->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
buf_send);
|
compute->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],buf_send);
|
||||||
compute->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
compute->
|
compute->
|
||||||
unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*reverse_recv_offset[iswap][irecv]]);
|
||||||
reverse_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1782,21 +1717,18 @@ void CommTiled::forward_comm(Dump *dump)
|
|||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++)
|
for (i = 0; i < nrecv; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
||||||
nsize*recvnum[iswap][i],
|
nsize*recvnum[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
||||||
MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
n = dump->pack_forward_comm(sendnum[iswap][i],sendlist[iswap][i],
|
n = dump->pack_forward_comm(sendnum[iswap][i],sendlist[iswap][i],
|
||||||
buf_send,pbc_flag[iswap][i],
|
buf_send,pbc_flag[iswap][i],pbc[iswap][i]);
|
||||||
pbc[iswap][i]);
|
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap][i],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap][i],0,world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
dump->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
dump->pack_forward_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
||||||
buf_send,pbc_flag[iswap][nsend],
|
buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]);
|
||||||
pbc[iswap][nsend]);
|
|
||||||
dump->unpack_forward_comm(recvnum[iswap][nrecv],
|
dump->unpack_forward_comm(recvnum[iswap][nrecv],
|
||||||
firstrecv[iswap][nrecv],buf_send);
|
firstrecv[iswap][nrecv],buf_send);
|
||||||
}
|
}
|
||||||
@ -1804,8 +1736,7 @@ void CommTiled::forward_comm(Dump *dump)
|
|||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
dump->unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
dump->unpack_forward_comm(recvnum[iswap][irecv],firstrecv[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*forward_recv_offset[iswap][irecv]]);
|
||||||
forward_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1829,28 +1760,23 @@ void CommTiled::reverse_comm(Dump *dump)
|
|||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++)
|
for (i = 0; i < nsend; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*reverse_recv_offset[iswap][i]],
|
||||||
nsize*sendnum[iswap][i],MPI_DOUBLE,
|
nsize*sendnum[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world,&requests[i]);
|
||||||
sendproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++) {
|
for (i = 0; i < nrecv; i++) {
|
||||||
n = dump->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],
|
n = dump->pack_reverse_comm(recvnum[iswap][i],firstrecv[iswap][i],buf_send);
|
||||||
buf_send);
|
|
||||||
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap][i],0,world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
dump->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],
|
dump->pack_reverse_comm(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],buf_send);
|
||||||
buf_send);
|
dump->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],buf_send);
|
||||||
dump->unpack_reverse_comm(sendnum[iswap][nsend],sendlist[iswap][nsend],
|
|
||||||
buf_send);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE);
|
||||||
dump->unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
dump->unpack_reverse_comm(sendnum[iswap][irecv],sendlist[iswap][irecv],
|
||||||
&buf_recv[nsize*
|
&buf_recv[nsize*reverse_recv_offset[iswap][irecv]]);
|
||||||
reverse_recv_offset[iswap][irecv]]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1882,8 +1808,7 @@ void CommTiled::forward_comm_array(int nsize, double **array)
|
|||||||
if (recvother[iswap]) {
|
if (recvother[iswap]) {
|
||||||
for (i = 0; i < nrecv; i++)
|
for (i = 0; i < nrecv; i++)
|
||||||
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
MPI_Irecv(&buf_recv[nsize*forward_recv_offset[iswap][i]],
|
||||||
nsize*recvnum[iswap][i],
|
nsize*recvnum[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
||||||
MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]);
|
|
||||||
}
|
}
|
||||||
if (sendother[iswap]) {
|
if (sendother[iswap]) {
|
||||||
for (i = 0; i < nsend; i++) {
|
for (i = 0; i < nsend; i++) {
|
||||||
@ -1893,8 +1818,7 @@ void CommTiled::forward_comm_array(int nsize, double **array)
|
|||||||
for (k = 0; k < nsize; k++)
|
for (k = 0; k < nsize; k++)
|
||||||
buf_send[m++] = array[j][k];
|
buf_send[m++] = array[j][k];
|
||||||
}
|
}
|
||||||
MPI_Send(buf_send,nsize*sendnum[iswap][i],
|
MPI_Send(buf_send,nsize*sendnum[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world);
|
||||||
MPI_DOUBLE,sendproc[iswap][i],0,world);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sendself[iswap]) {
|
if (sendself[iswap]) {
|
||||||
@ -2013,8 +1937,7 @@ void CommTiled::box_drop_tiled(int /*idim*/, double *lo, double *hi, int &indexm
|
|||||||
box_drop_tiled_recurse(lo,hi,0,nprocs-1,indexme);
|
box_drop_tiled_recurse(lo,hi,0,nprocs-1,indexme);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommTiled::box_drop_tiled_recurse(double *lo, double *hi,
|
void CommTiled::box_drop_tiled_recurse(double *lo, double *hi, int proclower, int procupper,
|
||||||
int proclower, int procupper,
|
|
||||||
int &indexme)
|
int &indexme)
|
||||||
{
|
{
|
||||||
// end recursion when partition is a single proc
|
// end recursion when partition is a single proc
|
||||||
@ -2052,8 +1975,7 @@ void CommTiled::box_drop_tiled_recurse(double *lo, double *hi,
|
|||||||
return other box owned by proc as lo/hi corner pts
|
return other box owned by proc as lo/hi corner pts
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void CommTiled::box_other_brick(int idim, int idir,
|
void CommTiled::box_other_brick(int idim, int idir, int proc, double *lo, double *hi)
|
||||||
int proc, double *lo, double *hi)
|
|
||||||
{
|
{
|
||||||
lo[0] = sublo[0]; lo[1] = sublo[1]; lo[2] = sublo[2];
|
lo[0] = sublo[0]; lo[1] = sublo[1]; lo[2] = sublo[2];
|
||||||
hi[0] = subhi[0]; hi[1] = subhi[1]; hi[2] = subhi[2];
|
hi[0] = subhi[0]; hi[1] = subhi[1]; hi[2] = subhi[2];
|
||||||
@ -2100,8 +2022,7 @@ void CommTiled::box_other_brick(int idim, int idir,
|
|||||||
return other box owned by proc as lo/hi corner pts
|
return other box owned by proc as lo/hi corner pts
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void CommTiled::box_other_tiled(int /*idim*/, int /*idir*/,
|
void CommTiled::box_other_tiled(int /*idim*/, int /*idir*/, int proc, double *lo, double *hi)
|
||||||
int proc, double *lo, double *hi)
|
|
||||||
{
|
{
|
||||||
double (*split)[2] = rcbinfo[proc].mysplit;
|
double (*split)[2] = rcbinfo[proc].mysplit;
|
||||||
|
|
||||||
@ -2230,8 +2151,7 @@ int CommTiled::point_drop_tiled(int idim, double *x)
|
|||||||
recursive point drop thru RCB tree
|
recursive point drop thru RCB tree
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int CommTiled::point_drop_tiled_recurse(double *x,
|
int CommTiled::point_drop_tiled_recurse(double *x, int proclower, int procupper)
|
||||||
int proclower, int procupper)
|
|
||||||
{
|
{
|
||||||
// end recursion when partition is a single proc
|
// end recursion when partition is a single proc
|
||||||
// return proc
|
// return proc
|
||||||
@ -2289,8 +2209,7 @@ void CommTiled::coord2proc_setup()
|
|||||||
memcpy(&rcbone.mysplit[0][0],&mysplit[0][0],6*sizeof(double));
|
memcpy(&rcbone.mysplit[0][0],&mysplit[0][0],6*sizeof(double));
|
||||||
rcbone.cutfrac = rcbcutfrac;
|
rcbone.cutfrac = rcbcutfrac;
|
||||||
rcbone.dim = rcbcutdim;
|
rcbone.dim = rcbcutdim;
|
||||||
MPI_Allgather(&rcbone,sizeof(RCBinfo),MPI_CHAR,
|
MPI_Allgather(&rcbone,sizeof(RCBinfo),MPI_CHAR,rcbinfo,sizeof(RCBinfo),MPI_CHAR,world);
|
||||||
rcbinfo,sizeof(RCBinfo),MPI_CHAR,world);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -339,8 +339,8 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
atom->bond_atom[i][m] = atom->bond_atom[i][n-1];
|
atom->bond_atom[i][m] = atom->bond_atom[i][n-1];
|
||||||
if (n_histories > 0)
|
if (n_histories > 0)
|
||||||
for (auto &ihistory: histories) {
|
for (auto &ihistory: histories) {
|
||||||
((FixBondHistory *) ihistory)->shift_history(i,m,n-1);
|
dynamic_cast<FixBondHistory *>(ihistory)->shift_history(i,m,n-1);
|
||||||
((FixBondHistory *) ihistory)->delete_history(i,n-1);
|
dynamic_cast<FixBondHistory *>(ihistory)->delete_history(i,n-1);
|
||||||
}
|
}
|
||||||
atom->num_bond[i]--;
|
atom->num_bond[i]--;
|
||||||
} else m++;
|
} else m++;
|
||||||
@ -442,32 +442,28 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
if (atom->avec->bonds_allow) {
|
if (atom->avec->bonds_allow) {
|
||||||
bigint nbonds = 0;
|
bigint nbonds = 0;
|
||||||
for (i = 0; i < nlocal; i++) nbonds += atom->num_bond[i];
|
for (i = 0; i < nlocal; i++) nbonds += atom->num_bond[i];
|
||||||
MPI_Allreduce(&nbonds,&atom->nbonds,1,MPI_LMP_BIGINT,
|
MPI_Allreduce(&nbonds,&atom->nbonds,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
MPI_SUM,world);
|
|
||||||
if (force->newton_bond == 0) atom->nbonds /= 2;
|
if (force->newton_bond == 0) atom->nbonds /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atom->avec->angles_allow) {
|
if (atom->avec->angles_allow) {
|
||||||
bigint nangles = 0;
|
bigint nangles = 0;
|
||||||
for (i = 0; i < nlocal; i++) nangles += atom->num_angle[i];
|
for (i = 0; i < nlocal; i++) nangles += atom->num_angle[i];
|
||||||
MPI_Allreduce(&nangles,&atom->nangles,1,MPI_LMP_BIGINT,
|
MPI_Allreduce(&nangles,&atom->nangles,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
MPI_SUM,world);
|
|
||||||
if (force->newton_bond == 0) atom->nangles /= 3;
|
if (force->newton_bond == 0) atom->nangles /= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atom->avec->dihedrals_allow) {
|
if (atom->avec->dihedrals_allow) {
|
||||||
bigint ndihedrals = 0;
|
bigint ndihedrals = 0;
|
||||||
for (i = 0; i < nlocal; i++) ndihedrals += atom->num_dihedral[i];
|
for (i = 0; i < nlocal; i++) ndihedrals += atom->num_dihedral[i];
|
||||||
MPI_Allreduce(&ndihedrals,&atom->ndihedrals,
|
MPI_Allreduce(&ndihedrals,&atom->ndihedrals,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
1,MPI_LMP_BIGINT,MPI_SUM,world);
|
|
||||||
if (force->newton_bond == 0) atom->ndihedrals /= 4;
|
if (force->newton_bond == 0) atom->ndihedrals /= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atom->avec->impropers_allow) {
|
if (atom->avec->impropers_allow) {
|
||||||
bigint nimpropers = 0;
|
bigint nimpropers = 0;
|
||||||
for (i = 0; i < nlocal; i++) nimpropers += atom->num_improper[i];
|
for (i = 0; i < nlocal; i++) nimpropers += atom->num_improper[i];
|
||||||
MPI_Allreduce(&nimpropers,&atom->nimpropers,
|
MPI_Allreduce(&nimpropers,&atom->nimpropers,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
1,MPI_LMP_BIGINT,MPI_SUM,world);
|
|
||||||
if (force->newton_bond == 0) atom->nimpropers /= 4;
|
if (force->newton_bond == 0) atom->nimpropers /= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,21 +542,18 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (comm->me == 0) {
|
if (comm->me == 0) {
|
||||||
|
constexpr auto fmtstr = " {} total {}, {} turned on, {} turned off\n";
|
||||||
if (atom->avec->bonds_allow)
|
if (atom->avec->bonds_allow)
|
||||||
utils::logmesg(lmp," {} total bonds, {} turned on, {} turned off\n",
|
utils::logmesg(lmp,fmtstr,atom->nbonds,"bonds",bond_on,bond_off);
|
||||||
atom->nbonds,bond_on,bond_off);
|
|
||||||
|
|
||||||
if (atom->avec->angles_allow)
|
if (atom->avec->angles_allow)
|
||||||
utils::logmesg(lmp," {} total angles, {} turned on, {} turned off\n",
|
utils::logmesg(lmp,fmtstr,atom->nangles,"angles",angle_on,angle_off);
|
||||||
atom->nangles,angle_on,angle_off);
|
|
||||||
|
|
||||||
if (atom->avec->dihedrals_allow)
|
if (atom->avec->dihedrals_allow)
|
||||||
utils::logmesg(lmp," {} total dihedrals, {} turned on, {} turned off\n",
|
utils::logmesg(lmp,fmtstr,atom->ndihedrals,"dihedrals",dihedral_on,dihedral_off);
|
||||||
atom->ndihedrals,dihedral_on,dihedral_off);
|
|
||||||
|
|
||||||
if (atom->avec->impropers_allow)
|
if (atom->avec->impropers_allow)
|
||||||
utils::logmesg(lmp," {} total impropers, {} turned on, {} turned off\n",
|
utils::logmesg(lmp,fmtstr,atom->nimpropers,"impropers",improper_on,improper_off);
|
||||||
atom->nimpropers,improper_on,improper_off);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// re-compute special list if requested
|
// re-compute special list if requested
|
||||||
|
|||||||
@ -66,7 +66,6 @@ class Dump : protected Pointers {
|
|||||||
char *multiname; // filename with % converted to cluster ID
|
char *multiname; // filename with % converted to cluster ID
|
||||||
MPI_Comm clustercomm; // MPI communicator within my cluster of procs
|
MPI_Comm clustercomm; // MPI communicator within my cluster of procs
|
||||||
|
|
||||||
int header_flag; // 0 = item, 2 = xyz
|
|
||||||
int flush_flag; // 0 if no flush, 1 if flush every dump
|
int flush_flag; // 0 if no flush, 1 if flush every dump
|
||||||
int sort_flag; // 1 if sorted output
|
int sort_flag; // 1 if sorted output
|
||||||
int balance_flag; // 1 if load balanced output
|
int balance_flag; // 1 if load balanced output
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -23,9 +22,7 @@
|
|||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
@ -36,15 +33,15 @@ using namespace FixConst;
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixBondHistory::FixBondHistory(LAMMPS *lmp, int narg, char **arg) :
|
FixBondHistory::FixBondHistory(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg)
|
Fix(lmp, narg, arg), bondstore(nullptr), id_fix(nullptr), id_array(nullptr)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (narg != 5) error->all(FLERR,"Illegal fix bond/history command");
|
if (narg != 5) error->all(FLERR, "Illegal fix bond/history command");
|
||||||
update_flag = utils::inumeric(FLERR,arg[3],false,lmp);
|
update_flag = utils::inumeric(FLERR, arg[3], false, lmp);
|
||||||
ndata = utils::inumeric(FLERR,arg[4],false,lmp);
|
ndata = utils::inumeric(FLERR, arg[4], false, lmp);
|
||||||
nbond = atom->bond_per_atom;
|
nbond = atom->bond_per_atom;
|
||||||
|
|
||||||
if (nbond == 0)
|
if (nbond == 0) error->all(FLERR, "Cannot store bond variables without any bonds");
|
||||||
error->all(FLERR, "Cannot store bond variables without any bonds");
|
|
||||||
|
|
||||||
stored_flag = false;
|
stored_flag = false;
|
||||||
restart_global = 1;
|
restart_global = 1;
|
||||||
@ -55,12 +52,8 @@ FixBondHistory::FixBondHistory(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// Prevents sequential calls to pre_exchange() without post_neighbor()
|
// Prevents sequential calls to pre_exchange() without post_neighbor()
|
||||||
updated_bond_flag = 0;
|
updated_bond_flag = 0;
|
||||||
|
|
||||||
bondstore = nullptr;
|
|
||||||
maxbond = 0;
|
maxbond = 0;
|
||||||
allocate();
|
allocate();
|
||||||
|
|
||||||
id_fix = nullptr;
|
|
||||||
id_array = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -68,8 +61,8 @@ FixBondHistory::FixBondHistory(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
FixBondHistory::~FixBondHistory()
|
FixBondHistory::~FixBondHistory()
|
||||||
{
|
{
|
||||||
if (id_fix && modify->nfix) modify->delete_fix(id_fix);
|
if (id_fix && modify->nfix) modify->delete_fix(id_fix);
|
||||||
delete [] id_fix;
|
delete[] id_fix;
|
||||||
delete [] id_array;
|
delete[] id_array;
|
||||||
|
|
||||||
memory->destroy(bondstore);
|
memory->destroy(bondstore);
|
||||||
}
|
}
|
||||||
@ -92,10 +85,10 @@ void FixBondHistory::post_constructor()
|
|||||||
|
|
||||||
id_fix = utils::strdup(id + std::string("_FIX_PROP_ATOM"));
|
id_fix = utils::strdup(id + std::string("_FIX_PROP_ATOM"));
|
||||||
id_array = utils::strdup(std::string("d2_") + id);
|
id_array = utils::strdup(std::string("d2_") + id);
|
||||||
modify->add_fix(fmt::format("{} {} property/atom {} {}",
|
modify->add_fix(fmt::format("{} {} property/atom {} {}", id_fix, group->names[igroup], id_array,
|
||||||
id_fix, group->names[igroup], id_array, nbond*ndata));
|
nbond * ndata));
|
||||||
int tmp1, tmp2;
|
int tmp1, tmp2;
|
||||||
index = atom->find_custom(&id_array[3],tmp1,tmp2);
|
index = atom->find_custom(&id_array[3], tmp1, tmp2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -103,7 +96,7 @@ void FixBondHistory::post_constructor()
|
|||||||
void FixBondHistory::update_atom_value(int i, int m, int idata, double value)
|
void FixBondHistory::update_atom_value(int i, int m, int idata, double value)
|
||||||
{
|
{
|
||||||
if (idata >= ndata || m > nbond) error->all(FLERR, "Index exceeded in fix bond history");
|
if (idata >= ndata || m > nbond) error->all(FLERR, "Index exceeded in fix bond history");
|
||||||
atom->darray[index][i][m*ndata+idata] = value;
|
atom->darray[index][i][m * ndata + idata] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -111,7 +104,7 @@ void FixBondHistory::update_atom_value(int i, int m, int idata, double value)
|
|||||||
double FixBondHistory::get_atom_value(int i, int m, int idata)
|
double FixBondHistory::get_atom_value(int i, int m, int idata)
|
||||||
{
|
{
|
||||||
if (idata >= ndata || m > nbond) error->all(FLERR, "Index exceeded in fix bond history");
|
if (idata >= ndata || m > nbond) error->all(FLERR, "Index exceeded in fix bond history");
|
||||||
return atom->darray[index][i][m*ndata+idata];
|
return atom->darray[index][i][m * ndata + idata];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -148,15 +141,13 @@ void FixBondHistory::pre_exchange()
|
|||||||
i2 = bondlist[n][1];
|
i2 = bondlist[n][1];
|
||||||
|
|
||||||
// skip bond if already broken
|
// skip bond if already broken
|
||||||
if (bondlist[n][2] <= 0) {
|
if (bondlist[n][2] <= 0) { continue; }
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i1 < nlocal) {
|
if (i1 < nlocal) {
|
||||||
for (m = 0; m < num_bond[i1]; m++) {
|
for (m = 0; m < num_bond[i1]; m++) {
|
||||||
if (bond_atom[i1][m] == tag[i2]) {
|
if (bond_atom[i1][m] == tag[i2]) {
|
||||||
for (idata = 0; idata < ndata; idata++) {
|
for (idata = 0; idata < ndata; idata++) {
|
||||||
stored[i1][m*ndata+idata] = bondstore[n][idata];
|
stored[i1][m * ndata + idata] = bondstore[n][idata];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,7 +157,7 @@ void FixBondHistory::pre_exchange()
|
|||||||
for (m = 0; m < num_bond[i2]; m++) {
|
for (m = 0; m < num_bond[i2]; m++) {
|
||||||
if (bond_atom[i2][m] == tag[i1]) {
|
if (bond_atom[i2][m] == tag[i1]) {
|
||||||
for (idata = 0; idata < ndata; idata++) {
|
for (idata = 0; idata < ndata; idata++) {
|
||||||
stored[i2][m*ndata+idata] = bondstore[n][idata];
|
stored[i2][m * ndata + idata] = bondstore[n][idata];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,9 +172,11 @@ void FixBondHistory::pre_exchange()
|
|||||||
void FixBondHistory::allocate()
|
void FixBondHistory::allocate()
|
||||||
{
|
{
|
||||||
//Ideally would just ask ntopo for maxbond, but protected
|
//Ideally would just ask ntopo for maxbond, but protected
|
||||||
if (comm->nprocs == 1) maxbond = atom->nbonds;
|
if (comm->nprocs == 1)
|
||||||
else maxbond = static_cast<int> (LB_FACTOR * atom->nbonds / comm->nprocs);
|
maxbond = atom->nbonds;
|
||||||
memory->create(bondstore,maxbond,ndata,"fix_bond_store:bondstore");
|
else
|
||||||
|
maxbond = static_cast<int>(LB_FACTOR * atom->nbonds / comm->nprocs);
|
||||||
|
memory->create(bondstore, maxbond, ndata, "fix_bond_store:bondstore");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -193,7 +186,7 @@ void FixBondHistory::setup_post_neighbor()
|
|||||||
//Grow array if number of bonds has increased
|
//Grow array if number of bonds has increased
|
||||||
while (neighbor->nbondlist >= maxbond) {
|
while (neighbor->nbondlist >= maxbond) {
|
||||||
maxbond += DELTA;
|
maxbond += DELTA;
|
||||||
memory->grow(bondstore,maxbond,ndata,"fix_bond_store:bondstore");
|
memory->grow(bondstore, maxbond, ndata, "fix_bond_store:bondstore");
|
||||||
}
|
}
|
||||||
|
|
||||||
pre_exchange();
|
pre_exchange();
|
||||||
@ -210,7 +203,7 @@ void FixBondHistory::post_neighbor()
|
|||||||
//Grow array if number of bonds has increased
|
//Grow array if number of bonds has increased
|
||||||
while (neighbor->nbondlist >= maxbond) {
|
while (neighbor->nbondlist >= maxbond) {
|
||||||
maxbond += DELTA;
|
maxbond += DELTA;
|
||||||
memory->grow(bondstore,maxbond,ndata,"fix_bond_store:bondstore");
|
memory->grow(bondstore, maxbond, ndata, "fix_bond_store:bondstore");
|
||||||
}
|
}
|
||||||
|
|
||||||
int i1, i2, n, m, idata;
|
int i1, i2, n, m, idata;
|
||||||
@ -228,25 +221,23 @@ void FixBondHistory::post_neighbor()
|
|||||||
i2 = bondlist[n][1];
|
i2 = bondlist[n][1];
|
||||||
|
|
||||||
// skip bond if already broken
|
// skip bond if already broken
|
||||||
if (bondlist[n][2] <= 0) {
|
if (bondlist[n][2] <= 0) { continue; }
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i1 < nlocal) {
|
if (i1 < nlocal) {
|
||||||
for (m = 0; m < num_bond[i1]; m++) {
|
for (m = 0; m < num_bond[i1]; m++) {
|
||||||
if (bond_atom[i1][m] == tag[i2]) {
|
if (bond_atom[i1][m] == tag[i2]) {
|
||||||
for (idata = 0; idata < ndata; idata++) {
|
for (idata = 0; idata < ndata; idata++) {
|
||||||
bondstore[n][idata] = stored[i1][m*ndata+idata];
|
bondstore[n][idata] = stored[i1][m * ndata + idata];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i2 < nlocal){
|
if (i2 < nlocal) {
|
||||||
for (m = 0; m < num_bond[i2]; m++) {
|
for (m = 0; m < num_bond[i2]; m++) {
|
||||||
if (bond_atom[i2][m] == tag[i1]) {
|
if (bond_atom[i2][m] == tag[i1]) {
|
||||||
for (idata = 0; idata < ndata; idata++) {
|
for (idata = 0; idata < ndata; idata++) {
|
||||||
bondstore[n][idata] = stored[i2][m*ndata+idata];
|
bondstore[n][idata] = stored[i2][m * ndata + idata];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,8 +264,8 @@ void FixBondHistory::write_restart(FILE *fp)
|
|||||||
|
|
||||||
if (comm->me == 0) {
|
if (comm->me == 0) {
|
||||||
int size = n * sizeof(double);
|
int size = n * sizeof(double);
|
||||||
fwrite(&size,sizeof(int),1,fp);
|
fwrite(&size, sizeof(int), 1, fp);
|
||||||
fwrite(list,sizeof(double),n,fp);
|
fwrite(list, sizeof(double), n, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +275,7 @@ void FixBondHistory::restart(char *buf)
|
|||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
double *list = (double *) buf;
|
double *list = (double *) buf;
|
||||||
stored_flag = static_cast<int> (list[n++]);
|
stored_flag = static_cast<int>(list[n++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -295,8 +286,7 @@ void FixBondHistory::set_arrays(int i)
|
|||||||
{
|
{
|
||||||
double **stored = atom->darray[index];
|
double **stored = atom->darray[index];
|
||||||
for (int m = 0; m < nbond; m++)
|
for (int m = 0; m < nbond; m++)
|
||||||
for (int idata = 0; idata < ndata; idata++)
|
for (int idata = 0; idata < ndata; idata++) stored[i][m * ndata + idata] = 0.0;
|
||||||
stored[i][m*ndata+idata] = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -306,8 +296,7 @@ void FixBondHistory::set_arrays(int i)
|
|||||||
void FixBondHistory::delete_history(int i, int m)
|
void FixBondHistory::delete_history(int i, int m)
|
||||||
{
|
{
|
||||||
double **stored = atom->darray[index];
|
double **stored = atom->darray[index];
|
||||||
for (int idata = 0; idata < ndata; idata ++)
|
for (int idata = 0; idata < ndata; idata++) stored[i][m * ndata + idata] = 0.0;
|
||||||
stored[i][m*ndata+idata] = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -319,8 +308,8 @@ void FixBondHistory::shift_history(int i, int m, int k)
|
|||||||
if (m == k) return;
|
if (m == k) return;
|
||||||
|
|
||||||
double **stored = atom->darray[index];
|
double **stored = atom->darray[index];
|
||||||
for (int idata = 0; idata < ndata; idata ++)
|
for (int idata = 0; idata < ndata; idata++)
|
||||||
stored[i][m*ndata+idata] = stored[i][k*ndata+idata];
|
stored[i][m * ndata + idata] = stored[i][k * ndata + idata];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -334,16 +323,15 @@ void FixBondHistory::cache_history(int i, int m)
|
|||||||
// Order tags to create a unique key pair
|
// Order tags to create a unique key pair
|
||||||
tagint max_tag = MAX(atom->tag[i], atom->bond_atom[i][m]);
|
tagint max_tag = MAX(atom->tag[i], atom->bond_atom[i][m]);
|
||||||
tagint min_tag = MIN(atom->tag[i], atom->bond_atom[i][m]);
|
tagint min_tag = MIN(atom->tag[i], atom->bond_atom[i][m]);
|
||||||
std::pair<tagint, tagint> key = std::make_pair(min_tag, max_tag);
|
auto key = std::make_pair(min_tag, max_tag);
|
||||||
|
|
||||||
// Copy data to vector
|
// Copy data to vector
|
||||||
double **stored = atom->darray[index];
|
double **stored = atom->darray[index];
|
||||||
std::vector <double> data;
|
std::vector<double> data;
|
||||||
for (int idata = 0; idata < ndata; idata ++)
|
for (int idata = 0; idata < ndata; idata++) data.push_back(stored[i][m * ndata + idata]);
|
||||||
data.push_back(stored[i][m*ndata+idata]);
|
|
||||||
|
|
||||||
// Add data to cache
|
// Add data to cache
|
||||||
cached_histories.insert(std::make_pair(key,data));
|
cached_histories.insert(std::make_pair(key, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -355,16 +343,15 @@ void FixBondHistory::check_cache(int i, int m)
|
|||||||
// Order tags to create a unique key pair
|
// Order tags to create a unique key pair
|
||||||
tagint max_tag = MAX(atom->tag[i], atom->bond_atom[i][m]);
|
tagint max_tag = MAX(atom->tag[i], atom->bond_atom[i][m]);
|
||||||
tagint min_tag = MIN(atom->tag[i], atom->bond_atom[i][m]);
|
tagint min_tag = MIN(atom->tag[i], atom->bond_atom[i][m]);
|
||||||
std::pair<tagint, tagint> key = std::make_pair(min_tag, max_tag);
|
auto key = std::make_pair(min_tag, max_tag);
|
||||||
|
|
||||||
// Check if it exists, if so, copy data
|
// Check if it exists, if so, copy data
|
||||||
double **stored = atom->darray[index];
|
double **stored = atom->darray[index];
|
||||||
std::vector <double> data;
|
std::vector<double> data;
|
||||||
auto pos = cached_histories.find(key);
|
auto pos = cached_histories.find(key);
|
||||||
if (pos != cached_histories.end()) {
|
if (pos != cached_histories.end()) {
|
||||||
data = pos->second;
|
data = pos->second;
|
||||||
for (int idata = 0; idata < ndata; idata ++)
|
for (int idata = 0; idata < ndata; idata++) stored[i][m * ndata + idata] = data[idata];
|
||||||
stored[i][m*ndata+idata] = data[idata];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifdef FIX_CLASS
|
#ifdef FIX_CLASS
|
||||||
// clang-format off
|
// clang-format off
|
||||||
FixStyle(BOND_HISTORY,FixBondHistory)
|
FixStyle(BOND_HISTORY,FixBondHistory);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -30,7 +30,6 @@ namespace LAMMPS_NS {
|
|||||||
|
|
||||||
class FixBondHistory : public Fix {
|
class FixBondHistory : public Fix {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FixBondHistory(class LAMMPS *, int, char **);
|
FixBondHistory(class LAMMPS *, int, char **);
|
||||||
~FixBondHistory() override;
|
~FixBondHistory() override;
|
||||||
int setmask() override;
|
int setmask() override;
|
||||||
@ -48,25 +47,24 @@ class FixBondHistory : public Fix {
|
|||||||
double get_atom_value(int, int, int);
|
double get_atom_value(int, int, int);
|
||||||
|
|
||||||
// methods to reorder/delete elements of atom->bond_atom
|
// methods to reorder/delete elements of atom->bond_atom
|
||||||
void delete_history(int,int);
|
void delete_history(int, int);
|
||||||
void shift_history(int,int,int);
|
void shift_history(int, int, int);
|
||||||
void cache_history(int,int);
|
void cache_history(int, int);
|
||||||
void check_cache(int,int);
|
void check_cache(int, int);
|
||||||
void clear_cache();
|
void clear_cache();
|
||||||
|
|
||||||
// if data is temporarily stored while the bond_atom array
|
// if data is temporarily stored while the bond_atom array
|
||||||
// is being reordered, use map of vectors with pairs for keys
|
// is being reordered, use map of vectors with pairs for keys
|
||||||
// to enable quick look up
|
// to enable quick look up
|
||||||
std::map<std::pair<tagint, tagint>, std::vector <double>> cached_histories;
|
std::map<std::pair<tagint, tagint>, std::vector<double>> cached_histories;
|
||||||
|
|
||||||
double **bondstore;
|
double **bondstore;
|
||||||
int stored_flag;
|
int stored_flag;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void allocate();
|
void allocate();
|
||||||
|
|
||||||
int update_flag; //Flag whether history values can evolve
|
int update_flag; //Flag whether history values can evolve
|
||||||
int updated_bond_flag;
|
int updated_bond_flag;
|
||||||
int nbond, maxbond, ndata;
|
int nbond, maxbond, ndata;
|
||||||
int index;
|
int index;
|
||||||
@ -93,7 +91,4 @@ E: Cannot store bond variables without any bonds
|
|||||||
|
|
||||||
Atoms must have a nonzero number of bonds to store data
|
Atoms must have a nonzero number of bonds to store data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -26,22 +25,21 @@
|
|||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
|
||||||
enum{MOLECULE,CHARGE,RMASS,IVEC,DVEC,IARRAY,DARRAY};
|
enum { MOLECULE, CHARGE, RMASS, IVEC, DVEC, IARRAY, DARRAY };
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg),
|
Fix(lmp, narg, arg), nvalue(0), styles(nullptr), index(nullptr), astyle(nullptr)
|
||||||
nvalue(0), styles(nullptr), index(nullptr), astyle(nullptr)
|
|
||||||
{
|
{
|
||||||
if (narg < 4) error->all(FLERR,"Illegal fix property/atom command");
|
if (narg < 4) error->all(FLERR, "Illegal fix property/atom command");
|
||||||
|
|
||||||
restart_peratom = 1;
|
restart_peratom = 1;
|
||||||
wd_section = 1;
|
wd_section = 1;
|
||||||
create_attribute = 1;
|
create_attribute = 1;
|
||||||
|
|
||||||
int iarg = 3;
|
int iarg = 3;
|
||||||
nvalue = narg-iarg;
|
nvalue = narg - iarg;
|
||||||
styles = new int[nvalue];
|
styles = new int[nvalue];
|
||||||
cols = new int[nvalue];
|
cols = new int[nvalue];
|
||||||
index = new int[nvalue];
|
index = new int[nvalue];
|
||||||
@ -54,33 +52,30 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
values_peratom = 0;
|
values_peratom = 0;
|
||||||
|
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg],"mol") == 0) {
|
if (strcmp(arg[iarg], "mol") == 0) {
|
||||||
if (atom->molecule_flag)
|
if (atom->molecule_flag)
|
||||||
error->all(FLERR,"Fix property/atom mol when atom_style already has molecule attribute");
|
error->all(FLERR, "Fix property/atom mol when atom_style already has molecule attribute");
|
||||||
if (molecule_flag)
|
if (molecule_flag) error->all(FLERR, "Fix property/atom cannot specify mol twice");
|
||||||
error->all(FLERR,"Fix property/atom cannot specify mol twice");
|
|
||||||
styles[nvalue] = MOLECULE;
|
styles[nvalue] = MOLECULE;
|
||||||
cols[nvalue] = 0;
|
cols[nvalue] = 0;
|
||||||
atom->molecule_flag = molecule_flag = 1;
|
atom->molecule_flag = molecule_flag = 1;
|
||||||
values_peratom++;
|
values_peratom++;
|
||||||
nvalue++;
|
nvalue++;
|
||||||
iarg++;
|
iarg++;
|
||||||
} else if (strcmp(arg[iarg],"q") == 0) {
|
} else if (strcmp(arg[iarg], "q") == 0) {
|
||||||
if (atom->q_flag)
|
if (atom->q_flag)
|
||||||
error->all(FLERR,"Fix property/atom q when atom_style already has charge attribute");
|
error->all(FLERR, "Fix property/atom q when atom_style already has charge attribute");
|
||||||
if (q_flag)
|
if (q_flag) error->all(FLERR, "Fix property/atom cannot specify q twice");
|
||||||
error->all(FLERR,"Fix property/atom cannot specify q twice");
|
|
||||||
styles[nvalue] = CHARGE;
|
styles[nvalue] = CHARGE;
|
||||||
cols[nvalue] = 0;
|
cols[nvalue] = 0;
|
||||||
atom->q_flag = q_flag = 1;
|
atom->q_flag = q_flag = 1;
|
||||||
values_peratom++;
|
values_peratom++;
|
||||||
nvalue++;
|
nvalue++;
|
||||||
iarg++;
|
iarg++;
|
||||||
} else if (strcmp(arg[iarg],"rmass") == 0) {
|
} else if (strcmp(arg[iarg], "rmass") == 0) {
|
||||||
if (atom->rmass_flag)
|
if (atom->rmass_flag)
|
||||||
error->all(FLERR,"Fix property/atom rmass when atom_style already has rmass attribute");
|
error->all(FLERR, "Fix property/atom rmass when atom_style already has rmass attribute");
|
||||||
if (rmass_flag)
|
if (rmass_flag) error->all(FLERR, "Fix property/atom cannot specify rmass twice");
|
||||||
error->all(FLERR,"Fix property/atom cannot specify rmass twice");
|
|
||||||
styles[nvalue] = RMASS;
|
styles[nvalue] = RMASS;
|
||||||
cols[nvalue] = 0;
|
cols[nvalue] = 0;
|
||||||
atom->rmass_flag = rmass_flag = 1;
|
atom->rmass_flag = rmass_flag = 1;
|
||||||
@ -88,51 +83,49 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
nvalue++;
|
nvalue++;
|
||||||
iarg++;
|
iarg++;
|
||||||
|
|
||||||
// custom atom vector
|
// custom atom vector
|
||||||
|
|
||||||
} else if (utils::strmatch(arg[iarg],"^i_")) {
|
} else if (utils::strmatch(arg[iarg], "^i_")) {
|
||||||
styles[nvalue] = IVEC;
|
styles[nvalue] = IVEC;
|
||||||
int flag,ncols;
|
int flag, ncols;
|
||||||
index[nvalue] = atom->find_custom(&arg[iarg][2],flag,ncols);
|
index[nvalue] = atom->find_custom(&arg[iarg][2], flag, ncols);
|
||||||
if (index[nvalue] >= 0)
|
if (index[nvalue] >= 0) error->all(FLERR, "Fix property/atom vector name already exists");
|
||||||
error->all(FLERR,"Fix property/atom vector name already exists");
|
|
||||||
if (ReadData::is_data_section(id))
|
if (ReadData::is_data_section(id))
|
||||||
error->all(FLERR,"Fix property/atom fix ID must not be a data file section name");
|
error->all(FLERR, "Fix property/atom fix ID must not be a data file section name");
|
||||||
index[nvalue] = atom->add_custom(&arg[iarg][2],0,0);
|
index[nvalue] = atom->add_custom(&arg[iarg][2], 0, 0);
|
||||||
cols[nvalue] = 0;
|
cols[nvalue] = 0;
|
||||||
values_peratom++;
|
values_peratom++;
|
||||||
nvalue++;
|
nvalue++;
|
||||||
iarg++;
|
iarg++;
|
||||||
|
|
||||||
} else if (utils::strmatch(arg[iarg],"^d_")) {
|
} else if (utils::strmatch(arg[iarg], "^d_")) {
|
||||||
styles[nvalue] = DVEC;
|
styles[nvalue] = DVEC;
|
||||||
int flag,ncols;
|
int flag, ncols;
|
||||||
index[nvalue] = atom->find_custom(&arg[iarg][2],flag,ncols);
|
index[nvalue] = atom->find_custom(&arg[iarg][2], flag, ncols);
|
||||||
if (index[nvalue] >= 0)
|
if (index[nvalue] >= 0) error->all(FLERR, "Fix property/atom vector name already exists");
|
||||||
error->all(FLERR,"Fix property/atom vector name already exists");
|
|
||||||
if (ReadData::is_data_section(id))
|
if (ReadData::is_data_section(id))
|
||||||
error->all(FLERR,"Fix property/atom fix ID must not be a data file section name");
|
error->all(FLERR, "Fix property/atom fix ID must not be a data file section name");
|
||||||
index[nvalue] = atom->add_custom(&arg[iarg][2],1,0);
|
index[nvalue] = atom->add_custom(&arg[iarg][2], 1, 0);
|
||||||
cols[nvalue] = 0;
|
cols[nvalue] = 0;
|
||||||
values_peratom++;
|
values_peratom++;
|
||||||
nvalue++;
|
nvalue++;
|
||||||
iarg++;
|
iarg++;
|
||||||
|
|
||||||
// custom atom array
|
// custom atom array
|
||||||
|
|
||||||
} else if (utils::strmatch(arg[iarg],"^[id]2_")) {
|
} else if (utils::strmatch(arg[iarg], "^[id]2_")) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix property/atom command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix property/atom command");
|
||||||
|
|
||||||
int which,flag,ncols;
|
int which, flag, ncols;
|
||||||
which = atom->find_custom(&arg[iarg][3],flag,ncols);
|
which = atom->find_custom(&arg[iarg][3], flag, ncols);
|
||||||
if (which >= 0)
|
if (which >= 0)
|
||||||
error->all(FLERR,"Fix property/atom array name {} already exists", &arg[iarg][3]);
|
error->all(FLERR, "Fix property/atom array name {} already exists", &arg[iarg][3]);
|
||||||
if (ReadData::is_data_section(id))
|
if (ReadData::is_data_section(id))
|
||||||
error->all(FLERR,"Fix property/atom fix ID must not be a data file section name");
|
error->all(FLERR, "Fix property/atom fix ID must not be a data file section name");
|
||||||
|
|
||||||
ncols = utils::inumeric(FLERR,arg[iarg+1],true,lmp);
|
ncols = utils::inumeric(FLERR, arg[iarg + 1], true, lmp);
|
||||||
if (ncols < 1)
|
if (ncols < 1)
|
||||||
error->all(FLERR,"Invalid array columns number {} in fix property/atom", ncols);
|
error->all(FLERR, "Invalid array columns number {} in fix property/atom", ncols);
|
||||||
|
|
||||||
if (arg[iarg][0] == 'i') {
|
if (arg[iarg][0] == 'i') {
|
||||||
which = 0;
|
which = 0;
|
||||||
@ -141,26 +134,28 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
which = 1;
|
which = 1;
|
||||||
styles[nvalue] = DARRAY;
|
styles[nvalue] = DARRAY;
|
||||||
}
|
}
|
||||||
index[nvalue] = atom->add_custom(&arg[iarg][3],which,ncols);
|
index[nvalue] = atom->add_custom(&arg[iarg][3], which, ncols);
|
||||||
cols[nvalue] = ncols;
|
cols[nvalue] = ncols;
|
||||||
values_peratom += ncols;
|
values_peratom += ncols;
|
||||||
nvalue++;
|
nvalue++;
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|
||||||
// no match
|
// no match
|
||||||
|
|
||||||
} else break;
|
} else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional args
|
// optional args
|
||||||
|
|
||||||
border = 0;
|
border = 0;
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg],"ghost") == 0) {
|
if (strcmp(arg[iarg], "ghost") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix property/atom command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix property/atom command");
|
||||||
border = utils::logical(FLERR,arg[iarg+1],false,lmp);
|
border = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else error->all(FLERR,"Illegal fix property/atom command");
|
} else
|
||||||
|
error->all(FLERR, "Illegal fix property/atom command");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (border) comm_border = values_peratom;
|
if (border) comm_border = values_peratom;
|
||||||
@ -170,12 +165,9 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (border == 0) {
|
if (border == 0) {
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
for (int i = 0; i < nvalue; i++)
|
for (int i = 0; i < nvalue; i++)
|
||||||
if (styles[i] == MOLECULE
|
if (styles[i] == MOLECULE || styles[i] == CHARGE || styles[i] == RMASS) flag = 1;
|
||||||
|| styles[i] == CHARGE
|
|
||||||
|| styles[i] == RMASS) flag = 1;
|
|
||||||
if (flag && comm->me == 0)
|
if (flag && comm->me == 0)
|
||||||
error->warning(FLERR,"Fix property/atom mol or charge or rmass "
|
error->warning(FLERR, "Fix property/atom mol or charge or rmass w/out ghost communication");
|
||||||
"w/out ghost communication");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// store current atom style
|
// store current atom style
|
||||||
@ -198,9 +190,9 @@ FixPropertyAtom::~FixPropertyAtom()
|
|||||||
{
|
{
|
||||||
// unregister callbacks to this fix from Atom class
|
// unregister callbacks to this fix from Atom class
|
||||||
|
|
||||||
atom->delete_callback(id,Atom::GROW);
|
atom->delete_callback(id, Atom::GROW);
|
||||||
atom->delete_callback(id,Atom::RESTART);
|
atom->delete_callback(id, Atom::RESTART);
|
||||||
if (border) atom->delete_callback(id,Atom::BORDER);
|
if (border) atom->delete_callback(id, Atom::BORDER);
|
||||||
|
|
||||||
// deallocate per-atom vectors in Atom class
|
// deallocate per-atom vectors in Atom class
|
||||||
// set ptrs to a null pointer, so they no longer exist for Atom class
|
// set ptrs to a null pointer, so they no longer exist for Atom class
|
||||||
@ -219,20 +211,20 @@ FixPropertyAtom::~FixPropertyAtom()
|
|||||||
memory->destroy(atom->rmass);
|
memory->destroy(atom->rmass);
|
||||||
atom->rmass = nullptr;
|
atom->rmass = nullptr;
|
||||||
} else if (styles[nv] == IVEC) {
|
} else if (styles[nv] == IVEC) {
|
||||||
atom->remove_custom(index[nv],0,cols[nv]);
|
atom->remove_custom(index[nv], 0, cols[nv]);
|
||||||
} else if (styles[nv] == DVEC) {
|
} else if (styles[nv] == DVEC) {
|
||||||
atom->remove_custom(index[nv],1,cols[nv]);
|
atom->remove_custom(index[nv], 1, cols[nv]);
|
||||||
} else if (styles[nv] == IARRAY) {
|
} else if (styles[nv] == IARRAY) {
|
||||||
atom->remove_custom(index[nv],0,cols[nv]);
|
atom->remove_custom(index[nv], 0, cols[nv]);
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
atom->remove_custom(index[nv],1,cols[nv]);
|
atom->remove_custom(index[nv], 1, cols[nv]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] styles;
|
delete[] styles;
|
||||||
delete [] cols;
|
delete[] cols;
|
||||||
delete [] index;
|
delete[] index;
|
||||||
delete [] astyle;
|
delete[] astyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -250,8 +242,8 @@ void FixPropertyAtom::init()
|
|||||||
// error if atom style has changed since fix was defined
|
// error if atom style has changed since fix was defined
|
||||||
// don't allow this because user could change to style that defines molecule,q
|
// don't allow this because user could change to style that defines molecule,q
|
||||||
|
|
||||||
if (strcmp(astyle,atom->atom_style) != 0)
|
if (strcmp(astyle, atom->atom_style) != 0)
|
||||||
error->all(FLERR,"Atom style was redefined after using fix property/atom");
|
error->all(FLERR, "Atom style was redefined after using fix property/atom");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -261,7 +253,7 @@ void FixPropertyAtom::init()
|
|||||||
|
|
||||||
void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf, tagint id_offset)
|
void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf, tagint id_offset)
|
||||||
{
|
{
|
||||||
int j,k,m,ncol;
|
int j, k, m, ncol;
|
||||||
tagint itag;
|
tagint itag;
|
||||||
char *next;
|
char *next;
|
||||||
|
|
||||||
@ -279,18 +271,18 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf, tagint
|
|||||||
tagint map_tag_max = atom->map_tag_max;
|
tagint map_tag_max = atom->map_tag_max;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
next = strchr(buf,'\n');
|
next = strchr(buf, '\n');
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ValueTokenizer values(buf);
|
ValueTokenizer values(buf);
|
||||||
if ((int)values.count() != values_peratom+1)
|
if ((int) values.count() != values_peratom + 1)
|
||||||
error->all(FLERR,"Incorrect format in {} section of data file: {}"
|
error->all(FLERR, "Incorrect format in {} section of data file: {} expected {} and got {}",
|
||||||
" expected {} and got {}",keyword,buf,values_peratom+1,values.count());
|
keyword, buf, values_peratom + 1, values.count());
|
||||||
|
|
||||||
itag = values.next_tagint() + id_offset;
|
itag = values.next_tagint() + id_offset;
|
||||||
if (itag <= 0 || itag > map_tag_max)
|
if (itag <= 0 || itag > map_tag_max)
|
||||||
error->all(FLERR,"Invalid atom ID {} in {} section of data file",itag, keyword);
|
error->all(FLERR, "Invalid atom ID {} in {} section of data file", itag, keyword);
|
||||||
|
|
||||||
// assign words in line to per-atom vectors
|
// assign words in line to per-atom vectors
|
||||||
|
|
||||||
@ -308,17 +300,16 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf, tagint
|
|||||||
atom->dvector[index[j]][m] = values.next_double();
|
atom->dvector[index[j]][m] = values.next_double();
|
||||||
} else if (styles[j] == IARRAY) {
|
} else if (styles[j] == IARRAY) {
|
||||||
ncol = cols[j];
|
ncol = cols[j];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) atom->iarray[index[j]][m][k] = values.next_int();
|
||||||
atom->iarray[index[j]][m][k] = values.next_int();
|
|
||||||
} else if (styles[j] == DARRAY) {
|
} else if (styles[j] == DARRAY) {
|
||||||
ncol = cols[j];
|
ncol = cols[j];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) atom->darray[index[j]][m][k] = values.next_double();
|
||||||
atom->darray[index[j]][m][k] = values.next_double();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (TokenizerException &e) {
|
} catch (TokenizerException &e) {
|
||||||
error->all(FLERR,"Invalid format in {} section of data file '{}': {}",keyword, buf,e.what());
|
error->all(FLERR, "Invalid format in {} section of data file '{}': {}", keyword, buf,
|
||||||
|
e.what());
|
||||||
}
|
}
|
||||||
buf = next + 1;
|
buf = next + 1;
|
||||||
}
|
}
|
||||||
@ -358,7 +349,7 @@ void FixPropertyAtom::write_data_section_size(int /*mth*/, int &nx, int &ny)
|
|||||||
|
|
||||||
void FixPropertyAtom::write_data_section_pack(int /*mth*/, double **buf)
|
void FixPropertyAtom::write_data_section_pack(int /*mth*/, double **buf)
|
||||||
{
|
{
|
||||||
int i,k,ncol;
|
int i, k, ncol;
|
||||||
|
|
||||||
// 1st column = atom tag
|
// 1st column = atom tag
|
||||||
// rest of columns = per-atom values
|
// rest of columns = per-atom values
|
||||||
@ -394,15 +385,13 @@ void FixPropertyAtom::write_data_section_pack(int /*mth*/, double **buf)
|
|||||||
int **iarray = atom->iarray[index[nv]];
|
int **iarray = atom->iarray[index[nv]];
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) buf[i][icol + k] = ubuf(iarray[i][k]).d;
|
||||||
buf[i][icol+k] = ubuf(iarray[i][k]).d;
|
|
||||||
icol += ncol;
|
icol += ncol;
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
double **darray = atom->darray[index[nv]];
|
double **darray = atom->darray[index[nv]];
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) buf[i][icol + k] = darray[i][k];
|
||||||
buf[i][icol+k] = darray[i][k];
|
|
||||||
icol += ncol;
|
icol += ncol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,21 +406,30 @@ void FixPropertyAtom::write_data_section_pack(int /*mth*/, double **buf)
|
|||||||
|
|
||||||
void FixPropertyAtom::write_data_section_keyword(int /*mth*/, FILE *fp)
|
void FixPropertyAtom::write_data_section_keyword(int /*mth*/, FILE *fp)
|
||||||
{
|
{
|
||||||
if (nvalue == 1 && styles[0] == MOLECULE) fprintf(fp,"\nMolecules\n\n");
|
if (nvalue == 1 && styles[0] == MOLECULE)
|
||||||
else if (nvalue == 1 && styles[0] == CHARGE) fprintf(fp,"\nCharges\n\n");
|
fprintf(fp, "\nMolecules\n\n");
|
||||||
|
else if (nvalue == 1 && styles[0] == CHARGE)
|
||||||
|
fprintf(fp, "\nCharges\n\n");
|
||||||
else {
|
else {
|
||||||
fprintf(fp,"\n%s #",id);
|
fprintf(fp, "\n%s #", id);
|
||||||
// write column hint as comment
|
// write column hint as comment
|
||||||
for (int i = 0; i < nvalue; ++i) {
|
for (int i = 0; i < nvalue; ++i) {
|
||||||
if (styles[i] == MOLECULE) fputs(" mol",fp);
|
if (styles[i] == MOLECULE)
|
||||||
else if (styles[i] == CHARGE) fputs(" q",fp);
|
fputs(" mol", fp);
|
||||||
else if (styles[i] == RMASS) fputs(" rmass",fp);
|
else if (styles[i] == CHARGE)
|
||||||
else if (styles[i] == IVEC) fprintf(fp," i_%s", atom->ivname[index[i]]);
|
fputs(" q", fp);
|
||||||
else if (styles[i] == DVEC) fprintf(fp, " d_%s", atom->dvname[index[i]]);
|
else if (styles[i] == RMASS)
|
||||||
else if (styles[i] == IARRAY) fprintf(fp, " i_%s", atom->ianame[index[i]]);
|
fputs(" rmass", fp);
|
||||||
else if (styles[i] == DARRAY) fprintf(fp, " d_%s", atom->daname[index[i]]);
|
else if (styles[i] == IVEC)
|
||||||
|
fprintf(fp, " i_%s", atom->ivname[index[i]]);
|
||||||
|
else if (styles[i] == DVEC)
|
||||||
|
fprintf(fp, " d_%s", atom->dvname[index[i]]);
|
||||||
|
else if (styles[i] == IARRAY)
|
||||||
|
fprintf(fp, " i_%s", atom->ianame[index[i]]);
|
||||||
|
else if (styles[i] == DARRAY)
|
||||||
|
fprintf(fp, " d_%s", atom->daname[index[i]]);
|
||||||
}
|
}
|
||||||
fputs("\n\n",fp);
|
fputs("\n\n", fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,39 +440,36 @@ void FixPropertyAtom::write_data_section_keyword(int /*mth*/, FILE *fp)
|
|||||||
only called by proc 0
|
only called by proc 0
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixPropertyAtom::write_data_section(int /*mth*/, FILE *fp,
|
void FixPropertyAtom::write_data_section(int /*mth*/, FILE *fp, int n, double **buf, int /*index*/)
|
||||||
int n, double **buf, int /*index*/)
|
|
||||||
{
|
{
|
||||||
int k,icol,ncol,nv;
|
int k, icol, ncol, nv;
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
line = fmt::format("{}",(tagint) ubuf(buf[i][0]).i);
|
line = fmt::format("{}", (tagint) ubuf(buf[i][0]).i);
|
||||||
icol = 1;
|
icol = 1;
|
||||||
for (nv = 0; nv < nvalue; nv++) {
|
for (nv = 0; nv < nvalue; nv++) {
|
||||||
if (styles[nv] == MOLECULE)
|
if (styles[nv] == MOLECULE)
|
||||||
line += fmt::format(" {}",(tagint) ubuf(buf[i][icol++]).i);
|
line += fmt::format(" {}", (tagint) ubuf(buf[i][icol++]).i);
|
||||||
else if (styles[nv] == CHARGE)
|
else if (styles[nv] == CHARGE)
|
||||||
line += fmt::format(" {}",buf[i][icol++]);
|
line += fmt::format(" {}", buf[i][icol++]);
|
||||||
else if (styles[nv] == RMASS)
|
else if (styles[nv] == RMASS)
|
||||||
line += fmt::format(" {}",buf[i][icol++]);
|
line += fmt::format(" {}", buf[i][icol++]);
|
||||||
else if (styles[nv] == IVEC)
|
else if (styles[nv] == IVEC)
|
||||||
line += fmt::format(" {}",(int) ubuf(buf[i][icol++]).i);
|
line += fmt::format(" {}", (int) ubuf(buf[i][icol++]).i);
|
||||||
else if (styles[nv] == DVEC)
|
else if (styles[nv] == DVEC)
|
||||||
line += fmt::format(" {}",buf[i][icol++]);
|
line += fmt::format(" {}", buf[i][icol++]);
|
||||||
else if (styles[nv] == IARRAY) {
|
else if (styles[nv] == IARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) line += fmt::format(" {}", (int) ubuf(buf[i][icol + k]).i);
|
||||||
line += fmt::format(" {}",(int) ubuf(buf[i][icol+k]).i);
|
|
||||||
icol += ncol;
|
icol += ncol;
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) line += fmt::format(" {}", buf[i][icol + k]);
|
||||||
line += fmt::format(" {}",buf[i][icol+k]);
|
|
||||||
icol += ncol;
|
icol += ncol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt::print(fp,line+"\n");
|
fmt::print(fp, line + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,13 +481,20 @@ double FixPropertyAtom::memory_usage()
|
|||||||
{
|
{
|
||||||
double bytes = 0.0;
|
double bytes = 0.0;
|
||||||
for (int m = 0; m < nvalue; m++) {
|
for (int m = 0; m < nvalue; m++) {
|
||||||
if (styles[m] == MOLECULE) bytes = atom->nmax * sizeof(tagint);
|
if (styles[m] == MOLECULE)
|
||||||
else if (styles[m] == CHARGE) bytes = atom->nmax * sizeof(double);
|
bytes = atom->nmax * sizeof(tagint);
|
||||||
else if (styles[m] == RMASS) bytes = atom->nmax * sizeof(double);
|
else if (styles[m] == CHARGE)
|
||||||
else if (styles[m] == IVEC) bytes = atom->nmax * sizeof(int);
|
bytes = atom->nmax * sizeof(double);
|
||||||
else if (styles[m] == DVEC) bytes = atom->nmax * sizeof(double);
|
else if (styles[m] == RMASS)
|
||||||
else if (styles[m] == IARRAY) bytes = (size_t) atom->nmax * cols[m] * sizeof(int);
|
bytes = atom->nmax * sizeof(double);
|
||||||
else if (styles[m] == DARRAY) bytes = (size_t) atom->nmax * cols[m] * sizeof(double);
|
else if (styles[m] == IVEC)
|
||||||
|
bytes = atom->nmax * sizeof(int);
|
||||||
|
else if (styles[m] == DVEC)
|
||||||
|
bytes = atom->nmax * sizeof(double);
|
||||||
|
else if (styles[m] == IARRAY)
|
||||||
|
bytes = (size_t) atom->nmax * cols[m] * sizeof(int);
|
||||||
|
else if (styles[m] == DARRAY)
|
||||||
|
bytes = (size_t) atom->nmax * cols[m] * sizeof(double);
|
||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
@ -508,33 +510,33 @@ void FixPropertyAtom::grow_arrays(int nmax)
|
|||||||
{
|
{
|
||||||
for (int nv = 0; nv < nvalue; nv++) {
|
for (int nv = 0; nv < nvalue; nv++) {
|
||||||
if (styles[nv] == MOLECULE) {
|
if (styles[nv] == MOLECULE) {
|
||||||
memory->grow(atom->molecule,nmax,"atom:molecule");
|
memory->grow(atom->molecule, nmax, "atom:molecule");
|
||||||
size_t nbytes = (nmax-nmax_old) * sizeof(tagint);
|
size_t nbytes = (nmax - nmax_old) * sizeof(tagint);
|
||||||
memset(&atom->molecule[nmax_old],0,nbytes);
|
memset(&atom->molecule[nmax_old], 0, nbytes);
|
||||||
} else if (styles[nv] == CHARGE) {
|
} else if (styles[nv] == CHARGE) {
|
||||||
memory->grow(atom->q,nmax,"atom:q");
|
memory->grow(atom->q, nmax, "atom:q");
|
||||||
size_t nbytes = (nmax-nmax_old) * sizeof(double);
|
size_t nbytes = (nmax - nmax_old) * sizeof(double);
|
||||||
memset(&atom->q[nmax_old],0,nbytes);
|
memset(&atom->q[nmax_old], 0, nbytes);
|
||||||
} else if (styles[nv] == RMASS) {
|
} else if (styles[nv] == RMASS) {
|
||||||
memory->grow(atom->rmass,nmax,"atom:rmass");
|
memory->grow(atom->rmass, nmax, "atom:rmass");
|
||||||
size_t nbytes = (nmax-nmax_old) * sizeof(double);
|
size_t nbytes = (nmax - nmax_old) * sizeof(double);
|
||||||
memset(&atom->rmass[nmax_old],0,nbytes);
|
memset(&atom->rmass[nmax_old], 0, nbytes);
|
||||||
} else if (styles[nv] == IVEC) {
|
} else if (styles[nv] == IVEC) {
|
||||||
memory->grow(atom->ivector[index[nv]],nmax,"atom:ivector");
|
memory->grow(atom->ivector[index[nv]], nmax, "atom:ivector");
|
||||||
size_t nbytes = (nmax-nmax_old) * sizeof(int);
|
size_t nbytes = (nmax - nmax_old) * sizeof(int);
|
||||||
memset(&atom->ivector[index[nv]][nmax_old],0,nbytes);
|
memset(&atom->ivector[index[nv]][nmax_old], 0, nbytes);
|
||||||
} else if (styles[nv] == DVEC) {
|
} else if (styles[nv] == DVEC) {
|
||||||
memory->grow(atom->dvector[index[nv]],nmax,"atom:dvector");
|
memory->grow(atom->dvector[index[nv]], nmax, "atom:dvector");
|
||||||
size_t nbytes = (nmax-nmax_old) * sizeof(double);
|
size_t nbytes = (nmax - nmax_old) * sizeof(double);
|
||||||
memset(&atom->dvector[index[nv]][nmax_old],0,nbytes);
|
memset(&atom->dvector[index[nv]][nmax_old], 0, nbytes);
|
||||||
} else if (styles[nv] == IARRAY) {
|
} else if (styles[nv] == IARRAY) {
|
||||||
memory->grow(atom->iarray[index[nv]],nmax,cols[nv],"atom:iarray");
|
memory->grow(atom->iarray[index[nv]], nmax, cols[nv], "atom:iarray");
|
||||||
size_t nbytes = (size_t) (nmax-nmax_old) * cols[nv] * sizeof(int);
|
size_t nbytes = (size_t) (nmax - nmax_old) * cols[nv] * sizeof(int);
|
||||||
if (nbytes) memset(&atom->iarray[index[nv]][nmax_old][0],0,nbytes);
|
if (nbytes) memset(&atom->iarray[index[nv]][nmax_old][0], 0, nbytes);
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
memory->grow(atom->darray[index[nv]],nmax,cols[nv],"atom:darray");
|
memory->grow(atom->darray[index[nv]], nmax, cols[nv], "atom:darray");
|
||||||
size_t nbytes = (size_t) (nmax-nmax_old) * cols[nv] * sizeof(double);
|
size_t nbytes = (size_t) (nmax - nmax_old) * cols[nv] * sizeof(double);
|
||||||
if (nbytes) memset(&atom->darray[index[nv]][nmax_old][0],0,nbytes);
|
if (nbytes) memset(&atom->darray[index[nv]][nmax_old][0], 0, nbytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,7 +549,7 @@ void FixPropertyAtom::grow_arrays(int nmax)
|
|||||||
|
|
||||||
void FixPropertyAtom::copy_arrays(int i, int j, int /*delflag*/)
|
void FixPropertyAtom::copy_arrays(int i, int j, int /*delflag*/)
|
||||||
{
|
{
|
||||||
int k,ncol;
|
int k, ncol;
|
||||||
|
|
||||||
for (int nv = 0; nv < nvalue; nv++) {
|
for (int nv = 0; nv < nvalue; nv++) {
|
||||||
if (styles[nv] == MOLECULE)
|
if (styles[nv] == MOLECULE)
|
||||||
@ -562,24 +564,21 @@ void FixPropertyAtom::copy_arrays(int i, int j, int /*delflag*/)
|
|||||||
atom->dvector[index[nv]][j] = atom->dvector[index[nv]][i];
|
atom->dvector[index[nv]][j] = atom->dvector[index[nv]][i];
|
||||||
else if (styles[nv] == IARRAY) {
|
else if (styles[nv] == IARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) atom->iarray[index[nv]][j][k] = atom->iarray[index[nv]][i][k];
|
||||||
atom->iarray[index[nv]][j][k] = atom->iarray[index[nv]][i][k];
|
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) atom->darray[index[nv]][j][k] = atom->darray[index[nv]][i][k];
|
||||||
atom->darray[index[nv]][j][k] = atom->darray[index[nv]][i][k];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
initialize one atom's storage values, called when atom is created
|
initialize one atom's storage values, called when atom is created
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixPropertyAtom::set_arrays(int i)
|
void FixPropertyAtom::set_arrays(int i)
|
||||||
{
|
{
|
||||||
int k,ncol;
|
int k, ncol;
|
||||||
|
|
||||||
for (int nv = 0; nv < nvalue; nv++) {
|
for (int nv = 0; nv < nvalue; nv++) {
|
||||||
if (styles[nv] == IVEC)
|
if (styles[nv] == IVEC)
|
||||||
@ -588,12 +587,10 @@ void FixPropertyAtom::set_arrays(int i)
|
|||||||
atom->dvector[index[nv]][i] = 0.0;
|
atom->dvector[index[nv]][i] = 0.0;
|
||||||
else if (styles[nv] == IARRAY) {
|
else if (styles[nv] == IARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) atom->iarray[index[nv]][i][k] = 0;
|
||||||
atom->iarray[index[nv]][i][k] = 0;
|
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) atom->darray[index[nv]][i][k] = 0.0;
|
||||||
atom->darray[index[nv]][i][k] = 0.0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -604,7 +601,7 @@ void FixPropertyAtom::set_arrays(int i)
|
|||||||
|
|
||||||
int FixPropertyAtom::pack_border(int n, int *list, double *buf)
|
int FixPropertyAtom::pack_border(int n, int *list, double *buf)
|
||||||
{
|
{
|
||||||
int i,j,k,ncol;
|
int i, j, k, ncol;
|
||||||
|
|
||||||
int m = 0;
|
int m = 0;
|
||||||
for (int nv = 0; nv < nvalue; nv++) {
|
for (int nv = 0; nv < nvalue; nv++) {
|
||||||
@ -643,16 +640,14 @@ int FixPropertyAtom::pack_border(int n, int *list, double *buf)
|
|||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
j = list[i];
|
j = list[i];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) buf[m++] = ubuf(iarray[j][k]).d;
|
||||||
buf[m++] = ubuf(iarray[j][k]).d;
|
|
||||||
}
|
}
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
double **darray = atom->darray[index[nv]];
|
double **darray = atom->darray[index[nv]];
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
j = list[i];
|
j = list[i];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) buf[m++] = darray[j][k];
|
||||||
buf[m++] = darray[j][k];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -666,49 +661,42 @@ int FixPropertyAtom::pack_border(int n, int *list, double *buf)
|
|||||||
|
|
||||||
int FixPropertyAtom::unpack_border(int n, int first, double *buf)
|
int FixPropertyAtom::unpack_border(int n, int first, double *buf)
|
||||||
{
|
{
|
||||||
int i,k,last,ncol;
|
int i, k, last, ncol;
|
||||||
|
|
||||||
int m = 0;
|
int m = 0;
|
||||||
for (int nv = 0; nv < nvalue; nv++) {
|
for (int nv = 0; nv < nvalue; nv++) {
|
||||||
if (styles[nv] == MOLECULE) {
|
if (styles[nv] == MOLECULE) {
|
||||||
tagint *molecule = atom->molecule;
|
tagint *molecule = atom->molecule;
|
||||||
last = first + n;
|
last = first + n;
|
||||||
for (i = first; i < last; i++)
|
for (i = first; i < last; i++) molecule[i] = (tagint) ubuf(buf[m++]).i;
|
||||||
molecule[i] = (tagint) ubuf(buf[m++]).i;
|
|
||||||
} else if (styles[nv] == CHARGE) {
|
} else if (styles[nv] == CHARGE) {
|
||||||
double *q = atom->q;
|
double *q = atom->q;
|
||||||
last = first + n;
|
last = first + n;
|
||||||
for (i = first; i < last; i++)
|
for (i = first; i < last; i++) q[i] = buf[m++];
|
||||||
q[i] = buf[m++];
|
|
||||||
} else if (styles[nv] == RMASS) {
|
} else if (styles[nv] == RMASS) {
|
||||||
double *rmass = atom->rmass;
|
double *rmass = atom->rmass;
|
||||||
last = first + n;
|
last = first + n;
|
||||||
for (i = first; i < last; i++)
|
for (i = first; i < last; i++) rmass[i] = buf[m++];
|
||||||
rmass[i] = buf[m++];
|
|
||||||
} else if (styles[nv] == IVEC) {
|
} else if (styles[nv] == IVEC) {
|
||||||
int *ivector = atom->ivector[index[nv]];
|
int *ivector = atom->ivector[index[nv]];
|
||||||
last = first + n;
|
last = first + n;
|
||||||
for (i = first; i < last; i++)
|
for (i = first; i < last; i++) ivector[i] = (int) ubuf(buf[m++]).i;
|
||||||
ivector[i] = (int) ubuf(buf[m++]).i;
|
|
||||||
} else if (styles[nv] == DVEC) {
|
} else if (styles[nv] == DVEC) {
|
||||||
double *dvector = atom->dvector[index[nv]];
|
double *dvector = atom->dvector[index[nv]];
|
||||||
last = first + n;
|
last = first + n;
|
||||||
for (i = first; i < last; i++)
|
for (i = first; i < last; i++) dvector[i] = buf[m++];
|
||||||
dvector[i] = buf[m++];
|
|
||||||
} else if (styles[nv] == IARRAY) {
|
} else if (styles[nv] == IARRAY) {
|
||||||
int **iarray = atom->iarray[index[nv]];
|
int **iarray = atom->iarray[index[nv]];
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
last = first + n;
|
last = first + n;
|
||||||
for (i = first; i < last; i++)
|
for (i = first; i < last; i++)
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) iarray[i][k] = (int) ubuf(buf[m++]).i;
|
||||||
iarray[i][k] = (int) ubuf(buf[m++]).i;
|
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
double **darray = atom->darray[index[nv]];
|
double **darray = atom->darray[index[nv]];
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
last = first + n;
|
last = first + n;
|
||||||
for (i = first; i < last; i++)
|
for (i = first; i < last; i++)
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) darray[i][k] = buf[m++];
|
||||||
darray[i][k] = buf[m++];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,23 +709,26 @@ int FixPropertyAtom::unpack_border(int n, int first, double *buf)
|
|||||||
|
|
||||||
int FixPropertyAtom::pack_exchange(int i, double *buf)
|
int FixPropertyAtom::pack_exchange(int i, double *buf)
|
||||||
{
|
{
|
||||||
int k,ncol;
|
int k, ncol;
|
||||||
|
|
||||||
int m = 0;
|
int m = 0;
|
||||||
for (int nv = 0; nv < nvalue; nv++) {
|
for (int nv = 0; nv < nvalue; nv++) {
|
||||||
if (styles[nv] == MOLECULE) buf[m++] = ubuf(atom->molecule[i]).d;
|
if (styles[nv] == MOLECULE)
|
||||||
else if (styles[nv] == CHARGE) buf[m++] = atom->q[i];
|
buf[m++] = ubuf(atom->molecule[i]).d;
|
||||||
else if (styles[nv] == RMASS) buf[m++] = atom->rmass[i];
|
else if (styles[nv] == CHARGE)
|
||||||
else if (styles[nv] == IVEC) buf[m++] = ubuf(atom->ivector[index[nv]][i]).d;
|
buf[m++] = atom->q[i];
|
||||||
else if (styles[nv] == DVEC) buf[m++] = atom->dvector[index[nv]][i];
|
else if (styles[nv] == RMASS)
|
||||||
|
buf[m++] = atom->rmass[i];
|
||||||
|
else if (styles[nv] == IVEC)
|
||||||
|
buf[m++] = ubuf(atom->ivector[index[nv]][i]).d;
|
||||||
|
else if (styles[nv] == DVEC)
|
||||||
|
buf[m++] = atom->dvector[index[nv]][i];
|
||||||
else if (styles[nv] == IARRAY) {
|
else if (styles[nv] == IARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) buf[m++] = ubuf(atom->iarray[index[nv]][i][k]).d;
|
||||||
buf[m++] = ubuf(atom->iarray[index[nv]][i][k]).d;
|
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) buf[m++] = atom->darray[index[nv]][i][k];
|
||||||
buf[m++] = atom->darray[index[nv]][i][k];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +741,7 @@ int FixPropertyAtom::pack_exchange(int i, double *buf)
|
|||||||
|
|
||||||
int FixPropertyAtom::unpack_exchange(int nlocal, double *buf)
|
int FixPropertyAtom::unpack_exchange(int nlocal, double *buf)
|
||||||
{
|
{
|
||||||
int k,ncol;
|
int k, ncol;
|
||||||
|
|
||||||
int m = 0;
|
int m = 0;
|
||||||
for (int nv = 0; nv < nvalue; nv++) {
|
for (int nv = 0; nv < nvalue; nv++) {
|
||||||
@ -766,12 +757,10 @@ int FixPropertyAtom::unpack_exchange(int nlocal, double *buf)
|
|||||||
atom->dvector[index[nv]][nlocal] = buf[m++];
|
atom->dvector[index[nv]][nlocal] = buf[m++];
|
||||||
else if (styles[nv] == IARRAY) {
|
else if (styles[nv] == IARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) atom->iarray[index[nv]][nlocal][k] = (int) ubuf(buf[m++]).i;
|
||||||
atom->iarray[index[nv]][nlocal][k] = (int) ubuf(buf[m++]).i;
|
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) atom->darray[index[nv]][nlocal][k] = buf[m++];
|
||||||
atom->darray[index[nv]][nlocal][k] = buf[m++];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,31 +773,34 @@ int FixPropertyAtom::unpack_exchange(int nlocal, double *buf)
|
|||||||
|
|
||||||
int FixPropertyAtom::pack_restart(int i, double *buf)
|
int FixPropertyAtom::pack_restart(int i, double *buf)
|
||||||
{
|
{
|
||||||
int k,ncol;
|
int k, ncol;
|
||||||
|
|
||||||
// pack buf[0] this way because other fixes unpack it
|
// pack buf[0] this way because other fixes unpack it
|
||||||
|
|
||||||
buf[0] = values_peratom+1;
|
buf[0] = values_peratom + 1;
|
||||||
|
|
||||||
int m = 1;
|
int m = 1;
|
||||||
for (int nv = 0; nv < nvalue; nv++) {
|
for (int nv = 0; nv < nvalue; nv++) {
|
||||||
if (styles[nv] == MOLECULE) buf[m++] = ubuf(atom->molecule[i]).d;
|
if (styles[nv] == MOLECULE)
|
||||||
else if (styles[nv] == CHARGE) buf[m++] = atom->q[i];
|
buf[m++] = ubuf(atom->molecule[i]).d;
|
||||||
else if (styles[nv] == RMASS) buf[m++] = atom->rmass[i];
|
else if (styles[nv] == CHARGE)
|
||||||
else if (styles[nv] == IVEC) buf[m++] = ubuf(atom->ivector[index[nv]][i]).d;
|
buf[m++] = atom->q[i];
|
||||||
else if (styles[nv] == DVEC) buf[m++] = atom->dvector[index[nv]][i];
|
else if (styles[nv] == RMASS)
|
||||||
|
buf[m++] = atom->rmass[i];
|
||||||
|
else if (styles[nv] == IVEC)
|
||||||
|
buf[m++] = ubuf(atom->ivector[index[nv]][i]).d;
|
||||||
|
else if (styles[nv] == DVEC)
|
||||||
|
buf[m++] = atom->dvector[index[nv]][i];
|
||||||
else if (styles[nv] == IARRAY) {
|
else if (styles[nv] == IARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) buf[m++] = ubuf(atom->iarray[index[nv]][i][k]).d;
|
||||||
buf[m++] = ubuf(atom->iarray[index[nv]][i][k]).d;
|
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) buf[m++] = atom->darray[index[nv]][i][k];
|
||||||
buf[m++] = atom->darray[index[nv]][i][k];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return values_peratom+1;
|
return values_peratom + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -817,14 +809,14 @@ int FixPropertyAtom::pack_restart(int i, double *buf)
|
|||||||
|
|
||||||
void FixPropertyAtom::unpack_restart(int nlocal, int nth)
|
void FixPropertyAtom::unpack_restart(int nlocal, int nth)
|
||||||
{
|
{
|
||||||
int k,ncol;
|
int k, ncol;
|
||||||
double **extra = atom->extra;
|
double **extra = atom->extra;
|
||||||
|
|
||||||
// skip to Nth set of extra values
|
// skip to Nth set of extra values
|
||||||
// unpack the Nth first values this way because other fixes pack them
|
// unpack the Nth first values this way because other fixes pack them
|
||||||
|
|
||||||
int m = 0;
|
int m = 0;
|
||||||
for (int i = 0; i < nth; i++) m += static_cast<int> (extra[nlocal][m]);
|
for (int i = 0; i < nth; i++) m += static_cast<int>(extra[nlocal][m]);
|
||||||
m++;
|
m++;
|
||||||
|
|
||||||
for (int nv = 0; nv < nvalue; nv++) {
|
for (int nv = 0; nv < nvalue; nv++) {
|
||||||
@ -844,8 +836,7 @@ void FixPropertyAtom::unpack_restart(int nlocal, int nth)
|
|||||||
atom->iarray[index[nv]][nlocal][k] = (int) ubuf(extra[nlocal][m++]).i;
|
atom->iarray[index[nv]][nlocal][k] = (int) ubuf(extra[nlocal][m++]).i;
|
||||||
} else if (styles[nv] == DARRAY) {
|
} else if (styles[nv] == DARRAY) {
|
||||||
ncol = cols[nv];
|
ncol = cols[nv];
|
||||||
for (k = 0; k < ncol; k++)
|
for (k = 0; k < ncol; k++) atom->darray[index[nv]][nlocal][k] = extra[nlocal][m++];
|
||||||
atom->darray[index[nv]][nlocal][k] = extra[nlocal][m++];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -856,7 +847,7 @@ void FixPropertyAtom::unpack_restart(int nlocal, int nth)
|
|||||||
|
|
||||||
int FixPropertyAtom::maxsize_restart()
|
int FixPropertyAtom::maxsize_restart()
|
||||||
{
|
{
|
||||||
return values_peratom+1;
|
return values_peratom + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -865,5 +856,5 @@ int FixPropertyAtom::maxsize_restart()
|
|||||||
|
|
||||||
int FixPropertyAtom::size_restart(int /*nlocal*/)
|
int FixPropertyAtom::size_restart(int /*nlocal*/)
|
||||||
{
|
{
|
||||||
return values_peratom+1;
|
return values_peratom + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,4 +123,3 @@ double FixStoreLocal::memory_usage()
|
|||||||
double bytes = (double) nmax * (double) nvalues * sizeof(double);
|
double bytes = (double) nmax * (double) nvalues * sizeof(double);
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -16,15 +15,12 @@
|
|||||||
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "atom_vec.h"
|
#include "atom_vec.h"
|
||||||
#include "comm.h"
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "neighbor.h"
|
|
||||||
#include "neigh_list.h"
|
#include "neigh_list.h"
|
||||||
|
#include "neighbor.h"
|
||||||
#include "pair.h"
|
#include "pair.h"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <vector>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
@ -33,15 +29,9 @@ using namespace FixConst;
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixUpdateSpecialBonds::FixUpdateSpecialBonds(LAMMPS *lmp, int narg, char **arg) :
|
FixUpdateSpecialBonds::FixUpdateSpecialBonds(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg)
|
Fix(lmp, narg, arg)
|
||||||
{
|
|
||||||
if (narg != 3) error->all(FLERR,"Illegal fix update/special/bonds command");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
FixUpdateSpecialBonds::~FixUpdateSpecialBonds()
|
|
||||||
{
|
{
|
||||||
|
if (narg != 3) error->all(FLERR, "Illegal fix update/special/bonds command");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -59,21 +49,18 @@ int FixUpdateSpecialBonds::setmask()
|
|||||||
void FixUpdateSpecialBonds::setup(int /*vflag*/)
|
void FixUpdateSpecialBonds::setup(int /*vflag*/)
|
||||||
{
|
{
|
||||||
// Require atoms know about all of their bonds and if they break
|
// Require atoms know about all of their bonds and if they break
|
||||||
if (force->newton_bond)
|
if (force->newton_bond) error->all(FLERR, "Fix update/special/bonds requires Newton bond off");
|
||||||
error->all(FLERR,"Fix update/special/bonds requires Newton bond off");
|
|
||||||
|
|
||||||
if (!atom->avec->bonds_allow)
|
if (!atom->avec->bonds_allow) error->all(FLERR, "Fix update/special/bonds requires atom bonds");
|
||||||
error->all(FLERR,"Fix update/special/bonds requires atom bonds");
|
|
||||||
|
|
||||||
// special lj must be 0 1 1 to censor pair forces between bonded particles
|
// special lj must be 0 1 1 to censor pair forces between bonded particles
|
||||||
// special coulomb must be 1 1 1 to ensure all pairs are included in the
|
// special coulomb must be 1 1 1 to ensure all pairs are included in the
|
||||||
// neighbor list and 1-3 and 1-4 special bond lists are skipped
|
// neighbor list and 1-3 and 1-4 special bond lists are skipped
|
||||||
if (force->special_lj[1] != 0.0 || force->special_lj[2] != 1.0 ||
|
if (force->special_lj[1] != 0.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0)
|
||||||
force->special_lj[3] != 1.0)
|
error->all(FLERR, "Fix update/special/bonds requires special LJ weights = 0,1,1");
|
||||||
error->all(FLERR,"Fix update/special/bonds requires special LJ weights = 0,1,1");
|
|
||||||
if (force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 ||
|
if (force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 ||
|
||||||
force->special_coul[3] != 1.0)
|
force->special_coul[3] != 1.0)
|
||||||
error->all(FLERR,"Fix update/special/bonds requires special Coulomb weights = 1,1,1");
|
error->all(FLERR, "Fix update/special/bonds requires special Coulomb weights = 1,1,1");
|
||||||
|
|
||||||
new_broken_pairs.clear();
|
new_broken_pairs.clear();
|
||||||
broken_pairs.clear();
|
broken_pairs.clear();
|
||||||
@ -107,7 +94,7 @@ void FixUpdateSpecialBonds::pre_exchange()
|
|||||||
for (m = 0; m < n1; m++)
|
for (m = 0; m < n1; m++)
|
||||||
if (slist[m] == tagj) break;
|
if (slist[m] == tagj) break;
|
||||||
n3 = nspecial[i][2];
|
n3 = nspecial[i][2];
|
||||||
for (; m < n3-1; m++) slist[m] = slist[m+1];
|
for (; m < n3 - 1; m++) slist[m] = slist[m + 1];
|
||||||
nspecial[i][0]--;
|
nspecial[i][0]--;
|
||||||
nspecial[i][1]--;
|
nspecial[i][1]--;
|
||||||
nspecial[i][2]--;
|
nspecial[i][2]--;
|
||||||
@ -119,7 +106,7 @@ void FixUpdateSpecialBonds::pre_exchange()
|
|||||||
for (m = 0; m < n1; m++)
|
for (m = 0; m < n1; m++)
|
||||||
if (slist[m] == tagi) break;
|
if (slist[m] == tagi) break;
|
||||||
n3 = nspecial[j][2];
|
n3 = nspecial[j][2];
|
||||||
for (; m < n3-1; m++) slist[m] = slist[m+1];
|
for (; m < n3 - 1; m++) slist[m] = slist[m + 1];
|
||||||
nspecial[j][0]--;
|
nspecial[j][0]--;
|
||||||
nspecial[j][1]--;
|
nspecial[j][1]--;
|
||||||
nspecial[j][2]--;
|
nspecial[j][2]--;
|
||||||
@ -135,14 +122,14 @@ void FixUpdateSpecialBonds::pre_exchange()
|
|||||||
|
|
||||||
void FixUpdateSpecialBonds::pre_force(int /*vflag*/)
|
void FixUpdateSpecialBonds::pre_force(int /*vflag*/)
|
||||||
{
|
{
|
||||||
int i1,i2,j,jj,jnum;
|
int i1, i2, j, jj, jnum;
|
||||||
int *jlist,*numneigh,**firstneigh;
|
int *jlist, *numneigh, **firstneigh;
|
||||||
tagint tag1, tag2;
|
tagint tag1, tag2;
|
||||||
|
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
tagint *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
NeighList *list = force->pair->list; // may need to be generalized to work with pair hybrid*
|
NeighList *list = force->pair->list; // may need to be generalized to work with pair hybrid*
|
||||||
numneigh = list->numneigh;
|
numneigh = list->numneigh;
|
||||||
firstneigh = list->firstneigh;
|
firstneigh = list->firstneigh;
|
||||||
|
|
||||||
@ -161,9 +148,8 @@ void FixUpdateSpecialBonds::pre_force(int /*vflag*/)
|
|||||||
jnum = numneigh[i1];
|
jnum = numneigh[i1];
|
||||||
for (jj = 0; jj < jnum; jj++) {
|
for (jj = 0; jj < jnum; jj++) {
|
||||||
j = jlist[jj];
|
j = jlist[jj];
|
||||||
j &= SPECIALMASK; // Clear special bond bits
|
j &= SPECIALMASK; // Clear special bond bits
|
||||||
if (tag[j] == tag2)
|
if (tag[j] == tag2) jlist[jj] = j;
|
||||||
jlist[jj] = j;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,13 +158,11 @@ void FixUpdateSpecialBonds::pre_force(int /*vflag*/)
|
|||||||
jnum = numneigh[i2];
|
jnum = numneigh[i2];
|
||||||
for (jj = 0; jj < jnum; jj++) {
|
for (jj = 0; jj < jnum; jj++) {
|
||||||
j = jlist[jj];
|
j = jlist[jj];
|
||||||
j &= SPECIALMASK; // Clear special bond bits
|
j &= SPECIALMASK; // Clear special bond bits
|
||||||
if (tag[j] == tag1)
|
if (tag[j] == tag1) jlist[jj] = j;
|
||||||
jlist[jj] = j;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new_broken_pairs.clear();
|
new_broken_pairs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,9 +170,7 @@ void FixUpdateSpecialBonds::pre_force(int /*vflag*/)
|
|||||||
|
|
||||||
void FixUpdateSpecialBonds::add_broken_bond(int i, int j)
|
void FixUpdateSpecialBonds::add_broken_bond(int i, int j)
|
||||||
{
|
{
|
||||||
tagint *tag = atom->tag;
|
auto tag_pair = std::make_pair(atom->tag[i], atom->tag[j]);
|
||||||
std::pair <tagint, tagint> tag_pair = std::make_pair(tag[i],tag[j]);
|
|
||||||
|
|
||||||
new_broken_pairs.push_back(tag_pair);
|
new_broken_pairs.push_back(tag_pair);
|
||||||
broken_pairs.push_back(tag_pair);
|
broken_pairs.push_back(tag_pair);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifdef FIX_CLASS
|
#ifdef FIX_CLASS
|
||||||
// clang-format off
|
// clang-format off
|
||||||
FixStyle(UPDATE_SPECIAL_BONDS,FixUpdateSpecialBonds)
|
FixStyle(UPDATE_SPECIAL_BONDS,FixUpdateSpecialBonds);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -22,26 +22,25 @@ FixStyle(UPDATE_SPECIAL_BONDS,FixUpdateSpecialBonds)
|
|||||||
|
|
||||||
#include "fix.h"
|
#include "fix.h"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class FixUpdateSpecialBonds : public Fix {
|
class FixUpdateSpecialBonds : public Fix {
|
||||||
public:
|
public:
|
||||||
FixUpdateSpecialBonds(class LAMMPS *, int, char **);
|
FixUpdateSpecialBonds(class LAMMPS *, int, char **);
|
||||||
~FixUpdateSpecialBonds();
|
int setmask() override;
|
||||||
int setmask();
|
void setup(int) override;
|
||||||
void setup(int);
|
void pre_exchange() override;
|
||||||
void pre_exchange();
|
void pre_force(int) override;
|
||||||
void pre_force(int);
|
void add_broken_bond(int, int);
|
||||||
void add_broken_bond(int,int);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Create two arrays to store bonds broken this timestep (new)
|
// Create two arrays to store bonds broken this timestep (new)
|
||||||
// and since the last neighbor list build
|
// and since the last neighbor list build
|
||||||
std::vector <std::pair<tagint, tagint>> new_broken_pairs;
|
std::vector<std::pair<tagint, tagint>> new_broken_pairs;
|
||||||
std::vector <std::pair<tagint, tagint>> broken_pairs;
|
std::vector<std::pair<tagint, tagint>> broken_pairs;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LAMMPS_NS
|
} // namespace LAMMPS_NS
|
||||||
|
|||||||
28
src/set.cpp
28
src/set.cpp
@ -950,28 +950,26 @@ void Set::set(int keyword)
|
|||||||
else
|
else
|
||||||
error->one(FLERR,"Cannot set quaternion for atom that has none");
|
error->one(FLERR,"Cannot set quaternion for atom that has none");
|
||||||
if (domain->dimension == 2 && (xvalue != 0.0 || yvalue != 0.0))
|
if (domain->dimension == 2 && (xvalue != 0.0 || yvalue != 0.0))
|
||||||
error->one(FLERR,"Cannot set quaternion with xy components "
|
error->one(FLERR,"Cannot set quaternion with xy components for 2d system");
|
||||||
"for 2d system");
|
|
||||||
|
|
||||||
double theta2 = MY_PI2 * wvalue/180.0;
|
const double theta2 = MY_PI2 * wvalue/180.0;
|
||||||
double sintheta2 = sin(theta2);
|
const double sintheta2 = sin(theta2);
|
||||||
|
double temp[4];
|
||||||
|
temp[0] = cos(theta2);
|
||||||
|
temp[1] = xvalue * sintheta2;
|
||||||
|
temp[2] = yvalue * sintheta2;
|
||||||
|
temp[3] = zvalue * sintheta2;
|
||||||
|
MathExtra::qnormalize(temp);
|
||||||
if (atom->quat_flag) {
|
if (atom->quat_flag) {
|
||||||
double temp[4];
|
|
||||||
temp[0] = cos(theta2);
|
|
||||||
temp[1] = xvalue * sintheta2;
|
|
||||||
temp[2] = yvalue * sintheta2;
|
|
||||||
temp[3] = zvalue * sintheta2;
|
|
||||||
MathExtra::qnormalize(temp);
|
|
||||||
quat2[i][0] = temp[0];
|
quat2[i][0] = temp[0];
|
||||||
quat2[i][1] = temp[1];
|
quat2[i][1] = temp[1];
|
||||||
quat2[i][2] = temp[2];
|
quat2[i][2] = temp[2];
|
||||||
quat2[i][3] = temp[3];
|
quat2[i][3] = temp[3];
|
||||||
} else {
|
} else {
|
||||||
quat[0] = cos(theta2);
|
quat[0] = temp[0];
|
||||||
quat[1] = xvalue * sintheta2;
|
quat[1] = temp[1];
|
||||||
quat[2] = yvalue * sintheta2;
|
quat[2] = temp[2];
|
||||||
quat[3] = zvalue * sintheta2;
|
quat[3] = temp[3];
|
||||||
MathExtra::qnormalize(quat);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user