This chapter describes the process of setup, simulation and post-processing for a test case in order to introduce the user to the basic procedures of running OpenFVM. More test cases can be accessed in the examples directory.
This tutorial shows how to prepare, run and post-process a case involving the non-isothermal, incompressible flow in a closed two-dimensional square domain. The flow is assumed as laminar and will be solved on a uniform mesh.
First create a new directory inside the examples directory case called tutorial. Start Gmsh and click Elementary > Add > New > Point to create points. Create points (0,0,0), (1,0,0), (1,1,0) and (0,1,0). Select module Geometry and click on Edit. If Gmsh is configured corectly an editor will open with the following lines:
Point(1) = {0, 0, 0, 0.1}; Point(2) = {1, 0, 0, 0.1}; Point(3) = {1, 1, 0, 0.1}; Point(4) = {0, 1, 0, 0.1};
Alter this file in the editor to look like the following listing. Add three lines with variables for dimensions in x, y and z directions (dx, dy, dz), number of divisions in each direction (nx, ny, nz) and the cell dimensions (cx, cy, cz):
dx = 1.0; dy = 1.0; dz = 5.0; nx = 30; ny = 30; nz = 1; cx = dx/nx; cy = dy/ny; cz = (cx + cy)/2; Point(1) = {0.0,0.0,0.0,1.0}; Point(2) = {dx,0.0,0.0,1.0}; Point(3) = {dx,dy,0.0,1.0}; Point(4) = {0.0,dy,0.0,1.0};
Save the file and click on Gmsh Reload to reload the new data. Go to menu Tools > Options... and click on Geometry in the list. Go to the Visibility tab and check the Point numbers check box. Click Apply and then Cancel to exit the Options dialog box. Now click Elementary > Add > New > Straight line to create lines. Create four lines from point 1 to point 2, from point 2 to point 3, from point 3 to point 4 and from point 4 to point 1. Click Elementary > Add > New > Plane surface to create a surface. Click on any line to create a loop and then press key E to end the command. A new surface will be created. Go to menu Tools > Options... and click on Geometry in the list. Go to Visibility tab and check the "Surface numbers" check box. Click Apply to view the number of the new surface and then "Cancel" to exit the Options dialog box. Select module Geometry and click on Edit. The file should look like this:
dx = 1.0; dy = 1.0; dz = 5.0; nx = 20; ny = 20; nz = 1; cx = dx/nx; cy = dy/ny; cz = (cx + cy)/2; Point(1) = {0.0,0.0,0.0,1.0}; Point(2) = {dx,0.0,0.0,1.0}; Point(3) = {dx,dy,0.0,1.0}; Point(4) = {0.0,dy,0.0,1.0}; Line(1) = {1,2}; Line(2) = {2,3}; Line(3) = {3,4}; Line(4) = {4,1}; Line Loop(5) = {1,2,3,4}; Plane Surface(6) = {5};
Add these lines to the end of the file and save:
out[] = Extrude {0,0,dz} { Surface{6}; Layers { 1 }; Recombine; };
In Gmsh select module Geometry and click on Reload. Now you should see the three-dimensional extrusion of the surface. In order to define the mesh add the following lines:
Transfinite Line {4,10,2,8} = nx + 1 Using Progression 1.0; Transfinite Line {3,9,1,11} = ny + 1 Using Progression 1.0; Transfinite Line {14,18,13,22} = nz + 1 Using Progression 1.0; Transfinite Surface {6} = {3,2,1,4}; Transfinite Surface {28} = {6,10,14,5}; Recombine Surface {27,23,6,19,15,28};
and to define the top, bottom, left, right, front and back physical surfaces and the physical volume add the following:
// Top surface Physical Surface(33) = {23}; // Bottom surface Physical Surface(34) = {15}; // Left surface Physical Surface(35) = {27}; // Right surface Physical Surface(36) = {19}; // Front surface Physical Surface(37) = {28}; // Back surface Physical Surface(38) = {6}; // Box volume Physical Volume (39) = {out[1]};
Save the file as tutorial.geo. In Gmsh click menu File > Open... and open tutorial.geo. Go to module Mesh, click 3D and click Save to save the mesh. This creates file tutorial.msh. Now that the mesh has been created it is necessary to define other input data such as boundary conditions. Open a text editor and copy the following lines to an empty file:
$Title OpenFVM $File Boundary conditions file $Boundary 1 4 Description of $Code 10000 2 Empty - Physical surfaces (ID u v w p T s) 37 0.0 0.0 0.0 0.0 0.0 0.0 38 0.0 0.0 0.0 0.0 0.0 0.0 10170 2 Wall - Physical surfaces (ID u v w p T s) 33 1.0 0.0 0.0 0.0 50.0 0.0 34 0.0 0.0 0.0 0.0 10.0 0.0 10180 2 Adiabatic wall - Physical surfaces (ID u v w p T s) 35 0.0 0.0 0.0 0.0 0.0 0.0 36 0.0 0.0 0.0 0.0 0.0 0.0 10250 1 Volume - Physical volumes (ID u v w p T s) 39 0.0 0.0 0.0 0.0 25.0 0.0 $EndFile
Save this file as tutorial.bcd in the same directory as above. In the same manner, copy these lines to a file called tutorial.mtl:
$Title OpenFVM $File Material file $Material 1 12 Description of $Code 20012 1 Compressibility of fluid 0 0.0 20015 1 Density of fluid 0 1.0 20021 1 Viscosity of fuild 0 1.0E-2 20022 1 Specific heat of fuild 0 1.0 20023 1 Thermal conductivity of fluid 0 0.5 21012 1 Compressibilty of fluid 1 0.0 21015 1 Density of fluid 1 1.0 21021 1 Viscosity of fluid 1 1.0E-2 21022 1 Specific heat of fuild 1 1.0 21023 1 Thermal conductivity of fluid 1 0.5 26050 1 Constant surface tension (fluid 0 / fluid 1) 0.0 26060 1 Thermal conductivity (boundary) 0.5 $EndFile
Create one more file copying these lines to a file called tutorial.par:
$Title OpenFVM $File Parameter file $Parameter 1 26 Description of $Code 30005 1 Convection interpolation scheme 1 1 1 1 0 1 30020 1 Binary output 1 30040 1 Calculate variable (u v w p T s) 1 1 0 1 1 0 30100 1 Steady state 1 30105 1 Convergence for steady state solutions 1E-6 1E-6 1E-6 1E-6 1E-6 1E-6 30200 1 Adjust time interval 0 30201 1 Maxmimum Courant number 0.9 30400 1 Number of saves 1 30450 1 Write face scalars (u v w p T s) 0 0 0 0 0 0 30455 1 Write face vectors (uvw) 0 30460 1 Write element scalars (u v w p T s) 0 0 0 0 1 0 30465 1 Write element vectors (uvw) 1 30470 1 Write vorticity (x y z) 0 0 0 30475 1 Write stream function (xy) 1 30485 1 Probe (u v w p T s) 1 0 0 0 0 0 30550 1 Maximum number of non-othorgonal corrections 0 30600 1 Convergence criterion (matrix solution) 1E-12 1E-12 1E-12 1E-12 1E-12 1E-12 30601 1 Maximum number of iterations (matrix solution) 5000 5000 5000 5000 5000 5000 30650 1 Matrix solver (u v w p T s) 3 3 3 4 3 3 30651 1 Matrix preconditioner (0-Null, 1-Jacobi, 2-SOR, 3-ILU) 3 3 3 3 3 3 30800 1 Interface scheme factor - CICSAM 1.0 30900 1 Maximum number of CICSAM corrections 2 32000 1 Start time 0.0 32001 1 End time 100.0 32002 1 Time interval 0.01 34000 1 Gravity vector 0.0 0.0 0.0 $EndFile
Go to the tutorial directory and type:
../OpenFVM tutorial d 1
Using this command a new mesh file is created: tutorial.000.msh. In this file, elements are renumbered from 0 to n - 1. In the same directory type:
../OpenFVM tutorial f 1
In order to track the residuals copy the following lines and save the file as tutorial.plt:
set title 'Convergence' set xlabel 'Iteration' set ylabel 'Residual' set logscale y plot 'tutorial.res' using 1:2 title 'u' with lines, \ 'tutorial.res' using 1:3 title 'v' with lines, \ 'tutorial.res' using 1:5 title 'p' with lines pause -1
This outputs the residual history as a function of iteration number.
To visualize the results open the file tutorial.pos in Gmsh.
The Gmsh script can be used to automatically porbe the u-velocity along the center line and save it to a file. Copy the following lines to a file named tutorial.scr.
// Include "tutorial.geo"; Include "tutorial.000.prb"; nbviews = PostProcessing.NbViews; View[0].Name = "U-Velocity [m/s]"; View[0].Visible = 0; Plugin(CutGrid).X0 = 0.5; Plugin(CutGrid).Y0 = 0.0; Plugin(CutGrid).Z0 = 2.5; Plugin(CutGrid).X1 = 1.0; Plugin(CutGrid).Y1 = 1.0; Plugin(CutGrid).Z1 = 2.5; Plugin(CutGrid).X2 = 0.5; Plugin(CutGrid).Y2 = 1.0; Plugin(CutGrid).Z2 = 2.5; Plugin(CutGrid).NumPointsU = 1; Plugin(CutGrid).NumPointsV = 250; Plugin(CutGrid).ConnectPoints = 0; Plugin(CutGrid).View = -1; Plugin(CutGrid).Run; View[1].Axes = 2; View[1].Type = 2; View[1].IntervalsType = 2; View[1].Name = "U-Velocity [m/s] - Centerline"; View[1].AxesLabelX = "U/U0"; View[1].AxesLabelY = "y/y0"; PostProcessing.Format = 4; // Save results to graph for using gnuplot Save View[1] "tutorial.txt"; //System "gnuplot tutorial.gph";
Create a file called tutorial.gph to create a plot:
#set terminal postscript eps # set output to eps file #set output 'tutorial.eps' set xtic auto # set xtics automatically set ytic auto # set ytics automatically set title 'Velocity profiles at the centerline \ of the lid-driven cavity at Re = 100' set xlabel 'U/U0' set ylabel 'y/y0' set xrange[-0.4:1.0] set yrange[0.0:1.0] set key 0.8,0.6 set pointsize 1 plot 'tutorial.txt' using 4:2 title 'tutorial' with lines 1 pause -1
Now open the tutorial.scr file in Gmsh and run the following command in the tutorial directory:
gnuplot tutorial.gph
at command prompt. This graph should show the velocity profile at the centerline of the lid-driven cavity.