Main FAQ

From OpenFOAMWiki

This page is now being replaced by the pages structured FAQ and the long version of the FAQ. Don't edit it!

Well, my head's full of questions
My temp'rature's risin' fast
Bob Dylan (Mixed Up Confusion)

Questions that have been asked more than once.

The structure of this page is still evolving. Once enough questions are inserted it will be clear which structure is the best.


1 General

Questions concerning the history of OpenFOAM, the license etc

1.1 What is OpenFOAM?

OpenFOAM is an open source library designed for development of parallel or serial multi-dimensional modeling codes. OpenFOAM includes numerous C++ classes for finite volume, finite element, and Lagrangian particle tracking. OpenFOAM also comes with numerous computational fluid dynamics, combustion, and heat transfer programs that demonstrate the capabilities and usage of OpenFOAM. These solvers are useful for a wide range of scientific and engineering applications and can be customized as needed. Read more...

1.2 Can I use OpenFOAM?

Yes. OpenFOAM has been released by OpenCFD under the terms of the GNU GPL 2 license.

According to this licence, you can freely download, install and use OpenFOAM. Moreover, you have full access to the source code of OpenFOAM and you can modify it to customize it on your needs.

1.3 How can I properly reference OpenFOAM?

You can cite the website, if web-referencing is allowed, otherwise, cite the OpenFOAM documentation.

1.4 Where can I find support or ask questions about openFOAM?

OpenFOAM is developed by OpenCFD, which also offer support packages for corporations, consultants and academic institutions.

You can ask questions on the OpenFOAM message board.

There also is an IRC channel at [ freenode]. The configuration parameters are:

  • Server:
  • Channel: #openFOAM-IRC

For a direct access to the IRC channel click here, if you have a browser configured to start your IRC client.

1.5 How do the OpenFOAM versions differ?

OpenFOAM 2.0.0 is the current stable release and the only version to be released as binary. This should be the version of choice for most users. 2.0.x is the official development branch and thus contains the newest bug-fixes and features, but comes at the price of being less tested.

OpenFOAM-1.6-ext is a project unrelated to OpenCFD to incorporate new features developed by the community. Bug fixes from 1.7.x are merged into 1.6-ext with some delay. If you are missing a feature in the official branch, this is a good place to look if someone else developed it (also see Main_OFextendFeatures).

2 Installation and Running

Problems with the installation and running of applications

2.1 Which platforms are supported by OpenFOAM ?

Ports to other operating systems that have been discussed on the message board are

2.2 Why isn't there a Windows port of OpenFOAM ?

Actually, nowadays, there are a few ports for Windows. The only feasible way in the past, was to port OpenFOAM to Windows using Cygwin, an application that implements the most common UNIX APIs on Windows. Now MinGW is the more popular porting solution, because while it still integrades parts of Cygwin (MinGW forked from version 1.3.3 of Cygwin [1]), it can run natively in Windows and be linked with other native Windows libraries and applications.

One problem is that the file-system NTFS, that is used by most modern Windows Versions, is (by default) only case-preserving (hello.c and Hello.C are the same file, when in the same folder). The OpenFOAM-sources need a fully case-sensitive file-system and can't even be unpacked properly on a Windows system (see [2]). There is a possibility of enabling full case-sensitivity in Windows [3], but can lead to some Windows programs to not work properly.

2.2.1 (Cross-)Compiling with Cygwin

A (relatively old) way to compile OpenFOAM on cygwin is described on the Message-Board. The resultant binary distribution of version 1.3 is available here (and there is a relating discussion thread on the Message-Board). This port does not include FoamX and paraFoam, although postprocessing can be done with ParaView by using foamToVTK, and FoamX exists for OpenFOAM 1.4.x. This port is not part of the official distribution.

Another unofficial port of OpenFOAM 1.4.x is available here, with FoamX and ParaView. Support is available here and here.

FreeFOAM should prove to be more successful, but it's still in development, and uses CMake instead of wmake.

