Commit 227489b1 authored by sjplimp's avatar sjplimp
Browse files

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@80 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent afce2f00
Loading
Loading
Loading
Loading
+11 −18
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ void DeleteAtoms::command(int narg, char **arg)
    error->all("Cannot use delete_atoms unless atoms have IDs");

  int natoms_previous = static_cast<int> (atom->natoms);
  int tag_lowest = natoms_previous + 1;

  // allocate and initialize deletion list
  
@@ -53,7 +52,6 @@ void DeleteAtoms::command(int narg, char **arg)
  for (int i = 0; i < nlocal; i++) list[i] = 0;

  // delete the atoms
  // return tag_lowest = min tag of each proc's deleted atoms

  if (strcmp(arg[0],"group") == 0) delete_group(narg,arg,list);
  else if (strcmp(arg[0],"region") == 0) delete_region(narg,arg,list);
@@ -62,14 +60,12 @@ void DeleteAtoms::command(int narg, char **arg)

  // delete local atoms in list
  // reset nlocal
  // tag_lowest_all = smallest deleted atom tag on any proc

  int *tag = atom->tag;

  int i = 0;
  while (i < nlocal) {
    if (list[i]) {
      tag_lowest = MIN(tag_lowest,tag[i]);
      atom->copy(nlocal-1,i);
      list[i] = list[nlocal-1];
      nlocal--;
@@ -78,19 +74,14 @@ void DeleteAtoms::command(int narg, char **arg)
  atom->nlocal = nlocal;
  delete [] list;

  int tag_lowest_all;
  MPI_Allreduce(&tag_lowest,&tag_lowest_all,1,MPI_INT,MPI_MIN,world);

  // if non-molecular system, reset atom tags to be contiguous
  // set all atom IDs >= tag_lowest_all to 0
  // tag_extend() will reset tags for those atoms
  // set all atom IDs to 0, call tag_extend()

  if (atom->molecular == 0) {
    int *tag = atom->tag;
    int nlocal = atom->nlocal;
 
    for (i = 0; i < nlocal; i++)
      if (tag[i] >= tag_lowest_all) tag[i] = 0;
    for (i = 0; i < nlocal; i++) tag[i] = 0;
    atom->tag_extend();
  }

@@ -188,14 +179,17 @@ void DeleteAtoms::delete_overlap(int narg, char **arg, int *list)

  // init entire system since comm->borders and neighbor->build is done
  // comm::init needs neighbor::init needs pair::init needs kspace::init, etc
  // set half_command since will require half neigh list even if
  //   neighbor would otherwise not create one, then unset it

  if (comm->me == 0 && screen)
    fprintf(screen,"System init for delete_atoms ...\n");
  neighbor->half_command = 1;
  sys->init();
  neighbor->half_command = 0;

  // setup domain, communication and neighboring
  // acquire ghosts
  // build half neighbor list via explicit call
    
  domain->pbc();
  domain->reset_box();
@@ -204,8 +198,11 @@ void DeleteAtoms::delete_overlap(int narg, char **arg, int *list)
  comm->exchange();
  comm->borders();

  if (!neighbor->half) neighbor->build_half_setup();
  neighbor->build_half();
  // call to build() forces memory allocation for neighbor lists
  // build half list explicitly if build() doesn't do it

  neighbor->build();
  if (!neighbor->half_every) neighbor->build_half();

  // error check on cutoff

@@ -289,10 +286,6 @@ void DeleteAtoms::delete_overlap(int narg, char **arg, int *list)
    }
  }

  // cleanup after neighbor list

  if (!neighbor->half) neighbor->build_half_cleanup();

  // delete temporary atom map

  if (mapflag) {
+5 −41
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ Neighbor::Neighbor()

  // half neighbor list info

  half = 0;
  half = half_command = 0;
  maxpage = 0;
  numneigh = NULL;
  firstneigh = NULL;
@@ -385,8 +385,9 @@ void Neighbor::init()
  }

  half = full = 0;
  if (half_every || half_once) half = 1;
  if (half_every || half_once || half_command) half = 1;
  if (full_every || full_once) full = 1;
  half = 1;

  // setup/delete memory for half and full lists

@@ -720,7 +721,7 @@ void Neighbor::build()

  // extend atom arrays if necessary
  // check half/full instead of half_every/full_every so memory will be
  //   allocated correctly when build_half() and build_full() are called
  //   allocated correctly whenever build_half() and build_full() are called

  if (atom->nlocal > maxlocal) {
    maxlocal = atom->nmax;
@@ -792,27 +793,6 @@ void Neighbor::build()
  }
}

