introduced process_neighbours function
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Tue, 9 Sep 2008 21:04:05 +0000 (23:04 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Tue, 9 Sep 2008 21:04:05 +0000 (23:04 +0200)
moldyn.c
moldyn.h

index 6da2b95..3ac0a2d 100644 (file)
--- a/moldyn.c
+++ b/moldyn.c
@@ -1772,7 +1772,7 @@ int moldyn_integrate(t_moldyn *moldyn) {
                }
 
                /* display progress */
-               //if(!(moldyn->total_steps%10)) {
+               if(!(moldyn->total_steps%10)) {
                        /* get current time */
                        gettimeofday(&t2,NULL);
 
@@ -1788,7 +1788,7 @@ printf("\rsched:%d, steps:%d/%d, T:%4.1f/%4.1f P:%4.1f/%4.1f V:%6.1f (%d)",
 
                        /* copy over time */
                        t1=t2;
-               //}
+               }
 
                /* increase absolute time */
                moldyn->time+=moldyn->tau;
@@ -2515,6 +2515,84 @@ int process_2b_bonds(t_moldyn *moldyn,void *data,
 
 }
 
+/*
+ * function to find neighboured atoms
+ */
+
+int process_neighbours(t_moldyn *moldyn,void *data,t_atom *atom,
+                       int (*process)(t_moldyn *moldyn,t_atom *atom,t_atom *natom,
+                                     void *data,u8 bc)) {
+
+       t_linkcell *lc;
+#ifdef STATIC_LISTS
+       int *neighbour[27];
+       int p;
+#elif LOWMEM_LISTS
+       int neighbour[27];
+       int p;
+#else
+       t_list neighbour[27];
+       t_list *this;
+#endif
+       u8 bc;
+       t_atom *natom;
+       int j;
+
+       lc=&(moldyn->lc);
+       
+       /* neighbour indexing */
+       link_cell_neighbour_index(moldyn,
+                                 (atom->r.x+moldyn->dim.x/2)/lc->x,
+                                 (atom->r.y+moldyn->dim.y/2)/lc->x,
+                                 (atom->r.z+moldyn->dim.z/2)/lc->x,
+                                 neighbour);
+
+       for(j=0;j<27;j++) {
+
+               bc=(j<lc->dnlc)?0:1;
+
+#ifdef STATIC_LISTS
+               p=0;
+
+               while(neighbour[j][p]!=-1) {
+
+                       natom=&(moldyn->atom[neighbour[j][p]]);
+                       p++;
+#elif LOWMEM_LISTS
+               p=neighbour[j];
+
+               while(p!=-1) {
+
+                       natom=&(moldyn->atom[p]);
+                       p=lc->subcell->list[p];
+#else
+               this=&(neighbour[j]);
+               list_reset_f(this);
+
+               if(this->start==NULL)
+                       continue;
+
+               do {
+
+                       natom=this->current->data;
+#endif
+
+                       /* process bond */
+                       process(moldyn,atom,natom,data,bc);
+
+#ifdef STATIC_LISTS
+               }
+#elif LOWMEM_LISTS
+               }
+#else
+               } while(list_next_f(this)!=L_NO_NEXT_ELEMENT);
+#endif
+       }
+
+       return 0;
+
+}
+
 /*
  * post processing functions
  */
index da951b5..87c8948 100644 (file)
--- a/moldyn.h
+++ b/moldyn.h
@@ -463,6 +463,10 @@ int moldyn_load(t_moldyn *moldyn);
 int process_2b_bonds(t_moldyn *moldyn,void *data,
                      int (*process)(t_moldyn *moldyn,t_atom *itom,t_atom *jtom,
                                     void *data,u8 bc));
+int process_neighbours(t_moldyn *moldyn,void *data,t_atom *atom,
+                       int (*process)(t_moldyn *moldyn,t_atom *atom,t_atom *natom,
+                                      void *data,u8 bc));
+
 int get_line(int fd,char *line,int max);
 
 int pair_correlation_init(t_moldyn *moldyn,double dr);