From: hackbard Date: Tue, 9 Sep 2008 21:04:05 +0000 (+0200) Subject: introduced process_neighbours function X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22a224e0f41f996954049c69bcc6fbb3cf62325f;p=physik%2Fposic.git introduced process_neighbours function --- diff --git a/moldyn.c b/moldyn.c index 6da2b95..3ac0a2d 100644 --- 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=(jdnlc)?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 */ diff --git a/moldyn.h b/moldyn.h index da951b5..87c8948 100644 --- 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);