|
|
<!-- --- title: Running OpenFOAM -->
|
|
|
|
|
|
[![home](/icons/home.svg "wiki home")](/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_ a particular OpenFOAM
|
|
|
version, do something with it and possibly restore to the previous
|
|
|
state without exiting the shell.
|
|
|
|
|
|
### 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.
|
|
|
|
|
|
|
|
|
### ![bash](/icons/gnubash.svg "bash") [Shell session](/running/shell-session)
|
|
|
|
|
|
Depending on your packaging system (or system administrator), an
|
|
|
[OpenFOAM shell session](/running/shell-session) command may be
|
|
|
available as a convenient means of defining and using an OpenFOAM
|
|
|
environment.
|
|
|
|
|
|
The shell session can be particularly useful when running a single
|
|
|
OpenFOAM application from within a workflow.
|
|
|
|
|
|
|
|
|
## Persistent selection
|
|
|
|
|
|
### 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.
|
|
|
|
|
|
|
|
|
### Configured via [openfoam-selector](/running/openfoam-selector)
|
|
|
|
|
|
Depending on your packaging system (or system administrator), an
|
|
|
[openfoam-selector](/running/openfoam-selector) may be available
|
|
|
to define the preferred OpenFOAM version for the ***login*** shell. |