So this would be the C code I need to implement into the code.

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++; }

In reply to Re: Particle movement question by koda123
in thread Particle movement question by koda123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.