From 3e9c22df246572da11384c0c195cb75ca126c2a1 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 4 Apr 2014 16:32:26 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11699 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/USER-OMP/fix_shear_history_omp.cpp | 48 +++++++++++++++----------- src/fix_recenter.cpp | 36 +++++++++++++++++-- src/fix_recenter.h | 6 ++-- src/irregular.cpp | 2 ++ 4 files changed, 66 insertions(+), 26 deletions(-) diff --git a/src/USER-OMP/fix_shear_history_omp.cpp b/src/USER-OMP/fix_shear_history_omp.cpp index 1f629a4bf5..18c3c2af4e 100644 --- a/src/USER-OMP/fix_shear_history_omp.cpp +++ b/src/USER-OMP/fix_shear_history_omp.cpp @@ -32,8 +32,8 @@ using namespace LAMMPS_NS; using namespace FixConst; /* ---------------------------------------------------------------------- - copy shear partner info from neighbor lists to atom arrays - so can be exchanged with atoms + copy shear partner info from neighbor lists to per-atom arrays + so it can be exchanged with those atoms ------------------------------------------------------------------------- */ void FixShearHistoryOMP::pre_exchange() @@ -44,7 +44,7 @@ void FixShearHistoryOMP::pre_exchange() const int nall = nlocal + nghost; const int nthreads = comm->nthreads; maxtouch = 0; - + #if defined(_OPENMP) #pragma omp parallel default(none) #endif @@ -56,22 +56,11 @@ void FixShearHistoryOMP::pre_exchange() const int tid = 0; #endif - // each thread works on a fixed chunk of local and ghost atoms. - const int ldelta = 1 + nlocal/nthreads; - const int lfrom = tid*ldelta; - const int lmax = lfrom +ldelta; - const int lto = (lmax > nlocal) ? nlocal : lmax; - int i,j,ii,jj,m,n,inum,jnum; int *ilist,*jlist,*numneigh,**firstneigh; int *touch,**firsttouch; double *shear,*allshear,**firstshear; - // zero npartners for all current atoms and - // clear page data structures for this thread - - for (i = lfrom; i < lto; i++) npartner[i] = 0; - MyPage &ipg = ipage[tid]; MyPage &dpg = dpage[tid]; ipg.reset(); @@ -90,6 +79,21 @@ void FixShearHistoryOMP::pre_exchange() firsttouch = list->listgranhistory->firstneigh; firstshear = list->listgranhistory->firstdouble; + int nlocal_neigh = 0; + if (inum) nlocal_neigh = ilist[inum-1] + 1; + + // each thread works on a fixed chunk of local and ghost atoms. + const int ldelta = 1 + nlocal_neigh/nthreads; + const int lfrom = tid*ldelta; + const int lmax = lfrom +ldelta; + const int lto = (lmax > nlocal_neigh) ? nlocal_neigh : lmax; + + // zero npartners for all current atoms and + // clear page data structures for this thread + + for (i = lfrom; i < lto; i++) npartner[i] = 0; + + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; jlist = firstneigh[i]; @@ -111,13 +115,15 @@ void FixShearHistoryOMP::pre_exchange() // get page chunks to store atom IDs and shear history for my atoms - for (ii = lfrom; ii < lto; ii++) { + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; - n = npartner[i]; - partner[i] = ipg.get(n); - shearpartner[i] = dpg.get(n); - if (partner[i] == NULL || shearpartner[i] == NULL) - error->one(FLERR,"Shear history overflow, boost neigh_modify one"); + if ((i >= lfrom) && (i < lto)) { + n = npartner[i]; + partner[i] = ipg.get(n); + shearpartner[i] = dpg.get(n); + if (partner[i] == NULL || shearpartner[i] == NULL) + error->one(FLERR,"Shear history overflow, boost neigh_modify one"); + } } // 2nd loop over neighbor list @@ -161,7 +167,7 @@ void FixShearHistoryOMP::pre_exchange() } // set maxtouch = max # of partners of any owned atom - m = 0; + maxtouch = m = 0; for (i = lfrom; i < lto; i++) m = MAX(m,npartner[i]); diff --git a/src/fix_recenter.cpp b/src/fix_recenter.cpp index 29e77b2555..2d8ee41f93 100644 --- a/src/fix_recenter.cpp +++ b/src/fix_recenter.cpp @@ -42,6 +42,16 @@ FixRecenter::FixRecenter(LAMMPS *lmp, int narg, char **arg) : xcom = ycom = zcom = 0.0; xflag = yflag = zflag = 1; xinitflag = yinitflag = zinitflag = 0; + shift[0] = shift[1] = shift[2] = 0.0; + distance = 0.0; + scalar_flag = 1; + vector_flag = 1; + size_vector = 3; + extscalar = 1; + extvector = 1; + global_freq = 1; + +/* ---------------------------------------------------------------------- */ if (strcmp(arg[3],"NULL") == 0) xflag = 0; else if (strcmp(arg[3],"INIT") == 0) xinitflag = 1; @@ -177,10 +187,30 @@ void FixRecenter::initial_integrate(int vflag) int *mask = atom->mask; int nlocal = atom->nlocal; + shift[0] = xflag ? (xtarget - xcm[0]) : 0.0; + shift[1] = yflag ? (ytarget - xcm[1]) : 0.0; + shift[2] = zflag ? (ztarget - xcm[2]) : 0.0; + distance = sqrt(shift[0]*shift[0] + shift[1]*shift[1] + shift[2]*shift[2]); + for (int i = 0; i < nlocal; i++) if (mask[i] & group2bit) { - if (xflag) x[i][0] += xtarget - xcm[0]; - if (yflag) x[i][1] += ytarget - xcm[1]; - if (zflag) x[i][2] += ztarget - xcm[2]; + x[i][0] += shift[0]; + x[i][1] += shift[1]; + x[i][2] += shift[2]; } } + +/* ---------------------------------------------------------------------- */ + +double FixRecenter::compute_scalar() +{ + return distance; +} + +/* ---------------------------------------------------------------------- */ + +double FixRecenter::compute_vector(int n) +{ + return shift[n]; +} + diff --git a/src/fix_recenter.h b/src/fix_recenter.h index 0abe8dcf56..bf6bcc0301 100644 --- a/src/fix_recenter.h +++ b/src/fix_recenter.h @@ -1,4 +1,4 @@ -/* ---------------------------------------------------------------------- +/* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov @@ -30,12 +30,14 @@ class FixRecenter : public Fix { int setmask(); void init(); void initial_integrate(int); + double compute_scalar(); + double compute_vector(int); private: int group2bit,scaleflag; int xflag,yflag,zflag; int xinitflag,yinitflag,zinitflag; - double xcom,ycom,zcom,xinit,yinit,zinit,masstotal; + double xcom,ycom,zcom,xinit,yinit,zinit,masstotal,distance,shift[3]; }; } diff --git a/src/irregular.cpp b/src/irregular.cpp index b9203ebdd8..6b3ade751e 100644 --- a/src/irregular.cpp +++ b/src/irregular.cpp @@ -145,7 +145,9 @@ void Irregular::migrate_atoms() // create irregular communication plan, perform comm, destroy plan // returned nrecv = size of buffer needed for incoming atoms + // debug: turn on sorting for repoducible irregular() via extra final arg + //int nrecv = create_atom(nsendatom,sizes,proclist,1); int nrecv = create_atom(nsendatom,sizes,proclist); if (nrecv > maxrecv) grow_recv(nrecv); exchange_atom(buf_send,sizes,buf_recv);