From: hackbard Date: Thu, 4 Oct 2007 12:25:31 +0000 (+0200) Subject: added del_atom function X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=97f4b6d802dc13e511f30adbaa25a7892289b0ff;p=physik%2Fposic.git added del_atom function --- diff --git a/moldyn.c b/moldyn.c index 415581c..41e022a 100644 --- a/moldyn.c +++ b/moldyn.c @@ -558,6 +558,35 @@ int add_atom(t_moldyn *moldyn,int element,double mass,u8 brand,u8 attr, return 0; } +int del_atom(t_moldyn *moldyn,int tag) { + + t_atom *new,*old; + int cnt; + + old=moldyn->atom; + + new=(t_atom *)malloc((moldyn->count-1)*sizeof(t_atom)); + if(!new) { + perror("[moldyn]malloc (del atom)"); + return -1; + } + + for(cnt=0;cntcount;cnt++) { + new[cnt-1]=old[cnt]; + new[cnt-1].tag=cnt-1; + } + + moldyn->count-=1; + moldyn->atom=new; + + free(old); + + return 0; +} + /* cubic init */ int cubic_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin) { diff --git a/moldyn.h b/moldyn.h index 36e701e..0078990 100644 --- a/moldyn.h +++ b/moldyn.h @@ -417,6 +417,7 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, u8 attr,u8 brand,int a,int b,int c,t_3dvec *origin); int add_atom(t_moldyn *moldyn,int element,double mass,u8 brand,u8 attr, t_3dvec *r,t_3dvec *v); +int del_atom(t_moldyn *moldyn,int tag); int cubic_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin); int fcc_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin); int diamond_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin);