3
running
Mark Olesen edited this page 2021-12-17 14:33:50 +01:00

home

Once OpenFOAM has been built and installed, running it requires a properly defined environment prior to executing any applications or solvers. For a runtime environment, the absolute minimum is the following:

Enviroment Use
WM_PROJECT_DIR The installation location of OpenFOAM
PATH Must include platforms-specific OpenFOAM bin directory
LD_LIBRARY_PATH Must include platforms-specific OpenFOAM lib directory, and MPI library variants

There are various ways to setup a minimum or fuller environment. Which one you choose is largely personal preference and depends on how much flexibility or permanence is desired.

[[TOC]]

Transient (one-time) use

In many cases it is desirable to activate or use a particular OpenFOAM version without any additional setup.

bash Shell session

Depending on your packaging system (or system administrator), an OpenFOAM shell session command may be available as a convenient means of defining and using an OpenFOAM environment. For example,

# Interactive shell
$ openfoam

The shell session can be particularly useful when running a single OpenFOAM application from within a workflow. For example,

# Use an older version
$ openfoam2012 simpleFoam

Manually

To manually activate a particular OpenFOAM version, source its corresponding etc/bashrc file:

$ . /path/to/openfoam/etc/bashrc

After using the desired OpenFOAM commands, the wmUnset alias can be used to remove it again.

NOTE: The /path/to/openfoam location will depend on the OpenFOAM version and installation.

Persistent selection

openfoam-selector

Depending on your packaging system (or system administrator), an openfoam-selector may be available to define the preferred OpenFOAM version for the login shell.

Manual

For a persistent OpenFOAM environment, the OpenFOAM bashrc file can be sourced from your ~/.bashrc file by adding a line resembling the following to that file:

. /path/to/openfoam/etc/bashrc

It is usually prudent to check the existence of the file prior to sourcing it:

if [ -f /path/to/openfoam/etc/bashrc ]
then  . /path/to/openfoam/etc/bashrc
fi

NOTE: The /path/to/openfoam location will depend on the OpenFOAM version and installation.


Copyright (C) 2019-2021 OpenCFD Ltd.