array_variables

<< Click to Display Table of Contents >>

Navigation:  Sample Problems > Usage > Variable_Types >

array_variables

Previous pageReturn to chapter overviewNext page

{ ARRAY_VARIABLES.PDE

 

   This example demonstrates the use of ARRAY VARIABLES.

   A set of heat equations is solved as a demonstration.

 

}  

 

title 'ARRAY Variable test'

 

variables

   U=array[5]                 { an array of field variables }

 

global variables

   g(threshold=0.1) = array[5] { and an array of global variables }

 

definitions

   u0 = 1-x^2-y^2

   s = array(1,2,3,4,5) { each equation has a different source }

 

{ use initial equations to diffuse the otherwise discontinuous initial value caused by value BC }

initial equations

  repeat i=1 to 5

       U[i]:   del2(u[i])  = 0

  endrepeat

 

equations

  repeat i=1 to 5

       U[i]:   del2(u[i]) +s[i] = dt(u[i])

       g[i]:   dt(g[i]) = i-g[i]

  endrepeat

 

boundaries

  Region 1

      start(-1,-1)

          repeat i=1 to 5  

              value(u[i])=u0  

          endrepeat

      line to (1,-1) to (1,1) to (-1,1) to close

 

time 0 to 10

 

plots

  for cycle=10

    contour(u_1)                 ! variables may be indexed with underscores

    repeat i=1 to 5

      contour(u[i])   as "U_"+$i   ! variables may be indexed with brackets

    endrepeat

    history(g)

    history(u) at  (0,0) (1/4,1/4)(1/2,1/2)(3/4,3/4)

    vtk(u,g)

    table(u,g)

    transfer(u,g)

 

end