Steady-State Flow Around a Cylindrical Pipe : Stream Function.

The Problem.
We want to solve the steady-state flow equation Uxx+Uyy=0 to compute the stream function U on the domain shown to the right, with the given boundary conditions. We will generate a uniform triangular mesh, and we select the bi-linear FEM discretizer with the Jacobi CG iterative linear system solver. We want to store the solution U and its derivatives Ux and Uy.

Use PDELab to ...

Why use PDELab?
In this case study, we use PDELab's finite element methods to solve a 2D steady-state flow problem. PDELab's bi-linear FEM discretizes a self-adjoint elliptic partial differential equation on an arbitrary 2-D domain for which a triangular or quadrilaterl finite element mesh can be generated. The system of linear equations produced by bi-linear FEM can be solved using any of the PDELab/ITPACK linear system solvers.

PDELab provides the following editors to assist in the process of specifying and solving the problem :

The purpose of this case study is to demonstrate how easily PDELab solves interesting problems.


Define the Problem
Step 1:When PDELab top level window appears, select 2-D and FEM and click on New File. The PDELab 2-D Finite Element Method Session appears. The Session toolkit is to the right of the Session window.

Step 2: Click on the Framework Editor in the Session toolkit.

Step 3: Choose PELLPACK from the Framework menu. The Framework Editor allows users to select the framework for defining the problem. In this case, selecting PELLPACK tells the symbolic processor that only linear, elliptic equations may be entered without special processing. The framework selection also signals the fortran code generator that the PELLPACK problem template must be generated.
Since PELLPACK modules can discretize only a single PDE, the Number of Equations is equal to 1, and the field cannot be edited. Click on PDE System. Enter the steady-state equation in the PDE System editor as shown here. Click on Done when finished.

Step 4: The equation has been specified, so click on Generate Framework. The Maxima symbolic processor is accessed to check for errors, and the GenCray code generator generates the appropriate PDELab problem specification. Any input errors are printed out in the Maxima window of the Framework Editor.

Step 5: When the input has been successfully processed, select Quit from the File menu. The PDELab language program appears in the Session window. The generated program is shown below. The default rectangular domain and boundary conditions appear in the boundary segment. The default solution scheme includes the bi-linear fem discretizer and Jacobi CG linear system solver.

PDELab language `.e' file

OPTIONS.       
   clockwise = .true.
   time
EQUTION.
   UXX+UYY = 0
BOUNDARY.
   U=0  on x = 0               
   U=0  on x = 1               
   U=0  on y = 0              
   U=0  on y = 1 
DISCRETIZATION. 
   Bi-Linear FEM
INDEXING.      
   As Is
SOLUTION. 
   Jacobi CG
END.

Step 6: We will now specify the domain and boundary conditions using the 2D BoundaryTool. Click on the 2D BoundaryTool.

Step 7: The default rectangular boundary appears in the domain window. Click on Clear Boundary and then New Boundary. We will now draw the 6 pieces of the domain boundary. First we must set the range of the (x,y) window. Click on Set Range in the Window Information bar. When the dialog box appears, enter the values for xmin, xmax, ymin, ymax by typing 0 8 0 2 and then click on Continue. The window changes according to the new specification.
We use the left, middle, and right mouse buttons to place the control points which define the line segments and the Bernstein interpolation curves of the boundary. The first 4 pieces are staight lines, and are therefore very easy to define. Click with the left mouse button on the point (0,0) in the BoundaryTool drawing window. Use the Mouse Position indicator to help identify the correct location. Then click with the middle mouse button on (0,2), (8,2), (8,0), and (5,0). The first four pieces of the boundary are finished. We now must draw a semi-circle by placing control points with the left mouse button.
Click on the following points with the left mouse button: (4.9, .45), (4.45, .68), (3.95, .9), (3.54, .68), and (3.1, .45). Finally, with the middle mouse button, click on (3, 0). The arc is complete. To finish the domain boudary use the right mouse button to click on (0,0). The domain (displaying the control points used to define the arc) is shown to the right.

Step 8: We now click on Set Conditions to assign the boundary conditions for each of the six sides. When the dialog box appears, click on Clear. Then enter the boundary conditions for each side as shown above. Click on Cancel to dismiss the Boundary Conditions Editor. Click on Save to save the new boundary definition and the new boundary conditions to the session. The text below shows how the boundary segment is replaced.

declarations. +both. +boundary.
      common / plotx / xc(6, 7)
      common / ploty / yc(6, 7)
fortran. +both. +boundary.
      data (xc(1,j),j=1,7) / 0.00,0.00,0.0,0.0,0.0,0.0,0.0 /
      data (xc(2,j),j=1,7) / 0.00,8.00,0.0,0.0,0.0,0.0,0.0 /
      data (xc(3,j),j=1,7) / 8.00,8.00,0.0,0.0,0.0,0.0,0.0 /
      data (xc(4,j),j=1,7) / 8.00,5.00,0.0,0.0,0.0,0.0,0.0 /
      data (xc(5,j),j=1,7) / 5.00,4.90,4.45,3.95,3.56,3.10,3.00 /
      data (xc(6,j),j=1,7) / 3.00,0.00,0.0,0.0,0.0,0.0,0.0 /
      data (yc(1,j),j=1,7) / 0.00,2.00,0.0,0.0,0.0,0.0,0.0 /
      data (yc(2,j),j=1,7) / 2.00,2.00,0.0,0.0,0.0,0.0,0.0 /
      data (yc(3,j),j=1,7) / 2.00,0.00,0.0,0.0,0.0,0.0,0.0 /
      data (yc(4,j),j=1,7) / 0.00,0.00,0.0,0.0,0.0,0.0,0.0 /
      data (yc(5,j),j=1,7) / 0.00,0.45,0.68,0.90,0.68,0.45,0.00 /
      data (yc(6,j),j=1,7) / 0.00,0.00,0.0,0.0,0.0,0.0,0.0 /
boundary. +parm.
      u=y ON X = param1x(1,t,2,6), Y = param1y(1,t,2,6)  FOR t = 0.00 TO 1.00
      u=2 ON X = param1x(2,t,2,6), Y = param1y(2,t,2,6)  FOR t = 0.00 TO 1.00
      u=y ON X = param1x(3,t,2,6), Y = param1y(3,t,2,6)  FOR t = 0.00 TO 1.00
      u=0 ON X = param1x(4,t,2,6), Y = param1y(4,t,2,6)  FOR t = 0.00 TO 1.00
      u=0 ON X = param1x(5,t,7,6), Y = param1y(5,t,7,6)  FOR t = 0.00 TO 1.00
      u=0 ON X = param1x(6,t,2,6), Y = param1y(6,t,2,6)  FOR t = 0.00 TO 1.00

The control points are listed in the fortran segment, and the boundary segment contains calls to the Bernstein interpolation functions param1x() and param1y() which use the listed control points.



Specify the Solution
Step 9: We will now generate the mesh. Do not close the BoundaryTool; it must be up when the Mesh Generator is invoked. Click on the MeshGenerator. The domain boundary appears in the window with the piece numbers identified.

Step 10: The Triangular mesh is the default selection. Enter 0.06 as the Edge Constraint, and use the default Element Constraint (The default constraint controls the meshing process in two ways: first, d < edge < 2d indicates that all generated element edge lengths will be between 0.06 and 2*0.06. Second, 30 deg < angle < 120 deg indicates that the angles of each mesh element will be no less 30 deg and no more than 120 deg, These two controls create a very uniform triangular mesh). Now click on Generate Mesh. The mesh to the right is generated and displayed. Finally, click on Save. A Filename Selection dialog requests a name for the file where the mesh data will be stored. Enter a filename, and click on Continue. The mesh data is written to the file, and a new mesh segment is written to the Session. It is placed immediately after the `boundary' segment and indicates that a file containing the mesh now exists and will be used in the problem solution process.

