function_definition

<< Click to Display Table of Contents >>

Navigation:  Sample Problems > Usage > Functions >

function_definition

Previous pageReturn to chapter overviewNext page

{  FUNCTION_DEFINITION.PDE  

 

  This example demonstrates the use of functional parameter definitions.

 

}  

 

title 'Functional Parameter Definition test'  

 

Variables  

    u  

 

definitions  

 

{ Declare "Sq" a function of argument "A".  

      "A" is a dummy name that represents the actual argument passed

       by an invocation.  }  

 Sq(a) = a*a  

{ Define two functions for use in domain layout.

       The "n" argument rotates by 90 degree increments.}  

 xx(n) = cos(n*pi/2)          

 yy(n) = sin(n*pi/2)  

 

equations  

{ invoke the "Sq" function as a component of the equation.  This makes

   the system nonlinear }  

 U: div(grad(u)) + 80*Sq(u)*dx(u) +4 = 0  

 

boundaries  

  region 1  

      start(xx(0),yy(0))  

      value(u)=0  

      line to (xx(1),yy(1))   { definition evaluates corners of a diamond }  

            to (xx(2),yy(2))  

            to (xx(3),yy(3))  

      to close  

 

monitors  

  contour(u)  

 

plots  

  surface(u)  

  contour(u)  

 

end