/* ----------------------------------------------------------------------
   prepare for one-time call to build a half neighbor list
   only needs to be called if Neighbor::init() set half = 0
------------------------------------------------------------------------- */

void Neighbor::build_half_setup()
{
  numneigh = (int *) memory->smalloc(maxlocal*sizeof(int),"neigh:numneigh");
  firstneigh =
    (int **) memory->smalloc(maxlocal*sizeof(int *),"neigh:firstneigh");
  add_pages(0);

  if (style == 0) {
    if (force->newton_pair == 0) half_build = &Neighbor::half_nsq_no_newton;
    else half_build = &Neighbor::half_nsq_newton;
  } else if (style == 1) {
    if (force->newton_pair == 0) half_build = &Neighbor::half_bin_no_newton;
    else half_build = &Neighbor::half_bin_newton;
  }
}

/* ----------------------------------------------------------------------
   one-time call to build a half neighbor list made by other classes
------------------------------------------------------------------------- */
@@ -823,23 +803,7 @@ void Neighbor::build_half()
}

/* ----------------------------------------------------------------------
   clean-up from one-time call to build a half neighbor list
   only needs to be called if Neighbor::init() set half = 0
------------------------------------------------------------------------- */

void Neighbor::build_half_cleanup()
{
  memory->sfree(numneigh);
  memory->sfree(firstneigh);
  for (int i = 0; i < maxpage; i++) memory->sfree(pages[i]);
  memory->sfree(pages);
  pages = NULL;
  maxpage = 0;
  half_build = NULL;
}

/* ----------------------------------------------------------------------
   build a full neighbor list, called occasionally by a fix
   one-time call to build a full neighbor list made by other classes
------------------------------------------------------------------------- */

void Neighbor::build_full()
+1 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ class Neighbor : public LAMMPS {
  int full_every;                  // 0/1 if full list built every step
  int half_once;                   // 0/1 if half pair list built occasionally
  int full_once;                   // 0/1 if full pair list built occasionally
  int half_command;                // 0/1 if command requires half list

  int *numneigh;                   // # of half neighbors for each atom
  int **firstneigh;                // ptr to 1st half neighbor of each atom
@@ -74,9 +75,7 @@ class Neighbor : public LAMMPS {
  int check_distance();       // check max distance moved since last build
  void setup_bins();          // setup bins based on box and cutoff
  void build();               // create all neighbor lists (half,full,bond)
  void build_half_setup();    // setup for one-time creation of half list
  void build_half();          // one-time creation of half neighbor list
  void build_half_cleanup();  // cleanup of one-time creation of half list
  void build_full();          // one-time creation of full neighbor list
  void modify_params(int, char**);  // modify parameters of neighbor build
  int memory_usage();         // tally memory usage
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ void Pressure::compute(Temperature *temperature)

  double inv_volume = 1.0 / (domain->xprd * domain->yprd * domain->zprd);

  if (force->pair->tail_flag)
  if (force->pair && force->pair->tail_flag)
    for (i = 0; i < n; i++) virial[i] += force->pair->ptail * inv_volume;

  // compute just total average pressure or entire pressure tensor
+4 −4
Original line number Diff line number Diff line
@@ -837,7 +837,7 @@ void Thermo::compute_pe()
  MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);

  if (force->kspace) dvalue += force->kspace->energy;
  if (force->pair->tail_flag) {
  if (force->pair && force->pair->tail_flag) {
    double volume = domain->xprd * domain->yprd * domain->zprd;
    dvalue += force->pair->etail / volume;
  }
@@ -881,7 +881,7 @@ void Thermo::compute_evdwl()

  MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);

  if (force->pair->tail_flag) {
  if (force->pair && force->pair->tail_flag) {
    double volume = domain->xprd * domain->yprd * domain->zprd;
    dvalue += force->pair->etail / volume;
  }
@@ -912,7 +912,7 @@ void Thermo::compute_epair()
  MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);

  if (force->kspace) dvalue += force->kspace->energy;
  if (force->pair->tail_flag) {
  if (force->pair && force->pair->tail_flag) {
    double volume = domain->xprd * domain->yprd * domain->zprd;
    dvalue += force->pair->etail / volume;
  }
@@ -993,7 +993,7 @@ void Thermo::compute_elong()

void Thermo::compute_etail()
{
  if (force->pair->tail_flag) {
  if (force->pair && force->pair->tail_flag) {
    double volume = domain->xprd * domain->yprd * domain->zprd;
    dvalue = force->pair->etail / volume;
    if (normflag) dvalue /= natoms;