Cygwin 1.5 introduced a mount type named managed mounts, that can handle fully case sensitive files and folders, and some special characters that Linux can use and Windows can't [4]. In theory, if OpenFOAM is built under this interpretation layer, than it should be compilable directly in Windows. After some testing, it was discovered that OpenFOAM has some very long path names, which aren't handled properly by Cygwin's managed mounts, due to path size limit [5].

With Cygwin 1.7, managed mounts were dropped and POSIX mounts were introduced [6], as well as file paths increased to 4096 characters [7]. The POSIX mount relies on a hidden feature of Windows [8], that enables NTFS POSIX compatibility system, also used by Interix's SFU/SUA [9], thus enabling full case sensitivity. In other words, as of Cygwin 1.7, it is possible to compile and cross-compile OpenFOAM directly in Windows, without major reconstruction of the files and structure of the source code. Nonetheless, the whole build system has to be done under Cygwin's layer, because the flag obcaseinsensitive doesn't actually make all of Windows applications aware of full file name case sensitivity. For more information, see Using Cygwin for cross-compiling OpenFOAM.

2.2.2 (Cross-)Compiling with MinGW

There are already a few variants of cross-compiling with MinGW and one port that compiles directly in Windows with MinGW and CodeBlocks. The complete list is available here in the wiki. This link is part of a full step-by-step tutorial on how to Cross Compile OpenFOAM in Linux for Windows with MinGW and Mingw-w64.

2.3 How do I port OpenFOAM to an unsupported platform ?

If your platform is not some kind of UNIX-flavour you're probably going to have a hard time.

For a starter see Porting to a new platform.

2.4 Why is OpenFOAM built and installed in my home directory ?

Building and installing and running OpenFOAM in your home directory gives you some advantages. It is common practice to share the home directories across all machines machines on a network. In this setup all computers will have access to and run the same binaries compiled by the same compiler to help ensure consistent results. It also makes sharing data for cluster work easier. Also to really leverage the power of OpenFOAM you will want to write code to link to and extend it. If it was installed in a common directory individual users programs could clash via naming conflicts etc...

Unfortunately this is not a winning situation for everybody. If you build and install OpenFOAM in your home directory you can't use it on heterogeneous machines on a network, i.e. a z80 based machine cannot run OpenFOAM compiled for a 6502 based machine, unless it has emulation software in which case it would be slow. Fear not because it is possible to configure OpenFOAM to compile and install in a common directory on each machine to accommodate heterogeneous machines on a network.

3 Physical

Questions about the physics implemented (boundary conditions and similar)

3.1 General

3.1.1 What is the meaning of the Field X

A table of the fields most commonly written by OpenFOAM-solvers can be found here.

3.1.2 Where do I enter the fluid-density for icoFoam, turbFoam and other incompressible solvers?

You don't. Instead of the dynamic viscosity \eta the kinematic viscosity \nu=\frac{\eta}{\rho} is used by the OpenFOAM-solvers.

Note: the pressure has to be normalized with the density, too. One consequence of this is that the dimensions of pressure become pressure divided by density.

3.1.3 What is the field phi that the solver is writing

The mass flow through the cell faces (\rho \vec u \cdot \vec A with \vec A the area of the face). See also this table

3.2 Boundary Conditions

3.2.1 What's the difference between the symmetryPlane and the zeroGradient boundary conditions?

The zeroGradient boundary condition sets the boundary value to the near-wall cell value.

A symmetryPlane boundary condition is a symmetry-plane which is equivalent to a zeroGradient for scalars, but not for vectors or tensors.

(Source: [10])

3.2.2 What does the lInf parameter mean in pressureTransmissive boundary condition?

lInf is the relaxation length-scale (in m) for outgoing pressure waves to return to pInf. This stops the pressure in the domain from floating about if the inlet pressure is not specified. (source: [11])

3.3 Turbulence modeling

3.3.1 How is wall-functions for RANS disabled and enabled?

All high-Re RANS turbulence models include wall-functions because it is inappropriate to use them without. Only the low-Re models operate without wall-functions as they include model-specific wall treatments.

(Source: [12])

3.4 Additional models

Has OpenFOAM been used to calculate this type of problems?

3.4.1 Eulerian two fluid model and granular flow

