Commit b6374bac authored by Steve Plimpton's avatar Steve Plimpton
Browse files

enable replicate to work with local ptrs

parent db6d2723
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -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]);
}
+5 −0
Original line number Diff line number Diff line
@@ -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;
};

}
+22 −17
Original line number Diff line number Diff line
@@ -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;
}
+6 −0
Original line number Diff line number Diff line
@@ -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;
+11 −18
Original line number Diff line number Diff line
@@ -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;
}
Loading