2727------------------------------------------------------------------------- */
2828
2929#include " fix_colvars.h"
30- #include " inthash.h"
3130
3231#include " atom.h"
3332#include " citeme.h"
@@ -61,7 +60,6 @@ struct LAMMPS_NS::commdata {
6160
6261using namespace LAMMPS_NS ;
6362using namespace FixConst ;
64- using namespace IntHash_NS ;
6563
6664// initialize static class members
6765int FixColvars::instances = 0 ;
@@ -122,7 +120,6 @@ FixColvars::FixColvars(LAMMPS *lmp, int narg, char **arg) :
122120 comm_buf = nullptr ;
123121 taglist = nullptr ;
124122 force_buf = nullptr ;
125- idmap = nullptr ;
126123
127124 script_args[0 ] = reinterpret_cast <unsigned char *>(utils::strdup (" fix_modify" ));
128125
@@ -227,11 +224,6 @@ FixColvars::~FixColvars()
227224
228225 if (proxy) delete proxy;
229226
230- if (idmap) {
231- inthash_destroy (idmap);
232- delete idmap;
233- }
234-
235227 if (root2root != MPI_COMM_NULL)
236228 MPI_Comm_free (&root2root);
237229
@@ -349,16 +341,11 @@ void FixColvars::init_taglist()
349341
350342 std::vector<int > const &tl = *(proxy->get_atom_ids ());
351343
352- if (idmap) {
353- delete idmap;
354- idmap = nullptr ;
355- }
356-
357- idmap = new inthash_t ;
358- inthash_init (idmap, num_coords);
344+ idmap.clear ();
345+ idmap.reserve (num_coords);
359346 for (int i = 0 ; i < num_coords; ++i) {
360347 taglist[i] = tl[i];
361- inthash_insert ( idmap, tl[i], i) ;
348+ idmap[ tl[i]] = i ;
362349 }
363350 }
364351
@@ -542,10 +529,9 @@ void FixColvars::setup(int vflag)
542529 ndata /= size_one;
543530
544531 for (int k=0 ; k<ndata; ++k) {
545-
546- const int j = inthash_lookup (idmap, comm_buf[k].tag );
547-
548- if (j != HASH_FAIL) {
532+ auto search = idmap.find (comm_buf[k].tag );
533+ if (search != idmap.end ()) {
534+ const int j = search->second ;
549535
550536 tp[j] = comm_buf[k].type ;
551537
@@ -701,8 +687,10 @@ void FixColvars::post_force(int /*vflag*/)
701687 ndata /= size_one;
702688
703689 for (int k=0 ; k<ndata; ++k) {
704- const int j = inthash_lookup (idmap, comm_buf[k].tag );
705- if (j != HASH_FAIL) {
690+ auto search = idmap.find (comm_buf[k].tag );
691+ if (search != idmap.end ()) {
692+ const int j = search->second ;
693+
706694 cd[j].x = comm_buf[k].x ;
707695 cd[j].y = comm_buf[k].y ;
708696 cd[j].z = comm_buf[k].z ;
@@ -826,8 +814,10 @@ void FixColvars::end_of_step()
826814 const tagint k = atom->map (taglist[i]);
827815 if ((k >= 0 ) && (k < nlocal)) {
828816
829- const int j = inthash_lookup (idmap, tag[k]);
830- if (j != HASH_FAIL) {
817+ auto search = idmap.find (tag[k]);
818+ if (search != idmap.end ()) {
819+ const int j = search->second ;
820+
831821 of[j].x = f[k][0 ];
832822 of[j].y = f[k][1 ];
833823 of[j].z = f[k][2 ];
@@ -845,8 +835,10 @@ void FixColvars::end_of_step()
845835 ndata /= size_one;
846836
847837 for (int k=0 ; k<ndata; ++k) {
848- const int j = inthash_lookup (idmap, comm_buf[k].tag );
849- if (j != HASH_FAIL) {
838+ auto search = idmap.find (comm_buf[k].tag );
839+ if (search != idmap.end ()) {
840+ const int j = search->second ;
841+
850842 of[j].x = comm_buf[k].x ;
851843 of[j].y = comm_buf[k].y ;
852844 of[j].z = comm_buf[k].z ;
0 commit comments