if (strcmp(streakfile,"none") || strcmp(tracefile,"none"))
Particlelines = SET_PARTICLES(N,pos1x,pos1y,pos2x,pos2y);
Particlelines = INIT_PARTICLES(&N,imax,jmax,delx,dely,ppc,problem,U,V
+);
SETBCOND(U,V,P,TEMP,FLAG,imax,jmax,wW,wE,wN,wS);
SETSPECBCOND(problem,U,V,P,TEMP,imax,jmax,UI,VI);
struct particleline *INIT_PARTICLES (int *N,int imax,int jmax,
REAL delx,REAL dely,
int ppc,char *problem,REAL **U,RE
+AL **V)
{
int i,j,ip,jp;
struct particleline *Particlelines;
REAL x,y;
REAL height=0,rad=0,mpx=0,mpy=0,vstart=0;
if((Particlelines=(struct particleline *)
malloc((unsigned)(*N) * sizeof(struct particleline))) ==
+NULL)
{
printf("no memory");
exit(0);
}
Particlelines -= 1; /* Particlelines from 1 to N */
for (i=1;i<=*N;i++)
{
Particlelines[i].length = 0;
Particlelines[i].Particles = PARTALLOC(-1.,-1.);
}
/* Set the particles */
for (i=1;i<=imax;i++)
for (j=1;j<=jmax;j++)
for (ip=1;ip<=ppc;ip++)
{
x = (i-1)*delx+(ip-.5)/((REAL)ppc)*delx;
for (jp=1;jp<=ppc;jp++)
{
y = (j-1)*dely+(jp-.5)/((REAL)ppc)*dely;
if(strcmp(problem, "dam")==0)
if (x<0.2*imax*delx)
SET_PART(&Particlelines[1],x,y);
if(strcmp(problem, "drop")==0)
{
if (y<height)
{
SET_PART(&Particlelines[1],x,y);
}
else if ((x-mpx)*(x-mpx)+(y-mpy)*(y-mpy) <= rad*rad)
{
SET_PART(&Particlelines[2],x,y);
V[i][j] = vstart;
}
}
}
}
return (Particlelines);
}
/*----------------------------------------------------------------*/
/* Add particle to "Partline" at (x,y) */
/*----------------------------------------------------------------*/
void SET_PART(struct particleline *Partline, REAL x,REAL y)
{
struct particle *part;
part = PARTALLOC(x,y); /* create particle
+*/
part->next = (*Partline).Particles->next; /* add it to "Partline"
+*/
(*Partline).Particles->next = part; /* in the first position
+*/
(*Partline).length++;
}
|