TP Fluide2 SMER S4 Partie1
TP Fluide2 SMER S4 Partie1
• To keep everything in order, the case directory is often located in the path
$WM_PROJECT_USER_DIR/run
• This is not compulsory but highly advisable, you can put the case in any directory of your preference.
• The name of the case directory if given by the user (do not use white spaces).
• You run the applications and utilities in the top level of this directory.
• The directory system contains run-time control and solver numerics.
• The directory constant contains physical properties, turbulence modeling properties, advanced physics
and so on.
• The directory constant/polyMesh contains the polyhedral mesh information.
• The directory 0 contains boundary conditions (BC) and initial conditions (IC).
Running my first OpenFOAM® case setup blindfold
Flow in a lid-driven square cavity – Re = 100
Incompressible flow
blockMesh
icoFoam functionObjects
sampling paraview
Running my first OpenFOAM® case setup blindfold
At the end of the day, you should get something like this
High-Re Solutions for incompressible flow using the navier-stokes equations and a multigrid method
U. Ghia, K. N. Ghia, C. T. Shin.
Journal of computational physics, 48, 387-411 (1982)
Running my first OpenFOAM® case setup blindfold
What are we going to do?
• We will use the lid-driven square cavity tutorial as a general example to show you how to set up
and run solvers and utilities in OpenFOAM®.
• In this tutorial we are going to generate the mesh using blockMesh.
• After generating the mesh, we will look for topological errors and assess the mesh quality. For
this we use the utility checkMesh. Later on, we are going to talk about what is a good mesh.
• Then, we will find the numerical solution using icoFoam, which is a transient solver for
incompressible, laminar flow of Newtonian fluids. By the way, we hope you did not forget where
to look for this information.
• And we will finish with some quantitative post-processing and qualitative visualization using
paraFoam and OpenFOAM® utilities.
• While we run this case, we are going to see a lot of information on the screen (standard output
stream or stdout), but it will not be saved. This information is mainly related to convergence of
the simulation, we will talk about this later on.
• A final word, we are going to use the solver icoFoam but have in mind that this is a very basic
solver with no modeling capabilities and limited post-processing features.
• Therefore, is better to use pisoFoam or pimpleFoam which are equivalent to icoFoam but
with many more features.
Running my first OpenFOAM® case setup blindfold
Running the case blindfold
• Let us run this case blindfold.
• Later we will study in details each file and directory.
• Remember, the variable $FOAM_RUN is pointing to the path where you unpacked the
tutorials.
• You can create this environment variable or write down the path to the directory.
• In the terminal window type:
1. $> cd $FOAM_RUN/cavity
2. $> ls –l
3. $> blockMesh
4. $> checkMesh
5. $> icoFoam
6. $> paraFoam
Running my first OpenFOAM® case setup blindfold
Running the case blindfold
• In step 1 we go to the case directory. Remember, $FOAM_RUN is pointing to the path where you
unpacked the tutorials.
• In step 2 we just list the directory structure (this step is optional). Does it look familiar to you? In
the directory 0 you will the initial and boundary conditions, in the constant directory you will
find the mesh information and physical properties, and in the directory system you will find the
dictionaries that controls the numerics, runtime parameters and sampling.
• In step 4 we check the mesh quality. We are going to address how to assess mesh quality later
on.
• In step 5 we run the simulation. This will show a lot information on the screen, the standard
output stream will not be saved.
• Finally, in step 6 we visualize the solution using paraFoam. In the next slides we are going to
briefly explore this application.
Running my first OpenFOAM® case setup blindfold
Crash introduction to paraFoam
Menu Bar
Toolbars
Pipeline Browser
Properties panel
Apply button
Press this button to
load the case or to
apply a filter
3D View/Canvas
Advanced Toggle
Running my first OpenFOAM® case setup blindfold
Crash introduction to paraFoam – Toolbars
• Main Controls
• Representation Toolbar
• Common Filters
Rotate
Zoom
Pan
Zoom
3D View/Canvas
Running my first OpenFOAM® case setup blindfold
Crash introduction to paraFoam – Fields visualization
Select Last Frame in the VCR Controls Current Time Controls
• You can access all the filters from the menu Filter.
Running my first OpenFOAM® case setup blindfold
Crash introduction to paraFoam – Filters
4. Press Apply
3. Press Apply
2. Filter options
(0.5, 1, 1)
3. Press Apply
(0.5, 0, 1)
2. Enter the coordinates of the line
Line
Running my first OpenFOAM® case setup blindfold
Crash introduction to paraFoam – Filters
4. Optional – Use the VCR Control to change the frame.
The line chart view will be updated automatically
1. Click on the line chart view (the blue frame indicates that it is the active view)
Running my first OpenFOAM® case setup blindfold
Running the case blindfold with log files
• In the previous case, we ran the simulation but we did not save the standard output
stream (stdout) in a log file.
• Our advice is to always save the standard output stream (stdout) in a log file.
• It is of interest to always save the log as if something goes wrong and you would like
to do troubleshooting, you will need this information.
• Also, if you are interested in plotting the residuals you will need the log file.
• By the way, if at any point you ask us what went wrong with your simulation, it is likely
that we will ask you for this file.
1. $> foamCleanTutorials
2. $> blockMesh | tee log.blockMesh
3. $> checkMesh | tee log.checkMesh
4. $> icoFoam | tee log.icoFoam
• You can use your favorite text editor to read the log file (e.g., gedit, vi, emacs).
Running my first OpenFOAM® case setup blindfold
Running the case blindfold with log files
• In step 1 we erase the mesh and all the folders, except for 0, constant and system. This
script comes with your OpenFOAM® installation.
• In step 2, we generate the mesh using the meshing tool blockMesh. We also redirect the
standard output to an ascii file with the name log.blockMesh (it can be any name). The tee
command will redirect the screen output to the file log.blockMesh and at the same time will
show you the information on the screen.
• In step 3 we check the mesh quality. We also redirect the standard output to an ascii file with the
name log.checkMesh (it can be any name).
• In step 4 we run the simulation. We also redirect the standard output to an ascii file with the
name log.icoFoam (it can be any name). Remember, the tee command will redirect the
screen output to the file log.icoFoam and at the same time will show you the information on
the screen.
Running my first OpenFOAM® case setup blindfold
Stopping the simulation
• Your simulation will automatically stop at the time value you set using the keyword endTime in
the controlDict dictionary.
endTime 50;
• If for any reason you want to stop your simulation before reaching the value set by the keyword
endTime, you can change this value to a number lower than the current simulation time (you
can use 0 for instance). This will stop your simulation, but it will not save your last time-step or
iteration, so be careful.
1 /*--------------------------------*- C++ -*----------------------------------*\
2 | ========= | |
3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4 | \\ / O peration | Version: 6.x |
5 | \\ / A nd | Web: www.OpenFOAM.org |
6 | \\/ M anipulation | |
7 \*---------------------------------------------------------------------------*/
8 FoamFile
9 {
10 version 2.0;
11 format ascii;
12 class dictionary;
13 object controlDict;
14 }
15 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16
17 application icoFoam;
18
19 startFrom startTime;
20
21 startTime 0;
22
23 stopAt endTime;
24
25 endTime 50;
Running my first OpenFOAM® case setup blindfold
Stopping the simulation
• If you want to stop the simulation and save the solution, in the controlDict dictionary made
the following modification,
stopAt writeNow;
This will stop your simulation and will save the current time-step or iteration.
44
45 runTimeModifiable true;
46
Running my first OpenFOAM® case setup blindfold
Stopping the simulation
• You can also kill the process. For instance, if you did not launch the solver in background, go to its terminal
window and press ctrl-c. This will stop your simulation, but it will not save your last time-step or iteration, so
be careful.
Running my first OpenFOAM® case setup blindfold
Stopping the simulation
• When working locally, we usually proceed in this way:
This will run the solver icoFoam (by the way, this works for any solver or utility), it will save the
standard output stream in the file log.icofoam and will show the solver output on the fly.
• If at any moment we want to stop the simulation, and we are not interested in saving the last
time-step, we press ctrl-c.
• If we are interested in saving the last time step, we modify the controlDict dictionary and
add the following keyword
stopAt writeNow;
• Remember, this modification can be done on the fly. However, you will need to set the keyword
runTimeModifiable to yes in the controlDict dictionary.
Running my first OpenFOAM® case setup blindfold
Cleaning the case folder
• If you want to erase the mesh and the solution in the current case folder, you can type in the
terminal,
$> foamCleanTutorials
If you are running in parallel, this will also erase the processorN directories. We will talk about
running in parallel later.
• If you are looking to only erase the mesh, you can type in the terminal,
$> foamCleanPolyMesh
• If you are only interested in erasing the saved solutions, in the terminal type,
$> foamListTimes -rm
• If you are running in parallel and you want to erase the solution saved in the processorN
directories, type in the terminal,
$> foamListTimes –rm -processor
A deeper view to my first OpenFOAM® case setup
• We will take a close look at what we did by looking at the case files.
• The case directory originally contains the following sub-directories: 0, constant, and
system. After running icoFoam it also contains the time step directories 1, 2, 3,
..., 48, 49, 50, the post-processing directory postProcessing, and the
log.icoFoam file (if you chose to redirect the standard output stream).
• The time step directories contain the values of all the variables at those time
steps (the solution). The 0 directory is thus the initial condition and boundary
conditions.
• The constant directory contains the mesh and dictionaries for thermophysical,
turbulence models and advanced physical models.
• The system directory contains settings for the run, discretization schemes and
solution procedures.
• The icoFoam solver reads these files and runs the case according to those
settings.
A deeper view to my first OpenFOAM® case setup
• Before continuing, we want to point out the following:
• Each dictionary file in the case directory has a header.
• Lines 1-7 are commented.
• You should always keep lines 8 to 14, if not, OpenFOAM® will complain.
• According to the dictionary you are using, the class keyword (line 12)
will be different. We are going to talk about this later on.
• From now on and unless it is strictly necessary, we will not show the
header when listing the dictionaries files.
• In this directory you will find the sub-directory polyMesh and the dictionary file
transportProperties.
• The transportProperties file is a dictionary for the dimensioned scalar nu, or the
kinematic viscosity.
1 Mass Kilogram kg
2 Length meters m
3 Time second s
4 Temperature Kelvin K
6 Current ampere A
17 nu nu [ 0 2 -1 0 0 0 0 ] 0.01;
[ 0 m^2 s^-1 0 0 0 0 ]
Which is equivalent to
A deeper view to my first OpenFOAM® case setup
The constant directory
(and by the way, open each file and go thru its content)
• In this case, as we are working with an incompressible flow, we only need to define
the kinematic viscosity.
• Later on, we will ask you to change the Reynolds number, to do so you can change
the value of nu. Remember,
• You can also change the free stream velocity U or the reference length L.
A deeper view to my first OpenFOAM® case setup
The constant directory
(and by the way, open each file and go thru its content)
• Depending on the physics involved and models used, you will need to define more
variables in the dictionary transportProperties.
• For instance, for a multiphase case you will need to define the density rho and
kinematic viscosity nu for each single phase. You will also need to define the surface
tension .
• Also, depending of your physical model, you will find more dictionaries in the constant
directory.
• For example, if you need to set gravity, you will need to create the dictionary g.
• If you work with compressible flows you will need to define the dynamic viscosity mu,
and many other physical properties in the dictionary thermophysicalProperties.
• As we are not dealing with compressible flows (for the moment), we are not going into
details.
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh directory
(and by the way, open each file and go thru its content)
• In this case, the polyMesh directory is initially empty. After generating the mesh, it
will contain the mesh in OpenFOAM® format.
• To generate the mesh in this case, we use the utility blockMesh. This utility reads
the dictionary blockMeshDict located in the system folder.
• We will briefly address a few important inputs of the blockMeshDict dictionary.
• Do not worry, we are going to revisit this dictionary during the meshing session.
• However, have in mind that rarely you will use this utility to generate a mesh for
complex geometries.
• Go to the directory system and open blockMeshDict dictionary with your favorite
text editor, we will use gedit.
A deeper view to my first OpenFOAM® case setup
The system/blockMeshDict dictionary
• The blockMeshDict dictionary first defines a list with a number of vertices:
• The keyword convertToMeters (line 17), is a scaling factor. In this case
17 convertToMeters 1;
18
we do not scale the dimensions.
19 xmin 0;
20 xmax 1; • In the section vertices (lines 37-58), we define the vertices coordinates of
21 ymin 0; the geometry. In this case, there are eight vertices defining the geometry.
22 ymax 1;
23 zmin 0;
OpenFOAM® always uses 3D meshes, even if the simulation is 2D.
24 zmax 1;
25 • We can directly define the vertex coordinates in the section vertices
26 xcells 20; (commented lines 49-56), or we can use macro syntax.
27 ycells 20;
28 zcells 1; • Using macro syntax we first define a variable and its value (lines 19-24),
29
37 vertices and then we can use them by adding the symbol $ to the variable name
38 ( (lines 39-46).
39 ($xmin $ymin $zmin) //vertex 0
40 ($xmax $ymin $zmin) //vertex 1 • In lines 26-28, we define a set of variables that will be used at a later time.
41 ($xmax $ymax $zmin) //vertex 2
42 ($xmin $ymax $zmin) //vertex 3 These variables are related to the number of cells in each direction.
43 ($xmin $ymin $zmax) //vertex 4
44 ($xmax $ymin $zmax) //vertex 5 • Finally, notice that the vertex numbering starts from 0 (as the counters in
45 ($xmax $ymax $zmax) //vertex 6 c++). This numbering applies for blocks as well.
46 ($xmin $ymax $zmax) //vertex 7
47
48 /*
49 (0 0 0)
50 (1 0 0)
51 (1 1 0)
52 (0 1 0)
53 (0 0 0.1)
54 (1 0 0.1)
55 (1 1 0.1)
56 (0 1 0.1)
57 */
58 );
A deeper view to my first OpenFOAM® case setup
The system/blockMeshDict dictionary
• The blockMeshDict dictionary also defines the boundary patches:
• To sum up, the blockMeshDict dictionary generates in this case a single block with:
• X/Y/Z dimensions: 1.0/1.0/1.0
• Cells in the X, Y and Z directions: 20 x 20 x 1 cells.
• One single hex block with straight lines.
• Patch type wall and patch name fixedWalls at three sides.
• Patch type wall and patch name movingWall at one side.
• Patch type empty and patch name frontAndBack patch at two sides.
• If you are interested in visualizing the actual block topology, you can use paraFoam
as follows,
• $> paraFoam –block
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh/boundary dictionary
• First of all, this file is automatically generated after you create the mesh
using blockMesh or snappyHexMesh, or when you convert the mesh from
a third-party format.
• In this file, the geometrical information related to the base type patch of
each boundary (or surface patch) of the domain is specified.
• The base type boundary condition is the actual surface patch where we are
going to apply a numerical type boundary condition (or numerical boundary
condition).
• The numerical type boundary condition assign a field value to the surface
patch (base type).
• We define the numerical type patch (or the value of the boundary
condition), in the directory 0 or time directories.
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh/boundary dictionary
fixedWall
fixedWall
34 frontAndBack
35 {
36 type empty;
37 inGroups 1(empty);
38 nFaces 800;
39 startFace 840;
40 }
41 )
frontAndBack
fixedWall
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh/boundary dictionary
18 3
19 ( Name and type of the surface patches
20 movingWall Name
21 {
22 type wall; Type • The name and type of the patch is given by
23 inGroups 1(wall);
24 nFaces 20; the user.
25 startFace 760;
26 } • In this case the name and type was assigned
27 fixedWalls in the dictionary blockMeshDict.
28 {
29 type wall; • You can change the name if you do not like it.
30 inGroups 1(wall);
31 nFaces 60; Do not use strange symbols or white spaces.
32 startFace 780;
33 } • You can also change the base type. For
34 frontAndBack instance, you can change the type of the
35 {
36 type empty;
patch movingWall from wall to patch.
37 inGroups 1(empty);
38 nFaces 800;
• When converting the mesh from a third party
39 startFace 840; format, OpenFOAM® will try to recover the
40 } information from the original format. But it
41 )
might happen that it does not recognizes the
base type and name of the original file. In this
case you will need to modify this file manually.
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh/boundary dictionary
18 3 inGroups keyword
19 ( • This keyword is optional. You can erase this information safely.
20 movingWall
21 { • It is used to group patches during visualization in
22 type wall; ParaView/paraFoam. If you open this mesh in paraFoam you will
23 inGroups 1(wall); see that there are two groups, namely: wall and empty.
24 nFaces 20;
25 startFace 760; • As usual, you can change the name.
26 } • If you want to put a surface patch in two groups, you can proceed
27 fixedWalls
as follows:
28 {
29 type wall; 2(wall wall1)
30 inGroups 1(wall);
31 nFaces 60;
In this case the surface patch belongs to the groups wall and
32 startFace 780; wall1.
33 } • Groups can have more than one patch.
34 frontAndBack
35 {
36 type empty; nFaces and startFace keywords
37 inGroups 1(empty);
38 nFaces 800; • Unless you know what you are doing, you do not need to
39 startFace 840; modify this information.
40 }
41 ) • This information is related to the starting face and ending face of
the boundary patch in the mesh data structure.
• This information is created automatically when generating the
mesh or converting the mesh.
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh/boundary dictionary
• There are a few base type patches that are constrained or paired. This means that the type
should be the same in the boundary file and in the numerical boundary condition defined in the
field files, e.g., the files 0/U and 0/p.
• In this case, the base type of the patch frontAndBack (defined in the file boundary), is
consistent with the numerical type patch defined in the field files 0/U and 0/p. They are of
the type empty.
• Also, the base type of the patches movingWall and fixedWalls (defined in the file boundary),
is consistent with the numerical type patch defined in the field files 0/U and 0/p.
• This is extremely important, especially if you are converting meshes as not always the type of
the patches is set as you would like.
• Hence, it is highly advisable to do a sanity check and verify that the base type of the patches
(the type defined in the file boundary), is consistent with the numerical type of the patches
(the patch type defined in the field files contained in the directory 0 (or whatever time directory
you defined the boundary and initial conditions).
• If the base type and numerical type boundary conditions are not consistent, OpenFOAM® will
complain.
• Do not worry, we are going to address boundary conditions later on.
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh/boundary dictionary
symmetry symmetry
symmetryPlane symmetryPlane
empty empty
wedge wedge
cyclic cyclic
processor processor
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh/boundary dictionary
• The base type patch can be any of the numerical or derived type
boundary conditions available in OpenFOAM®. Mathematically speaking;
they can be Dirichlet, Neumann or Robin boundary conditions.
fixedValue
zeroGradient
inletOutlet
slip
patch
totalPressure
supersonicFreeStream
and so on …
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh/boundary dictionary
type fixedValue;
wall zeroGradient
value uniform (U V W);
• This boundary condition is not contained in the patch base type boundary
condition group, because specialize modeling options can be used on this
boundary condition.
• An example is turbulence modeling, where turbulence can be generated or
dissipated at the walls.
A deeper view to my first OpenFOAM® case setup
The constant/polyMesh/boundary dictionary
• The name of the base type boundary condition and the name of the
numerical type boundary condition needs to be the same, if not,
OpenFOAM® will complain.
• Pay attention to this, specially if you are converting the mesh from another
format.
• As you can see, all the names are the same across all the dictionary files.
A deeper view to my first OpenFOAM® case setup
The system directory
(and by the way, open each file and go thru its content)
• The 0 directory contains the initial and boundary conditions for all primitive variables,
in this case p and U. The U file contains the following information (velocity vector):
• The 0 directory contains the initial and boundary conditions for all primitive variables,
in this case p and U. The U file contains the following information (velocity):
• The 0 directory contains the initial and boundary conditions for all primitive variables,
in this case p and U. The p file contains the following information (modified pressure):
• The 0 directory contains the initial and boundary conditions for all primitive variables,
in this case p and U. The p file contains the following information (modified pressure):
with units
• If the field variable is a tensor (e.g. the velocity gradient tensor), the class should be
volTensorField.
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 6.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volTensorField;
object gradU;
}
A deeper view to my first OpenFOAM® case setup
The output screen
• Finally, let us talk about the output screen, which shows a lot of information.
Velocity residuals
Simulation time
Courant number
Pressure residuals
No orthogonal corrections
Only one PISO correction
Execution time (wall time)
Continuity errors
Additional information
End of the simulation Minimum and maximum values of each field
A deeper view to my first OpenFOAM® case setup
The output screen
• Another very important output information is the CFL or Courant number.
• The Courant number imposes the CFL number condition, which is the maximum allowable
CFL number a numerical scheme can use. For the n - dimensional case, the CFL number
condition becomes,
• In OpenFOAM®, most of the solvers are implicit, which means they are unconditionally
stable. In other words, they are not constrained to the CFL number condition.
• However, the fact that you are using a numerical method that is unconditionally stable, does
not mean that you can choose a time step of any size.
• The time-step must be chosen in such a way that it resolves the time-dependent features, and it
maintains the solver stability.
• For the moment and for the sake of simplicity, let us try to keep the CFL number below 5.0 and
preferably close to 1.0 (for good accuracy).
• Other properties of the numerical method that you should observe are: conservationess,
boundedness, transportiveness, and accuracy. We are going to address these properties and
the CFL number when we deal with the FVM theory.
A deeper view to my first OpenFOAM® case setup
The output screen
• To control the CFL number you can change the time step or you can change the mesh.
• The easiest way is by changing the time step.
• For a time step of 0.01 seconds, this is the output you should get for this case,
Time = 49.99
CFL number at
Courant Number mean: 0.044365026 max: 0.16800273
time step n - 1
smoothSolver: Solving for Ux, Initial residual = 1.1174405e-09, Final residual = 1.1174405e-09, No Iterations 0
smoothSolver: Solving for Uy, Initial residual = 1.4904251e-09, Final residual = 1.4904251e-09, No Iterations 0
DICPCG: Solving for p, Initial residual = 6.7291723e-07, Final residual = 6.7291723e-07, No Iterations 0
time step continuity errors : sum local = 2.5096865e-10, global = -1.7872395e-19, cumulative = 2.6884327e-18
ExecutionTime = 4.47 s ClockTime = 5 s
Time = 50
CFL number at
Courant Number mean: 0.044365026 max: 0.16800273
smoothSolver: Solving for Ux, Initial residual = 1.0907508e-09, Final residual = 1.0907508e-09, No Iterations 0 time step n
smoothSolver: Solving for Uy, Initial residual = 1.4677462e-09, Final residual = 1.4677462e-09, No Iterations 0
DICPCG: Solving for p, Initial residual = 1.0020944e-06, Final residual = 1.0746895e-07, No Iterations 1
time step continuity errors : sum local = 4.0107145e-11, global = -5.0601748e-20, cumulative = 2.637831e-18
ExecutionTime = 4.47 s ClockTime = 5 s
Time = 49.9
CFL number at
Courant Number mean: 0.4441161 max: 1.6798756
time step n - 1
smoothSolver: Solving for Ux, Initial residual = 0.00016535808, Final residual = 2.7960145e-09, No Iterations 5
smoothSolver: Solving for Uy, Initial residual = 0.00015920267, Final residual = 2.7704949e-09, No Iterations 5
DICPCG: Solving for p, Initial residual = 0.0015842846, Final residual = 5.2788554e-07, No Iterations 26
time step continuity errors : sum local = 8.6128916e-09, global = 3.5439859e-19, cumulative = 2.4940081e-17
ExecutionTime = 0.81 s ClockTime = 1 s
Time = 50
CFL number at
Courant Number mean: 0.44411473 max: 1.6798833
smoothSolver: Solving for Ux, Initial residual = 0.00016378098, Final residual = 2.7690608e-09, No Iterations 5 time step n
smoothSolver: Solving for Uy, Initial residual = 0.00015720331, Final residual = 2.7354499e-09, No Iterations 5
DICPCG: Solving for p, Initial residual = 0.0015662416, Final residual = 5.2290439e-07, No Iterations 26
time step continuity errors : sum local = 8.5379223e-09, global = -3.6676527e-19, cumulative = 2.4573316e-17
ExecutionTime = 0.81 s ClockTime = 1 s
Time = 2
CFL number at
Courant Number mean: 1.6828931 max: 5.6061178
time step n - 1
smoothSolver: Solving for Ux, Initial residual = 0.96587058, Final residual = 4.9900041e-09, No Iterations 27
smoothSolver: Solving for Uy, Initial residual = 0.88080685, Final residual = 9.7837781e-09, No Iterations 25
DICPCG: Solving for p, Initial residual = 0.95568243, Final residual = 7.9266324e-07, No Iterations 33
time step continuity errors : sum local = 6.3955627e-06, global = 1.3227253e-17, cumulative = 1.4125109e-17
ExecutionTime = 0.04 s ClockTime = 0 s
Time = 2.5
Time = 50
/*
// This is a line comment This is a block comment
*/
• As in C++, you can use the #include directive in your dictionaries (do not forget to create the respective include file):
#include “ n t C nd t n ”
U Sub-dictionary U
{
solver PBiCGStab;
preconditioner DILU;
tolerance 1e-06;
relTol 0;
}
…
…
…
}
A deeper view to my first OpenFOAM® case setup
Dictionary files general features
• Macro expansion.
• We first declare a variable (x = 10) and then we use it through the $ macro substitution ($x).
type fixedValue;
value uniform $scalarField; //Use declared variable
• You can use macro expansion to duplicate and access variables in dictionaries
“( eft|r ght|t )W ”
{
type fixedValue;
value uniform (0 0 0);
}
“.*W ”
{
type fixedValue;
value uniform (0 0 0);
}
• Inline calculations.
• You can use the directive #calc to do inline calculations, the syntax is as follows:
X = 10.0; //Declare variable
Y = 3.0; //Declare variable
• With inline calculations you can access all the mathematical functions available in C++.
• Macro expansions and inline calculations are very useful to parametrize dictionaries and avoid repetitive tasks.
• Switches: they are used to enable or disable a function or a feature in the dictionaries.
• Switches are logical values. You can use the following values:
Switches
false true
off on
no yes
n y
f t
none true
• You can find all the valid switches in the following file:
OpenFOAM-6/src/OpenFOAM/primitives/bools/Switch/Switch.C
A deeper view to my first OpenFOAM® case setup
Solvers and utilities help
• If you need help about a solver or utility, you can use the option –help. For
instance:
will print some basic help and usage information about icoFoam
• Remember, you have the source code there so you can always
check the original source.