Commit cb077829 authored by Ryan S. Elliott's avatar Ryan S. Elliott
Browse files

Multiple neig lists working in pair_kim

parent 5958b24e
Loading
Loading
Loading
Loading
+42 −15
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ PairKIM::PairKIM(LAMMPS *lmp) :
   kim_global_influence_distance(0.0),
   kim_number_of_cutoffs(0),
   kim_cutoff_values(0),
   neighborLists(0),
   kim_particle_codes(0),
   lmps_maxalloc(0),
   kim_particleSpecies(0),
@@ -102,6 +103,13 @@ PairKIM::~PairKIM()
      delete [] lmps_map_species_to_unique;
   }

   // clean up neighborlist pointers
   if (neighborLists)
   {
     delete [] neighborLists;
     neighborLists = 0;
   }

   // clean up KIM interface (if necessary)
   kim_free();

@@ -378,14 +386,30 @@ void PairKIM::init_style()
   if (!lmps_using_newton) comm_reverse_off = 9;

   // request full neighbor list
   for (int i = 0; i < kim_number_of_cutoffs; ++i)
   {
     int irequest = neighbor->request(this,instance_me);
     neighbor->requests[irequest]->id = i;
     neighbor->requests[irequest]->half = 0;
     neighbor->requests[irequest]->full = 1;
     neighbor->requests[irequest]->ghost = 1;
     neighbor->requests[irequest]->cut = 1;
     neighbor->requests[irequest]->cutoff = kim_cutoff_values[i];
   }

   return;
}

/* ----------------------------------------------------------------------
   neighbor callback to inform pair style of neighbor list to use
   half or full
------------------------------------------------------------------------- */

void PairKIM::init_list(int id, NeighList *ptr)
{
  neighborLists[id] = ptr;
}

/* ----------------------------------------------------------------------
   init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */
@@ -525,7 +549,7 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf)

double PairKIM::memory_usage()
{
   double bytes = lmps_maxalloc * sizeof(int);
   double bytes = 2 * lmps_maxalloc * sizeof(int);
   return bytes;
}

@@ -542,21 +566,18 @@ int PairKIM::get_neigh(void const * const dataObject,
   PairKIM const * const Model
       = reinterpret_cast<PairKIM const * const>(dataObject);

   if ((numberOfCutoffs != 1) || (cutoffs[0] > Model->kim_cutoff_values[0]))
     return true;
   if (numberOfCutoffs != Model->kim_number_of_cutoffs) return true;
   for (int i = 0; i < numberOfCutoffs; ++i)
   {
     if (Model->kim_cutoff_values[i] < cutoffs[i]) return true;
   }

   if (neighborListIndex != 0) return true;
   // neighborListIndex and particleNumber are validated by KIM API

   // initialize numNeigh
   *numberOfNeighbors = 0;

   if ((particleNumber >= Model->lmps_local_tot_num_atoms) ||
       (particleNumber < 0)) /* invalid id */
   {
     return true;
   }

   NeighList * neiobj = Model->list;
   NeighList * neiobj = Model->neighborLists[neighborListIndex];
   int nAtoms = Model->lmps_local_tot_num_atoms;

   int j, jj, inum, *ilist, *numneigh, **firstneigh;
@@ -664,6 +685,12 @@ void PairKIM::kim_init()
   pkim->GetInfluenceDistance(&kim_global_influence_distance);
   pkim->GetNeighborListCutoffsPointer(&kim_number_of_cutoffs,
                                       &kim_cutoff_values);
   if (neighborLists)
   {
     delete [] neighborLists;
     neighborLists = 0;
   }
   neighborLists = new NeighList*[kim_number_of_cutoffs];

   kimerror = pargs->SetArgumentPointer(
       KIM::COMPUTE_ARGUMENT_NAME::numberOfParticles,
+2 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ namespace LAMMPS_NS {
      virtual void settings(int, char**);
      virtual void coeff(int, char**);
      virtual void init_style();
     //virtual void init_list(int id, NeighList *ptr);
      virtual void init_list(int id, NeighList *ptr);
      virtual double init_one(int, int);
      virtual int pack_reverse_comm(int, int, double*);
      virtual void unpack_reverse_comm(int, int*, double*);
@@ -103,6 +103,7 @@ namespace LAMMPS_NS {
      double kim_global_influence_distance;  // KIM Model cutoff value
      int kim_number_of_cutoffs;
      double const * kim_cutoff_values;
      class NeighList ** neighborLists;

      // values set in init_style()
      bool kim_model_init_ok;