ArrayRepeat

Top  Previous  Next

arrayrepeat04

{ ARRAYREPEAT.PDE  }

{

This problem demonstrates the use of data ARRAYs, together with

indexed REPEAT loops.  The system is a heatflow equation with an array

of imbedded source dots.

}

 

title 'REPEAT loop & Data Array test'

 

Variables

    u

 

definitions

    a = 1

 

    xc=array(1/3, 2/3, 3/3, 4/3, 5/3)  { a list of X-coordinates }

    yc=array(1/3, 2/3, 3/3, 4/3, 5/3)  { a list of Y-coordinates }

 

   rad = 0.1

   s = 0

 

equations

    div(a*grad(u)) + s  = 0;           { the heatflow equation }

 

boundaries

    region 1

       start(0,0)

         value(u)=0

line to (2,0) to (2,2) to (0,2) to close

    region 2

        a = 0.05

        s = 4*magnitude(x-1,y-1)

       repeat i=1 to 5             { an indexed loop on X-position }

           repeat j=1 to 5         { an indexed loop on Y-position }

               { an array of circular dots at the  tabulated coordinates: }

               start "Loop"+$i+$j (xc[i]+rad,yc[j])

               arc(center=xc[i],yc[j]) angle=360

           endrepeat

       endrepeat

 

monitors

    contour(u)

 

plots

    contour(u) painted

    surface(u)

    surface(s)

    elevation(u) on "Loop55"

 

end