MESH.
   read fem from file &
       (filename='stream.mesh', &
       i1ndim=2, i1mnpt=2965, i1melm=5653, i1mtyp=1, i1mnen=4, &
       i3nint=4, i3ntyp=1, meshtype=2, meshedge=0.06)       
You can now close the Mesh Generator by clicking on Quit. Then close the BoundaryTool by clicking on Quit.

Step 11: The bi-linear fem discretization module and the Jacobi CG linear solver module are the default specifications for the 2-D FEM session, so it is not necessary to modify them. However, you can click on the SolnMenu and look at the parameters for the Jacobi CG module which may be set by the user.

The Module Specification editor with the Jacobi CG module selected and the value of the zeta parameter displayed is shown to the left. Any parameter that may be set by the user is listed here. You can view and/or modify the values for any of the parameters. Dismiss the Module Specification editor by clicking on Cancel.

Step 11: We need to specify what output we want the system to produce for us. Click on the Output Specification Editor. Click on the Plot Function menu. Select u from the menu. Then select ux and uy. Now click on Output Filename. The Filename Selection dialog request the name of the file where the solution values for u will be stored. Enter a name for the output file. This file is a PDELab format file that can be loaded into the OutputTool enviroment where it can be used to visualize contour plots, solution plots, animations, etc. Now click on Continue. Two new segments are written to the Session: a save segment listing the name of the file, and an output segment listing the requested contents. Click on Continue. The new segments are shown below. The computed values for u, ux, and uy will be written to a file in PDELab format.

SAVE.
   set output file (outputfile =  `stream.out')
OUTPUT.  
   output  mesh 
   output function(u) 
   output function(ux) 
   output function(uy)
Step 12: You can save the PDELab language program to a `.e' file by clicking on the SaveAs button in the Session toolkit. A Filename dialog requests a name for your .e file.


Execute the Problem
Step 13: We are now ready to enter the ExecuteTool environment, where the PDELab language program will be processed. A fortran main program will be generated from the .e file. It will be compiled and linked with the PDELab module libraries and the standard PDELab I/O libraries. Click on the ExecuteTool button in the Session toolkit.

Step 14: The PDELab .e file is loaded automatically. Click on the Run button The trace of the process for compiling and linking the PDELab executable appears in the trace window. When the compiling and linking process is complete, the executable program is run and the solution and trance files are generated and placed in your user directory. Click on Quit to exit the ExecuteTool.


Visualize the Solution
Step 15: The solution output has been generated during execution. You should find the output file containing the PDELab format data in the location specified by the save segment. If no path was specified, this file is located in the execution directory. The file contains the solution and its derivatives. Click on the OutputTool in the Session toolkit. Select PDELab Solution in the File menu. Select the output file that was generated by your program when the OutputTool requests the file name. The Select Solution Box is displayed after file is loaded. The selection box contains the solution u and its derivatives ux and uy.


The stream function U.

The y component of the velocity.

The x component of the velocity.

Step 16: Select u from the Select Solution Box. Then choose the Visual2D visualization package and press Run Tool. The solution u is shown. Select Quit to exit Visual2D. You can return to the OutputTool and from the Solutions Selection Panel under Solutions in the OutputTool menu bar, de-select u and select ux. In the same manner, use Visual2D to visualize ux. Select Quit to exit the tool. Similary, view uy with Visual2D.



Here is the final '.e file' generated by PDELab tools. The session toolbox is to the right of the session window, and the contents of the .e file describing the PDE problem are to the right of the session window. The '.e file' contents can be edited by the tools or by the user.