Skip to content

OpenFOAM: Introduction

March 28, 2011

OpenFOAM:

OpenFOAM (Open Field Operation and Manipulation) is primarily a C++ toolbox for the customisation and extension of numerical solvers for continuum mechanics problems, including computational fluid dynamics (CFD).

Capabilities of OpenFOAM:

It has

  • a plugin (paraFoam) for visualisation of solution data and meshes in ParaView.
  • a wide range of mesh converters allowing import from a number of leading commercial packages
  • an automatic hexahedral mesher to mesh engineering configurations

It also comes with a library and solvers for efficiently tracking particles in a multiphase flow using the lagrangian approach.

Standard Solvers include:

  • Basic CFD
  • Incompressible flows
  • Compressible flows
  • Multiphase flows
  • DNS and LES
  • Particle-tracking flows
  • Combustion
  • Heat transfer
  • Molecular dynamics
  • Direct simulation Monte Carlo
  • Electromagnetics
  • Solid dynamics
  • Finance

How to install in Ubuntu:

OpenFOAM and Paraview are currently available for the following versions of Ubuntu:

  • 10.04 LTS, codename lucid
  • 10.10, codename maverick

Installation

OpenFOAM and Paraview can be simply installed using the apt package management tool. The user will need to provide superuser password authentication when executing the following commands with sudo

  1. In a terminal window, add OpenFOAM to the list of repository locations for apt to search, by copying and pasting the following in a terminal prompt (Applications -> Accessories -> Terminal):
    VERS=`grep CODENAME /etc/lsb-release | cut -d= -f2`
    sudo sh -c “echo deb http://www.openfoam.com/download/ubuntu $VERS main >> /etc/apt/sources.list”
    • Note 1: Line 1 stores the version name of your Ubuntu distribution (e.g. maverick) under $VERS, which is used in line 2
    • Note 2: This only needs to be done once for a given system
  2. Update the apt package list to account for the new download repository location
    sudo apt-get update
  3. Install OpenFOAM (171 in the name refers to version 1.7.1):
    sudo apt-get install openfoam171
  4. Install Paraview (381 in the name refers to version 3.8.1):
    sudo apt-get install paraviewopenfoam381

OpenFOAM-1.7.1 and Paraview-3.8.1 are now installed in the /opt directory.

User Configuration

In order to use the installed OpenFOAM package, complete the following

  1. Open the .bashrc file in the user’s home directory in an editor, e.g. by typing in a terminal window (note the dot)
    gedit ~/.bashrc
  2. At the bottom of that file, add the following line 1   \relax \special {t4ht= (note the dot) and save the file
    . /opt/openfoam171/etc/bashrc
  3. This change to the .bashrc file will be
    . ~/.bashrc
  4. Open a new2   \relax \special {t4ht= terminal window and test that the icoFoam application, from the OpenFOAM package, is working by typing
    icoFoam -help
  5. A “Usage” message should appear. Your installation and user configuration is complete.

Getting Started

Create a project directory within the $HOME/OpenFOAM directory named <USER>-1.7.1 (e.g. chris-1.7.1 for user chris and OpenFOAM version 1.7.1) and create a directory named run within it, e.g. by typing:

  • mkdir -p $FOAM_RUN

Copy the tutorial examples directory in the OpenFOAM distribution to the run directory. If the OpenFOAM environment variables are set correctly, then the following command will be correct:

  • cp -r $FOAM_TUTORIALS $FOAM_RUN

Run the first example case of incompressible laminar flow in a cavity:

  • cd $FOAM_RUN/tutorials/incompressible/icoFoam/cavity
  • blockMesh
  • icoFoam
  • paraFoam

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: