git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11283 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -44,4 +44,4 @@ The person who created this package is Axel Kohlmeyer at Temple U
|
|||||||
|
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
Version: 2013-06-27
|
Version: 2013-12-16
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
#ifdef LAMMPS_BIGBIG
|
|
||||||
#error LAMMPS_BIGBIG not supported by this file
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "mpi.h"
|
#include "mpi.h"
|
||||||
#include "lammps.h"
|
#include "lammps.h"
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
|
|||||||
@ -443,6 +443,11 @@ void FixColvars::one_time_init()
|
|||||||
if (screen) fputs("colvars: Creating proxy instance\n",screen);
|
if (screen) fputs("colvars: Creating proxy instance\n",screen);
|
||||||
if (logfile) fputs("colvars: Creating proxy instance\n",logfile);
|
if (logfile) fputs("colvars: Creating proxy instance\n",logfile);
|
||||||
|
|
||||||
|
#ifdef LAMMPS_BIGBIG
|
||||||
|
if (screen) fputs("colvars: cannot handle atom ids > 2147483647\n",screen);
|
||||||
|
if (logfile) fputs("colvars: cannot handle atom ids > 2147483647\n",logfile);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (inp_name) {
|
if (inp_name) {
|
||||||
if (strcmp(inp_name,"NULL") == 0) {
|
if (strcmp(inp_name,"NULL") == 0) {
|
||||||
memory->sfree(inp_name);
|
memory->sfree(inp_name);
|
||||||
@ -490,14 +495,14 @@ void FixColvars::one_time_init()
|
|||||||
inthash_insert(hashtable, tl[i], i);
|
inthash_insert(hashtable, tl[i], i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MPI_Bcast(taglist, num_coords, MPI_INT, 0, world);
|
MPI_Bcast(taglist, num_coords, MPI_LMP_TAGINT, 0, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixColvars::setup(int vflag)
|
void FixColvars::setup(int vflag)
|
||||||
{
|
{
|
||||||
const int * const tag = atom->tag;
|
const tagint * const tag = atom->tag;
|
||||||
const int * const type = atom->type;
|
const int * const type = atom->type;
|
||||||
int i,nme,tmp,ndata;
|
int i,nme,tmp,ndata;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
@ -510,7 +515,7 @@ void FixColvars::setup(int vflag)
|
|||||||
// determine size of comm buffer
|
// determine size of comm buffer
|
||||||
nme=0;
|
nme=0;
|
||||||
for (i=0; i < num_coords; ++i) {
|
for (i=0; i < num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal))
|
if ((k >= 0) && (k < nlocal))
|
||||||
++nme;
|
++nme;
|
||||||
}
|
}
|
||||||
@ -536,7 +541,7 @@ void FixColvars::setup(int vflag)
|
|||||||
// store coordinate data in holding array, clear old forces
|
// store coordinate data in holding array, clear old forces
|
||||||
|
|
||||||
for (i=0; i<num_coords; ++i) {
|
for (i=0; i<num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal)) {
|
if ((k >= 0) && (k < nlocal)) {
|
||||||
|
|
||||||
of[i].tag = cd[i].tag = tag[k];
|
of[i].tag = cd[i].tag = tag[k];
|
||||||
@ -593,7 +598,7 @@ void FixColvars::setup(int vflag)
|
|||||||
|
|
||||||
nme = 0;
|
nme = 0;
|
||||||
for (i=0; i<num_coords; ++i) {
|
for (i=0; i<num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal)) {
|
if ((k >= 0) && (k < nlocal)) {
|
||||||
|
|
||||||
comm_buf[nme].tag = tag[k];
|
comm_buf[nme].tag = tag[k];
|
||||||
@ -665,7 +670,7 @@ void FixColvars::post_force(int vflag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const int * const tag = atom->tag;
|
const tagint * const tag = atom->tag;
|
||||||
const double * const * const x = atom->x;
|
const double * const * const x = atom->x;
|
||||||
double * const * const f = atom->f;
|
double * const * const f = atom->f;
|
||||||
const imageint * const image = atom->image;
|
const imageint * const image = atom->image;
|
||||||
@ -681,7 +686,7 @@ void FixColvars::post_force(int vflag)
|
|||||||
/* check and potentially grow local communication buffers. */
|
/* check and potentially grow local communication buffers. */
|
||||||
int i,nmax_new,nme=0;
|
int i,nmax_new,nme=0;
|
||||||
for (i=0; i < num_coords; ++i) {
|
for (i=0; i < num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal))
|
if ((k >= 0) && (k < nlocal))
|
||||||
++nme;
|
++nme;
|
||||||
}
|
}
|
||||||
@ -702,7 +707,7 @@ void FixColvars::post_force(int vflag)
|
|||||||
// store coordinate data
|
// store coordinate data
|
||||||
|
|
||||||
for (i=0; i<num_coords; ++i) {
|
for (i=0; i<num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal)) {
|
if ((k >= 0) && (k < nlocal)) {
|
||||||
|
|
||||||
if (unwrap_flag) {
|
if (unwrap_flag) {
|
||||||
@ -744,7 +749,7 @@ void FixColvars::post_force(int vflag)
|
|||||||
/* copy coordinate data into communication buffer */
|
/* copy coordinate data into communication buffer */
|
||||||
nme = 0;
|
nme = 0;
|
||||||
for (i=0; i<num_coords; ++i) {
|
for (i=0; i<num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal)) {
|
if ((k >= 0) && (k < nlocal)) {
|
||||||
comm_buf[nme].tag = tag[k];
|
comm_buf[nme].tag = tag[k];
|
||||||
|
|
||||||
@ -796,7 +801,7 @@ void FixColvars::post_force(int vflag)
|
|||||||
MPI_Bcast(force_buf, 3*num_coords, MPI_DOUBLE, 0, world);
|
MPI_Bcast(force_buf, 3*num_coords, MPI_DOUBLE, 0, world);
|
||||||
|
|
||||||
for (int i=0; i < num_coords; ++i) {
|
for (int i=0; i < num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal)) {
|
if ((k >= 0) && (k < nlocal)) {
|
||||||
f[k][0] += force_buf[3*i+0];
|
f[k][0] += force_buf[3*i+0];
|
||||||
f[k][1] += force_buf[3*i+1];
|
f[k][1] += force_buf[3*i+1];
|
||||||
@ -824,14 +829,14 @@ void FixColvars::end_of_step()
|
|||||||
{
|
{
|
||||||
if (store_forces) {
|
if (store_forces) {
|
||||||
|
|
||||||
const int * const tag = atom->tag;
|
const tagint * const tag = atom->tag;
|
||||||
double * const * const f = atom->f;
|
double * const * const f = atom->f;
|
||||||
const int nlocal = atom->nlocal;
|
const int nlocal = atom->nlocal;
|
||||||
|
|
||||||
/* check and potentially grow local communication buffers. */
|
/* check and potentially grow local communication buffers. */
|
||||||
int i,nmax_new,nme=0;
|
int i,nmax_new,nme=0;
|
||||||
for (i=0; i < num_coords; ++i) {
|
for (i=0; i < num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal))
|
if ((k >= 0) && (k < nlocal))
|
||||||
++nme;
|
++nme;
|
||||||
}
|
}
|
||||||
@ -852,7 +857,7 @@ void FixColvars::end_of_step()
|
|||||||
std::vector<struct commdata> &of = *oforce;
|
std::vector<struct commdata> &of = *oforce;
|
||||||
|
|
||||||
for (i=0; i<num_coords; ++i) {
|
for (i=0; i<num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal)) {
|
if ((k >= 0) && (k < nlocal)) {
|
||||||
|
|
||||||
const int j = inthash_lookup(idmap, tag[k]);
|
const int j = inthash_lookup(idmap, tag[k]);
|
||||||
@ -887,7 +892,7 @@ void FixColvars::end_of_step()
|
|||||||
/* copy total force data into communication buffer */
|
/* copy total force data into communication buffer */
|
||||||
nme = 0;
|
nme = 0;
|
||||||
for (i=0; i<num_coords; ++i) {
|
for (i=0; i<num_coords; ++i) {
|
||||||
const int k = atom->map(taglist[i]);
|
const tagint k = atom->map(taglist[i]);
|
||||||
if ((k >= 0) && (k < nlocal)) {
|
if ((k >= 0) && (k < nlocal)) {
|
||||||
comm_buf[nme].tag = tag[k];
|
comm_buf[nme].tag = tag[k];
|
||||||
comm_buf[nme].x = f[k][0];
|
comm_buf[nme].x = f[k][0];
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class FixColvars : public Fix {
|
|||||||
|
|
||||||
int me; // my MPI rank in this "world".
|
int me; // my MPI rank in this "world".
|
||||||
int num_coords; // total number of atoms controlled by this fix
|
int num_coords; // total number of atoms controlled by this fix
|
||||||
int *taglist; // list of all atom IDs referenced by colvars.
|
tagint *taglist; // list of all atom IDs referenced by colvars.
|
||||||
std::vector<struct commdata> *coords; // coordinates of colvar atoms
|
std::vector<struct commdata> *coords; // coordinates of colvar atoms
|
||||||
std::vector<struct commdata> *forces; // received forces of colvar atoms
|
std::vector<struct commdata> *forces; // received forces of colvar atoms
|
||||||
std::vector<struct commdata> *oforce; // old total forces of colvar atoms
|
std::vector<struct commdata> *oforce; // old total forces of colvar atoms
|
||||||
|
|||||||
@ -30,10 +30,10 @@ using namespace LAMMPS_NS;
|
|||||||
helper function. integer comparison for qsort()
|
helper function. integer comparison for qsort()
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int cmpint(const void *p1, const void *p2)
|
static int cmptagint(const void *p1, const void *p2)
|
||||||
{
|
{
|
||||||
const int i1 = * static_cast<const int *>(p1);
|
const tagint i1 = * static_cast<const tagint *>(p1);
|
||||||
const int i2 = * static_cast<const int *>(p2);
|
const tagint i2 = * static_cast<const tagint *>(p2);
|
||||||
if (i1 == i2) return 0;
|
if (i1 == i2) return 0;
|
||||||
else {
|
else {
|
||||||
if (i1 < i2) return -1;
|
if (i1 < i2) return -1;
|
||||||
@ -49,7 +49,7 @@ static void write_group(FILE *fp, int gid, Atom *atom, Group *group, int me,
|
|||||||
int np, MPI_Comm world, FILE *screen, FILE *logfile)
|
int np, MPI_Comm world, FILE *screen, FILE *logfile)
|
||||||
{
|
{
|
||||||
char fmt[8];
|
char fmt[8];
|
||||||
int *sendlist, *recvlist;
|
tagint *sendlist, *recvlist;
|
||||||
bigint num = group->count(gid);
|
bigint num = group->count(gid);
|
||||||
int lnum, cols;
|
int lnum, cols;
|
||||||
|
|
||||||
@ -77,13 +77,13 @@ static void write_group(FILE *fp, int gid, Atom *atom, Group *group, int me,
|
|||||||
|
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
const int * const mask = atom->mask;
|
const int * const mask = atom->mask;
|
||||||
const int * const tag = atom->tag;
|
const tagint * const tag = atom->tag;
|
||||||
const int groupbit = group->bitmask[gid];
|
const int groupbit = group->bitmask[gid];
|
||||||
const int nlocal = atom->nlocal;
|
const int nlocal = atom->nlocal;
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
sendlist = new int[nlocal];
|
sendlist = new tagint[nlocal];
|
||||||
recvlist = new int[num];
|
recvlist = new tagint[num];
|
||||||
lnum = 0;
|
lnum = 0;
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) sendlist[lnum++] = tag[i];
|
if (mask[i] & groupbit) sendlist[lnum++] = tag[i];
|
||||||
@ -97,18 +97,18 @@ static void write_group(FILE *fp, int gid, Atom *atom, Group *group, int me,
|
|||||||
|
|
||||||
allrecv = lnum;
|
allrecv = lnum;
|
||||||
for (int i=1; i < np; ++i) {
|
for (int i=1; i < np; ++i) {
|
||||||
MPI_Irecv(recvlist+allrecv,num-allrecv,MPI_INT,i,0, world,&request);
|
MPI_Irecv(recvlist+allrecv,num-allrecv,MPI_LMP_TAGINT,i,0, world,&request);
|
||||||
MPI_Send(&nrecv,0,MPI_INT,i,0,world);
|
MPI_Send(&nrecv,0,MPI_INT,i,0,world);
|
||||||
MPI_Wait(&request,&status);
|
MPI_Wait(&request,&status);
|
||||||
MPI_Get_count(&status,MPI_INT,&nrecv);
|
MPI_Get_count(&status,MPI_LMP_TAGINT,&nrecv);
|
||||||
allrecv += nrecv;
|
allrecv += nrecv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort received list
|
// sort received list
|
||||||
qsort((void *)recvlist, num, sizeof(int), cmpint);
|
qsort((void *)recvlist, num, sizeof(tagint), cmptagint);
|
||||||
} else {
|
} else {
|
||||||
MPI_Recv(&nrecv,0,MPI_INT,0,0,world,&status);
|
MPI_Recv(&nrecv,0,MPI_INT,0,0,world,&status);
|
||||||
MPI_Rsend(sendlist,lnum,MPI_INT,0,0,world);
|
MPI_Rsend(sendlist,lnum,MPI_LMP_TAGINT,0,0,world);
|
||||||
}
|
}
|
||||||
delete [] sendlist;
|
delete [] sendlist;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,10 +47,6 @@ negotiate an appropriate license for such distribution."
|
|||||||
Justin Gullingsrud, and James Phillips, (TCBG, Beckman Institute, UIUC)
|
Justin Gullingsrud, and James Phillips, (TCBG, Beckman Institute, UIUC)
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef LAMMPS_BIGBIG
|
|
||||||
#error LAMMPS_BIGBIG not supported by this file
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "fix_imd.h"
|
#include "fix_imd.h"
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
@ -83,48 +79,51 @@ negotiate an appropriate license for such distribution."
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
|
using namespace FixConst;
|
||||||
|
|
||||||
/* re-usable integer hash table code with static linkage. */
|
/* re-usable integer hash table code with static linkage. */
|
||||||
|
|
||||||
/** hash table top level data structure */
|
/** hash table top level data structure */
|
||||||
typedef struct inthash_t {
|
typedef struct taginthash_t {
|
||||||
struct inthash_node_t **bucket; /* array of hash nodes */
|
struct taginthash_node_t **bucket; /* array of hash nodes */
|
||||||
int size; /* size of the array */
|
tagint size; /* size of the array */
|
||||||
int entries; /* number of entries in table */
|
tagint entries; /* number of entries in table */
|
||||||
int downshift; /* shift cound, used in hash function */
|
tagint downshift; /* shift count, used in hash function */
|
||||||
int mask; /* used to select bits for hashing */
|
tagint mask; /* used to select bits for hashing */
|
||||||
} inthash_t;
|
} taginthash_t;
|
||||||
|
|
||||||
/** hash table node data structure */
|
/** hash table node data structure */
|
||||||
typedef struct inthash_node_t {
|
typedef struct taginthash_node_t {
|
||||||
int data; /* data in hash node */
|
tagint data; /* data in hash node */
|
||||||
int key; /* key for hash lookup */
|
tagint key; /* key for hash lookup */
|
||||||
struct inthash_node_t *next; /* next node in hash chain */
|
struct taginthash_node_t *next; /* next node in hash chain */
|
||||||
} inthash_node_t;
|
} taginthash_node_t;
|
||||||
|
|
||||||
#define HASH_FAIL -1
|
#define HASH_FAIL -1
|
||||||
#define HASH_LIMIT 0.5
|
#define HASH_LIMIT 0.5
|
||||||
|
|
||||||
/* initialize new hash table */
|
/* initialize new hash table */
|
||||||
static void inthash_init(inthash_t *tptr, int buckets);
|
static void taginthash_init(taginthash_t *tptr, tagint buckets);
|
||||||
/* lookup entry in hash table */
|
/* lookup entry in hash table */
|
||||||
static int inthash_lookup(const inthash_t *tptr, int key);
|
static tagint taginthash_lookup(const taginthash_t *tptr, tagint key);
|
||||||
/* generate list of keys for reverse lookups. */
|
/* generate list of keys for reverse lookups. */
|
||||||
static int *inthash_keys(inthash_t *tptr);
|
static tagint *taginthash_keys(taginthash_t *tptr);
|
||||||
/* insert an entry into hash table. */
|
/* insert an entry taginto hash table. */
|
||||||
static int inthash_insert(inthash_t *tptr, int key, int data);
|
static tagint taginthash_insert(taginthash_t *tptr, tagint key, tagint data);
|
||||||
/* delete the hash table */
|
/* delete the hash table */
|
||||||
static void inthash_destroy(inthash_t *tptr);
|
static void taginthash_destroy(taginthash_t *tptr);
|
||||||
/* adapted sort for in-place sorting of map indices. */
|
/* adapted sort for in-place sorting of map indices. */
|
||||||
static void id_sort(int *idmap, int left, int right);
|
static void id_sort(tagint *idmap, tagint left, tagint right);
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* integer hash code:
|
* integer hash code:
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
/* inthash() - Hash function returns a hash number for a given key.
|
/* taginthash() - Hash function returns a hash number for a given key.
|
||||||
* tptr: Pointer to a hash table, key: The key to create a hash number for */
|
* tptr: Pointer to a hash table, key: The key to create a hash number for */
|
||||||
static int inthash(const inthash_t *tptr, int key) {
|
static tagint taginthash(const taginthash_t *tptr, tagint key) {
|
||||||
int hashvalue;
|
tagint hashvalue;
|
||||||
|
|
||||||
hashvalue = (((key*1103515249)>>tptr->downshift) & tptr->mask);
|
hashvalue = (((key*1103515249)>>tptr->downshift) & tptr->mask);
|
||||||
if (hashvalue < 0) {
|
if (hashvalue < 0) {
|
||||||
@ -135,25 +134,25 @@ static int inthash(const inthash_t *tptr, int key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rebuild_table_int() - Create new hash table when old one fills up.
|
* rebuild_table_tagint() - Create new hash table when old one fills up.
|
||||||
*
|
*
|
||||||
* tptr: Pointer to a hash table
|
* tptr: Pointer to a hash table
|
||||||
*/
|
*/
|
||||||
static void rebuild_table_int(inthash_t *tptr) {
|
static void rebuild_table_tagint(taginthash_t *tptr) {
|
||||||
inthash_node_t **old_bucket, *old_hash, *tmp;
|
taginthash_node_t **old_bucket, *old_hash, *tmp;
|
||||||
int old_size, h, i;
|
tagint old_size, h, i;
|
||||||
|
|
||||||
old_bucket=tptr->bucket;
|
old_bucket=tptr->bucket;
|
||||||
old_size=tptr->size;
|
old_size=tptr->size;
|
||||||
|
|
||||||
/* create a new table and rehash old buckets */
|
/* create a new table and rehash old buckets */
|
||||||
inthash_init(tptr, old_size<<1);
|
taginthash_init(tptr, old_size<<1);
|
||||||
for (i=0; i<old_size; i++) {
|
for (i=0; i<old_size; i++) {
|
||||||
old_hash=old_bucket[i];
|
old_hash=old_bucket[i];
|
||||||
while(old_hash) {
|
while(old_hash) {
|
||||||
tmp=old_hash;
|
tmp=old_hash;
|
||||||
old_hash=old_hash->next;
|
old_hash=old_hash->next;
|
||||||
h=inthash(tptr, tmp->key);
|
h=taginthash(tptr, tmp->key);
|
||||||
tmp->next=tptr->bucket[h];
|
tmp->next=tptr->bucket[h];
|
||||||
tptr->bucket[h]=tmp;
|
tptr->bucket[h]=tmp;
|
||||||
tptr->entries++;
|
tptr->entries++;
|
||||||
@ -167,12 +166,12 @@ static void rebuild_table_int(inthash_t *tptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* inthash_init() - Initialize a new hash table.
|
* taginthash_init() - Initialize a new hash table.
|
||||||
*
|
*
|
||||||
* tptr: Pointer to the hash table to initialize
|
* tptr: Pointer to the hash table to initialize
|
||||||
* buckets: The number of initial buckets to create
|
* buckets: The number of initial buckets to create
|
||||||
*/
|
*/
|
||||||
void inthash_init(inthash_t *tptr, int buckets) {
|
void taginthash_init(taginthash_t *tptr, tagint buckets) {
|
||||||
|
|
||||||
/* make sure we allocate something */
|
/* make sure we allocate something */
|
||||||
if (buckets==0)
|
if (buckets==0)
|
||||||
@ -192,25 +191,25 @@ void inthash_init(inthash_t *tptr, int buckets) {
|
|||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
/* allocate memory for table */
|
/* allocate memory for table */
|
||||||
tptr->bucket=(inthash_node_t **) calloc(tptr->size, sizeof(inthash_node_t *));
|
tptr->bucket=(taginthash_node_t **) calloc(tptr->size, sizeof(taginthash_node_t *));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* inthash_lookup() - Lookup an entry in the hash table and return a pointer to
|
* taginthash_lookup() - Lookup an entry in the hash table and return a pointer to
|
||||||
* it or HASH_FAIL if it wasn't found.
|
* it or HASH_FAIL if it wasn't found.
|
||||||
*
|
*
|
||||||
* tptr: Pointer to the hash table
|
* tptr: Pointer to the hash table
|
||||||
* key: The key to lookup
|
* key: The key to lookup
|
||||||
*/
|
*/
|
||||||
int inthash_lookup(const inthash_t *tptr, int key) {
|
tagint taginthash_lookup(const taginthash_t *tptr, tagint key) {
|
||||||
int h;
|
tagint h;
|
||||||
inthash_node_t *node;
|
taginthash_node_t *node;
|
||||||
|
|
||||||
|
|
||||||
/* find the entry in the hash table */
|
/* find the entry in the hash table */
|
||||||
h=inthash(tptr, key);
|
h=taginthash(tptr, key);
|
||||||
for (node=tptr->bucket[h]; node!=NULL; node=node->next) {
|
for (node=tptr->bucket[h]; node!=NULL; node=node->next) {
|
||||||
if (node->key == key)
|
if (node->key == key)
|
||||||
break;
|
break;
|
||||||
@ -222,17 +221,17 @@ int inthash_lookup(const inthash_t *tptr, int key) {
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* inthash_keys() - Return a list of keys.
|
* taginthash_keys() - Return a list of keys.
|
||||||
* NOTE: the returned list must be freed with free(3).
|
* NOTE: the returned list must be freed with free(3).
|
||||||
*/
|
*/
|
||||||
int *inthash_keys(inthash_t *tptr) {
|
tagint *taginthash_keys(taginthash_t *tptr) {
|
||||||
|
|
||||||
int *keys;
|
tagint *keys;
|
||||||
inthash_node_t *node;
|
taginthash_node_t *node;
|
||||||
|
|
||||||
keys = (int *)calloc(tptr->entries, sizeof(int));
|
keys = (tagint *)calloc(tptr->entries, sizeof(tagint));
|
||||||
|
|
||||||
for (int i=0; i < tptr->size; ++i) {
|
for (tagint i=0; i < tptr->size; ++i) {
|
||||||
for (node=tptr->bucket[i]; node != NULL; node=node->next) {
|
for (node=tptr->bucket[i]; node != NULL; node=node->next) {
|
||||||
keys[node->data] = node->key;
|
keys[node->data] = node->key;
|
||||||
}
|
}
|
||||||
@ -242,29 +241,29 @@ int *inthash_keys(inthash_t *tptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* inthash_insert() - Insert an entry into the hash table. If the entry already
|
* taginthash_insert() - Insert an entry into the hash table. If the entry already
|
||||||
* exists return a pointer to it, otherwise return HASH_FAIL.
|
* exists return a pointer to it, otherwise return HASH_FAIL.
|
||||||
*
|
*
|
||||||
* tptr: A pointer to the hash table
|
* tptr: A pointer to the hash table
|
||||||
* key: The key to insert into the hash table
|
* key: The key to insert into the hash table
|
||||||
* data: A pointer to the data to insert into the hash table
|
* data: A pointer to the data to insert into the hash table
|
||||||
*/
|
*/
|
||||||
int inthash_insert(inthash_t *tptr, int key, int data) {
|
tagint taginthash_insert(taginthash_t *tptr, tagint key, tagint data) {
|
||||||
int tmp;
|
tagint tmp;
|
||||||
inthash_node_t *node;
|
taginthash_node_t *node;
|
||||||
int h;
|
tagint h;
|
||||||
|
|
||||||
/* check to see if the entry exists */
|
/* check to see if the entry exists */
|
||||||
if ((tmp=inthash_lookup(tptr, key)) != HASH_FAIL)
|
if ((tmp=taginthash_lookup(tptr, key)) != HASH_FAIL)
|
||||||
return(tmp);
|
return(tmp);
|
||||||
|
|
||||||
/* expand the table if needed */
|
/* expand the table if needed */
|
||||||
while (tptr->entries>=HASH_LIMIT*tptr->size)
|
while (tptr->entries>=HASH_LIMIT*tptr->size)
|
||||||
rebuild_table_int(tptr);
|
rebuild_table_tagint(tptr);
|
||||||
|
|
||||||
/* insert the new entry */
|
/* insert the new entry */
|
||||||
h=inthash(tptr, key);
|
h=taginthash(tptr, key);
|
||||||
node=(struct inthash_node_t *) malloc(sizeof(inthash_node_t));
|
node=(struct taginthash_node_t *) malloc(sizeof(taginthash_node_t));
|
||||||
node->data=data;
|
node->data=data;
|
||||||
node->key=key;
|
node->key=key;
|
||||||
node->next=tptr->bucket[h];
|
node->next=tptr->bucket[h];
|
||||||
@ -275,12 +274,12 @@ int inthash_insert(inthash_t *tptr, int key, int data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* inthash_destroy() - Delete the entire table, and all remaining entries.
|
* taginthash_destroy() - Delete the entire table, and all remaining entries.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void inthash_destroy(inthash_t *tptr) {
|
void taginthash_destroy(taginthash_t *tptr) {
|
||||||
inthash_node_t *node, *last;
|
taginthash_node_t *node, *last;
|
||||||
int i;
|
tagint i;
|
||||||
|
|
||||||
for (i=0; i<tptr->size; i++) {
|
for (i=0; i<tptr->size; i++) {
|
||||||
node = tptr->bucket[i];
|
node = tptr->bucket[i];
|
||||||
@ -294,18 +293,18 @@ void inthash_destroy(inthash_t *tptr) {
|
|||||||
/* free the entire array of buckets */
|
/* free the entire array of buckets */
|
||||||
if (tptr->bucket != NULL) {
|
if (tptr->bucket != NULL) {
|
||||||
free(tptr->bucket);
|
free(tptr->bucket);
|
||||||
memset(tptr, 0, sizeof(inthash_t));
|
memset(tptr, 0, sizeof(taginthash_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* integer list sort code:
|
* taginteger list sort code:
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
/* sort for integer map. initial call id_sort(idmap, 0, natoms - 1); */
|
/* sort for taginteger map. initial call id_sort(idmap, 0, natoms - 1); */
|
||||||
static void id_sort(int *idmap, int left, int right)
|
static void id_sort(tagint *idmap, tagint left, tagint right)
|
||||||
{
|
{
|
||||||
int pivot, l_hold, r_hold;
|
tagint pivot, l_hold, r_hold;
|
||||||
|
|
||||||
l_hold = left;
|
l_hold = left;
|
||||||
r_hold = right;
|
r_hold = right;
|
||||||
@ -433,12 +432,9 @@ static void imdsock_destroy(void *);
|
|||||||
* The implementation follows at the end of the file. *
|
* The implementation follows at the end of the file. *
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
|
||||||
using namespace FixConst;
|
|
||||||
|
|
||||||
/* struct for packed data communication of coordinates and forces. */
|
/* struct for packed data communication of coordinates and forces. */
|
||||||
struct commdata {
|
struct commdata {
|
||||||
int tag;
|
tagint tag;
|
||||||
float x,y,z;
|
float x,y,z;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -580,10 +576,10 @@ FixIMD::~FixIMD()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inthash_t *hashtable = (inthash_t *)idmap;
|
taginthash_t *hashtable = (taginthash_t *)idmap;
|
||||||
memory->destroy(comm_buf);
|
memory->destroy(comm_buf);
|
||||||
memory->destroy(force_buf);
|
memory->destroy(force_buf);
|
||||||
inthash_destroy(hashtable);
|
taginthash_destroy(hashtable);
|
||||||
delete hashtable;
|
delete hashtable;
|
||||||
free(rev_idmap);
|
free(rev_idmap);
|
||||||
// close sockets
|
// close sockets
|
||||||
@ -626,12 +622,13 @@ int FixIMD::reconnect()
|
|||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
if (clientsock) return 1;
|
if (clientsock) return 1;
|
||||||
if (screen && connect_msg)
|
if (screen && connect_msg) {
|
||||||
if (nowait_flag)
|
if (nowait_flag) {
|
||||||
fprintf(screen,"Listening for IMD connection on port %d. Transfer rate %d.\n",imd_port, imd_trate);
|
fprintf(screen,"Listening for IMD connection on port %d. Transfer rate %d.\n",imd_port, imd_trate);
|
||||||
else
|
} else {
|
||||||
fprintf(screen,"Waiting for IMD connection on port %d. Transfer rate %d.\n",imd_port, imd_trate);
|
fprintf(screen,"Waiting for IMD connection on port %d. Transfer rate %d.\n",imd_port, imd_trate);
|
||||||
|
}
|
||||||
|
}
|
||||||
connect_msg = 0;
|
connect_msg = 0;
|
||||||
clientsock = NULL;
|
clientsock = NULL;
|
||||||
if (nowait_flag) {
|
if (nowait_flag) {
|
||||||
@ -693,7 +690,7 @@ void FixIMD::setup(int)
|
|||||||
int i,j;
|
int i,j;
|
||||||
int nmax,nme,nlocal;
|
int nmax,nme,nlocal;
|
||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
int *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
nlocal = atom->nlocal;
|
nlocal = atom->nlocal;
|
||||||
nme=0;
|
nme=0;
|
||||||
for (i=0; i < nlocal; ++i)
|
for (i=0; i < nlocal; ++i)
|
||||||
@ -712,8 +709,8 @@ void FixIMD::setup(int)
|
|||||||
error->all(FLERR,"LAMMPS terminated on error in setting up IMD connection.");
|
error->all(FLERR,"LAMMPS terminated on error in setting up IMD connection.");
|
||||||
|
|
||||||
/* initialize and build hashtable. */
|
/* initialize and build hashtable. */
|
||||||
inthash_t *hashtable=new inthash_t;
|
taginthash_t *hashtable=new taginthash_t;
|
||||||
inthash_init(hashtable, num_coords);
|
taginthash_init(hashtable, num_coords);
|
||||||
idmap = (void *)hashtable;
|
idmap = (void *)hashtable;
|
||||||
|
|
||||||
MPI_Status status;
|
MPI_Status status;
|
||||||
@ -722,7 +719,7 @@ void FixIMD::setup(int)
|
|||||||
struct commdata *buf = static_cast<struct commdata *>(comm_buf);
|
struct commdata *buf = static_cast<struct commdata *>(comm_buf);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
int *taglist = new int[num_coords];
|
tagint *taglist = new tagint[num_coords];
|
||||||
int numtag=0; /* counter to map atom tags to a 0-based consecutive index list */
|
int numtag=0; /* counter to map atom tags to a 0-based consecutive index list */
|
||||||
|
|
||||||
for (i=0; i < nlocal; ++i) {
|
for (i=0; i < nlocal; ++i) {
|
||||||
@ -750,13 +747,13 @@ void FixIMD::setup(int)
|
|||||||
* same list when running in parallel and build hash table. */
|
* same list when running in parallel and build hash table. */
|
||||||
id_sort(taglist, 0, num_coords-1);
|
id_sort(taglist, 0, num_coords-1);
|
||||||
for (i=0; i < num_coords; ++i) {
|
for (i=0; i < num_coords; ++i) {
|
||||||
inthash_insert(hashtable, taglist[i], i);
|
taginthash_insert(hashtable, taglist[i], i);
|
||||||
}
|
}
|
||||||
delete[] taglist;
|
delete[] taglist;
|
||||||
|
|
||||||
/* generate reverse index-to-tag map for communicating
|
/* generate reverse index-to-tag map for communicating
|
||||||
* IMD forces back to the proper atoms */
|
* IMD forces back to the proper atoms */
|
||||||
rev_idmap=inthash_keys(hashtable);
|
rev_idmap=taginthash_keys(hashtable);
|
||||||
} else {
|
} else {
|
||||||
nme=0;
|
nme=0;
|
||||||
for (i=0; i < nlocal; ++i) {
|
for (i=0; i < nlocal; ++i) {
|
||||||
@ -827,7 +824,7 @@ void FixIMD::post_force(int vflag)
|
|||||||
return; /* IMD client has detached and not yet come back. do nothing. */
|
return; /* IMD client has detached and not yet come back. do nothing. */
|
||||||
}
|
}
|
||||||
|
|
||||||
int *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
imageint *image = atom->image;
|
imageint *image = atom->image;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
@ -1040,8 +1037,8 @@ void FixIMD::post_force(int vflag)
|
|||||||
|
|
||||||
for (i=0; i<nlocal; ++i) {
|
for (i=0; i<nlocal; ++i) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
const int j = 3*inthash_lookup((inthash_t *)idmap, tag[i]);
|
const tagint j = 3*taginthash_lookup((taginthash_t *)idmap, tag[i]);
|
||||||
if (j != HASH_FAIL) {
|
if (j != 3*HASH_FAIL) {
|
||||||
int ix = (image[i] & IMGMASK) - IMGMAX;
|
int ix = (image[i] & IMGMASK) - IMGMAX;
|
||||||
int iy = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
int iy = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
||||||
int iz = (image[i] >> IMG2BITS) - IMGMAX;
|
int iz = (image[i] >> IMG2BITS) - IMGMAX;
|
||||||
@ -1061,8 +1058,8 @@ void FixIMD::post_force(int vflag)
|
|||||||
} else {
|
} else {
|
||||||
for (i=0; i<nlocal; ++i) {
|
for (i=0; i<nlocal; ++i) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
const int j = 3*inthash_lookup((inthash_t *)idmap, tag[i]);
|
const tagint j = 3*taginthash_lookup((taginthash_t *)idmap, tag[i]);
|
||||||
if (j != HASH_FAIL) {
|
if (j != 3*HASH_FAIL) {
|
||||||
recvcoord[j] = x[i][0];
|
recvcoord[j] = x[i][0];
|
||||||
recvcoord[j+1] = x[i][1];
|
recvcoord[j+1] = x[i][1];
|
||||||
recvcoord[j+2] = x[i][2];
|
recvcoord[j+2] = x[i][2];
|
||||||
@ -1080,8 +1077,8 @@ void FixIMD::post_force(int vflag)
|
|||||||
ndata /= size_one;
|
ndata /= size_one;
|
||||||
|
|
||||||
for (k=0; k<ndata; ++k) {
|
for (k=0; k<ndata; ++k) {
|
||||||
const int j = 3*inthash_lookup((inthash_t *)idmap, buf[k].tag);
|
const tagint j = 3*taginthash_lookup((taginthash_t *)idmap, buf[k].tag);
|
||||||
if (j != HASH_FAIL) {
|
if (j != 3*HASH_FAIL) {
|
||||||
recvcoord[j] = buf[k].x;
|
recvcoord[j] = buf[k].x;
|
||||||
recvcoord[j+1] = buf[k].y;
|
recvcoord[j+1] = buf[k].y;
|
||||||
recvcoord[j+2] = buf[k].z;
|
recvcoord[j+2] = buf[k].z;
|
||||||
|
|||||||
@ -82,7 +82,7 @@ class FixIMD : public Fix {
|
|||||||
int maxbuf; // size of atom communication buffer.
|
int maxbuf; // size of atom communication buffer.
|
||||||
void *comm_buf; // communication buffer
|
void *comm_buf; // communication buffer
|
||||||
void *idmap; // hash for mapping atom indices to consistent order.
|
void *idmap; // hash for mapping atom indices to consistent order.
|
||||||
int *rev_idmap; // list of the hash keys for reverse mapping.
|
tagint *rev_idmap; // list of the hash keys for reverse mapping.
|
||||||
|
|
||||||
int imd_forces; // number of forces communicated via IMD.
|
int imd_forces; // number of forces communicated via IMD.
|
||||||
void *force_buf; // force data buffer
|
void *force_buf; // force data buffer
|
||||||
|
|||||||
@ -15,10 +15,6 @@
|
|||||||
Contributing author: Axel Kohlmeyer (Temple U)
|
Contributing author: Axel Kohlmeyer (Temple U)
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef LAMMPS_BIGBIG
|
|
||||||
#error LAMMPS_BIGBIG not supported by this file
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -305,11 +301,11 @@ void DumpMolfile::openfile()
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void DumpMolfile::pack(int *ids)
|
void DumpMolfile::pack(tagint *ids)
|
||||||
{
|
{
|
||||||
int m,n;
|
int m,n;
|
||||||
|
|
||||||
int *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
int *type = atom->type;
|
int *type = atom->type;
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
imageint *image = atom->image;
|
imageint *image = atom->image;
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class DumpMolfile : public Dump {
|
|||||||
virtual void init_style();
|
virtual void init_style();
|
||||||
virtual int modify_param(int, char **);
|
virtual int modify_param(int, char **);
|
||||||
virtual void write_header(bigint) {};
|
virtual void write_header(bigint) {};
|
||||||
virtual void pack(int *);
|
virtual void pack(tagint *);
|
||||||
virtual void write_data(int, double *);
|
virtual void write_data(int, double *);
|
||||||
virtual bigint memory_usage();
|
virtual bigint memory_usage();
|
||||||
virtual void openfile();
|
virtual void openfile();
|
||||||
|
|||||||
Reference in New Issue
Block a user