Main FAQ

From OpenFOAMWiki
Revision as of 09:47, 26 July 2007 by Mattijs (Talk | contribs)

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.

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.

(Source: [1])

2 Installation and Running

Problems with the installation and running of applications

2.1 Which platforms are supported by OpenFOAM ?

As of version 1.3, binaries exist for two platforms:

  • Linux for i386-Architecture
  • Linux for AMD Opteron (probably also Intel Xeons with 64 Bit extension)

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 ?

The only feasible way to port OpenFOAM to Windows is by using Cygwin, an application that implements the most common UNIX APIs on Windows.

The problem is that the file-sytem NTFS, that is used by most modern Windows Versions, is case-insensitive (hello.c and Hello.C are the same file). The OpenFOAM-sources need a case-sensitive file-system and can't even be unpacked properly on a Windows sytem (see [2]).

A 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 (but postprocessing can be done with ParaView by using foamToVTK and an attempt to port FoamX to cygwin is underway here). This port is not part of the official distribution (yet).

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 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 [3])

  • 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 [4])

2.5 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

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.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: [5])

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 floating about it the inlet pressure is not specified. (source: [6])

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: [7])

3.4 Additional models

Has OpenFOAM been used to calculate this type of problems?

3.4.1 Eulerian two fluid model and granular flow

It has been done and will be released. See here.

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: [8])

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: [9])

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 FoamX doesn't know my new solver

Look here: Howto_adding_a_new_solver_to_foamX

5.3 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

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.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 writting 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: [10]

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 Adding new features

7.3.1 How do I add a new wall-function?

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

7.3.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)

8.3 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)