From: hackbard Date: Sun, 26 Nov 2006 23:05:00 +0000 (+0000) Subject: more changes ... X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=1097ea2efb575855edd332c28a9cd8f807cd0716;p=physik%2Fposic.git more changes ... --- diff --git a/moldyn.c b/moldyn.c index c7243e0..fe54330 100644 --- a/moldyn.c +++ b/moldyn.c @@ -227,20 +227,22 @@ int moldyn_shutdown(t_moldyn *moldyn) { return 0; } -int create_lattice(u8 type,int element,double mass,double lc, - int a,int b,int c,t_atom **atom) { +int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, + u8 attr,u8 bnum,int a,int b,int c) { int count; int ret; t_3dvec origin; + t_atom *atom; count=a*b*c; + atom=moldyn->atom; if(type==FCC) count*=4; if(type==DIAMOND) count*=8; - *atom=malloc(count*sizeof(t_atom)); - if(*atom==NULL) { + atom=malloc(count*sizeof(t_atom)); + if(atom==NULL) { perror("malloc (atoms)"); return -1; } @@ -249,10 +251,10 @@ int create_lattice(u8 type,int element,double mass,double lc, switch(type) { case FCC: - ret=fcc_init(a,b,c,lc,*atom,&origin); + ret=fcc_init(a,b,c,lc,atom,&origin); break; case DIAMOND: - ret=diamond_init(a,b,c,lc,*atom,&origin); + ret=diamond_init(a,b,c,lc,atom,&origin); break; default: printf("unknown lattice type (%02x)\n",type); @@ -268,17 +270,45 @@ int create_lattice(u8 type,int element,double mass,double lc, } while(count) { - (*atom)[count-1].element=element; - (*atom)[count-1].mass=mass; + atom[count-1].element=element; + atom[count-1].mass=mass; + atom[count-1].attr=attr; + atom[count-1].bnum=bnum; count-=1; } return ret; } -int destroy_lattice(t_atom *atom) { +int add_atom(t_moldyn *moldyn,int element,double mass,u8 bnum,u8 attr, + t_3dvec r,t_3dvec v) { + + t_atom *atom; + void *ptr; + int count; + + atom=moldyn->atom; + count=++(moldyn->count); - if(atom) free(atom); + ptr=realloc(atom,count*sizeof(t_atom)); + if(!ptr) { + perror("[moldyn] realloc (add atom)"); + return -1; + } + + atom=ptr; + atom->r=r; + atom->v=v; + atom->element=element; + atom->bnum=bnum; + atom->attr=attr; + + return 0; +} + +int destroy_atoms(t_moldyn *moldyn) { + + if(moldyn->atom) free(moldyn->atom); return 0; } @@ -547,14 +577,36 @@ int link_cell_shutdown(t_moldyn *moldyn) { return 0; } -int moldyn_add_schedule(t_moldyn *moldyn,) { +int moldyn_add_schedule(t_moldyn *moldyn,int runs,double tau ) { + + int count; + void *ptr; + t_moldyn_schedule *schedule; + + schedule=moldyn->schedule; + count=++(schedule->content_count); + ptr=realloc(moldyn->schedule.runs,count*sizeof(int)); + if(!ptr) { + perror("[moldyn] realloc (runs)"); + return -1; + } + moldyn->schedule.runs[count-1]=runs; + + ptr=realloc(schedule->tau,count*sizeof(double)); + if(!ptr) { + perror("[moldyn] realloc (tau)"); + return -1; + } + moldyn->schedule.tau[count-1]=tau; return 0; } int moldyn_set_schedule_hook(t_moldyn *moldyn,void *hook,void *hook_params) { + moldyn->schedule.hook=hook; + moldyn->schedule.hook_params=hook_params; return 0; } diff --git a/moldyn.h b/moldyn.h index a76b3b4..a7fa60a 100644 --- a/moldyn.h +++ b/moldyn.h @@ -53,11 +53,11 @@ typedef struct s_linkcell { #include "visual/visual.h" -# moldyn schedule structure */ +/* moldyn schedule structure */ typedef struct s_moldyn_schedule { int content_count; int *runs; - int *tau; + double *tau; int (*hook)(t_moldyn *,void *); void *hook_params; } t_moldyn_schedule;