Unverified Commit 02ffa46f authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

simplify memory management and plug leaks in pair style bop

parent 32870951
Loading
Loading
Loading
Loading
+15 −42
Original line number Diff line number Diff line
@@ -257,12 +257,8 @@ PairBOP::~PairBOP()
    memory->destroy(gfunc6);
    memory->destroy(gpara);
  }
  if(allocate_sigma) {
    destroy_sigma();
  }
  if(allocate_pi) {
    destroy_pi();
  }
  memory->destroy(bt_sg);
  memory->destroy(bt_pi);
}

/* ---------------------------------------------------------------------- */
@@ -635,8 +631,6 @@ void PairBOP::coeff(int narg, char **arg)
  bop_step=0;
  nb_pi=0;
  nb_sg=0;
  allocate_sigma=0;
  allocate_pi=0;
  allocate_neigh=0;
  update_list=0;
  maxnall=0;
@@ -774,8 +768,7 @@ void PairBOP::gneigh()
    memory->create(BOP_total3,nall,"BOP_total");
    if (otfly==0) memory->create(cos_index,nall,"cos_index");
    allocate_neigh=1;
  }
  else {
  } else {
    memory->grow(BOP_index,nall,"BOP_index");
    memory->grow(BOP_index3,nall,"BOP_index3");
    memory->grow(BOP_total,nall,"BOP_total");
@@ -1140,10 +1133,6 @@ double PairBOP::sigmaBo(int itmp, int jtmp)
  if(nb_sg==0) {
    nb_sg=(maxneigh)*(maxneigh/2);
  }
  if(allocate_sigma) {
    destroy_sigma();
  }

  create_sigma(nb_sg);
  sigB=0;
  if(itmp<nlocal) {
@@ -3798,9 +3787,6 @@ double PairBOP::PiBo(int itmp, int jtmp)

// Loop over all local atoms for i

  if(allocate_pi) {
    destroy_pi();
  }
  create_pi(nb_pi);
  piB=0;
    i = ilist[itmp];
@@ -4866,7 +4852,6 @@ double PairBOP::PiBo(int itmp, int jtmp)
          }
        }
      }
  destroy_pi();
  return(piB);
}

@@ -5670,26 +5655,14 @@ void PairBOP::memory_theta_destroy()

void PairBOP::create_pi(int n_tot)
{
  memory->destroy(bt_pi);
  bt_pi = (B_PI *) memory->smalloc(n_tot*sizeof(B_PI),"BOP:bt_pi");
  allocate_pi=1;
}

void PairBOP::create_sigma(int n_tot)
{
  bt_sg = (B_SG *) memory->smalloc(n_tot*sizeof(B_SG),"BOP:bt_sg");
  allocate_sigma=1;
}

void PairBOP::destroy_pi()
{
  memory->destroy(bt_pi);
  allocate_pi=0;
}

void PairBOP::destroy_sigma()
{
  memory->destroy(bt_sg);
  allocate_sigma=0;
  bt_sg = (B_SG *) memory->smalloc(n_tot*sizeof(B_SG),"BOP:bt_sg");
}

/* ---------------------------------------------------------------------- */
+0 −2
Original line number Diff line number Diff line
@@ -58,8 +58,6 @@ class PairBOP : public Pair {
  int ***elem2param;
  int nparams;
  int bop_step;
  int allocate_pi;
  int allocate_sigma;
  int allocate_neigh;
  int nb_pi,nb_sg;
  int ago1;