They are implemented in twoPhaseEulerFoam.

3.4.2 Viscoelastic flows?

Have been done. Will be released. For details see this thread on the Message Board.

4 Solution procedure

Manipulating the solution procedure by non-programming means

4.1 How does one turn off the dimensional checking?

Dimensional checking is one of the cool features in OpenFOAM that helps to develop solvers that do something physicaly meaningfull. Therefore: don't do this if not absolutely necessary.

To switch it off at run-time set

dimensionSet 0;

in OpenFOAM-1.1/.OpenFOAM-1.1/controlDict.

A more controlled way is to use the dimensions()-method to set the dimension of the volXXXField in question to the desired dimension.

(source: [13])

4.2 Is there a way to switch between single and double precision?

For Version 1.2 and older: Only by editing src/OpenFOAM/primitives/scalar/scalar.H and recompiling OpenFOAM. But why would you want to do that (except for memory issues)? (source: [14])

For Version 1.3: Recompile OpenFOAM with single-precision enabled (for details see Howto_compile_OpenFOAM)

5 Preprocessing

Preparing the simulations

5.1 How to quickly change the mesh with blockMesh

A description how to achieve this with m4 can be found here: How to quickly change the mesh with blockMesh

5.2 How do I set up a two-dimensional axisymmetric problem?

You use a contributed utility called makeAxialMesh.

6 Postprocessing

Working with the results

6.1 Postprocessing of Lagrangian particles

6.1.1 Using foamToVTK

This is not yet possible to direcly post-process Lagrangian particles (including droplets) with paraFoam, according to this thread. However, you can work around this limitation by using foamToVTK and Paraview's existing ability to handle point data.

Follow these steps:
  1. Run the foamToVTK post-processing utility. As with all OpenFOAM programs, it requires at a minimum, the root and case paths.
  2. Read in your Eulerian data, if you wish
  3. Read the Lagrangian data separately and 'Glyph' it. Glyphs are how Paraview represents point data. Usually, the sphere glyph is the most appropriate.

The glyphs used to represent particles can be colored and sized to reflect the data associated with the particle. If you cannot see your particles, check that indeed you have represented them as glyphs and that the size scaling you have chosen is adequately large.

6.1.2 Using paraFoam

First you execute paraFoam as usual but you select only in the data to be load the fields and the mesh of the continuous phase.

Then you click on the Open button (or File -> Open in the menu). You select the case.OpenFOAM file created by paraFoam. So you can load again the data of the case. But this time, you select

  1. in Mesh Parts the lagrangian clouds (be sure that only lagrangian geometries are selected),
  2. in Volume Fields unselect everything
  3. in Lagragian Fields select the fields you are interested in.

Then click on the Apply button.

To visualize the particle, use the Glyph filter (cf. end of previous paragraph).

Remark : Test with OpenFOAM-1.6 and ParaView 3.6.1

6.2 Postprocessing of simulations on multiple mesh-regions

Two possibilites to do this are described on How To Postprocess Multiple Regions

7 Programming

Questions about writing applications and solvers

7.1 Compiling

7.1.1 Where does wmake get the values for the environmental variables from?

All wmake variables come from (in this order)

  1. $WM_DIR/rules/General/general
  2. $WM_DIR/rules/${WM_ARCH}${WM_COMPILER}/general
  3. $WM_DIR/rules/${WM_ARCH}/c++

(Source: [15])

For a complete list of foam related environment variables, see Environment_variables.

7.2 Working with fields

7.2.1 How to calculate the field value of an arbitrary point?

See Calculating the field value at an arbitrary point.

7.3 OpenFOAM's template library

7.3.1 What is the object registry?

See objectRegistry explained.

7.3.2 What do the filenames mean?

OpenFOAM's file naming convention. For exampleClass, these filenames may exist:

  • exampleClass.H - Main header.
  • exampleClass.C - Main body.
  • exampleClassFwd.H - Forward declarations.
  • exampleClassI.H - Inline functions implemented.
  • exampleClassIO.C - IO functions implemented.
  • exampleClassM.H - Macros.
  • exampleClassFunctionName.C - FunctionName's implementation (seperated for no other reason than aesthetics).

