]> hackdaworld.org Git - physik/posic.git/commitdiff
fixed static lists + first work on lowmem lists
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Mon, 1 Sep 2008 14:23:14 +0000 (16:23 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Mon, 1 Sep 2008 14:23:14 +0000 (16:23 +0200)
moldyn.c
potentials/albe_fast.c

index b73cd3432b65971aabc055e7f126fc5efdb3deb4..7a9709e107a69c0f735eff1f01006611bcbb30ec 100644 (file)
--- a/moldyn.c
+++ b/moldyn.c
@@ -1308,6 +1308,8 @@ int link_cell_init(t_moldyn *moldyn,u8 vol) {
 
 #ifdef STATIC_LISTS
        lc->subcell=malloc(lc->cells*sizeof(int*));
+#elif LOWMEM_LIST
+       lc->subcell=malloc(t_lowmem_list);
 #else
        lc->subcell=malloc(lc->cells*sizeof(t_list));
 #endif
@@ -1325,6 +1327,9 @@ int link_cell_init(t_moldyn *moldyn,u8 vol) {
 #ifdef STATIC_LISTS
                printf("[moldyn] initializing 'static' linked cells (%d)\n",
                       lc->cells);
+#elif LOWMEM_LIST
+               printf("[moldyn] initializing 'lowmem' linked cells (%d)\n",
+                      lc->cells);
 #else
                printf("[moldyn] initializing 'dynamic' linked cells (%d)\n",
                       lc->cells);
@@ -1348,6 +1353,17 @@ int link_cell_init(t_moldyn *moldyn,u8 vol) {
                               i,lc->subcell[0],lc->subcell);
                */
        }
+#elif LOWMEM_LIST
+       lc->subcell->head=malloc(lc->cells*sizeof(int));
+       if(lc->subcell->head==NULL) {
+               perror("[moldyn] head init (malloc)");
+               return -1;
+       }
+       lc->subcell->list=malloc(moldyn->count*sizeof(int));
+       if(lc->subcell->list==NULL) {
+               perror("[moldyn] list init (malloc)");
+               return -1;
+       }
 #else
        for(i=0;i<lc->cells;i++)
                list_init_f(&(lc->subcell[i]));
@@ -1377,7 +1393,9 @@ int link_cell_update(t_moldyn *moldyn) {
 
        for(i=0;i<lc->cells;i++)
 #ifdef STATIC_LISTS
-               memset(lc->subcell[i],0,(MAX_ATOMS_PER_LIST+1)*sizeof(int));
+               memset(lc->subcell[i],-1,(MAX_ATOMS_PER_LIST+1)*sizeof(int));
+#elif LOWMEM_LIST
+               lc->subcell->head[i]=-1;
 #else
                list_destroy_f(&(lc->subcell[i]));
 #endif
@@ -1389,7 +1407,7 @@ int link_cell_update(t_moldyn *moldyn) {
        
 #ifdef STATIC_LISTS
                p=0;
-               while(lc->subcell[i+j*nx+k*nx*ny][p]!=0)
+               while(lc->subcell[i+j*nx+k*nx*ny][p]!=-1)
                        p++;
 
                if(p>=MAX_ATOMS_PER_LIST) {
@@ -1398,6 +1416,9 @@ int link_cell_update(t_moldyn *moldyn) {
                }
 
                lc->subcell[i+j*nx+k*nx*ny][p]=count;
+#elif LOWMEM_LIST
+               lc->subcell->list[count]=list->subcell->head[i+j*nx+k*nx*ny];
+               list->subcell->head=count;
 #else
                list_add_immediate_f(&(lc->subcell[i+j*nx+k*nx*ny]),
                                     &(atom[count]));
@@ -1851,6 +1872,7 @@ int potential_force_calc(t_moldyn *moldyn) {
 
        /* reset force, site energy and virial of every atom */
 #ifdef PARALLEL
+       i=omp_get_thread_num();
        #pragma omp parallel for private(virial)
 #endif
        for(i=0;i<count;i++) {
@@ -1903,7 +1925,7 @@ int potential_force_calc(t_moldyn *moldyn) {
 #ifdef STATIC_LISTS
                                p=0;
 
-                               while(neighbour_i[j][p]!=0) {
+                               while(neighbour_i[j][p]!=-1) {
 
                                        jtom=&(atom[neighbour_i[j][p]]);
                                        p++;
@@ -1956,7 +1978,7 @@ int potential_force_calc(t_moldyn *moldyn) {
 #ifdef STATIC_LISTS
                        p=0;
 
-                       while(neighbour_i[j][p]!=0) {
+                       while(neighbour_i[j][p]!=-1) {
 
                                jtom=&(atom[neighbour_i[j][p]]);
                                p++;
@@ -2000,7 +2022,7 @@ int potential_force_calc(t_moldyn *moldyn) {
 #ifdef STATIC_LISTS
                                        q=0;
 
-                                       while(neighbour_i[j][q]!=0) {
+                                       while(neighbour_i[k][q]!=-1) {
 
                                                ktom=&(atom[neighbour_i[k][q]]);
                                                q++;
@@ -2055,7 +2077,7 @@ int potential_force_calc(t_moldyn *moldyn) {
 #ifdef STATIC_LISTS
                                        q=0;
 
-                                       while(neighbour_i[j][q]!=0) {
+                                       while(neighbour_i[k][q]!=-1) {
 
                                                ktom=&(atom[neighbour_i[k][q]]);
                                                q++;
@@ -2371,7 +2393,7 @@ int process_2b_bonds(t_moldyn *moldyn,void *data,
 #ifdef STATIC_LISTS
                        p=0;
 
-                       while(neighbour[j][p]!=0) {
+                       while(neighbour[j][p]!=-1) {
 
                                jtom=&(moldyn->atom[neighbour[j][p]]);
                                p++;
index 6331064eb63b2f217470214b2024256cc5458acd..4523938ba271e4d5de6e899ac0b892e4d014688c 100644 (file)
@@ -171,7 +171,7 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
 #ifdef STATIC_LISTS
                        p=0;
 
-                       while(neighbour_i[j][p]!=0) {
+                       while(neighbour_i[j][p]!=-1) {
 
                                jtom=&(atom[neighbour_i[j][p]]);
                                p++;
@@ -236,7 +236,7 @@ int albe_potential_force_calc(t_moldyn *moldyn) {
 #ifdef STATIC_LISTS
                                        q=0;
 
-                                       while(neighbour_i[j][q]!=0) {
+                                       while(neighbour_i[k][q]!=-1) {
 
                                                ktom=&(atom[neighbour_i[k][q]]);
                                                q++;
@@ -466,7 +466,7 @@ if(moldyn->time>DSTART&&moldyn->time<DEND) {
 #ifdef STATIC_LISTS
                                        q=0;
 
-                                       while(neighbour_i[j][q]!=0) {
+                                       while(neighbour_i[k][q]!=-1) {
 
                                                ktom=&(atom[neighbour_i[k][q]]);
                                                q++;