|
|
<!-- --- title: Shell session -->
|
|
|
|
|
|
[![home](/icons/home.svg "wiki home")](/home)
|
|
|
[![running](/icons/play.svg "running")](/running)
|
|
|
|
|
|
[[_TOC_]]
|
|
|
|
|
|
![bash](/icons/gnubash.svg "bash")
|
|
|
|
|
|
## Introduction
|
|
|
|
|
|
Depending on your packaging system (or system administrator),
|
|
|
various openfoam shell sessions may be available. For example,
|
|
|
```
|
|
|
/usr/bin/openfoam -> openfoam2006
|
|
|
/usr/bin/openfoam1912
|
|
|
/usr/bin/openfoam2006
|
|
|
```
|
|
|
They provide the simplest means of starting OpenFOAM immediately and
|
|
|
can be used for an _interactive_ bash session, or to run a single
|
|
|
OpenFOAM command within the OpenFOAM environment.
|
|
|
|
|
|
Using the `-help` option for the respective shell session
|
|
|
(eg, `openfoam2006 -help`) displays some useful information.
|
|
|
|
|
|
|
|
|
## Purpose
|
|
|
|
|
|
The purpose of the OpenFOAM shell session is simply convenience.
|
|
|
|
|
|
- quickly set and use an interactive environment for OpenFOAM
|
|
|
- use a single OpenFOAM application without preliminary setup of an
|
|
|
OpenFOAM environment.
|
|
|
- use OpenFOAM applications from a parallel installation with a
|
|
|
different precision.
|
|
|
- entrypoint for container scripts
|
|
|
|
|
|
|
|
|
## Interactive
|
|
|
|
|
|
Calling an OpenFOAM shell session without any arguments opens an
|
|
|
interactive _bash_ session with the respective OpenFOAM environment
|
|
|
and sources your usual `~/.bashrc` environment, to ensure that other
|
|
|
paths and aliases are as expected.
|
|
|
|
|
|
For example,
|
|
|
```
|
|
|
$ openfoam
|
|
|
|
|
|
Using: OpenFOAM-1912 - see www.openfoam.com
|
|
|
Arch: linux64GccDPInt32Opt (mpi=openmpi-system)
|
|
|
OpenFOAM shell session - use exit to quit
|
|
|
|
|
|
OpenFOAM-1912:~/
|
|
|
mark$
|
|
|
```
|
|
|
|
|
|
***NOTE***
|
|
|
Although the OpenFOAM environment is sourced _after_ your home
|
|
|
`~/.bashrc`, it is advisable to ensure that there are no circular
|
|
|
references from within your `~/.bashrc` file.
|
|
|
|
|
|
|
|
|
## Non-interactive
|
|
|
|
|
|
If an OpenFOAM shell session is called with arguments, it will setup
|
|
|
an OpenFOAM environment before executing a single command. For
|
|
|
example,
|
|
|
```
|
|
|
$ blockMesh -help
|
|
|
blockMesh: Command not found.
|
|
|
|
|
|
$ openfoam blockMesh -help
|
|
|
|
|
|
Usage: blockMesh [OPTIONS]
|
|
|
Options:
|
|
|
...
|
|
|
|
|
|
```
|
|
|
|
|
|
It is also possible to execute arbitrary shell sequences with the
|
|
|
well-known `-c` option. For example,
|
|
|
|
|
|
```
|
|
|
$ openfoam2006 -c 'echo "openfoam=$WM_PROJECT_DIR uses $WM_OPTIONS"'
|
|
|
```
|
|
|
yields: `openfoam=/usr/lib/openfoam/openfoam2006 uses linux64GccDPInt32Opt`
|
|
|
|
|
|
|
|
|
## NOTES
|
|
|
|
|
|
- OpenFOAM shell sessions are included as part of Debian and RPM packages.
|
|
|
|
|
|
- ***Never*** attempt to embed the shell session wrapper as part of
|
|
|
your `~/.bashrc` - this may cause an infinite loop! |