There may be others as well. Unknown naming conventions:

  • exampleClasss.H
  • exampleClasss.C

Some filenames add an s to the end. These may be associated with static variables / functions. They may also be associated with the NoRepository flag.

7.3.3 What is tmp<>?

See tmp explained.

7.3.4 What is runtime selection?

See Runtime selection mechanism.

7.4 Adding new features

7.4.1 How do I add a new wall-function?

See the How-To: Adding a new wall-function.

7.4.2 How do I add a new boundary condition?

See the How-To: Adding a new boundary condition.

8 Troubleshooting

8.1 An application ends with a segmentation fault. What is wrong?

A segmentation fault usually occurs when a program trys to access memory outside its bounds (see Segmentation Fault on Wikipedia). In OpenFOAM this usually occurs when a List<> or similar is accessed with an index outside of the allocated domain. To find out where this occurs make a separate copy of the OF-sources, recompile them with the swich WM_COMPILE_OPTION set to Debug (just uncomment the right lines in the bashrc/cshrc files). This makes OF run slower, but accesses to List<> etc are checked for ranges and the program aborts if you access outside of a range (plus you get a stack trace). This won't solve your problem, but it will help you find out where it occurs.

See also General debugging tips. For recompiling OpenFOAM look at Howto_compile_OpenFOAM

8.2 My program stops with an output that starts with #0 Foam::error::printStack(Foam::Ostream&)

You encountered a program error. Upon hitting that error OpenFOAM produced a stack trace (a list of the functions that were called) which is very useful to find the location at which the problem occured. It is possible to get that stack-trace with the source files and the line numbers of the functions which might help to find out what the problem is. To do so you have to compile a debug version of OpenFOAM. (see also the segmentation fault-question above)

9 Specific solvers/utilities

9.1 The porous-solvers

9.1.1 Where do I find rhoPorousSimpleFoam etc ?

These solvers are found in $FOAM_TUTORIALS along with their example cases. You have to compile them yourself before using them

10 Outdated

10.1 FoamX doesn't know my new solver

Look here: Howto_adding_a_new_solver_to_foamX

10.2 FoamX is unable to contact name server

These problems are almost always one of the following:

  1. the hostname is not set ('localhost' is not acceptable to Corba)
  2. the hostname is not (or twice) in /etc/hosts
  3. only the truncated name is present in /etc/hosts
  4. some port opening problem due to security
  5. libelf is missing
  6. libXp is missing
  7. SELinux is conflicting
  8. nscd (the name service caching daemon) is not running

(see the Message Board for issues on hostname, libelf, libXp, SELinux and nscd, and for general discussion on FoamX problems)

10.3 Why doesn't FoamX allow me to enter numbers?

FoamX is set up to run on a system where the default language is English. If you want to run it on a system which uses another language, you have to manually modify the ~/OpenFOAM/OpenFOAM-1.3/bin/FoamX script.

  • For Linux and other UNIX-like systems, add the line:
export LANG=en_EN

at the beginning of the FoamX script, and the line:


at the end of the same file, replacing your_LANGUAGE_CODE with the corresponding code of the language in use in your system (for example, it_IT for italian).

(Source [16])

  • For a Cygwin/Windows system, add the line
    -Duser.language=en \

in the last part of the FoamX script so that it looks like as follows.

"$jdkhome/bin/java" \
    -cp "$jars" \
    -DFoamX.SystemPath="$WM_PROJECT_DIR" \
    -DFoamX.SystemConfigPath="$FOAMX_CONFIG" \
    -DFoamX.UserConfigPath="$FOAMX_CONFIG" \
    -Duser.language=en \
    FoamX.App $orbArgs $args

(Source [17])

10.4 How can I make a solver stop if the solution contains NaNs ?

Usually OpenFOAM keeps calculating even if the solution contains NaNs (Not a number) and therefore is of no use. To avoid this set the environment variable FOAM_SIGFPE to a non-zero value. In tcsh:

setenv FOAM_SIGFPE 1 

or in bash:

export FOAM_SIGFPE=1