*
* usage: ./dfe 100 50 2 1 1 10
*
+ * anmerkung frank: bisschen was ging so: ./dfe 1 5 2 1 1 10
+ * ist auch schotter, aber mit richtigen parametern
+ * wirds. viel glueck!!
+ *
* author: christian leirer, frank zirkelbach
*
* need api: cvs -d:pserver:anonymous@hackdaworld.dyndns.org:/my-code co api
int main(int argc,char **argv) {
- int x,y;
+ int x,y=0;
int dx,dy;
- int mx,my;
+ int mx=0,my=0;
double lf[2];
double sf[2];
double mf;
double lpp;
int i;
int size;
- t_gp gp;
+ t_gp gp,cgp;
t_gp *gp_ptr;
t_list list;
t_list_element *tmp;
fd=open("/dev/null",O_WRONLY);
- list_init(&list,fd);
+ list_init(&list,1);
size=X_*Y_;
bmp_init(&bmp,1);
bmp.mode=WRITE;
bmp_alloc_map(&bmp);
- srandom(time(NULL));
+ srand(time(NULL));
for(x=0;x<X_;x++) {
memset(&gp,0,sizeof(t_gp));
/* mainloop */
for(i=0;i<STEPS;i++) {
+
/* determine status of vortex, liquid or solid */
list_reset(&list);
do {
if(y>=0&&y<Y_) {
gp.x=x; gp.y=y;
if(list_search_data(&list,&gp,2*sizeof(int))==L_SUCCESS)
- gp_ptr->pp+=exp(-1.0*sqrt(x*x+y*y)/xi);
-
+ lpp+=exp(-1.0*sqrt(x*x+y*y)/xi);
}
}
}
}
+ gp_ptr->pp=pp-lpp;
if(lpp>(0.8*pp)) gp_ptr->status=FLUESSIG;
else gp_ptr->status=FEST;
list.current=tmp;
/* force on vortex */
list_reset(&list);
+ mf=0;
do {
lf[0]=0; lf[1]=0;
sf[0]=0; sf[1]=0;
if(list_search_data(&list,&gp,2*sizeof(int))==L_SUCCESS) {
memcpy(&gp,list.current->data,sizeof(t_gp));
if(gp.status&FEST) {
- if(dy==0) sf[0]+=(-1.0/(dx*dx+dy*dy)*co*(dx/abs(dx)));
- else if (dx==0) sf[1]+=(-1.0/(dx*dx+dy*dy)*co*(dy/abs(dy)));
- /* hier ist die scheisse drin!! */
+ if(dy==0) sf[0]+=(-1.0/(dx*dx)*co*(dx/abs(dx)));
+ else if (dx==0) sf[1]+=(-1.0/(dy*dy)*co*(dy/abs(dy)));
else {
- sf[0]+=(-1.0/(dx*dx+dy*dy)*co*dx/abs(dy));
- sf[1]+=(-1.0/(dx*dx+dy*dy)*co*dy/abs(dx));
+ sf[0]+=(-1.0/(dx*dx+dy*dy)*co*1.0*dx/abs(dy));
+ sf[1]+=(-1.0/(dx*dx+dy*dy)*co*1.0*dy/abs(dx));
}
}
else {
- /* und hier wahrscheinlich auch */
if(dy==0) lf[0]+=(-1.0*(dx/abs(dx))*(by+co));
else if(dx==0) lf[1]+=(-1.0*(dy/abs(dy))*(by+co));
else{
}
gp_ptr->fx=sf[0]+lf[0]+((1.0*rand()/RAND_MAX)-0.5)/rs;
gp_ptr->fy=sf[1]+lf[1]+((1.0*rand()/RAND_MAX)-0.5)/rs;
+ if(gp_ptr->y==0) gp_ptr->fy+=by;
if(gp_ptr->status&FEST) {
gp_ptr->fy+=(bf*exp(-y*1.0/100));
if(gp_ptr->fx>0) {
if(gp_ptr->fy>0) gp_ptr->fy=0;
}
}
- if(gp_ptr->y==0) gp_ptr->fy+=by; /* wenn rand by dazu, arschloch !!1 */
if((mf<gp_ptr->fx)||(mf<gp_ptr->fy)) {
mf=gp_ptr->fx>gp_ptr->fy?gp_ptr->fx:gp_ptr->fy;
mx=gp_ptr->x;
/* move vortex with highest force */
gp.x=mx; gp.y=my;
- printf("step %d: move vortex %d %d,",i,mx,my);
+ printf("step %d: want to move vortex %d %d,",i,mx,my);
list_search_data(&list,&gp,2*sizeof(int));
gp_ptr=(t_gp *)list.current->data;
dx=0; dy=0;
else dy=-1;
}
printf(" with direction dx=%d dy=%d | force: %f %f\n",dx,dy,gp_ptr->fx,gp_ptr->fy);
- gp_ptr->x+=dx;
- gp_ptr->y+=dy;
- if(gp.y==0) list_add_element(&list,&gp,sizeof(t_gp));
+ cgp.x=gp_ptr->x+dx;
+ cgp.y=gp_ptr->y+dy;
+ if(list_search_data(&list,&cgp,2*sizeof(int))==L_SUCCESS) {
+ printf("but there is allready a flussfaden! this parameter set suX!\n");
+ }
+ else if(gp_ptr->y==0&&dy==-1) {
+ printf("but this wuld be stupid (out of target), skipped!\n");
+ }
+ else {
+ printf("and i am doing it now! :)\n");
+ gp_ptr->x+=dx;
+ gp_ptr->y+=dy;
+ if(gp.y==0) {
+ printf("adding moved flussfaden (y=0)\n");
+ list_add_element(&list,&gp,sizeof(t_gp));
+ }
+ }
+ if(gp_ptr->y==Y_-1) {
+ printf("flussfaden reached top of target, ending simulation!\n");
+ return 1;
+ }
+
+ /*
+ printf("alle flussfaden:\n");
+ list_reset(&list);
+ do {
+ gp_ptr=(t_gp *)list.current->data;
+ printf("flussfaden bei %d %d\n",gp_ptr->x,gp_ptr->y);
+ } while(list_next(&list)!=L_NO_NEXT_ELEMENT);
+ */
/* plot every PLOT steps */
if(i%PLOT==0) {