src/OpenFOAM logo
The Open Source CFD Toolbox
  Search
  
  Back to OpenFOAM Home
 
  OpenCFD®
  Company profile
  OpenFOAM support
  OpenFOAM development
  OpenFOAM training
  Solutions
  Contact OpenCFD
  Recruitment
  Recommended links
 
  OpenFOAM®
  Features
  Download
  Documentation
  * User Guide
  * C++ Source Guide
  * README file
  * Release notes
  * Upgrading to 1.5
 
  Our trade mark policy
 
  © 2000-2008 OpenCFD Ltd
SourceForge.net Logo
OpenCFD® Solutions Contact OpenFOAM®
OpenFOAM 1.5 User Guide © 2000-2008 OpenCFD Ltd

2.1 Lid-driven cavity flow

This tutorial will describe how to pre-process, run and post-process a case involving isothermal, incompressible flow in a two-dimensional square domain. The geometry is shown in 2.1 in which all the boundaries of the square are walls. The top wall moves in the x  \special {t4ht=-direction at a speed of 1 m/s while the other 3 are stationary. Initially, the flow will be assumed laminar and will be solved on a uniform mesh using the icoFoam solver for laminar, isothermal, incompressible flow. During the course of the tutorial, the effect of increased mesh resolution and mesh grading towards the walls will be investigated. Finally, the flow Reynolds number will be increased and the turbFoam solver will be used for turbulent, isothermal, incompressible flow.

                      U   = 1 m/s
                        x







d =  0.1 m


                y

                     x
\special {t4ht=


Figure 2.1: Geometry of the lid driven cavity.


2.1.1 Pre-processing

Cases are setup in OpenFOAM by editing case files. Users should select an editor of choice with which to do this, such as emacs, vi, gedit, kate, nedit, etc. Editing files is possible in OpenFOAM because the I/O uses a dictionary format with keywords that convey sufficient meaning to be understood by even the least experienced users. In previous versions of OpenFOAM, there existed FoamX, a GUI case editor, but so great was the preference for editing files from the OpenFOAM users, that this was discontinued in version 1.5 due to lack of interest in its maintenance.

A case being simulated involves data for mesh, fields, properties, control parameters, etc. As described in 4.1, in OpenFOAM this data is stored in a set of files within a case directory rather than in a single case file, as is common with in many CFD packages. The case directory is given a suitably descriptive name, e.g. the first example case for this tutorial is simply named cavity. In preparation of editing case files and running the first cavity case, the user should change to the case directory


    cd $FOAM_RUN/tutorials/icoFoam/cavity

2.1.1.1 Mesh generation
OpenFOAM always operates in a 3 dimensional Cartesian coordinate system and all geometries are generated in 3 dimensions. OpenFOAM solves the case in 3 dimensions by default but can be instructed to solve in 2 dimensions by specifying a ‘special’ empty boundary condition on boundaries normal to the (3rd) dimension for which no solution is required.

The cavity domain consists of a square of side length d = 0.1 m  \special {t4ht= in the x  \special {t4ht=-y  \special {t4ht= plane. A uniform mesh of 20 by 20 cells will be used initially. The block structure is shown in 2.2.


 3                           2


      7                           6








y
 0   x                       1

  z  4                            5
\special {t4ht=


Figure 2.2: Block structure of the mesh for the cavity.


The mesh generator supplied with OpenFOAM, blockMesh, generates meshes from a description specified in an input dictionary, blockMeshDict located in the constant/polyMesh directory for a given case. The blockMeshDict entries for this case are as follows:


1  /*--------------------------------*- C++ -*----------------------------------*\
2  | =========                 |                                                 |
3  | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
4  |  \\    /   O peration     | Version:  1.5                                   |
5  |   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
6  |    \\/     M anipulation  |                                                 |
7  \*---------------------------------------------------------------------------*/
8  FoamFile
9  {
10      version     2.0;
11      format      ascii;
12      class       dictionary;
13      object      blockMeshDict;
14  }
15  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16  
17  convertToMeters 0.1;
18  
19  vertices
20  (
21      (0 0 0)
22      (1 0 0)
23      (1 1 0)
24      (0 1 0)
25      (0 0 0.1)
26      (1 0 0.1)
27      (1 1 0.1)
28      (0 1 0.1)
29  );
30  
31  blocks
32  (
33      hex (0 1 2 3 4 5 6 7) (20 20 1) simpleGrading (1 1 1)
34  );
35  
36  edges
37  (
38  );
39  
40  patches
41  (
42      wall movingWall
43      (
44          (3 7 6 2)
45      )
46      wall fixedWalls
47      (
48          (0 4 7 3)
49          (2 6 5 1)
50          (1 5 4 0)
51      )
52      empty frontAndBack
53      (
54          (0 3 2 1)
55          (4 5 6 7)
56      )
57  );
58  
59  mergePatchPairs
60  (
61  );
62  
63  // ************************************************************************* //

The file first contains header information in the form of a banner (lines 1-7), then file information contained in a FoamFile sub-dictionary, delimited by curly braces ({...}).

For the remainder of the manual:
For the sake of clarity and to save space, file headers, including the banner and FoamFile sub-dictionary, will be removed from verbatim quoting of case files

The file first specifies coordinates of the block vertices; it then defines the blocks (here, only 1) from the vertex labels and the number of cells within it; and finally, it defines the boundary patches. The user is encouraged to consult 5.3 to understand the meaning of the entries in the blockMeshDict file.

The mesh is generated by running blockMesh on this blockMeshDict file. From within the case directory, this is done, simply by typing in the terminal:


    blockMesh
The running status of blockMesh is reported in the terminal window. Any mistakes in the blockMeshDict file are picked up by blockMesh and the resulting error message directs the user to the line in the file where the problem occurred. There should be no error messages at this stage.
2.1.1.2 Boundary and initial conditions
Once the mesh generation is complete, the user can look at this initial fields set up for this case. The case is set up to start at time t = 0  \special {t4ht= s, so the initial field data is stored in a 0 sub-directory of the cavity directory. The 0 sub-directory contains 2 files, p and U, one for each of the pressure (p  \special {t4ht=) and velocity (U  \special {t4ht=) fields whose initial values and boundary conditions must be set. Let us examine file p:


17  dimensions      [0 2 -2 0 0 0 0];
18  
19  internalField   uniform 0;
20  
21  boundaryField
22  {
23      movingWall
24      {
25          type            zeroGradient;
26      }
27  
28      fixedWalls
29      {
30          type            zeroGradient;
31      }
32  
33      frontAndBack
34      {
35          type            empty;
36      }
37  }
38  
39  // ************************************************************************* //

There are 3 principal entries in field data files:

dimensions
specifies the dimensions of the field, here kinematic pressure, i.e. m2 s-2   \special {t4ht=(see 4.2.6 for more information);
internalField
the internal field data which can be uniform, described by a single value; or nonuniform, where all the values of the field must be specified (see 4.2.8 for more information);
boundaryField
the boundary field data that includes boundary conditions and data for all the boundary patches (see 4.2.8 for more information).

For this case cavity, the boundary consists of walls only, split into 2 patches named: (1) fixedWalls for the fixed sides and base of the cavity; (2) movingWall for the moving top of the cavity. As walls, both are given a zeroGradient for p, meaning “the normal gradient of pressure is zero”. The frontAndBack patch represents the front and back planes of the 2D case and therefore must be set as empty.

In this case, as in most we encounter, the initial fields are set to be uniform. Here the pressure is kinematic, and as an incompressible case, its absolute value is not relevant, so is set to uniform 0 for convenience.

The user can similarly examine the velocity field in the 0/U file. The dimensions are those expected for velocity, the internal field is initialised as uniform zero, which in the case of velocity must be expressed by 3 vector components, i.e.uniform (0 0 0) (see 4.2.5 for more information).

The boundary field for velocity requires the same boundary condition for the frontAndBack patch. The other patches are walls: a no-slip condition is assumed on the fixedWalls, hence a fixedValue condition with a value of uniform (0 0 0). The top surface moves at a speed of 1 m/s in the x  \special {t4ht=-direction so requires a fixedValue condition also but with uniform (1 0 0).

2.1.1.3 Physical properties
The physical properties for the case are stored in dictionaries whose names are given the suffix . . . Properties, located in the Dictionaries directory tree. For an icoFoam case, the only property that must be specified is the kinematic viscosity which is stored from the transportProperties dictionary. The user can check that the kinematic viscosity is set correctly by opening the transportProperties dictionary to view/edit its entries. The keyword for kinematic viscosity is nu, the phonetic label for the Greek symbol n  \special {t4ht= by which it is represented in equations. Initially this case will be run with a Reynolds number of 10, where the Reynolds number is defined as:
      d| U |
Re =  -----
       n
\special {t4ht=
(2.1)

where d  \special {t4ht= and |U | \special {t4ht= are the characteristic length and velocity respectively and n  \special {t4ht= is the kinematic viscosity. Here d =  \special {t4ht= 0.1 m  \special {t4ht=, |U |=  \special {t4ht= 1    -1
m s   \special {t4ht=, so that for Re  =  \special {t4ht= 10, n =  \special {t4ht= 0.01 m2 s-1   \special {t4ht=. The correct file entry for kinematic viscosity is thus specified below:


17  nu              nu [0 2 -1 0 0 0 0] 0.01;
18  
19  // ************************************************************************* //

2.1.1.4 Control
Input data relating to the control of time and reading and writing of the solution data are read in from the controlDict dictionary. The user should view this file; as a case control file, it is located in the system directory.

The start/stop times and the time step for the run must be set. OpenFOAM offers great flexibility with time control which is described in full in 4.3. In this tutorial we wish to start the run at time t = 0  \special {t4ht= which means that OpenFOAM needs to read field data from a directory named 0 -- see 4.1 for more information of the case file structure. Therefore we set the startFrom keyword to startTime and then specify the startTime keyword to be 0.

For the end time, we wish to reach the steady state solution where the flow is circulating around the cavity. As a general rule, the fluid should pass through the domain 10 times to reach steady state in laminar flow. In this case the flow does not pass through this domain as there is no inlet or outlet, so instead the end time can be set to the time taken for the lid to travel ten times across the cavity, i.e. 1 s  \special {t4ht=; in fact, with hindsight, we discover that 0.5 s  \special {t4ht= is sufficient so we shall adopt this value. To specify this end time, we must specify the stopAt keyword as endTime and then set the endTime keyword to 0.5.

Now we need to set the time step, represented by the keyword deltaT. To achieve temporal accuracy and numerical stability when running icoFoam, a Courant number of less than 1 is required. The Courant number is defined for one cell as:

      dt|U |
Co  = ------
        dx
\special {t4ht=
(2.2)

where dt  \special {t4ht= is the time step, |U | \special {t4ht= is the magnitude of the velocity through that cell and dx  \special {t4ht= is the cell size in the direction of the velocity. The flow velocity varies across the domain and we must ensure Co  < 1  \special {t4ht= everywhere. We therefore choose dt  \special {t4ht= based on the worst case: the maximum Co  \special {t4ht= corresponding to the combined effect of a large flow velocity and small cell size. Here, the cell size is fixed across the domain so the maximum Co  \special {t4ht= will occur next to the lid where the velocity approaches 1    - 1
m s   \special {t4ht=. The cell size is:

      d   0.1
dx =  --= --- = 0.005 m
      n    20
\special {t4ht=
(2.3)

Therefore to achieve a Courant number less than or equal to 1 throughout the domain the time step deltaT must be set to less than or equal to:

dt = Co--dx =  1×--0.005--= 0.005 s
       |U |         1
\special {t4ht=
(2.4)

As the simulation progresses we wish to write results at certain intervals of time that we can later view with a post-processing package. The writeControl keyword presents several options for setting the time at which the results are written; here we select the timeStep option which specifies that results are written every n  \special {t4ht=th time step where the value n  \special {t4ht= is specified under the writeInterval keyword. Let us decide that we wish to write our results at times 0.1, 0.2,. . . , 0.5 s  \special {t4ht=. With a time step of 0.005 s  \special {t4ht=, we therefore need to output results at every 20th time time step and so we set writeInterval to 20.

OpenFOAM creates a new directory named after the current time, e.g. 0.1 s  \special {t4ht=, on each occasion that it writes a set of data, as discussed in full in 4.1. In the icoFoam solver, it writes out the results for each field, U and p, into the time directories. For this case, the entries in the controlDict are shown below:


17  application icoFoam;
18  
19  startFrom       startTime;
20  
21  startTime       0;
22  
23  stopAt          endTime;
24  
25  endTime         0.5;
26  
27  deltaT          0.005;
28  
29  writeControl    timeStep;
30  
31  writeInterval   20;
32  
33  purgeWrite      0;
34  
35  writeFormat     ascii;
36  
37  writePrecision  6;
38  
39  writeCompression uncompressed;
40  
41  timeFormat      general;
42  
43  timePrecision   6;
44  
45  runTimeModifiable yes;
46  
47  // ************************************************************************* //

2.1.1.5 Discretisation and linear-solver settings
The user specifies the choice of finite volume discretisation schemes in the fvSchemes dictionary in the system directory. The specification of the linear equation solvers and tolerances and other algorithm controls is made in the fvSolution dictionary, similarly in the system directory. The user is free to view these dictionaries but we do not need to discuss all their entries at this stage except for pRefCell and pRefValue in the PISO sub-dictionary of the fvSolution dictionary. In a closed incompressible system such as the cavity, pressure is relative: it is the pressure range that matters not the absolute values. In cases such as this, the solver sets a reference level by pRefValue in cell pRefCell. In this example both are set to 0. Changing either of these values will change the absolute pressure field, but not, of course, the relative pressure field or velocity field.

2.1.2 Viewing the mesh

Before the case is run it is a good idea to view the mesh to check for any errors. The mesh is viewed in paraFoam, the post-processing tool supplied with OpenFOAM. The paraFoam post-processing is started by typing in the terminal from within the case directory


    paraFoam

Alternatively, it can be launched from another directory location with an optional -case argument giving the case directory, e.g.


    paraFoam -case $FOAM_RUN/tutorials/icoFoam/cavity

This launches the ParaView window as shown in 6.1. In the Pipeline Browser, the user can see that ParaView has opened cavity.OpenFOAM, the module for the cavity case. Before clicking the Apply button, the user needs to select some geometry from the Region Status and panel. Because the case is small, it is easiest to select all the data by checking the box adjacent to the Region Status panel title, which automatically checks all individual components within the respective panel.

The user should then click the Apply button to load the geometry into ParaView. The user should then open the Display panel that controls the visual representation of the selected module. Within the Display panel the user should do the following as shown in 2.3: (1) set Color by Solid Color; (2) click Set Solid Color and select an appropriate colour e.g. black (for a white background); (3) in the Style panel, select Wireframe from the Representation menu. The background colour can be set by selecting View Settings... from Edit in the top menu panel.


Open  Display panel
Select Color by Solid  Color

Set Solid  Color,  e.g. black
Select Wireframe
\special {t4ht=


Figure 2.3: Viewing the mesh in paraFoam.


The user can try manipulating the view as described in 6.1.5. In particular, since this is a 2D case, it is recommended that Use Parallel Projection is selected in the General panel of View Settings window selected from the Edit menu. This is described in more detail in 6.1.5.1. The Orientation Axes can be toggled on and off in the Annotation window or moved by drag and drop with the mouse.

2.1.3 Running an application

Like any UNIX/Linux executable, OpenFOAM applications can be run in two ways: as a foreground process, i.e. one in which the shell waits until the command has finished before giving a command prompt; as a background process, one which does not have to be completed before the shell accepts additional commands.

On this occasion, we will run icoFoam in the foreground. The icoFoam solver is executed either by entering the case directory and typing


    icoFoam
at the command prompt, or with the optional -case argument giving the case directory, e.g.


    icoFoam -case $FOAM_RUN/tutorials/icoFoam/cavity

The progress of the job is written to the terminal window. It tells the user the current time, maximum Courant number, initial and final residuals for all fields.


Open  Display panel
Select Color by interpolated p

Rescale to Data Range
Select Surface
\special {t4ht=


Figure 2.4: Displaying pressure contours for the cavity case.




\special {t4ht=


Figure 2.5: Pressures in the cavity case.


2.1.4 Post-processing

As soon as results are written to time directories, they can be viewed using paraFoam. Return to the paraFoam window and select the Properties panel for the cavity.OpenFOAM case module. If the correct window panels for the case module do not seem to be present at any time, please ensure that: cavity.OpenFOAM is highlighted in blue; eye button alongside it is switched on to show the graphics are enabled;

To prepare paraFoam to display the data of interest, we must first load the data at the required run time of 0.5 s. If the case was run while ParaView was open, the output data in time directories will not be automatically loaded within ParaView. To load the data the user should select Update GUI in the Properties window and then click the green Apply button. The time data will be loaded into ParaView.

2.1.4.1 Contour plots
To view pressure, the user should open the Display panel since it that controls the visual representation of the selected module. To make a simple plot of pressure, the user should select the following, as described in detail in 2.4: in the Style panel, select Surface from the Representation menu; in the Color panel, select Color by PIC\special {t4ht= and Rescale to Data Range. Now in order to view the solution at t = 0.5 s  \special {t4ht=, the user can use the VCR Controls or Current Time Controls to change the current time to 0.5. These are located in the toolbars below the menus at the top of the ParaView window, as shown in 6.4. The pressure field solution has, as expected, a region of low pressure at the top left of the cavity and one of high pressure at the top right of the cavity as shown in 2.5.

With the point icon (PIC\special {t4ht=) the pressure field is interpolated across each cell to give a continuous appearance. Instead if the user selects the cell icon, PIC\special {t4ht=, from the Color by menu, a single value for pressure will be attributed to each cell so that each cell will be denoted by a single colour with no grading.

A colour bar can be included by either by clicking the Toggle Color Legend Visibility button in the Active Variable Controls toolbar, or by selecting Show Color Legend from the View menu. Clicking the Edit Color Map button, either in the Active Variable Controls toolbar or in the Color panel of the Display window, the user can set a range of attributes of the colour bar, such as text size, font selection and numbering format for the scale. The colour bar can be located in the image window by drag and drop with the mouse.

If the user rotates the image, they can see that they have now coloured the complete geometry surface by the pressure. In order to produce a genuine contour plot the user should first create a cutting plane, or ‘slice’, through the geometry using the Slice filter as described in 6.1.6.1. The cutting plane should be centred at (0.05,0.05,0.005)  \special {t4ht= and its normal should be set to (0,0,1)  \special {t4ht=. Having generated the cutting plane, the contours can be created using by the Contour filter described in 6.1.6.


       Open  Parameters panel
Specify Set Scale Factor 0.005

       Select Scale  Mode  off
    Select Glyph  Type Arrow
\special {t4ht=


Figure 2.6: Properties panel for the Glyph filter.




\special {t4ht=


Figure 2.7: Velocities in the cavity case.


2.1.4.2 Vector plots
Before we start to plot the vectors of the flow velocity, it may be useful to remove other modules that have been created, e.g. using the Slice and Contour filters described above. These can: either be deleted entirely, by highlighting the relevant module in the Pipeline Browser and clicking Delete in their respective Properties panel; or, be disabled by toggling the eye button for the relevant module in the Pipeline Browser.

We now wish to generate a vector glyph for velocity at the centre of each cell. We first need to filter the data to cell centres as described in 6.1.7.1. With the cavity.OpenFOAM module highlighted in the Pipeline Browser, the user should select Cell Centers from the Filter menu and then click Apply.

With these Centers highlighted in the Pipeline Browser, the user should then select Glyph from the Filter menu. The Properties window panel should appear as shown in 2.6. In the resulting Properties panel, the velocity field, U, is automatically selected in the vectors menu, since it is the only vector field present. By default the Scale Mode for the glyphs will be Vector Magnitude of velocity but, since the we may wish to view the velocities throughout the domain, the user should instead select off and Set Scale Factor to 0.005. On clicking Apply, the glyphs appear but, probably as a single colour, e.g. white. The user should colour the glyphs by velocity magnitude which, as usual, is controlled by setting Color by U in the Display panel. The user should also select Show Color Legend in Edit Color Map. The output is shown in 2.7, in which uppercase Times Roman fonts are selected for the Color Legend headings and the labels are specified to 2 fixed significant figures by deselecting Automatic Label Format and entering %-#6.2f in the Label Format text box. The background colour is set to white in the General panel of View Settings as described in 6.1.5.1.


Open  Parameters panel
Set Max Propagation   to Length  0.5

Set Initial  Step  Length  to Cell Length  0.01
Set Integration   Direction  to BOTH
Specify Line  Source and  set points and resolution
\special {t4ht=


Figure 2.8: Properties panel for the Stream Tracer filter.




\special {t4ht=


Figure 2.9: Streamlines in the cavity case.


2.1.4.3 Streamline plots
Again, before the user continues to post-process in ParaView, they should disable modules such as those for the vector plot described above. We now wish to plot a streamlines of velocity as described in 6.1.8.

With the cavity.OpenFOAM module highlighted in the Pipeline Browser, the user should then select Stream Tracer from the Filter menu and then click Apply. The Properties window panel should appear as shown in 2.8. The Seed points should be specified along a Line Source running vertically through the centre of the geometry, i.e. from (0.05,0,0.005)  \special {t4ht= to (0.05,0.1,0.005)  \special {t4ht=. For the image in this guide we used: a point Resolution of 21; Max Propagation by Length 0.5; Initial Step Length by Cell Length 0.01; and, Integration Direction BOTH. The Runge-Kutta 2 IntegratorType was used with default parameters.

On clicking Apply the tracer is generated. The user should then select Tube from the Filter menu to produce high quality streamline images. For the image in this report, we used: Num. sides 6; Radius 0.0003; and, Radius factor 10. The streamtubes are coloured by velocity magnitude. On clicking Apply the image in 2.9 should be produced.

2.1.5 Increasing the mesh resolution

The mesh resolution will now be increased by a factor of two in each direction. The results from the coarser mesh will be mapped onto the finer mesh to use as initial conditions for the problem. The solution from the finer mesh will then be compared with those from the coarser mesh.

2.1.5.1 Creating a new case using an existing case
We now wish to create a new case named cavityFine that is created from cavity. The user should therefore clone the cavity case and edit the necessary files. First the user should create a new case directory at the same directory level as the cavity case, e.g.


    cd $FOAM_RUN/tutorials/icoFoam
    mkdir cavityFine
The user should then copy the base directories from the cavity case into cavityFine, and then enter the cavityFine case.


    cp -r cavity/constant cavityFine
    cp -r cavity/system cavityFine
    cd cavityFine

2.1.5.2 Creating the finer mesh
We now wish to increase the number of cells in the mesh by using blockMesh. The user should open the blockMeshDict file in an editor and edit the block specification. The blocks are specified in a list under the blocks keyword. The syntax of the block definitions is described fully in 5.3.1.3; at this stage it is sufficient to know that following hex is first the list of vertices in the block, then a list (or vector) of numbers of cells in each direction. This was originally set to (20 20 1) for the cavity case. The user should now change this to (41 41 1) and save the file. The new refined mesh should then be created by running blockMesh as before.

2.1.5.3 Mapping the coarse mesh results onto the fine mesh
The mapFields utility maps one or more fields relating to a given geometry onto the corresponding fields for another geometry. In our example, the fields are deemed ‘consistent’ because the geometry and the boundary types, or conditions, of both source and target fields are identical. We use the -consistent command line option when executing mapFields in this example.

The field data that mapFields maps is read from the time directory specified by startFrom/startTime in the controlDict of the target case, i.e. those into which the results are being mapped. In this example, we wish to map the final results of the coarser mesh from case cavity onto the finer mesh of case cavityFine. Therefore, since these results are stored in the 0.5 directory of cavity, the startTime should be set to 0.5 s  \special {t4ht= in the controlDict dictionary and startFrom should be set to startTime.

The case is ready to run mapFields. Typing mapFields -help quickly shows that mapFields requires the source case directory as an argument. We are using the -consistent option, so the utility is executed from withing the cavityFine directory by


    mapFields ../cavity -consistent
The utility should run with output to the terminal including:

  Source: ".." "cavity"
  Target: "." "cavityFine"
  
  Create databases as time
  
  Source time: 0.5
  Target time: 0.5
  Create meshes
  
  Source mesh size: 400   Target mesh size: 1681
  
  Consistently creating and mapping fields for time 0.5
  
      interpolating p
      interpolating U
  
  End

2.1.5.4 Control adjustments
To maintain a Courant number of less that 1, as discussed in 2.1.1.4, the time step must now be halved since the size of all cells has halved. Therefore deltaT should be set to to 0.0025 s  \special {t4ht= in the controlDict dictionary. Field data is currently written out at an interval of a fixed number of time steps. Here we demonstrate how to specify data output at fixed intervals of time. Under the writeControl keyword in controlDict, instead of requesting output by a fixed number of time steps with the timeStep entry, a fixed amount of run time can be specified between the writing of results using the runTime entry. In this case the user should specify output every 0.1 s  \special {t4ht= and therefore should set writeInterval to 0.1 and writeControl to runTime. Finally, since the case is starting with a the solution obtained on the coarse mesh we only need to run it for a short period to achieve reasonable convergence to steady-state. Therefore the endTime should be set to 0.7 s  \special {t4ht=. Make sure these settings are correct and then save the file.

2.1.5.5 Running the code as a background process
The user should experience running icoFoam as a background process, redirecting the terminal output to a log file that can be viewed later. From the cavityFine directory, the user should execute:


    icoFoam > log &
    cat log

2.1.5.6 Vector plot with the refined mesh
The user can open multiple cases simultaneously in ParaView; essentially because each new case is simply another module that appears in the Pipeline Browser. There is one minor inconvenience when opening a new case in ParaView because there is a prerequisite that the selected data is a file with a name that has an extension. However, in OpenFOAM, each case is stored in a multitude of files with no extensions within a specific directory structure. The solution, that the paraFoam script performs automatically, is to create a dummy file with the extension .OpenFOAM -- hence, the cavity case module is called cavity.OpenFOAM.

However, if the user wishes to open another case directly from within ParaView, they need to create such a dummy file. For example, to load the cavityFine case the file would be created by typing at the command prompt:


    cd $FOAM_RUN/tutorials/icoFoam
    touch cavityFine/cavityFine.OpenFOAM

Now the cavityFine case can be loaded into ParaView by selecting Open from the File menu, and having navigated the directory tree, selecting cavityFine.OpenFOAM. The user can now make a vector plot of the results from the refined mesh in ParaView. The plot can be compared with the cavity case by enabling glyph images for both case simultaneously.


      Open  Display panel
Select Ux from  Line Series

      Select arcxlength
    Select Scatter  Plot
\special {t4ht=


Figure 2.10: Selecting fields for graph plotting.


2.1.5.7 Plotting graphs
The user may wish to visualise the results by extracting some scalar measure of velocity and plotting 2-dimensional graphs along lines through the domain. OpenFOAM is well equipped for this kind of data manipulation. There are numerous utilities that do specialised data manipulations, and some, simpler calculations are incorporated into a single utility foamCalc. As a utility, it is unique in that it is executed by


    foamCalc <calcType> <fieldName1 ... fieldNameN>
The calculator operation is specified in <calcType>; at the time of writing, the following operations are implemented: div; components; mag; magGrad; magSqr. The user can obtain a full list of <calcType> by deliberately calling one that does not exist, so that foamCalc throws up an error message and lists the types available, e.g.

  >> foamCalc xxxx
  Selecting calcType xxxx
      unknown calcType type xxxx, constructor not in hash table
      Valid calcType selections are:
  
  5
  (