From b6374bacfb13a4b9c7273c2d07dd5dd1dd055ba0 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 18 Dec 2019 08:56:03 -0700 Subject: [PATCH] enable replicate to work with local ptrs --- src/DIPOLE/atom_vec_dipole.cpp | 15 +++- src/DIPOLE/atom_vec_dipole.h | 5 ++ src/MOLECULE/atom_vec_angle.cpp | 39 ++++++---- src/MOLECULE/atom_vec_angle.h | 6 ++ src/MOLECULE/atom_vec_bond.cpp | 29 +++---- src/MOLECULE/atom_vec_bond.h | 10 ++- src/MOLECULE/atom_vec_full.cpp | 55 ++++++------- src/MOLECULE/atom_vec_full.h | 6 ++ src/MOLECULE/atom_vec_molecular.cpp | 55 ++++++------- src/MOLECULE/atom_vec_molecular.h | 6 ++ src/MOLECULE/atom_vec_template.cpp | 23 ++++-- src/MOLECULE/atom_vec_template.h | 5 ++ src/PERI/atom_vec_peri.cpp | 37 +++++---- src/PERI/atom_vec_peri.h | 7 ++ src/SPIN/atom_vec_spin.cpp | 29 +++++-- src/SPIN/atom_vec_spin.h | 5 ++ src/USER-DPD/atom_vec_dpd.cpp | 34 +++++--- src/USER-DPD/atom_vec_dpd.h | 7 ++ src/USER-EFF/atom_vec_electron.cpp | 25 ++++-- src/USER-EFF/atom_vec_electron.h | 6 ++ src/USER-MESO/atom_vec_edpd.cpp | 32 +++++--- src/USER-MESO/atom_vec_edpd.h | 7 ++ src/USER-MESO/atom_vec_mdpd.cpp | 24 ++++-- src/USER-MESO/atom_vec_mdpd.h | 6 ++ src/USER-MESO/atom_vec_tdpd.cpp | 14 +++- src/USER-MESO/atom_vec_tdpd.h | 5 ++ src/USER-SMD/atom_vec_smd.cpp | 90 ++++++++++++--------- src/USER-SMD/atom_vec_smd.h | 8 ++ src/USER-SPH/atom_vec_meso.cpp | 36 +++++---- src/USER-SPH/atom_vec_meso.h | 6 ++ src/atom.cpp | 83 +++++++------------- src/atom.h | 15 ++-- src/atom_vec.cpp | 6 +- src/atom_vec.h | 3 +- src/atom_vec_body.cpp | 58 +++++++------- src/atom_vec_body.h | 6 +- src/atom_vec_ellipsoid.cpp | 61 ++++++--------- src/atom_vec_ellipsoid.h | 6 +- src/atom_vec_hybrid.cpp | 16 ++-- src/atom_vec_hybrid.h | 3 +- src/atom_vec_line.cpp | 93 ++++++++++------------ src/atom_vec_line.h | 7 +- src/atom_vec_sphere.cpp | 45 +++++++---- src/atom_vec_sphere.h | 6 +- src/atom_vec_tri.cpp | 116 +++++++++++++--------------- src/atom_vec_tri.h | 7 +- src/replicate.cpp | 3 +- 47 files changed, 686 insertions(+), 480 deletions(-) diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index 5cdbab1b33..074a59d5a1 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -54,6 +54,16 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecDipole::grow_pointers() +{ + mu = atom->mu; +} + /* ---------------------------------------------------------------------- modify what AtomVec::data_atom() just unpacked or initialize other atom quantities @@ -61,6 +71,7 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) void AtomVecDipole::data_atom_post(int ilocal) { - double *mu = atom->mu[ilocal]; - mu[3] = sqrt(mu[0]*mu[0] + mu[1]*mu[1] + mu[2]*mu[2]); + double *mu_one = mu[ilocal]; + mu_one[3] = + sqrt(mu_one[0]*mu_one[0] + mu_one[1]*mu_one[1] + mu_one[2]*mu_one[2]); } diff --git a/src/DIPOLE/atom_vec_dipole.h b/src/DIPOLE/atom_vec_dipole.h index 45f33d109d..2030892a43 100644 --- a/src/DIPOLE/atom_vec_dipole.h +++ b/src/DIPOLE/atom_vec_dipole.h @@ -27,7 +27,12 @@ namespace LAMMPS_NS { class AtomVecDipole : public AtomVec { public: AtomVecDipole(class LAMMPS *); + + void grow_pointers(); void data_atom_post(int); + + private: + double **mu; }; } diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index 1bd6f9a071..f3ebe3258b 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -66,6 +66,20 @@ AtomVecAngle::~AtomVecAngle() delete [] angle_negative; } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecAngle::grow_pointers() +{ + num_bond = atom->num_bond; + bond_type = atom->bond_type; + num_angle = atom->num_angle; + angle_type = atom->angle_type; + nspecial = atom->nspecial; +} + /* ---------------------------------------------------------------------- modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ @@ -87,11 +101,6 @@ void AtomVecAngle::pack_restart_pre(int ilocal) // flip any negative types to positive and flag which ones - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; - int any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { @@ -120,15 +129,11 @@ void AtomVecAngle::pack_restart_post(int ilocal) // restore the flagged types to their negative values if (any_bond_negative) { - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; for (int m = 0; m < num_bond[ilocal]; m++) if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } if (any_angle_negative) { - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; for (int m = 0; m < num_angle[ilocal]; m++) if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m]; } @@ -140,9 +145,9 @@ void AtomVecAngle::pack_restart_post(int ilocal) void AtomVecAngle::unpack_restart_init(int ilocal) { - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- @@ -152,9 +157,9 @@ void AtomVecAngle::unpack_restart_init(int ilocal) void AtomVecAngle::data_atom_post(int ilocal) { - atom->num_bond[ilocal] = 0; - atom->num_angle[ilocal] = 0; - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + num_bond[ilocal] = 0; + num_angle[ilocal] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_angle.h b/src/MOLECULE/atom_vec_angle.h index 48e55b0988..0ce0b4baab 100644 --- a/src/MOLECULE/atom_vec_angle.h +++ b/src/MOLECULE/atom_vec_angle.h @@ -28,12 +28,18 @@ class AtomVecAngle : public AtomVec { public: AtomVecAngle(class LAMMPS *); ~AtomVecAngle(); + + void grow_pointers(); void pack_restart_pre(int); void pack_restart_post(int); void unpack_restart_init(int); void data_atom_post(int); private: + int *num_bond,*num_angle; + int **bond_type,**angle_type; + int **nspecial; + int any_bond_negative,any_angle_negative; int bond_per_atom,angle_per_atom; int *bond_negative,*angle_negative; diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 00e8e3260d..64a52fa80a 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -61,19 +61,17 @@ AtomVecBond::~AtomVecBond() } /* ---------------------------------------------------------------------- - grow atom arrays - must set local copy of body ptr - needed in replicate when 2 atom classes exist and pack_restart() is called + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() ------------------------------------------------------------------------- */ -void AtomVecBond::grow(int n) +void AtomVecBond::grow_pointers() { - AtomVec::grow(n); num_bond = atom->num_bond; bond_type = atom->bond_type; + nspecial = atom->nspecial; } - /* ---------------------------------------------------------------------- modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ @@ -90,9 +88,6 @@ void AtomVecBond::pack_restart_pre(int ilocal) // flip any negative types to positive and flag which ones - //int *num_bond = atom->num_bond; - //int **bond_type = atom->bond_type; - any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { @@ -112,8 +107,6 @@ void AtomVecBond::pack_restart_post(int ilocal) // restore the flagged types to their negative values if (any_bond_negative) { - //int *num_bond = atom->num_bond; - //int **bond_type = atom->bond_type; for (int m = 0; m < num_bond[ilocal]; m++) if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } @@ -125,9 +118,9 @@ void AtomVecBond::pack_restart_post(int ilocal) void AtomVecBond::unpack_restart_init(int ilocal) { - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- @@ -137,8 +130,8 @@ void AtomVecBond::unpack_restart_init(int ilocal) void AtomVecBond::data_atom_post(int ilocal) { - atom->num_bond[ilocal] = 0; - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + num_bond[ilocal] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_bond.h b/src/MOLECULE/atom_vec_bond.h index 90c4b1f217..c938655127 100644 --- a/src/MOLECULE/atom_vec_bond.h +++ b/src/MOLECULE/atom_vec_bond.h @@ -28,19 +28,21 @@ class AtomVecBond : public AtomVec { public: AtomVecBond(class LAMMPS *); ~AtomVecBond(); - void grow(int); + + void grow_pointers(); void pack_restart_pre(int); void pack_restart_post(int); void unpack_restart_init(int); void data_atom_post(int); private: + int *num_bond; + int **bond_type; + int **nspecial; + int any_bond_negative; int bond_per_atom; int *bond_negative; - - int *num_bond; - int **bond_type; }; } diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index be7c92ce93..89afae5005 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -88,6 +88,24 @@ AtomVecFull::~AtomVecFull() delete [] improper_negative; } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecFull::grow_pointers() +{ + num_bond = atom->num_bond; + bond_type = atom->bond_type; + num_angle = atom->num_angle; + angle_type = atom->angle_type; + num_dihedral = atom->num_dihedral; + dihedral_type = atom->dihedral_type; + num_improper = atom->num_improper; + improper_type = atom->improper_type; + nspecial = atom->nspecial; +} + /* ---------------------------------------------------------------------- modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ @@ -119,15 +137,6 @@ void AtomVecFull::pack_restart_pre(int ilocal) // flip any negative types to positive and flag which ones - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; - int *num_dihedral = atom->num_dihedral; - int **dihedral_type = atom->dihedral_type; - int *num_improper = atom->num_improper; - int **improper_type = atom->improper_type; - any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { @@ -174,30 +183,22 @@ void AtomVecFull::pack_restart_post(int ilocal) // restore the flagged types to their negative values if (any_bond_negative) { - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; for (int m = 0; m < num_bond[ilocal]; m++) if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } if (any_angle_negative) { - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; for (int m = 0; m < num_angle[ilocal]; m++) if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m]; } if (any_dihedral_negative) { - int *num_dihedral = atom->num_dihedral; - int **dihedral_type = atom->dihedral_type; for (int m = 0; m < num_dihedral[ilocal]; m++) if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; } if (any_improper_negative) { - int *num_improper = atom->num_improper; - int **improper_type = atom->improper_type; for (int m = 0; m < num_improper[ilocal]; m++) if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m]; @@ -210,9 +211,9 @@ void AtomVecFull::pack_restart_post(int ilocal) void AtomVecFull::unpack_restart_init(int ilocal) { - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- @@ -222,11 +223,11 @@ void AtomVecFull::unpack_restart_init(int ilocal) void AtomVecFull::data_atom_post(int ilocal) { - atom->num_bond[ilocal] = 0; - atom->num_angle[ilocal] = 0; - atom->num_dihedral[ilocal] = 0; - atom->num_improper[ilocal] = 0; - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + num_bond[ilocal] = 0; + num_angle[ilocal] = 0; + num_dihedral[ilocal] = 0; + num_improper[ilocal] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_full.h b/src/MOLECULE/atom_vec_full.h index 455bbd0d5e..1abd3351d3 100644 --- a/src/MOLECULE/atom_vec_full.h +++ b/src/MOLECULE/atom_vec_full.h @@ -28,12 +28,18 @@ class AtomVecFull : public AtomVec { public: AtomVecFull(class LAMMPS *); ~AtomVecFull(); + + void grow_pointers(); void pack_restart_pre(int); void pack_restart_post(int); void unpack_restart_init(int); void data_atom_post(int); private: + int *num_bond,*num_angle,*num_dihedral,*num_improper; + int **bond_type,**angle_type,**dihedral_type,**improper_type; + int **nspecial; + int any_bond_negative,any_angle_negative, any_dihedral_negative,any_improper_negative; int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index ea15216aee..c2b71468c0 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -88,6 +88,24 @@ AtomVecMolecular::~AtomVecMolecular() delete [] improper_negative; } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecMolecular::grow_pointers() +{ + num_bond = atom->num_bond; + bond_type = atom->bond_type; + num_angle = atom->num_angle; + angle_type = atom->angle_type; + num_dihedral = atom->num_dihedral; + dihedral_type = atom->dihedral_type; + num_improper = atom->num_improper; + improper_type = atom->improper_type; + nspecial = atom->nspecial; +} + /* ---------------------------------------------------------------------- modify values for AtomVec::pack_restart() to pack ------------------------------------------------------------------------- */ @@ -119,15 +137,6 @@ void AtomVecMolecular::pack_restart_pre(int ilocal) // flip any negative types to positive and flag which ones - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; - int *num_dihedral = atom->num_dihedral; - int **dihedral_type = atom->dihedral_type; - int *num_improper = atom->num_improper; - int **improper_type = atom->improper_type; - any_bond_negative = 0; for (int m = 0; m < num_bond[ilocal]; m++) { if (bond_type[ilocal][m] < 0) { @@ -174,30 +183,22 @@ void AtomVecMolecular::pack_restart_post(int ilocal) // restore the flagged types to their negative values if (any_bond_negative) { - int *num_bond = atom->num_bond; - int **bond_type = atom->bond_type; for (int m = 0; m < num_bond[ilocal]; m++) if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m]; } if (any_angle_negative) { - int *num_angle = atom->num_angle; - int **angle_type = atom->angle_type; for (int m = 0; m < num_angle[ilocal]; m++) if (angle_negative[m]) angle_type[ilocal][m] = -angle_type[ilocal][m]; } if (any_dihedral_negative) { - int *num_dihedral = atom->num_dihedral; - int **dihedral_type = atom->dihedral_type; for (int m = 0; m < num_dihedral[ilocal]; m++) if (dihedral_negative[m]) dihedral_type[ilocal][m] = -dihedral_type[ilocal][m]; } if (any_improper_negative) { - int *num_improper = atom->num_improper; - int **improper_type = atom->improper_type; for (int m = 0; m < num_improper[ilocal]; m++) if (improper_negative[m]) improper_type[ilocal][m] = -improper_type[ilocal][m]; @@ -210,9 +211,9 @@ void AtomVecMolecular::pack_restart_post(int ilocal) void AtomVecMolecular::unpack_restart_init(int ilocal) { - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } /* ---------------------------------------------------------------------- @@ -222,11 +223,11 @@ void AtomVecMolecular::unpack_restart_init(int ilocal) void AtomVecMolecular::data_atom_post(int ilocal) { - atom->num_bond[ilocal] = 0; - atom->num_angle[ilocal] = 0; - atom->num_dihedral[ilocal] = 0; - atom->num_improper[ilocal] = 0; - atom->nspecial[ilocal][0] = 0; - atom->nspecial[ilocal][1] = 0; - atom->nspecial[ilocal][2] = 0; + num_bond[ilocal] = 0; + num_angle[ilocal] = 0; + num_dihedral[ilocal] = 0; + num_improper[ilocal] = 0; + nspecial[ilocal][0] = 0; + nspecial[ilocal][1] = 0; + nspecial[ilocal][2] = 0; } diff --git a/src/MOLECULE/atom_vec_molecular.h b/src/MOLECULE/atom_vec_molecular.h index 5b79f8b5c6..bcfa13d9d3 100644 --- a/src/MOLECULE/atom_vec_molecular.h +++ b/src/MOLECULE/atom_vec_molecular.h @@ -28,12 +28,18 @@ class AtomVecMolecular : public AtomVec { public: AtomVecMolecular(class LAMMPS *); ~AtomVecMolecular(); + + void grow_pointers(); void pack_restart_pre(int); void pack_restart_post(int); void unpack_restart_init(int); void data_atom_post(int); private: + int *num_bond,*num_angle,*num_dihedral,*num_improper; + int **bond_type,**angle_type,**dihedral_type,**improper_type; + int **nspecial; + int any_bond_negative,any_angle_negative, any_dihedral_negative,any_improper_negative; int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom; diff --git a/src/MOLECULE/atom_vec_template.cpp b/src/MOLECULE/atom_vec_template.cpp index 546c19da12..97d4c865ba 100644 --- a/src/MOLECULE/atom_vec_template.cpp +++ b/src/MOLECULE/atom_vec_template.cpp @@ -96,14 +96,25 @@ void AtomVecTemplate::process_args(int narg, char **arg) } } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecTemplate::grow_pointers() +{ + molindex = atom->molindex; + molatom = atom->molatom; +} + /* ---------------------------------------------------------------------- initialize non-zero atom quantities ------------------------------------------------------------------------- */ void AtomVecTemplate::create_atom_post(int ilocal) { - atom->molindex[ilocal] = -1; - atom->molatom[ilocal] = -1; + molindex[ilocal] = -1; + molatom[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -113,11 +124,11 @@ void AtomVecTemplate::create_atom_post(int ilocal) void AtomVecTemplate::data_atom_post(int ilocal) { - int molindex = atom->molindex[ilocal]; - int molatom = atom->molatom[ilocal]; + int molindex_one = molindex[ilocal]; + int molatom_one = molatom[ilocal]; - if (molindex < 0 || molindex >= nset) + if (molindex_one < 0 || molindex_one >= nset) error->one(FLERR,"Invalid template index in Atoms section of data file"); - if (molatom < 0 || molatom >= onemols[molindex]->natoms) + if (molatom_one < 0 || molatom_one >= onemols[molindex_one]->natoms) error->one(FLERR,"Invalid template atom in Atoms section of data file"); } diff --git a/src/MOLECULE/atom_vec_template.h b/src/MOLECULE/atom_vec_template.h index 52ef5e70e1..3bf2ec6273 100644 --- a/src/MOLECULE/atom_vec_template.h +++ b/src/MOLECULE/atom_vec_template.h @@ -27,9 +27,14 @@ namespace LAMMPS_NS { class AtomVecTemplate : public AtomVec { public: AtomVecTemplate(class LAMMPS *); + + void grow_pointers(); void process_args(int, char **); void create_atom_post(int); void data_atom_post(int); + + private: + int *molindex,*molatom; }; } diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index 58ff9c54d9..46d03c35eb 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -69,18 +69,31 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecPeri::grow_pointers() +{ + rmass = atom->rmass; + vfrac = atom->vfrac; + s0 = atom->s0; + x0 = atom->x0; +} + /* ---------------------------------------------------------------------- initialize non-zero atom quantities ------------------------------------------------------------------------- */ void AtomVecPeri::create_atom_post(int ilocal) { - atom->vfrac[ilocal] = 1.0; - atom->rmass[ilocal] = 1.0; - atom->s0[ilocal] = DBL_MAX; - atom->x0[ilocal][0] = atom->x[ilocal][0]; - atom->x0[ilocal][1] = atom->x[ilocal][1]; - atom->x0[ilocal][2] = atom->x[ilocal][2]; + vfrac[ilocal] = 1.0; + rmass[ilocal] = 1.0; + s0[ilocal] = DBL_MAX; + x0[ilocal][0] = x[ilocal][0]; + x0[ilocal][1] = x[ilocal][1]; + x0[ilocal][2] = x[ilocal][2]; } /* ---------------------------------------------------------------------- @@ -90,12 +103,12 @@ void AtomVecPeri::create_atom_post(int ilocal) void AtomVecPeri::data_atom_post(int ilocal) { - atom->s0[ilocal] = DBL_MAX; - atom->x0[ilocal][0] = atom->x[ilocal][0]; - atom->x0[ilocal][1] = atom->x[ilocal][1]; - atom->x0[ilocal][2] = atom->x[ilocal][2]; + s0[ilocal] = DBL_MAX; + x0[ilocal][0] = x[ilocal][0]; + x0[ilocal][1] = x[ilocal][1]; + x0[ilocal][2] = x[ilocal][2]; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid mass in Atoms section of data file"); } @@ -124,14 +137,12 @@ void AtomVecPeri::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { - double *vfrac = atom->vfrac; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = vfrac[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { - double *s0 = atom->s0; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = s0[i]; else buf[n] = 0.0; diff --git a/src/PERI/atom_vec_peri.h b/src/PERI/atom_vec_peri.h index 13a62eb194..5739ea55c1 100644 --- a/src/PERI/atom_vec_peri.h +++ b/src/PERI/atom_vec_peri.h @@ -27,10 +27,17 @@ namespace LAMMPS_NS { class AtomVecPeri : public AtomVec { public: AtomVecPeri(class LAMMPS *); + + void grow_pointers(); void create_atom_post(int); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); + + private: + double *rmass,*vfrac,*s0; + double **x0; + }; } diff --git a/src/SPIN/atom_vec_spin.cpp b/src/SPIN/atom_vec_spin.cpp index 638a3b8021..1e745fd0c1 100644 --- a/src/SPIN/atom_vec_spin.cpp +++ b/src/SPIN/atom_vec_spin.cpp @@ -61,6 +61,18 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecSpin::grow_pointers() +{ + sp = atom->sp; + fm = atom->fm; + fm_long = atom->fm_long; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -69,9 +81,9 @@ AtomVecSpin::AtomVecSpin(LAMMPS *lmp) : AtomVec(lmp) void AtomVecSpin::force_clear(int n, size_t nbytes) { - memset(&atom->f[n][0],0,3*nbytes); - memset(&atom->fm[n][0],0,3*nbytes); - memset(&atom->fm_long[n][0],0,3*nbytes); + memset(&f[n][0],0,3*nbytes); + memset(&fm[n][0],0,3*nbytes); + memset(&fm_long[n][0],0,3*nbytes); } /* ---------------------------------------------------------------------- @@ -81,9 +93,10 @@ void AtomVecSpin::force_clear(int n, size_t nbytes) void AtomVecSpin::data_atom_post(int ilocal) { - double *sp = atom->sp[ilocal]; - double inorm = 1.0/sqrt(sp[0]*sp[0] + sp[1]*sp[1] + sp[2]*sp[2]); - sp[0] *= inorm; - sp[1] *= inorm; - sp[2] *= inorm; + double *sp_one = sp[ilocal]; + double norm = + 1.0/sqrt(sp_one[0]*sp_one[0] + sp_one[1]*sp_one[1] + sp_one[2]*sp_one[2]); + sp_one[0] *= norm; + sp_one[1] *= norm; + sp_one[2] *= norm; } diff --git a/src/SPIN/atom_vec_spin.h b/src/SPIN/atom_vec_spin.h index c68f3a0419..f24791605d 100644 --- a/src/SPIN/atom_vec_spin.h +++ b/src/SPIN/atom_vec_spin.h @@ -27,8 +27,13 @@ namespace LAMMPS_NS { class AtomVecSpin : public AtomVec { public: AtomVecSpin(class LAMMPS *); + + void grow_pointers(); void force_clear(int, size_t); void data_atom_post(int); + + private: + double **sp,**fm,**fm_long; }; } diff --git a/src/USER-DPD/atom_vec_dpd.cpp b/src/USER-DPD/atom_vec_dpd.cpp index 124a081191..34efd9bc2b 100644 --- a/src/USER-DPD/atom_vec_dpd.cpp +++ b/src/USER-DPD/atom_vec_dpd.cpp @@ -52,14 +52,30 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecDPD::grow_pointers() +{ + rho = atom->rho; + dpdTheta = atom->dpdTheta; + uCond = atom->uCond; + uMech = atom->uMech; + uChem = atom->uChem; + uCG = atom->uCG; + uCGnew = atom->uCGnew; +} + /* ---------------------------------------------------------------------- initialize other atom quantities after AtomVec::unpack_restart() ------------------------------------------------------------------------- */ void AtomVecDPD::unpack_restart_init(int ilocal) { - atom->uCG[ilocal] = 0.0; - atom->uCGnew[ilocal] = 0.0; + uCG[ilocal] = 0.0; + uCGnew[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -69,14 +85,14 @@ void AtomVecDPD::unpack_restart_init(int ilocal) void AtomVecDPD::data_atom_post(int ilocal) { - atom->rho[ilocal] = 0.0; - atom->uCond[ilocal] = 0.0; - atom->uMech[ilocal] = 0.0; - atom->uChem[ilocal] = 0.0; - atom->uCG[ilocal] = 0.0; - atom->uCGnew[ilocal] = 0.0; + rho[ilocal] = 0.0; + uCond[ilocal] = 0.0; + uMech[ilocal] = 0.0; + uChem[ilocal] = 0.0; + uCG[ilocal] = 0.0; + uCGnew[ilocal] = 0.0; - if (atom->dpdTheta[ilocal] <= 0) + if (dpdTheta[ilocal] <= 0) error->one(FLERR,"Internal temperature in Atoms section of date file " "must be > zero"); } diff --git a/src/USER-DPD/atom_vec_dpd.h b/src/USER-DPD/atom_vec_dpd.h index 20c8a9a2d2..61abc658b8 100644 --- a/src/USER-DPD/atom_vec_dpd.h +++ b/src/USER-DPD/atom_vec_dpd.h @@ -27,8 +27,15 @@ namespace LAMMPS_NS { class AtomVecDPD : public AtomVec { public: AtomVecDPD(class LAMMPS *); + + void grow_pointers(); void unpack_restart_init(int); void data_atom_post(int); + +private: + double *rho,*dpdTheta; + double *uCond,*uMech,*uChem; + double *uCG,*uCGnew; }; } diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index 0ac56c48a3..0912fb0498 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -69,6 +69,19 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecElectron::grow_pointers() +{ + spin = atom->spin; + eradius = atom->eradius; + ervel = atom->ervel; + erforce = atom->erforce; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -76,7 +89,7 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) void AtomVecElectron::force_clear(int n, size_t nbytes) { - memset(&atom->erforce[n],0,nbytes); + memset(&erforce[n],0,nbytes); } /* ---------------------------------------------------------------------- @@ -85,8 +98,8 @@ void AtomVecElectron::force_clear(int n, size_t nbytes) void AtomVecElectron::create_atom_post(int ilocal) { - atom->spin[ilocal] = 1; - atom->eradius[ilocal] = 1.0; + spin[ilocal] = 1; + eradius[ilocal] = 1.0; } /* ---------------------------------------------------------------------- @@ -96,7 +109,7 @@ void AtomVecElectron::create_atom_post(int ilocal) void AtomVecElectron::data_atom_post(int ilocal) { - atom->ervel[ilocal] = 0.0; + ervel[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -126,28 +139,24 @@ void AtomVecElectron::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { - int *spin = atom->spin; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = spin[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { - double *eradius = atom->eradius; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = eradius[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 2) { - double *ervel = atom->ervel; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = ervel[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 3) { - double *erforce = atom->erforce; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = erforce[i]; else buf[n] = 0.0; diff --git a/src/USER-EFF/atom_vec_electron.h b/src/USER-EFF/atom_vec_electron.h index fabb03438d..9175ca52f7 100644 --- a/src/USER-EFF/atom_vec_electron.h +++ b/src/USER-EFF/atom_vec_electron.h @@ -27,11 +27,17 @@ namespace LAMMPS_NS { class AtomVecElectron : public AtomVec { public: AtomVecElectron(class LAMMPS *); + + void grow_pointers(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); + +private: + int *spin; + double *eradius,*ervel,*erforce; }; } diff --git a/src/USER-MESO/atom_vec_edpd.cpp b/src/USER-MESO/atom_vec_edpd.cpp index e06ac633ec..d08a626fad 100644 --- a/src/USER-MESO/atom_vec_edpd.cpp +++ b/src/USER-MESO/atom_vec_edpd.cpp @@ -67,6 +67,20 @@ void AtomVecEDPD::init() error->all(FLERR,"Atom style edpd requires lj units"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecEDPD::grow_pointers() +{ + edpd_cv = atom->edpd_cv; + edpd_temp = atom->edpd_temp; + edpd_flux = atom->edpd_flux; + vest = atom->vest; + vest_temp = atom->vest_temp; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -74,7 +88,7 @@ void AtomVecEDPD::init() void AtomVecEDPD::force_clear(int n, size_t nbytes) { - memset(&atom->edpd_flux[n],0,nbytes); + memset(&edpd_flux[n],0,nbytes); } /* ---------------------------------------------------------------------- @@ -83,9 +97,9 @@ void AtomVecEDPD::force_clear(int n, size_t nbytes) void AtomVecEDPD::create_atom_post(int ilocal) { - atom->edpd_temp[ilocal] = 1.0; - atom->edpd_cv[ilocal]= 1.0e5; - atom->vest_temp[ilocal] = atom->edpd_temp[ilocal]; + edpd_temp[ilocal] = 1.0; + edpd_cv[ilocal]= 1.0e5; + vest_temp[ilocal] = edpd_temp[ilocal]; } /* ---------------------------------------------------------------------- @@ -95,9 +109,9 @@ void AtomVecEDPD::create_atom_post(int ilocal) void AtomVecEDPD::data_atom_post(int ilocal) { - atom->edpd_flux[ilocal] = 0.0; - atom->vest[ilocal][0] = 0.0; - atom->vest[ilocal][1] = 0.0; - atom->vest[ilocal][2] = 0.0; - atom->vest_temp[ilocal] = atom->edpd_temp[ilocal]; + edpd_flux[ilocal] = 0.0; + vest[ilocal][0] = 0.0; + vest[ilocal][1] = 0.0; + vest[ilocal][2] = 0.0; + vest_temp[ilocal] = edpd_temp[ilocal]; } diff --git a/src/USER-MESO/atom_vec_edpd.h b/src/USER-MESO/atom_vec_edpd.h index bb667ae792..a69c44a035 100644 --- a/src/USER-MESO/atom_vec_edpd.h +++ b/src/USER-MESO/atom_vec_edpd.h @@ -28,9 +28,16 @@ class AtomVecEDPD : public AtomVec { public: AtomVecEDPD(class LAMMPS *); void init(); + + void grow_pointers(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); + + private: + double *edpd_cv,*edpd_temp,*edpd_flux; + double **vest; + double *vest_temp; }; } diff --git a/src/USER-MESO/atom_vec_mdpd.cpp b/src/USER-MESO/atom_vec_mdpd.cpp index b87ff14c3c..0acaaf6253 100644 --- a/src/USER-MESO/atom_vec_mdpd.cpp +++ b/src/USER-MESO/atom_vec_mdpd.cpp @@ -61,6 +61,18 @@ void AtomVecMDPD::init() error->all(FLERR,"Atom style mdpd requires lj units"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecMDPD::grow_pointers() +{ + rho = atom->rho; + drho = atom->drho; + vest = atom->vest; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -68,7 +80,7 @@ void AtomVecMDPD::init() void AtomVecMDPD::force_clear(int n, size_t nbytes) { - memset(&atom->drho[n],0,nbytes); + memset(&drho[n],0,nbytes); } /* ---------------------------------------------------------------------- @@ -78,10 +90,10 @@ void AtomVecMDPD::force_clear(int n, size_t nbytes) void AtomVecMDPD::data_atom_post(int ilocal) { - atom->drho[ilocal] = 0.0; - atom->vest[ilocal][0] = 0.0; - atom->vest[ilocal][1] = 0.0; - atom->vest[ilocal][2] = 0.0; + drho[ilocal] = 0.0; + vest[ilocal][0] = 0.0; + vest[ilocal][1] = 0.0; + vest[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -109,14 +121,12 @@ void AtomVecMDPD::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { - double *rho = atom->rho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = rho[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { - double *drho = atom->drho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = drho[i]; else buf[n] = 0.0; diff --git a/src/USER-MESO/atom_vec_mdpd.h b/src/USER-MESO/atom_vec_mdpd.h index 0eb4fff2df..55f5e9bb2d 100644 --- a/src/USER-MESO/atom_vec_mdpd.h +++ b/src/USER-MESO/atom_vec_mdpd.h @@ -28,10 +28,16 @@ class AtomVecMDPD : public AtomVec { public: AtomVecMDPD(class LAMMPS *); void init(); + + void grow_pointers(); void force_clear(int, size_t); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); + + private: + double *rho,*drho; + double **vest; }; } diff --git a/src/USER-MESO/atom_vec_tdpd.cpp b/src/USER-MESO/atom_vec_tdpd.cpp index 5734fcf9ad..f50fe168d6 100644 --- a/src/USER-MESO/atom_vec_tdpd.cpp +++ b/src/USER-MESO/atom_vec_tdpd.cpp @@ -80,6 +80,18 @@ void AtomVecTDPD::init() error->all(FLERR,"Atom style tdpd requires lj units"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecTDPD::grow_pointers() +{ + cc_flux = atom->cc_flux; + vest = atom->vest; +} + + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -87,7 +99,7 @@ void AtomVecTDPD::init() void AtomVecTDPD::force_clear(int n, size_t nbytes) { - memset(&atom->cc_flux[n][0],0,cc_species*nbytes); + memset(&cc_flux[n][0],0,cc_species*nbytes); } /* ---------------------------------------------------------------------- diff --git a/src/USER-MESO/atom_vec_tdpd.h b/src/USER-MESO/atom_vec_tdpd.h index 7321859fb4..971696cc5c 100644 --- a/src/USER-MESO/atom_vec_tdpd.h +++ b/src/USER-MESO/atom_vec_tdpd.h @@ -29,10 +29,15 @@ class AtomVecTDPD : public AtomVec { AtomVecTDPD(class LAMMPS *); void process_args(int, char **); void init(); + + void grow_pointers(); void force_clear(int, size_t); void data_atom_post(int); protected: + double **cc_flux; + double **vest; + int cc_species; }; diff --git a/src/USER-SMD/atom_vec_smd.cpp b/src/USER-SMD/atom_vec_smd.cpp index 9f0ed04a09..4c8126d2cc 100644 --- a/src/USER-SMD/atom_vec_smd.cpp +++ b/src/USER-SMD/atom_vec_smd.cpp @@ -62,11 +62,11 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) // except: fields_data_atom & fields_data_vel must match data file fields_grow = (char *) - "de vfrac rmass x0 radius contact_radius molecule " - "smd_data_9 e vest smd_stress " + "e de vfrac rmass x0 radius contact_radius molecule " + "smd_data_9 vest smd_stress " "eff_plastic_strain eff_plastic_strain_rate damage"; fields_copy = (char *) - "vfrac rmass x0 radius contact_radius molecule e " + "e vfrac rmass x0 radius contact_radius molecule " "eff_plastic_strain eff_plastic_strain_rate vest " "smd_data_9 smd_stress damage"; fields_comm = (char *) "radius vfrac vest e"; @@ -101,6 +101,29 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecSMD::grow_pointers() +{ + e = atom->e; + de = atom->de; + vfrac = atom->vfrac; + rmass = atom->rmass; + x0 = atom->x0; + radius = atom->radius; + contact_radius = atom->contact_radius; + molecule = atom->molecule; + smd_data_9 = atom->smd_data_9; + vest = atom->vest; + smd_stress = atom->smd_stress; + eff_plastic_strain = atom->eff_plastic_strain; + eff_plastic_strain_rate = atom->eff_plastic_strain_rate; + damage = atom->damage; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -109,8 +132,8 @@ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : AtomVec(lmp) void AtomVecSMD::force_clear(int n, size_t nbytes) { - memset(&atom->de[n],0,nbytes); - memset(&atom->f[n][0],0,3*nbytes); + memset(&de[n],0,nbytes); + memset(&f[n][0],0,3*nbytes); } /* ---------------------------------------------------------------------- @@ -119,19 +142,19 @@ void AtomVecSMD::force_clear(int n, size_t nbytes) void AtomVecSMD::create_atom_post(int ilocal) { - atom->x0[ilocal][0] = atom->x[ilocal][0]; - atom->x0[ilocal][1] = atom->x[ilocal][1]; - atom->x0[ilocal][2] = atom->x[ilocal][2]; + x0[ilocal][0] = x[ilocal][0]; + x0[ilocal][1] = x[ilocal][1]; + x0[ilocal][2] = x[ilocal][2]; - atom->vfrac[ilocal] = 1.0; - atom->rmass[ilocal] = 1.0; - atom->radius[ilocal] = 0.5; - atom->contact_radius[ilocal] = 0.5; - atom->molecule[ilocal] = 1; + vfrac[ilocal] = 1.0; + rmass[ilocal] = 1.0; + radius[ilocal] = 0.5; + contact_radius[ilocal] = 0.5; + molecule[ilocal] = 1; - atom->smd_data_9[ilocal][0] = 1.0; // xx - atom->smd_data_9[ilocal][4] = 1.0; // yy - atom->smd_data_9[ilocal][8] = 1.0; // zz + smd_data_9[ilocal][0] = 1.0; // xx + smd_data_9[ilocal][4] = 1.0; // yy + smd_data_9[ilocal][8] = 1.0; // zz } /* ---------------------------------------------------------------------- @@ -141,32 +164,27 @@ void AtomVecSMD::create_atom_post(int ilocal) void AtomVecSMD::data_atom_post(int ilocal) { - atom->e[ilocal] = 0.0; - atom->x0[ilocal][0] = atom->x[ilocal][0]; - atom->x0[ilocal][1] = atom->x[ilocal][1]; - atom->x0[ilocal][2] = atom->x[ilocal][2]; + e[ilocal] = 0.0; + x0[ilocal][0] = x[ilocal][0]; + x0[ilocal][1] = x[ilocal][1]; + x0[ilocal][2] = x[ilocal][2]; - atom->vest[ilocal][0] = 0.0; - atom->vest[ilocal][1] = 0.0; - atom->vest[ilocal][2] = 0.0; + vest[ilocal][0] = 0.0; + vest[ilocal][1] = 0.0; + vest[ilocal][2] = 0.0; - atom->damage[ilocal] = 0.0; + damage[ilocal] = 0.0; - atom->eff_plastic_strain[ilocal] = 0.0; - atom->eff_plastic_strain_rate[ilocal] = 0.0; + eff_plastic_strain[ilocal] = 0.0; + eff_plastic_strain_rate[ilocal] = 0.0; for (int k = 0; k < NMAT_FULL; k++) - atom->smd_data_9[ilocal][k] = 0.0; + smd_data_9[ilocal][k] = 0.0; for (int k = 0; k < NMAT_SYMM; k++) - atom->smd_stress[ilocal][k] = 0.0; + smd_stress[ilocal][k] = 0.0; - atom->smd_data_9[ilocal][0] = 1.0; // xx - atom->smd_data_9[ilocal][4] = 1.0; // yy - atom->smd_data_9[ilocal][8] = 1.0; // zz + smd_data_9[ilocal][0] = 1.0; // xx + smd_data_9[ilocal][4] = 1.0; // yy + smd_data_9[ilocal][8] = 1.0; // zz } - - - - - diff --git a/src/USER-SMD/atom_vec_smd.h b/src/USER-SMD/atom_vec_smd.h index 539f209ca7..00709aeada 100644 --- a/src/USER-SMD/atom_vec_smd.h +++ b/src/USER-SMD/atom_vec_smd.h @@ -38,9 +38,17 @@ namespace LAMMPS_NS { class AtomVecSMD : public AtomVec { public: AtomVecSMD(class LAMMPS *); + + void grow_pointers(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); + + private: + int *molecule; + double *e,*de,*vfrac,*rmass,*radius,*contact_radius; + double *eff_plastic_strain,*eff_plastic_strain_rate,*damage; + double **x0,**smd_data_9,**smd_stress,**vest; }; } diff --git a/src/USER-SPH/atom_vec_meso.cpp b/src/USER-SPH/atom_vec_meso.cpp index a80ab91d2e..fdddd15f27 100644 --- a/src/USER-SPH/atom_vec_meso.cpp +++ b/src/USER-SPH/atom_vec_meso.cpp @@ -52,6 +52,21 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) setup_fields(); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecMeso::grow_pointers() +{ + rho = atom->rho; + drho = atom->drho; + e = atom->e; + de = atom->de; + cv = atom->cv; + vest = atom->vest; +} + /* ---------------------------------------------------------------------- clear extra forces starting at atom N nbytes = # of bytes to clear for a per-atom vector @@ -59,8 +74,8 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) void AtomVecMeso::force_clear(int n, size_t nbytes) { - memset(&atom->de[n],0,nbytes); - memset(&atom->drho[n],0,nbytes); + memset(&de[n],0,nbytes); + memset(&drho[n],0,nbytes); } /* ---------------------------------------------------------------------- @@ -69,7 +84,7 @@ void AtomVecMeso::force_clear(int n, size_t nbytes) void AtomVecMeso::create_atom_post(int ilocal) { - atom->cv[ilocal] = 1.0; + cv[ilocal] = 1.0; } /* ---------------------------------------------------------------------- @@ -79,11 +94,11 @@ void AtomVecMeso::create_atom_post(int ilocal) void AtomVecMeso::data_atom_post(int ilocal) { - atom->vest[ilocal][0] = 0.0; - atom->vest[ilocal][1] = 0.0; - atom->vest[ilocal][2] = 0.0; - atom->de[ilocal] = 0.0; - atom->drho[ilocal] = 0.0; + vest[ilocal][0] = 0.0; + vest[ilocal][1] = 0.0; + vest[ilocal][2] = 0.0; + de[ilocal] = 0.0; + drho[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -114,35 +129,30 @@ void AtomVecMeso::pack_property_atom(int index, double *buf, int n = 0; if (index == 0) { - double *rho = atom->rho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = rho[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 1) { - double *drho = atom->drho; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = drho[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 2) { - double *e = atom->e; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = e[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 3) { - double *de = atom->de; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = de[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 4) { - double *cv = atom->cv; for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = cv[i]; else buf[n] = 0.0; diff --git a/src/USER-SPH/atom_vec_meso.h b/src/USER-SPH/atom_vec_meso.h index c8a1090474..bd84c34fbc 100644 --- a/src/USER-SPH/atom_vec_meso.h +++ b/src/USER-SPH/atom_vec_meso.h @@ -27,11 +27,17 @@ namespace LAMMPS_NS { class AtomVecMeso : public AtomVec { public: AtomVecMeso(class LAMMPS *); + + void grow_pointers(); void force_clear(int, size_t); void create_atom_post(int); void data_atom_post(int); int property_atom(char *); void pack_property_atom(int, double *, int, int); + + private: + double *rho,*drho,*e,*de,*cv; + double **vest; }; } diff --git a/src/atom.cpp b/src/atom.cpp index 0fbee8f583..353ed510a4 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -175,42 +175,8 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) iname = dname = NULL; // initialize atom style and array existence flags - // customize by adding new flag - sphere_flag = peri_flag = electron_flag = 0; - wavepacket_flag = sph_flag = 0; - - molecule_flag = 0; - q_flag = mu_flag = 0; - omega_flag = torque_flag = angmom_flag = 0; - radius_flag = rmass_flag = 0; - ellipsoid_flag = line_flag = tri_flag = body_flag = 0; - - // magnetic flags - - sp_flag = 0; - - vfrac_flag = 0; - spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0; - cs_flag = csforce_flag = vforce_flag = etag_flag = 0; - - rho_flag = e_flag = cv_flag = vest_flag = 0; - dpd_flag = edpd_flag = tdpd_flag = 0; - - // USER-SMD - - smd_flag = 0; - contact_radius_flag = 0; - smd_data_9_flag = 0; - smd_stress_flag = 0; - x0_flag = 0; - eff_plastic_strain_flag = 0; - eff_plastic_strain_rate_flag = 0; - damage_flag = 0; - - // Peridynamic scale factor - - pdscale = 1.0; + set_atomflag_defaults(); // initialize peratom data structure @@ -668,6 +634,32 @@ void Atom::add_peratom_vary(const char *name, void *address, nperatom++; } +/* ---------------------------------------------------------------------- + add info for a single per-atom array to PerAtom data struct + customize by adding new flag, identical list as atom.h 2nd customization +------------------------------------------------------------------------- */ + +void Atom::set_atomflag_defaults() +{ + sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0; + peri_flag = electron_flag = 0; + wavepacket_flag = sph_flag = 0; + molecule_flag = molindex_flag = molatom_flag = 0; + q_flag = mu_flag = 0; + rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0; + vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; + cs_flag = csforce_flag = vforce_flag = ervelforce_flag = etag_flag = 0; + rho_flag = e_flag = cv_flag = vest_flag = 0; + dpd_flag = edpd_flag = tdpd_flag = 0; + sp_flag = 0; + x0_flag = 0; + smd_flag = damage_flag = 0; + contact_radius_flag = smd_data_9_flag = smd_stress_flag = 0; + eff_plastic_strain_flag = eff_plastic_strain_rate_flag = 0; + + pdscale = 1.0; +} + /* ---------------------------------------------------------------------- create an AtomVec style called from lammps.cpp, input script, restart file, replicate @@ -682,26 +674,8 @@ void Atom::create_avec(const char *style, int narg, char **arg, int trysuffix) // unset atom style and array existence flags // may have been set by old avec - // customize by adding new flag - sphere_flag = peri_flag = electron_flag = 0; - wavepacket_flag = sph_flag = 0; - - molecule_flag = 0; - q_flag = mu_flag = 0; - omega_flag = torque_flag = angmom_flag = 0; - radius_flag = rmass_flag = 0; - ellipsoid_flag = line_flag = tri_flag = body_flag = 0; - - // magnetic flags - - sp_flag = 0; - - vfrac_flag = 0; - spin_flag = eradius_flag = ervel_flag = erforce_flag = ervelforce_flag = 0; - cs_flag = csforce_flag = vforce_flag = etag_flag = 0; - - rho_flag = e_flag = cv_flag = vest_flag = 0; + set_atomflag_defaults(); // create instance of AtomVec // use grow() to initialize atom-based arrays to length 1 @@ -785,6 +759,7 @@ AtomVec *Atom::avec_creator(LAMMPS *lmp) return new T(lmp); } + /* ---------------------------------------------------------------------- */ void Atom::init() diff --git a/src/atom.h b/src/atom.h index bc1eb1a7d7..6c7110b5be 100644 --- a/src/atom.h +++ b/src/atom.h @@ -143,7 +143,8 @@ class Atom : protected Pointers { double **vest; // -------------------------------------------------------------------- - // 1st customization section: customize by adding new flags + // 2nd customization section: customize by adding new flags + // identical list as Atom::set_atomflag_defaults() // most are existence flags for per-atom vectors and arrays // 1 if variable is used, 0 if not @@ -165,14 +166,10 @@ class Atom : protected Pointers { // USER-SMD package - int smd_flag; - int contact_radius_flag; - int smd_data_9_flag; - int smd_stress_flag; int x0_flag; - int eff_plastic_strain_flag; - int eff_plastic_strain_rate_flag; - int damage_flag; + int smd_flag,damage_flag; + int contact_radius_flag,smd_data_9_flag,smd_stress_flag; + int eff_plastic_strain_flag,eff_plastic_strain_rate_flag; // Peridynamics scale factor, used by dump cfg @@ -264,6 +261,7 @@ class Atom : protected Pointers { void *, int collength=0); void create_avec(const char *, int, char **, int); virtual class AtomVec *new_avec(const char *, int, int &); + void init(); void setup(); @@ -380,6 +378,7 @@ class Atom : protected Pointers { double bininvx,bininvy,bininvz; // inverse actual bin sizes double bboxlo[3],bboxhi[3]; // bounding box of my sub-domain + void set_atomflag_defaults(); void setup_sort_bins(); int next_prime(int); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index e31c235760..fac4cc2f6e 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -185,7 +185,7 @@ void AtomVec::grow(int n) atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) error->one(FLERR,"Per-processor system is too big"); - + tag = memory->grow(atom->tag,nmax,"atom:tag"); type = memory->grow(atom->type,nmax,"atom:type"); mask = memory->grow(atom->mask,nmax,"atom:mask"); @@ -230,6 +230,8 @@ void AtomVec::grow(int n) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); + + grow_pointers(); } /* ---------------------------------------------------------------------- @@ -2387,7 +2389,6 @@ void AtomVec::setup_fields() // set style-specific sizes // NOTE: check for others vars in atom_vec.cpp/h ?? - // NOTE: need to set maxexchange, e.g for style hybrid? comm_x_only = 1; if (ncomm) comm_x_only = 0; @@ -2435,7 +2436,6 @@ void AtomVec::setup_fields() else size_data_atom += cols; } - size_data_vel = 0; for (n = 0; n < ndata_vel; n++) { cols = mdata_vel.cols[n]; diff --git a/src/atom_vec.h b/src/atom_vec.h index 5911c8414b..94517f80ad 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -74,7 +74,8 @@ class AtomVec : protected Pointers { virtual void force_clear(int, size_t) {} - virtual void grow(int); + void grow(int); + virtual void grow_pointers() {} void copy(int, int, int); virtual void copy_bonus(int, int, int) {} diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index a04f23a47c..0f3557596f 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -100,6 +100,7 @@ AtomVecBody::~AtomVecBody() void AtomVecBody::process_args(int narg, char **arg) { // suppress unused parameter warning dependent on style_body.h + (void)(arg); if (narg < 1) error->all(FLERR,"Invalid atom_style body command"); @@ -120,11 +121,12 @@ void AtomVecBody::process_args(int narg, char **arg) icp = bptr->icp; dcp = bptr->dcp; - // max size of forward/border comm + // max size of forward/border and exchange comm // bptr values = max number of additional ivalues/dvalues from Body class size_forward_bonus += bptr->size_forward; size_border_bonus += bptr->size_border; + maxexchange = bptr->maxexchange; setup_fields(); } @@ -138,7 +140,11 @@ void AtomVecBody::process_args(int narg, char **arg) void AtomVecBody::grow(int n) { AtomVec::grow(n); + body = atom->body; + rmass = atom->rmass; + radius = atom->radius; + angmom = atom->angmom; } /* ---------------------------------------------------------------------- @@ -186,7 +192,7 @@ void AtomVecBody::copy_bonus(int i, int j, int delflag) void AtomVecBody::copy_bonus_all(int i, int j) { - atom->body[bonus[i].ilocal] = j; + body[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -503,9 +509,9 @@ int AtomVecBody::unpack_restart_bonus(int ilocal, double *buf) void AtomVecBody::create_atom_post(int ilocal) { - atom->radius[ilocal] = 0.5; - atom->rmass[ilocal] = 1.0; - atom->body[ilocal] = -1; + radius[ilocal] = 0.5; + rmass[ilocal] = 1.0; + body[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -515,19 +521,19 @@ void AtomVecBody::create_atom_post(int ilocal) void AtomVecBody::data_atom_post(int ilocal) { - body_flag = atom->body[ilocal]; + body_flag = body[ilocal]; if (body_flag == 0) body_flag = -1; else if (body_flag == 1) body_flag = 0; else error->one(FLERR,"Invalid body flag in Atoms section of data file"); - atom->body[ilocal] = body_flag; + body[ilocal] = body_flag; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); - atom->radius[ilocal] = 0.5; - atom->angmom[ilocal][0] = 0.0; - atom->angmom[ilocal][1] = 0.0; - atom->angmom[ilocal][2] = 0.0; + radius[ilocal] = 0.5; + angmom[ilocal][0] = 0.0; + angmom[ilocal][1] = 0.0; + angmom[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -537,12 +543,12 @@ void AtomVecBody::data_atom_post(int ilocal) void AtomVecBody::data_body(int m, int ninteger, int ndouble, int *ivalues, double *dvalues) { - if (atom->body[m]) + if (body[m]) error->one(FLERR,"Assigning body parameters to non-body atom"); if (nlocal_bonus == nmax_bonus) grow_bonus(); bonus[nlocal_bonus].ilocal = m; bptr->data_body(nlocal_bonus,ninteger,ndouble,ivalues,dvalues); - atom->body[m] = nlocal_bonus++; + body[m] = nlocal_bonus++; } /* ---------------------------------------------------------------------- @@ -570,10 +576,10 @@ bigint AtomVecBody::memory_usage_bonus() void AtomVecBody::pack_data_pre(int ilocal) { - body_flag = atom->body[ilocal]; + body_flag = body[ilocal]; - if (body_flag < 0) atom->body[ilocal] = 0; - else atom->body[ilocal] = 1; + if (body_flag < 0) body[ilocal] = 0; + else body[ilocal] = 1; } /* ---------------------------------------------------------------------- @@ -582,7 +588,7 @@ void AtomVecBody::pack_data_pre(int ilocal) void AtomVecBody::pack_data_post(int ilocal) { - atom->body[ilocal] = body_flag; + body[ilocal] = body_flag; } /* ---------------------------------------------------------------------- @@ -602,8 +608,8 @@ double AtomVecBody::radius_body(int ninteger, int ndouble, void AtomVecBody::set_quat(int m, double *quat_external) { - if (atom->body[m] < 0) error->one(FLERR,"Assigning quat to non-body atom"); - double *quat = bonus[atom->body[m]].quat; + if (body[m] < 0) error->one(FLERR,"Assigning quat to non-body atom"); + double *quat = bonus[body[m]].quat; quat[0] = quat_external[0]; quat[1] = quat_external[1]; quat[2] = quat_external[2]; quat[3] = quat_external[3]; } @@ -616,15 +622,15 @@ void AtomVecBody::set_quat(int m, double *quat_external) void AtomVecBody::check(int flag) { for (int i = 0; i < atom->nlocal; i++) { - if (atom->body[i] >= 0 && atom->body[i] >= nlocal_bonus) { + if (body[i] >= 0 && body[i] >= nlocal_bonus) { printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag); errorx->one(FLERR,"BAD AAA"); } } for (int i = atom->nlocal; i < atom->nlocal+atom->nghost; i++) { - if (atom->body[i] >= 0 && - (atom->body[i] < nlocal_bonus || - atom->body[i] >= nlocal_bonus+nghost_bonus)) { + if (body[i] >= 0 && + (body[i] < nlocal_bonus || + body[i] >= nlocal_bonus+nghost_bonus)) { printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag); errorx->one(FLERR,"BAD BBB"); } @@ -636,7 +642,7 @@ void AtomVecBody::check(int flag) } } for (int i = 0; i < nlocal_bonus; i++) { - if (atom->body[bonus[i].ilocal] != i) { + if (body[bonus[i].ilocal] != i) { printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag); errorx->one(FLERR,"BAD DDD"); } @@ -649,7 +655,7 @@ void AtomVecBody::check(int flag) } } for (int i = nlocal_bonus; i < nlocal_bonus+nghost_bonus; i++) { - if (atom->body[bonus[i].ilocal] != i) { + if (body[bonus[i].ilocal] != i) { printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag); errorx->one(FLERR,"BAD FFF"); } diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index 3f32c8223c..adfc7768eb 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -71,12 +71,14 @@ class AtomVecBody : public AtomVec { int nlocal_bonus; private: + int *body; + double *rmass,*radius; + double **angmom; + int nghost_bonus,nmax_bonus; int intdoubleratio; // sizeof(double) / sizeof(int) int body_flag; - int *body; - MyPoolChunk *icp; MyPoolChunk *dcp; diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index e8ab6d5613..2537fe2538 100644 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -75,6 +75,17 @@ AtomVecEllipsoid::~AtomVecEllipsoid() memory->sfree(bonus); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecEllipsoid::grow_pointers() +{ + ellipsoid = atom->ellipsoid; + rmass = atom->rmass; +} + /* ---------------------------------------------------------------------- grow bonus data structure ------------------------------------------------------------------------- */ @@ -95,8 +106,6 @@ void AtomVecEllipsoid::grow_bonus() void AtomVecEllipsoid::copy_bonus(int i, int j, int delflag) { - int *ellipsoid = atom->ellipsoid; - // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && ellipsoid[j] >= 0) { @@ -118,7 +127,7 @@ void AtomVecEllipsoid::copy_bonus(int i, int j, int delflag) void AtomVecEllipsoid::copy_bonus_all(int i, int j) { - atom->ellipsoid[bonus[i].ilocal] = j; + ellipsoid[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -143,8 +152,6 @@ int AtomVecEllipsoid::pack_comm_bonus(int n, int *list, double *buf) int i,j,m; double *quat; - int *ellipsoid = atom->ellipsoid; - m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -167,8 +174,6 @@ void AtomVecEllipsoid::unpack_comm_bonus(int n, int first, double *buf) int i,m,last; double *quat; - int *ellipsoid = atom->ellipsoid; - m = 0; last = first + n; for (i = first; i < last; i++) { @@ -190,8 +195,6 @@ int AtomVecEllipsoid::pack_border_bonus(int n, int *list, double *buf) double dx,dy,dz; double *shape,*quat; - int *ellipsoid = atom->ellipsoid; - m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -220,8 +223,6 @@ int AtomVecEllipsoid::unpack_border_bonus(int n, int first, double *buf) int i,j,m,last; double *shape,*quat; - int *ellipsoid = atom->ellipsoid; - m = 0; last = first + n; for (i = first; i < last; i++) { @@ -257,8 +258,6 @@ int AtomVecEllipsoid::pack_exchange_bonus(int i, double *buf) { int m = 0; - int *ellipsoid = atom->ellipsoid; - if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -283,8 +282,6 @@ int AtomVecEllipsoid::unpack_exchange_bonus(int ilocal, double *buf) { int m = 0; - int *ellipsoid = atom->ellipsoid; - ellipsoid[ilocal] = (int) ubuf(buf[m++]).i; if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1; else { @@ -314,8 +311,6 @@ int AtomVecEllipsoid::size_restart_bonus() { int i; - int *ellipsoid = atom->ellipsoid; - int n = 0; int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { @@ -336,8 +331,6 @@ int AtomVecEllipsoid::pack_restart_bonus(int i, double *buf) { int m = 0; - int *ellipsoid = atom->ellipsoid; - if (ellipsoid[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -362,8 +355,6 @@ int AtomVecEllipsoid::unpack_restart_bonus(int ilocal, double *buf) { int m = 0; - int *ellipsoid = atom->ellipsoid; - ellipsoid[ilocal] = (int) ubuf(buf[m++]).i; if (ellipsoid[ilocal] == 0) ellipsoid[ilocal] = -1; else { @@ -390,8 +381,6 @@ int AtomVecEllipsoid::unpack_restart_bonus(int ilocal, double *buf) void AtomVecEllipsoid::data_atom_bonus(int m, char **values) { - int *ellipsoid = atom->ellipsoid; - if (ellipsoid[m]) error->one(FLERR,"Assigning ellipsoid parameters to non-ellipsoid atom"); @@ -414,7 +403,7 @@ void AtomVecEllipsoid::data_atom_bonus(int m, char **values) // reset ellipsoid mass // previously stored density in rmass - atom->rmass[m] *= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; + rmass[m] *= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; bonus[nlocal_bonus].ilocal = m; ellipsoid[m] = nlocal_bonus++; @@ -437,8 +426,8 @@ bigint AtomVecEllipsoid::memory_usage_bonus() void AtomVecEllipsoid::create_atom_post(int ilocal) { - atom->rmass[ilocal] = 1.0; - atom->ellipsoid[ilocal] = -1; + rmass[ilocal] = 1.0; + ellipsoid[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -448,13 +437,13 @@ void AtomVecEllipsoid::create_atom_post(int ilocal) void AtomVecEllipsoid::data_atom_post(int ilocal) { - ellipsoid_flag = atom->ellipsoid[ilocal]; + ellipsoid_flag = ellipsoid[ilocal]; if (ellipsoid_flag == 0) ellipsoid_flag = -1; else if (ellipsoid_flag == 1) ellipsoid_flag = 0; else error->one(FLERR,"Invalid ellipsoid flag in Atoms section of data file"); - atom->ellipsoid[ilocal] = ellipsoid_flag; + ellipsoid[ilocal] = ellipsoid_flag; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); } @@ -467,14 +456,14 @@ void AtomVecEllipsoid::pack_data_pre(int ilocal) double *shape; ellipsoid_flag = atom->ellipsoid[ilocal]; - rmass = atom->rmass[ilocal]; + rmass_one = atom->rmass[ilocal]; - if (ellipsoid_flag < 0) atom->ellipsoid[ilocal] = 0; - else atom->ellipsoid[ilocal] = 1; + if (ellipsoid_flag < 0) ellipsoid[ilocal] = 0; + else ellipsoid[ilocal] = 1; if (ellipsoid_flag >= 0) { shape = bonus[ellipsoid_flag].shape; - atom->rmass[ilocal] /= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; + rmass[ilocal] /= 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2]; } } @@ -484,8 +473,8 @@ void AtomVecEllipsoid::pack_data_pre(int ilocal) void AtomVecEllipsoid::pack_data_post(int ilocal) { - atom->ellipsoid[ilocal] = ellipsoid_flag; - atom->rmass[ilocal] = rmass; + ellipsoid[ilocal] = ellipsoid_flag; + rmass[ilocal] = rmass_one; } /* ---------------------------------------------------------------------- @@ -497,8 +486,6 @@ void AtomVecEllipsoid::pack_data_post(int ilocal) void AtomVecEllipsoid:: set_shape(int i, double shapex, double shapey, double shapez) { - int *ellipsoid = atom->ellipsoid; - if (ellipsoid[i] < 0) { if (shapex == 0.0 && shapey == 0.0 && shapez == 0.0) return; if (nlocal_bonus == nmax_bonus) grow_bonus(); diff --git a/src/atom_vec_ellipsoid.h b/src/atom_vec_ellipsoid.h index 79d17a2206..bbf3922bb3 100644 --- a/src/atom_vec_ellipsoid.h +++ b/src/atom_vec_ellipsoid.h @@ -36,6 +36,7 @@ class AtomVecEllipsoid : public AtomVec { AtomVecEllipsoid(class LAMMPS *); ~AtomVecEllipsoid(); + void grow_pointers(); void copy_bonus(int, int, int); void clear_bonus(); int pack_comm_bonus(int, int *, double *); @@ -62,9 +63,12 @@ class AtomVecEllipsoid : public AtomVec { int nlocal_bonus; private: + int *ellipsoid; + double *rmass; + int nghost_bonus,nmax_bonus; int ellipsoid_flag; - double rmass; + double rmass_one; void grow_bonus(); void copy_bonus_all(int, int); diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 9a79f66972..d1166e5a8e 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -36,7 +36,6 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) // NOTE: set bonus_flag if any substyle does // set nstyles_bonus, styles_bonus - // NOTE: call method in each sub-style to set q_flag ?? // these strings will be concatenated from sub-style strings // fields_data_atom & fields_data_vel start with fields common to all styles @@ -124,8 +123,8 @@ void AtomVecHybrid::process_args(int narg, char **arg) for (int k = 0; k < nstyles; k++) { if ((styles[k]->molecular == 1 && molecular == 2) || (styles[k]->molecular == 2 && molecular == 1)) - error->all(FLERR,"Cannot mix molecular and molecule template " - "atom styles"); + error->all(FLERR, + "Cannot mix molecular and molecule template atom styles"); molecular = MAX(molecular,styles[k]->molecular); bonds_allow = MAX(bonds_allow,styles[k]->bonds_allow); @@ -135,11 +134,9 @@ void AtomVecHybrid::process_args(int narg, char **arg) mass_type = MAX(mass_type,styles[k]->mass_type); dipole_type = MAX(dipole_type,styles[k]->dipole_type); forceclearflag = MAX(forceclearflag,styles[k]->forceclearflag); + maxexchange += styles[k]->maxexchange; if (styles[k]->molecular == 2) onemols = styles[k]->onemols; - - // NOTE: need to sum this one? - maxexchange += styles[k]->maxexchange; } // issue a warning if both per-type mass and per-atom rmass are defined @@ -237,6 +234,13 @@ void AtomVecHybrid::init() /* ---------------------------------------------------------------------- */ +void AtomVecHybrid::grow_pointers() +{ + for (int k = 0; k < nstyles; k++) styles[k]->grow_pointers(); +} + +/* ---------------------------------------------------------------------- */ + void AtomVecHybrid::force_clear(int n, size_t nbytes) { for (int k = 0; k < nstyles; k++) diff --git a/src/atom_vec_hybrid.h b/src/atom_vec_hybrid.h index 7d838b7a7f..7d8e45c579 100644 --- a/src/atom_vec_hybrid.h +++ b/src/atom_vec_hybrid.h @@ -34,8 +34,9 @@ class AtomVecHybrid : public AtomVec { ~AtomVecHybrid(); void process_args(int, char **); void init(); - void force_clear(int, size_t); + void grow_pointers(); + void force_clear(int, size_t); void copy_bonus(int, int, int); void clear_bonus() {} int pack_comm_bonus(int, int *, double *); diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index 7ab697b349..e178d1f78a 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -86,6 +86,19 @@ void AtomVecLine::init() error->all(FLERR,"Atom_style line can only be used in 2d simulations"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecLine::grow_pointers() +{ + line = atom->line; + radius = atom->radius; + rmass = atom->rmass; + omega = atom->omega; +} + /* ---------------------------------------------------------------------- grow bonus data structure ------------------------------------------------------------------------- */ @@ -106,8 +119,6 @@ void AtomVecLine::grow_bonus() void AtomVecLine::copy_bonus(int i, int j, int delflag) { - int *line = atom->line; - // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && line[j] >= 0) { @@ -129,7 +140,7 @@ void AtomVecLine::copy_bonus(int i, int j, int delflag) void AtomVecLine::copy_bonus_all(int i, int j) { - atom->line[bonus[i].ilocal] = j; + line[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -153,8 +164,6 @@ int AtomVecLine::pack_comm_bonus(int n, int *list, double *buf) { int i,j,m; - int *line = atom->line; - m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -170,8 +179,6 @@ void AtomVecLine::unpack_comm_bonus(int n, int first, double *buf) { int i,m,last; - int *line = atom->line; - m = 0; last = first + n; for (i = first; i < last; i++) { @@ -185,8 +192,6 @@ int AtomVecLine::pack_border_bonus(int n, int *list, double *buf) { int i,j,m; - int *line = atom->line; - m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -207,8 +212,6 @@ int AtomVecLine::unpack_border_bonus(int n, int first, double *buf) { int i,j,m,last; - int *line = atom->line; - m = 0; last = first + n; for (i = first; i < last; i++) { @@ -237,8 +240,6 @@ int AtomVecLine::pack_exchange_bonus(int i, double *buf) { int m = 0; - int *line = atom->line; - if (line[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -256,8 +257,6 @@ int AtomVecLine::unpack_exchange_bonus(int ilocal, double *buf) { int m = 0; - int *line = atom->line; - line[ilocal] = (int) ubuf(buf[m++]).i; if (line[ilocal] == 0) line[ilocal] = -1; else { @@ -280,8 +279,6 @@ int AtomVecLine::size_restart_bonus() { int i; - int *line = atom->line; - int n = 0; int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { @@ -302,8 +299,6 @@ int AtomVecLine::pack_restart_bonus(int i, double *buf) { int m = 0; - int *line = atom->line; - if (line[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -323,8 +318,6 @@ int AtomVecLine::unpack_restart_bonus(int ilocal, double *buf) { int m = 0; - int *line = atom->line; - line[ilocal] = (int) ubuf(buf[m++]).i; if (line[ilocal] == 0) line[ilocal] = -1; else { @@ -344,8 +337,6 @@ int AtomVecLine::unpack_restart_bonus(int ilocal, double *buf) void AtomVecLine::data_atom_bonus(int m, char **values) { - int *line = atom->line; - if (line[m]) error->one(FLERR,"Assigning line parameters to non-line atom"); if (nlocal_bonus == nmax_bonus) grow_bonus(); @@ -377,8 +368,8 @@ void AtomVecLine::data_atom_bonus(int m, char **values) // reset line radius and mass // rmass currently holds density - atom->radius[m] = 0.5 * length; - atom->rmass[m] *= length; + radius[m] = 0.5 * length; + rmass[m] *= length; bonus[nlocal_bonus].ilocal = m; line[m] = nlocal_bonus++; @@ -402,10 +393,10 @@ bigint AtomVecLine::memory_usage_bonus() void AtomVecLine::create_atom_post(int ilocal) { - double radius = 0.5; - atom->radius[ilocal] = radius; - atom->rmass[ilocal] = 4.0*MY_PI/3.0 * radius*radius*radius; - atom->line[ilocal] = -1; + double radius_one = 0.5; + radius[ilocal] = radius_one; + rmass[ilocal] = 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + line[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -415,24 +406,24 @@ void AtomVecLine::create_atom_post(int ilocal) void AtomVecLine::data_atom_post(int ilocal) { - line_flag = atom->line[ilocal]; + line_flag = line[ilocal]; if (line_flag == 0) line_flag = -1; else if (line_flag == 1) line_flag = 0; else error->one(FLERR,"Invalid line flag in Atoms section of data file"); - atom->line[ilocal] = line_flag; + line[ilocal] = line_flag; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); if (line_flag < 0) { - double radius = 0.5; - atom->radius[ilocal] = radius; - atom->rmass[ilocal] *= 4.0*MY_PI/3.0 * radius*radius*radius; - } else atom->radius[ilocal] = 0.0; + double radius_one = 0.5; + radius[ilocal] = radius_one; + rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + } else radius[ilocal] = 0.0; - atom->omega[ilocal][0] = 0.0; - atom->omega[ilocal][1] = 0.0; - atom->omega[ilocal][2] = 0.0; + omega[ilocal][0] = 0.0; + omega[ilocal][1] = 0.0; + omega[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -441,16 +432,16 @@ void AtomVecLine::data_atom_post(int ilocal) void AtomVecLine::pack_data_pre(int ilocal) { - line_flag = atom->line[ilocal]; - rmass = atom->rmass[ilocal]; + line_flag = line[ilocal]; + rmass_one = rmass[ilocal]; - if (line_flag < 0) atom->line[ilocal] = 0; - else atom->line[ilocal] = 1; + if (line_flag < 0) line[ilocal] = 0; + else line[ilocal] = 1; if (line_flag < 0) { - double radius = atom->radius[ilocal]; - atom->rmass[ilocal] /= 4.0*MY_PI/3.0 * radius*radius*radius; - } else atom->rmass[ilocal] /= bonus[line_flag].length; + double radius_one = radius[ilocal]; + rmass[ilocal] /= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + } else rmass[ilocal] /= bonus[line_flag].length; } /* ---------------------------------------------------------------------- @@ -459,8 +450,8 @@ void AtomVecLine::pack_data_pre(int ilocal) void AtomVecLine::pack_data_post(int ilocal) { - atom->line[ilocal] = line_flag; - atom->rmass[ilocal] = rmass; + line[ilocal] = line_flag; + rmass[ilocal] = rmass_one; } /* ---------------------------------------------------------------------- @@ -471,8 +462,6 @@ void AtomVecLine::pack_data_post(int ilocal) void AtomVecLine::set_length(int i, double value) { - int *line = atom->line; - if (line[i] < 0) { if (value == 0.0) return; if (nlocal_bonus == nmax_bonus) grow_bonus(); @@ -489,8 +478,8 @@ void AtomVecLine::set_length(int i, double value) // also set radius = half of length // unless value = 0.0, then set diameter = 1.0 - atom->radius[i] = 0.5 * value; - if (value == 0.0) atom->radius[i] = 0.5; + radius[i] = 0.5 * value; + if (value == 0.0) radius[i] = 0.5; } /* ---------------------------------------------------------------------- diff --git a/src/atom_vec_line.h b/src/atom_vec_line.h index a47843f4f2..7bca58c64b 100644 --- a/src/atom_vec_line.h +++ b/src/atom_vec_line.h @@ -36,6 +36,7 @@ class AtomVecLine : public AtomVec { ~AtomVecLine(); void init(); + void grow_pointers(); void copy_bonus(int, int, int); void clear_bonus(); int pack_comm_bonus(int, int *, double *); @@ -62,9 +63,13 @@ class AtomVecLine : public AtomVec { int nlocal_bonus; private: + int *line; + double *radius,*rmass; + double **omega; + int nghost_bonus,nmax_bonus; int line_flag; - double rmass; + double rmass_one; void grow_bonus(); void copy_bonus_all(int, int); diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index b601fc8f7c..64a198c94d 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -100,14 +100,25 @@ void AtomVecSphere::init() } } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecSphere::grow_pointers() +{ + radius = atom->radius; + rmass = atom->rmass; +} + /* ---------------------------------------------------------------------- initialize non-zero atom quantities ------------------------------------------------------------------------- */ void AtomVecSphere::create_atom_post(int ilocal) { - atom->radius[ilocal] = 0.5; - atom->rmass[ilocal] = 4.0*MY_PI/3.0 * 0.5*0.5*0.5; + radius[ilocal] = 0.5; + rmass[ilocal] = 4.0*MY_PI/3.0 * 0.5*0.5*0.5; } /* ---------------------------------------------------------------------- @@ -117,13 +128,12 @@ void AtomVecSphere::create_atom_post(int ilocal) void AtomVecSphere::data_atom_post(int ilocal) { - double radius = 0.5 * atom->radius[ilocal]; - atom->radius[ilocal] = radius; - if (radius > 0.0) - atom->rmass[ilocal] = - 4.0*MY_PI/3.0 * radius*radius*radius * atom->rmass[ilocal]; + radius_one = 0.5 * atom->radius[ilocal]; + radius[ilocal] = radius_one; + if (radius_one > 0.0) + rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); } @@ -132,13 +142,14 @@ void AtomVecSphere::data_atom_post(int ilocal) ------------------------------------------------------------------------- */ void AtomVecSphere::pack_data_pre(int ilocal) -{ - radius = atom->radius[ilocal]; - rmass = atom->rmass[ilocal]; +{ + radius_one = radius[ilocal]; + rmass_one = rmass[ilocal]; - atom->radius[ilocal] *= 2.0; - if (radius == 0.0) - atom->rmass[ilocal] = rmass / (4.0*MY_PI/3.0 * radius*radius*radius); + radius[ilocal] *= 2.0; + if (radius_one!= 0.0) + rmass[ilocal] = + rmass_one / (4.0*MY_PI/3.0 * radius_one*radius_one*radius_one); } /* ---------------------------------------------------------------------- @@ -146,7 +157,7 @@ void AtomVecSphere::pack_data_pre(int ilocal) ------------------------------------------------------------------------- */ void AtomVecSphere::pack_data_post(int ilocal) -{ - atom->radius[ilocal] = radius; - atom->rmass[ilocal] = rmass; +{ + radius[ilocal] = radius_one; + rmass[ilocal] = rmass_one; } diff --git a/src/atom_vec_sphere.h b/src/atom_vec_sphere.h index c205ba43de..2b735f1163 100644 --- a/src/atom_vec_sphere.h +++ b/src/atom_vec_sphere.h @@ -29,14 +29,18 @@ class AtomVecSphere : public AtomVec { AtomVecSphere(class LAMMPS *); void process_args(int, char **); void init(); + + void grow_pointers(); void create_atom_post(int); void data_atom_post(int); void pack_data_pre(int); void pack_data_post(int); private: + double *radius,*rmass; + int radvary; - double radius,rmass; + double radius_one,rmass_one; }; } diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index 7345646a1e..b130198075 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -88,6 +88,20 @@ void AtomVecTri::init() error->all(FLERR,"Atom_style tri can only be used in 3d simulations"); } +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecTri::grow_pointers() +{ + tri = atom->tri; + radius = atom->radius; + rmass = atom->rmass; + omega = atom->omega; + angmom = atom->angmom; +} + /* ---------------------------------------------------------------------- grow bonus data structure ------------------------------------------------------------------------- */ @@ -109,8 +123,6 @@ void AtomVecTri::grow_bonus() void AtomVecTri::copy_bonus(int i, int j, int delflag) { - int *tri = atom->tri; - // if deleting atom J via delflag and J has bonus data, then delete it if (delflag && tri[j] >= 0) { @@ -132,7 +144,7 @@ void AtomVecTri::copy_bonus(int i, int j, int delflag) void AtomVecTri::copy_bonus_all(int i, int j) { - atom->tri[bonus[i].ilocal] = j; + tri[bonus[i].ilocal] = j; memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); } @@ -157,8 +169,6 @@ int AtomVecTri::pack_comm_bonus(int n, int *list, double *buf) int i,j,m; double *quat; - int *tri = atom->tri; - m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -181,8 +191,6 @@ void AtomVecTri::unpack_comm_bonus(int n, int first, double *buf) int i,m,last; double *quat; - int *tri = atom->tri; - m = 0; last = first + n; for (i = first; i < last; i++) { @@ -203,8 +211,6 @@ int AtomVecTri::pack_border_bonus(int n, int *list, double *buf) int i,j,m; double *quat,*c1,*c2,*c3,*inertia; - int *tri = atom->tri; - m = 0; for (i = 0; i < n; i++) { j = list[i]; @@ -245,8 +251,6 @@ int AtomVecTri::unpack_border_bonus(int n, int first, double *buf) int i,j,m,last; double *quat,*c1,*c2,*c3,*inertia; - int *tri = atom->tri; - m = 0; last = first + n; for (i = first; i < last; i++) { @@ -294,8 +298,6 @@ int AtomVecTri::pack_exchange_bonus(int i, double *buf) { int m = 0; - int *tri = atom->tri; - if (tri[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -332,8 +334,6 @@ int AtomVecTri::unpack_exchange_bonus(int ilocal, double *buf) { int m = 0; - int *tri = atom->tri; - tri[ilocal] = (int) ubuf(buf[m++]).i; if (tri[ilocal] == 0) tri[ilocal] = -1; else { @@ -375,8 +375,6 @@ int AtomVecTri::size_restart_bonus() { int i; - int *tri = atom->tri; - int n = 0; int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { @@ -395,8 +393,6 @@ int AtomVecTri::pack_restart_bonus(int i, double *buf) { int m = 0; - int *tri = atom->tri; - if (tri[i] < 0) buf[m++] = ubuf(0).d; else { buf[m++] = ubuf(1).d; @@ -435,8 +431,6 @@ int AtomVecTri::unpack_restart_bonus(int ilocal, double *buf) { int m = 0; - int *tri = atom->tri; - tri[ilocal] = (int) ubuf(buf[m++]).i; if (tri[ilocal] == 0) tri[ilocal] = -1; else { @@ -475,8 +469,6 @@ int AtomVecTri::unpack_restart_bonus(int ilocal, double *buf) void AtomVecTri::data_atom_bonus(int m, char **values) { - int *tri = atom->tri; - if (tri[m]) error->one(FLERR,"Assigning tri parameters to non-tri atom"); if (nlocal_bonus == nmax_bonus) grow_bonus(); @@ -523,9 +515,9 @@ void AtomVecTri::data_atom_bonus(int m, char **values) if (delta/size > EPSILON) error->one(FLERR,"Inconsistent triangle in data file"); - atom->x[m][0] = centroid[0]; - atom->x[m][1] = centroid[1]; - atom->x[m][2] = centroid[2]; + x[m][0] = centroid[0]; + x[m][1] = centroid[1]; + x[m][2] = centroid[2]; // reset tri radius and mass // rmass currently holds density @@ -533,22 +525,22 @@ void AtomVecTri::data_atom_bonus(int m, char **values) double c4[3]; MathExtra::sub3(c1,centroid,c4); - atom->radius[m] = MathExtra::lensq3(c4); + radius[m] = MathExtra::lensq3(c4); MathExtra::sub3(c2,centroid,c4); - atom->radius[m] = MAX(atom->radius[m],MathExtra::lensq3(c4)); + radius[m] = MAX(radius[m],MathExtra::lensq3(c4)); MathExtra::sub3(c3,centroid,c4); - atom->radius[m] = MAX(atom->radius[m],MathExtra::lensq3(c4)); - atom->radius[m] = sqrt(atom->radius[m]); + radius[m] = MAX(radius[m],MathExtra::lensq3(c4)); + radius[m] = sqrt(radius[m]); double norm[3]; MathExtra::cross3(c2mc1,c3mc1,norm); double area = 0.5 * MathExtra::len3(norm); - atom->rmass[m] *= area; + rmass[m] *= area; // inertia = inertia tensor of triangle as 6-vector in Voigt notation double inertia[6]; - MathExtra::inertia_triangle(c1,c2,c3,atom->rmass[m],inertia); + MathExtra::inertia_triangle(c1,c2,c3,rmass[m],inertia); // diagonalize inertia tensor via Jacobi rotations // bonus[].inertia = 3 eigenvalues = principal moments of inertia @@ -622,10 +614,10 @@ bigint AtomVecTri::memory_usage_bonus() void AtomVecTri::create_atom_post(int ilocal) { - double radius = 0.5; - atom->radius[ilocal] = radius; - atom->rmass[ilocal] = 4.0*MY_PI/3.0 * radius*radius*radius; - atom->tri[ilocal] = -1; + double radius_one = 0.5; + radius[ilocal] = radius_one; + rmass[ilocal] = 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + tri[ilocal] = -1; } /* ---------------------------------------------------------------------- @@ -635,27 +627,27 @@ void AtomVecTri::create_atom_post(int ilocal) void AtomVecTri::data_atom_post(int ilocal) { - tri_flag = atom->tri[ilocal]; + tri_flag = tri[ilocal]; if (tri_flag == 0) tri_flag = -1; else if (tri_flag == 1) tri_flag = 0; else error->one(FLERR,"Invalid tri flag in Atoms section of data file"); - atom->tri[ilocal] = tri_flag; + tri[ilocal] = tri_flag; - if (atom->rmass[ilocal] <= 0.0) + if (rmass[ilocal] <= 0.0) error->one(FLERR,"Invalid density in Atoms section of data file"); if (tri_flag < 0) { - double radius = 0.5; - atom->radius[ilocal] = radius; - atom->rmass[ilocal] *= 4.0*MY_PI/3.0 * radius*radius*radius; - } else atom->radius[ilocal] = 0.0; + double radius_one = 0.5; + radius[ilocal] = radius_one; + rmass[ilocal] *= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; + } else radius[ilocal] = 0.0; - atom->omega[ilocal][0] = 0.0; - atom->omega[ilocal][1] = 0.0; - atom->omega[ilocal][2] = 0.0; - atom->angmom[ilocal][0] = 0.0; - atom->angmom[ilocal][1] = 0.0; - atom->angmom[ilocal][2] = 0.0; + omega[ilocal][0] = 0.0; + omega[ilocal][1] = 0.0; + omega[ilocal][2] = 0.0; + angmom[ilocal][0] = 0.0; + angmom[ilocal][1] = 0.0; + angmom[ilocal][2] = 0.0; } /* ---------------------------------------------------------------------- @@ -664,22 +656,22 @@ void AtomVecTri::data_atom_post(int ilocal) void AtomVecTri::pack_data_pre(int ilocal) { - tri_flag = atom->tri[ilocal]; - rmass = atom->rmass[ilocal]; + tri_flag = tri[ilocal]; + rmass_one = rmass[ilocal]; - if (tri_flag < 0) atom->tri[ilocal] = 0; - else atom->tri[ilocal] = 1; + if (tri_flag < 0) tri[ilocal] = 0; + else tri[ilocal] = 1; if (tri_flag < 0) { - double radius = atom->radius[ilocal]; - atom->rmass[ilocal] /= 4.0*MY_PI/3.0 * radius*radius*radius; + double radius_one = radius[ilocal]; + rmass[ilocal] /= 4.0*MY_PI/3.0 * radius_one*radius_one*radius_one; } else { double c2mc1[3],c3mc1[3],norm[3]; MathExtra::sub3(bonus[tri_flag].c2,bonus[tri_flag].c1,c2mc1); MathExtra::sub3(bonus[tri_flag].c3,bonus[tri_flag].c1,c3mc1); MathExtra::cross3(c2mc1,c3mc1,norm); double area = 0.5 * MathExtra::len3(norm); - atom->rmass[ilocal] /= area; + rmass[ilocal] /= area; } } @@ -689,8 +681,8 @@ void AtomVecTri::pack_data_pre(int ilocal) void AtomVecTri::pack_data_post(int ilocal) { - atom->tri[ilocal] = tri_flag; - atom->rmass[ilocal] = rmass; + tri[ilocal] = tri_flag; + rmass[ilocal] = rmass_one; } /* ---------------------------------------------------------------------- @@ -704,8 +696,6 @@ void AtomVecTri::set_equilateral(int i, double size) // also set radius = distance from center to corner-pt = len(c1) // unless size = 0.0, then set diameter = 1.0 - int *tri = atom->tri; - if (tri[i] < 0) { if (size == 0.0) return; if (nlocal_bonus == nmax_bonus) grow_bonus(); @@ -730,11 +720,11 @@ void AtomVecTri::set_equilateral(int i, double size) inertia[0] = sqrt(3.0)/96.0 * size*size*size*size; inertia[1] = sqrt(3.0)/96.0 * size*size*size*size; inertia[2] = sqrt(3.0)/48.0 * size*size*size*size; - atom->radius[i] = MathExtra::len3(c1); + radius[i] = MathExtra::len3(c1); bonus[nlocal_bonus].ilocal = i; tri[i] = nlocal_bonus++; } else if (size == 0.0) { - atom->radius[i] = 0.5; + radius[i] = 0.5; copy_bonus_all(nlocal_bonus-1,tri[i]); nlocal_bonus--; tri[i] = -1; @@ -755,6 +745,6 @@ void AtomVecTri::set_equilateral(int i, double size) inertia[0] = sqrt(3.0)/96.0 * size*size*size*size; inertia[1] = sqrt(3.0)/96.0 * size*size*size*size; inertia[2] = sqrt(3.0)/48.0 * size*size*size*size; - atom->radius[i] = MathExtra::len3(c1); + radius[i] = MathExtra::len3(c1); } } diff --git a/src/atom_vec_tri.h b/src/atom_vec_tri.h index ad4c0103ca..0b16285fe6 100644 --- a/src/atom_vec_tri.h +++ b/src/atom_vec_tri.h @@ -38,6 +38,7 @@ class AtomVecTri : public AtomVec { ~AtomVecTri(); void init(); + void grow_pointers(); void copy_bonus(int, int, int); void clear_bonus(); int pack_comm_bonus(int, int *, double *); @@ -64,9 +65,13 @@ class AtomVecTri : public AtomVec { int nlocal_bonus; private: + int *tri; + double *radius,*rmass; + double **omega,**angmom; + int nghost_bonus,nmax_bonus; int tri_flag; - double rmass; + double rmass_one; void grow_bonus(); void copy_bonus_all(int, int); diff --git a/src/replicate.cpp b/src/replicate.cpp index 3659f7cf7a..26b61769b0 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -100,7 +100,8 @@ void Replicate::command(int narg, char **arg) maxmol = maxmol_all; } - // check image flags maximum extent; only efficient small image flags compared to new system + // check image flags maximum extent + // only efficient small image flags compared to new system int _imagelo[3], _imagehi[3]; _imagelo[0] = 0;