Relocate cross-compilation (mingw) from code repo

- a wiki location seems to be more reasonable

Separate page for "running"

- collect information for shell session and openfoam-selector, which
  was previously scatttered in various places

Rename "page-build-code" to "building", with symlink for old location

Misc style changes
Mark Olesen
2020-07-28 15:01:59 +02:00
parent f21694b23d
commit d927e0297a
17 changed files with 613 additions and 368 deletions

160
building.md Normal file

@ -0,0 +1,160 @@
<!-- --- title: Building from source -->
[![home](/icons/home.svg "wiki home")](/home)
[![packages](/icons/package.svg "packages")](/precompiled)
[[_TOC_]]
## ![linux](/icons/linux.svg "linux") Linux, Unix-like systems
|Version | Build |
|--------|--------|
|v2006 | [Build][latest-build] |
|v1912 | [Build][v1912-build] |
|v1906 | [Build][v1906-build] |
|older | _obsolete_ |
## Packaging systems
<a name="packaging"></a>
|System | Links | Status | Notes |
|---------------|--------------|----------------|---------------|
| [spack](https://spack.readthedocs.io/) | package [openfoam](https://github.com/spack/spack/tree/develop/var/spack/repos/builtin/packages/openfoam/) | Actively maintained by OpenCFD | [notes](#spack) |
| [EasyBuild](https://easybuild.readthedocs.io/) | package [OpenFOAM](https://github.com/easybuilders/easybuild-easyconfigs/tree/master/easybuild/easyconfigs/o/OpenFOAM) | Maintained independently, with input from OpenCFD | |
| debian, RPM | _See [precompiled](/precompiled)_ | Actively maintained by OpenCFD | |
### spack
<a name="spack"></a>
The installation of openfoam with spack will generally require the
latest (development version) of spack. If this is available, you can
install openfoam in various configurations and dependencies, but
typically can simply install directly:
```
$ spack install openfoam
```
## ![darwin](/icons/apple.svg "darwin") Darwin (Mac-OS)
The support for Darwin is complete, but less well tested than Linux.
- The Darwin build (and operation) requires a **case-sensitive file system**,
which is often created as a disk image and mounted (for older systems).
- Compilation uses the system clang compiler.
### Known issues
CGAL
- ThirdParty CGAL will normally need to be compiled _without_ mpfr/gmp.
This should be done manually prior to building OpenFOAM or other
ThirdParty. Eg,
```
cd $WM_THIRD_PARTY_DIR
./makeCGAL gmp-none mpfr-none
```
The `wmake/rules/darwin64Clang/CGAL` file has been adjusted to
eliminate references to gmp/mpfr libraries.
## ![microsoft](/icons/microsoft.svg "microsoft") Windows (cross-compiled)
Windows 64bit binaries can be generated on 64bit Linux by
***[cross-compilation](/building/cross-compile-mingw)***.
## ![tuning](/icons/settings.svg "tuning") Tuning
### Different compiler versions
<a name="different-compiler-versions"></a>
By default, OpenFOAM handles newer/older non-system compilers as
_ThirdParty_ installations and uses the combination of `WM_COMPILER`
and `WM_COMPILER_TYPE` to select them. In some cases, however, it can
be much more convenient for the user to install prebuilt compiler
binaries as *system* compilers (eg, using deb or rpm packages).
This poses a slight problem since the OpenFOAM build rules normally
use the main compiler name (`gcc`, `clang` etc) without any additional
version information, but the various *system* compilers are frequently
installed with versioned names such as `gcc-8`, `clang-10` etc.
Here is a simple way to solve this, using clang-10 on openSUSE for the
example:
1. Install the desired system compiler.
In this case [clang-10 from tools:compiler][llvm10-opensuse] which
installs `/usr/bin/clang-10` and `/usr/bin/clang++-10`.
2. Next override the OpenFOAM compiler calls, but without blindly
rewriting everything.
We create a new directory for our special rules:
```
mkdir wmake/rules/linux64Clang100
```
Inside this directory, we add an general rules file
(`wmake/rules/linux64Clang100/general`) with the following contents:
```
# Override compiler calls for llvm-10
cc = clang-10
CC = clang++-10 -std=c++11
```
Or if this shall be restricted to system compilers only:
```
# Override system compiler calls for llvm-10
ifeq (system,$(WM_COMPILER_TYPE))
cc = clang-10
CC = clang++-10 -std=c++11
endif
```
3. The final step is to select this compiler definition with the following
combination:
```
# Preferences for system Clang100
export WM_COMPILER=Clang100
export WM_COMPILER_TYPE=system
```
If this change represents your standard default compiler definition,
then place the information into the `etc/prefs.sh` file (see the
`etc/bashrc` file for some details) and re-source your OpenFOAM
environment.
If you would like to selectively enable this compiler definition, a
common means is to place the same definition information into a user
configuration file (for example, `~/.OpenFOAM/clang100`) and then
specify that configuration when sourcing your OpenFOAM environment.
For example,
```
source /path/to/OpenFOAM-version/etc/bashrc clang100
```
The `bashrc` will locate and use the configuration file, after which the
compiler will be properly selected. To verify that this is indeed the
case:
```
wmake -show-cxx
```
should display the selected compiler.
You may also wish to verify its path:
```
wmake -show-path-cxx
```
For older versions, `which $(wmake -show-cxx)` instead.
--------
[latest-build]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Build.md
[v2006-build]: https://develop.openfoam.com/Development/openfoam/blob/maintenance-v2006/doc/Build.md
[v1912-build]: https://develop.openfoam.com/Development/openfoam/blob/maintenance-v1912/doc/Build.md
[v1906-build]: https://develop.openfoam.com/Development/openfoam/blob/maintenance-v1906/doc/Build.md
[v1906-notes]: https://www.openfoam.com/releases/openfoam-v1906/
[llvm10-opensuse]: https://software.opensuse.org//download.html?project=devel%3Atools%3Acompiler&package=llvm10

@ -0,0 +1,156 @@
<!-- --- title: Cross-Compiling with mingw -->
[![home](/icons/home.svg "wiki home")](/home)
[![build](/icons/cpu.svg "build")](/building)
[![packages](/icons/package.svg "packages")](/precompiled)
[[_TOC_]]
![windows](/icons/microsoft.svg "windows")
Windows 64bit binaries can be generated on 64bit Linux using
the [mingw](http://mingw.org/) compiler for _cross-compilation_.
## Minimum version
The mingw cross-compiler should be at least version 8.2.0 (tested) or
slightly older. Versions that are much older may have faulty regex
implementations.
## Host setup
### For openSUSE
On openSUSE use the packages for compilation:
```
zypper in mingw64-cross-binutils
zypper in mingw64-cross-cpp mingw64-cross-gcc mingw64-cross-gcc-c++
zypper in mingw64-filesystem mingw64-headers mingw64-runtime
zypper in mingw64-libwinpthread1 mingw64-winpthreads-devel
zypper in mingw64-libfftw3 mingw64-fftw3-devel
zypper in mingw64-libz mingw64-zlib-devel
```
### For CentOS/RedHat
For CentOS/RedHat, the cross-compiler is available under `PowerTools`:
```
dnf config-manager --set-enabled PowerTools
```
The package names to install are _somwhat_ different from the openSUSE
ones:
```
dnf install mingw64-gcc-c++
dnf install mingw64-winpthreads mingw64-zlib
```
Notably, many of the development packages are simply rolled into the
runtime ones. There does not seem to be an FFTW package readily
available.
### General
If there are issues with zlib, it is possible to download it manually
and compile as a _static_ library.
```
CC="$(wmake -show-c)" CFLAGS="$(wmake -show-cflags)" ./configure --static
make
```
The resulting output files (zconf.h, zlib.h) and (libz.a) either need
to be installed in system locations where OpenFOAM can find them, or if
they are to be shipped directly with OpenFOAM, they can also be placed
in the `src/OpenFOAM/include` and `platforms/XXX/lib` paths.
If the header files are only needed during compilation, it can be a
fairly convenient hack to simply place copies of them in the
`src/OSspecific/MSwindows` directory.
Flex is used in a few locations within OpenFOAM for generating code.
The generated C++ code requires the `FlexLexer.h` header file, but
its `/usr/include` location will be ignored by the cross-compiler.
As another ugly hack, a copy of this file can be made in a standard
project include location. For example,
```
ln -s /usr/include/FlexLexer.h src/OSspecific/MSwindows
```
The last point to consider when cross-compiling is the behaviour of
the OpenFOAM wmake toolchain used during compilation. These are found
under `wmake/src`. If the `Makefile` is used directly, executables
will be created that work on the target platform (Windows), but *not*
on the host platform (which is what is required). This is addressed
directly by the `wmake/src/Allmake` script, which will use the system
gcc to create host binaries for the wmake toolchain. If, for some
reason, you also require target wmake toolchain binaries, you will
need to invoke `make` manually within the `wmake/src` directory.
The settings for cross-compilation are normally defined in the
`etc/prefs.sh` file with contents like this:
```
# For mingw cross-compile
export WM_COMPILER=Mingw
export WM_MPLIB=MSMPI
export WM_LABEL_SIZE=32
# other settings...
```
Additional adjustments may be required in some other places. For example
in `etc/config.sh/FFTW`
```
fftw_version=fftw-system
export FFTW_ARCH_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw
```
## Run-time setup
When running, the `WM_PROJECT_DIR` environment must be set.
OpenFOAM will otherwise not be able to locate its files.
If running with MSYS2, make certain to set the following environmental
control (preferrably for all users):
```
MSYS2_PATH_TYPE inherit
```
For the cross-compiled executables and libraries to work, the
corresponding runtime libraries are required.
These will need to be copied across from the Linux host system to the
target machine.
On openSUSE these runtime libraries are provided by the packages:
```
mingw64-libgcc_s_seh1
mingw64-libstdc++6
mingw64-libz
mingw64-libwinpthread1
```
Both for CentOS/RedHat and for openSUSE, this roughly corresponds to
the entire directory contents:
- `/usr/x86_64-w64-mingw32/sys-root/mingw/bin/*.dll`
## Known limitations (2020-06-16)
- kahip does not build
- ptscotch does not build
- boost should build ok, but no CGAL support (ie, no foamyHexMesh)
- no ParaView plugin, runTimePostProcessing
- reacting EulerFoam solvers have too many interdependencies and do
not yet compile cleanly.
It is advisable to compile with the wmake `-k` option to keep going
even when the EulerFoam solvers fail to compile.
--------
[v1906-notes]: https://www.openfoam.com/releases/openfoam-v1906/

@ -450,7 +450,7 @@ $ foamDictionary -debug-switch fieldExpr=4 -expand mydict
----
[sourceforge]: https://sourceforge.net/projects/openfoam/files/
[compiler-versions]: /page-build-code#different-compiler-versions
[compiler-versions]: /building#different-compiler-versions
[expressions]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Expressions.md

21
home.md

@ -1,24 +1,25 @@
<!-- --- title: OpenFOAM -->
<!-- --- title: OpenFOAM wiki -->
## About [![OpenFOAM](/icons/nabla.png "OpenFOAM")](http://www.openfoam.com)
## [![OpenFOAM](/icons/nabla.png "OpenFOAM")](http://www.openfoam.com) About
This wiki provides information to users about
[accessing](/page-access-code),
[building](/page-build-code),
[building](/building),
[upgrading](/guides/upgrade/upgrade)
to the latest version of [OpenFOAM](http://www.openfoam.com).
| Information | Comments |
|---------------------|---------------------|
| [![readme](/icons/columns.svg "readme")][foam-readme] [**Readme**][foam-readme] | Further cross-links in the OpenFOAM repository to _system requirements_ etc. |
| [![repo](/icons/gitlab.svg "repositories")](/page-access-code) [**Access**](/page-access-code) the code | Locations and descriptions of branch names |
| [![build](/icons/cpu.svg "build")](/page-build-code) [**Build**](/page-build-code) from source | Information about building and links to build or packaging systems |
| [![readme](/icons/book-open.svg "readme")][foam-readme] [**Readme**][foam-readme] | Further cross-links in the OpenFOAM repository to _system requirements_ etc. |
| [![repo](/icons/gitlab.svg "repositories")](/page-access-code) [**Access**](/page-access-code) the code | Locations and descriptions of repository branch names |
| [![build](/icons/cpu.svg "build")](/building) [**Build**](/building) from source | Information about building and links to build or packaging systems |
| [![upgrade](/icons/chevrons-up.svg "upgrade guide")][upgrade-guide] [**Upgrade**][upgrade-guide] guides | User and developer information for upgrading cases and code to more recent releases |
| [![run](/icons/play.svg "run")](/running) [**Run**](/running) OpenFOAM | Using the OpenFOAM environment |
| [![download](/icons/download.svg "download")][download-source] [**Download**][download-source] source packs | Download shortcuts: https://dl.openfoam.com/source/ |
## Repositories [![repo](/icons/gitlab.svg "repositories")][all-repos]
## [![repo](/icons/gitlab.svg "repositories")][all-repos] Repositories
The [develop.openfoam.com site][all-repos] hosts the ***publicly
accessible*** repositories:
@ -30,7 +31,7 @@ accessible*** repositories:
| Additional [modules][all-modules] | _individual_ |
## Linux binaries [![packages](/icons/package.svg "packages")](/precompiled)
## [![packages](/icons/package.svg "packages")](/precompiled) Linux binaries
[***Pre-compiled binary packages***](/precompiled) may be available for
select Linux systems:
@ -42,7 +43,7 @@ select Linux systems:
| [CentOS/RedHat/Fedora](/precompiled/redhat) |
## Coding ![code](/icons/code.svg "code")
## [![coding](/icons/code.svg "code")](#coding) Coding
| | Comments |
|---------------|---------------|
@ -51,7 +52,7 @@ select Linux systems:
| [![code style](/icons/italic.svg "code style")][code-style] [Coding Style][code-style] | coding style in OpenFOAM |
## Feedback ![feedback](/icons/message-square.svg "feedback")
## [![Feedback](/icons/message-square.svg "")](#feedback) Feedback
Users can provide feedback by [_submitting issues_](/Submitting-issues)
or by [_feature requests_](/page-feature-requests).

3
icons/apple.svg Normal file

@ -0,0 +1,3 @@
<svg role="img"
width="48" height="48"
viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Apple icon</title><path d="M7.078 23.55c-.473-.316-.893-.703-1.244-1.15-.383-.463-.738-.95-1.064-1.454-.766-1.12-1.365-2.345-1.78-3.636-.5-1.502-.743-2.94-.743-4.347 0-1.57.34-2.94 1.002-4.09.49-.9 1.22-1.653 2.1-2.182.85-.53 1.84-.82 2.84-.84.35 0 .73.05 1.13.15.29.08.64.21 1.07.37.55.21.85.34.95.37.32.12.59.17.8.17.16 0 .39-.05.645-.13.145-.05.42-.14.81-.31.386-.14.692-.26.935-.35.37-.11.728-.21 1.05-.26.39-.06.777-.08 1.148-.05.71.05 1.36.2 1.94.42 1.02.41 1.843 1.05 2.457 1.96-.26.16-.5.346-.725.55-.487.43-.9.94-1.23 1.505-.43.77-.65 1.64-.644 2.52.015 1.083.29 2.035.84 2.86.387.6.904 1.114 1.534 1.536.31.21.582.355.84.45-.12.375-.252.74-.405 1.1-.347.807-.76 1.58-1.25 2.31-.432.63-.772 1.1-1.03 1.41-.402.48-.79.84-1.18 1.097-.43.285-.935.436-1.452.436-.35.015-.7-.03-1.034-.127-.29-.095-.576-.202-.856-.323-.293-.134-.596-.248-.905-.34-.38-.1-.77-.148-1.164-.147-.4 0-.79.05-1.16.145-.31.088-.61.196-.907.325-.42.175-.695.29-.855.34-.324.096-.656.154-.99.175-.52 0-1.004-.15-1.486-.45zm6.854-18.46c-.68.34-1.326.484-1.973.436-.1-.646 0-1.31.27-2.037.24-.62.56-1.18 1-1.68.46-.52 1.01-.95 1.63-1.26.66-.34 1.29-.52 1.89-.55.08.68 0 1.35-.25 2.07-.228.64-.568 1.23-1 1.76-.435.52-.975.95-1.586 1.26z"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

1
icons/book-open.svg Normal file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-book-open"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"></path><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"></path></svg>

After

Width:  |  Height:  |  Size: 339 B

3
icons/gnubash.svg Normal file

@ -0,0 +1,3 @@
<svg role="img"
width="48" height="48"
viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GNU Bash icon</title><path d="M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z"/></svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

@ -1,7 +1,15 @@
https://feathericons.com - free use with/without attribution
Location: https://feathericons.com
License: free use with/without attribution
Details:
size=24px, stroke-width=2px
Potentially useful:
Location: https://github.com/simple-icons/simple-icons
License: CC0 (No Rights Reserved) - public-domain
Details:
https://github.com/simple-icons/simple-icons
edit to add:
- width="24" height="24"
- width="48" height="48"
----

3
icons/linux.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.6 KiB

3
icons/microsoft.svg Normal file

@ -0,0 +1,3 @@
<svg role="img"
width="48" height="48"
viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Microsoft icon</title><path d="M11.4 24H0V12.6h11.4V24zM24 24H12.6V12.6H24V24zM11.4 11.4H0V0h11.4v11.4zm12.6 0H12.6V0H24v11.4z"/></svg>

After

Width:  |  Height:  |  Size: 237 B

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-columns"><path d="M12 3h7a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-7m0-18H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7m0-18v18"></path></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-play"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 263 B

1
icons/settings.svg Normal file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-settings"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>

After

Width:  |  Height:  |  Size: 1011 B

@ -1,213 +0,0 @@
<!-- --- title: Building from source -->
[![home](/icons/home.svg "wiki home")](/home)
[![packages](/icons/package.svg "packages")](/precompiled)
[[_TOC_]]
## Linux, Unix-like systems
|Version | Build |
|--------|--------|
|v2006 | [Build][latest-build] |
|v1912 | [Build][v1912-build] |
|v1906 | [Build][v1906-build] |
Older versions use a general [build guide webpage](https://www.openfoam.com/code/build-guide.php),
which will be replaced by alternative content in the future.
### Packaging systems
<a name="packaging"></a>
|System | Links | Status | Notes |
|---------------|--------------|----------------|---------------|
| [spack](https://spack.readthedocs.io/) | package [openfoam](https://github.com/spack/spack/tree/develop/var/spack/repos/builtin/packages/openfoam/) | Actively maintained by OpenCFD | [notes](#spack) |
| [EasyBuild](https://easybuild.readthedocs.io/) | package [OpenFOAM](https://github.com/easybuilders/easybuild-easyconfigs/tree/master/easybuild/easyconfigs/o/OpenFOAM) | Maintained independently, with input from OpenCFD | |
| debian | _See [precompiled](/precompiled)_ | Actively maintained by OpenCFD | |
| RPM-based | _See [precompiled](/precompiled)_ | Actively maintained by OpenCFD | |
### spack
<a name="spack"></a>
The installation of openfoam with spack will generally require the
latest (development version) of spack. If this is available, you can
install openfoam in various configurations and dependencies, but
typically can simply install directly:
```
$ spack install openfoam
```
#### OpenFOAM session
<a name="openfoam-session"></a>
Depending on how your packaging system has handled things, an `openfoam`
session command may be available as an alternative to the
`openfoam-selector` mechanism.
On the openSUSE installation, for example:
```
/usr/bin/openfoam -> openfoam1912
/usr/bin/openfoam1912
/usr/bin/openfoam-selector
/usr/bin/openfoam-selector-menu
```
Using `openfoam -help` displays some useful information.
Calling it without any arguments opens an interactive *bash* session
with an OpenFOAM environment and your usual `~/.bashrc` environment.
```
$ openfoam
Using: OpenFOAM-1912 - see www.openfoam.com
Arch: linux64GccDPInt32Opt (mpi=openmpi-system)
OpenFOAM shell session - use exit to quit
OpenFOAM-1912:~/
mark$
```
If 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:
...
```
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.
### Different compiler versions
<a name="different-compiler-versions"></a>
By default, OpenFOAM handles newer/older non-system compilers as
_ThirdParty_ installations and uses the combination of `WM_COMPILER`
and `WM_COMPILER_TYPE` to select them. In some cases, however, it can
be much more convenient for the user to install prebuilt compiler
binaries as *system* compilers (eg, using deb or rpm packages).
This poses a slight problem since the OpenFOAM build rules normally
use the main compiler name (`gcc`, `clang` etc) without any additional
version information, but the various *system* compilers are frequently
installed with versioned names such as `gcc-8`, `clang-9` etc.
Here is a simple way to solve this, using clang-9 on openSUSE for the
example:
1. Install the desired system compiler.
In this case [clang-9 from tools:compiler][llvm9-opensuse] which
installs `/usr/bin/clang-9` and `/usr/bin/clang++-9`.
2. Next override the OpenFOAM compiler calls, but without blindly
rewriting everything.
We create a new directory for our special rules:
```
mkdir wmake/rules/linux64Clang90
```
Inside this directory, we add a general rules file
(`wmake/rules/linux64Clang90/general`) with the following contents:
```
# Override compiler calls for llvm-9
cc = clang-9
CC = clang++-9 -std=c++11
```
Or if this shall be restricted to system compilers only:
```
# Override compiler calls for llvm-9
ifeq ($(WM_COMPILER_TYPE),system)
cc = clang-9
CC = clang++-9 -std=c++11
endif
```
3. The final step is to select this compiler definition with the following
combination:
```
# Preferences for system Clang90
export WM_COMPILER=Clang90
export WM_COMPILER_TYPE=system
```
If this change represents your standard default compiler definition,
then place the information into the `etc/prefs.sh` file (see the
`etc/bashrc` file for some details) and re-source your OpenFOAM
environment.
If you would like to selectively enable this compiler definition, a
common means is to place the same definition information into a user
configuration file (for example, `~/.OpenFOAM/clang90`) and then
specify that configuration when sourcing your OpenFOAM environment.
For example,
```
source /path/to/OpenFOAM-version/etc/bashrc clang90
```
The `bashrc` will locate and use the configuration file, after which the
compiler will be properly selected. To verify that this is indeed the
case:
```
wmake -show-cxx
```
should display the selected compiler. You may also wish to verify its
path:
```
wmake -show-path-cxx
```
For older versions, `which $(wmake -show-cxx)` instead.
## Darwin (Mac-OS)
The support for Darwin is complete, but is less well tested than Linux.
- The Darwin build (and operation) requires a **case-sensitive file system**,
which is often created as a disk image and mounted (for older systems).
- Compilation uses the system clang compiler.
### Known issues
CGAL
- ThirdParty CGAL will normally need to be compiled without mpfr/gmp.
This should be done manually prior to building OpenFOAM or other
ThirdParty. Eg,
```
cd $WM_THIRD_PARTY_DIR
./makeCGAL gmp-none mpfr-none
```
The `wmake/rules/darwin64Clang/CGAL` file has been adjusted to
eliminate references to gmp/mpfr libraries.
## Windows
Starting with [v1906][v1906-notes], Windows source compilation is
supported via [cross-compilation][latest-cross] using the
[mingw](http://mingw.org/) compiler on 64bit Linux to generate a Win64 target.
See the version-relevant build information.
--------
[foam-readme]: https://develop.openfoam.com/Development/openfoam/blob/develop/README.md
[latest-build]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Build.md
[latest-cross]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Cross-Compile-mingw.md
[v1912-build]: https://develop.openfoam.com/Development/openfoam/blob/maintenance-v1912/doc/Build.md
[v1906-build]: https://develop.openfoam.com/Development/openfoam/blob/maintenance-v1906/doc/Build.md
[v1906-notes]: https://www.openfoam.com/releases/openfoam-v1906/
[llvm9-opensuse]: https://software.opensuse.org//download.html?project=devel%3Atools%3Acompiler&package=llvm9

1
page-build-code.md Symbolic link

@ -0,0 +1 @@
building.md

@ -1,24 +1,22 @@
<!-- --- title: Precompiled Packages -->
[![home](/icons/home.svg "wiki home")](/home)
[![build](/icons/cpu.svg "build")](/building)
[![running](/icons/play.svg "running")](/running)
[[_TOC_]]
## Precompiled packages
To make OpenFOAM more readily available to a larger range of users,
OpenCFD works actively together with the community surrounding
To make OpenFOAM readily available to a larger range of users,
OpenCFD works actively with the community surrounding
respective Linux distributions to provide precompiled binary
installations as system packages. The distributions currently include
the following:
|System |
| System |
|---------------|
| [Debian/Ubuntu](/precompiled/debian) |
| [openSUSE](/precompiled/suse) |
| [CentOS/RedHat/Fedora](/precompiled/redhat) |
Of these, Debian/Ubuntu and openSUSE generally receive first attention:
Debian/Ubuntu and openSUSE generally receive first attention:
1. Debian/Ubuntu is a very popular distribution with OpenFOAM users.
2. OpenSUSE is historically our internal development platform. Since
@ -26,7 +24,23 @@ Of these, Debian/Ubuntu and openSUSE generally receive first attention:
well-crafted spec file to subsequently address RedHat-based
distributions.
### Installation Locations
[[_TOC_]]
## Using the OpenFOAM package
<a name="using"></a>
After installation, the OpenFOAM environment can be accessed as
described in [running](/running).
- The Debian and RPM packages **always** include the
[OpenFOAM shell sessions](/running/shell-session).
- If the `openfoam-selector` is available at the time of installation,
the newly installed packages will be registered with it, allowing
use of the [openfoam-selector](/running/openfoam-selector)
mechanism.
## Installation Locations
<a name="locations"></a>
The packages have been designed to allow simultaneous installation of
@ -50,7 +64,7 @@ For example,
- ...
### Sub-packages
## Sub-packages
<a name="sub-packages"></a>
Satisfying the wishes and requirements of all users is a difficult
@ -89,137 +103,26 @@ kept very similar, except `dev` (Debian) vs. `develop` (RPM) names
that follow the respective system conventions.
### After installation - using the OpenFOAM environment
<a name="environment"></a>
The [OpenFOAM bash session wrapper](#openfoam-session) provide the
simplest means of starting OpenFOAM immediately. For example,
```
$ openfoam1912
```
This can be used for an interactive bash session, or to run a single
OpenFOAM command within the OpenFOAM environment.
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:
```
source /usr/lib/openfoam/openfoam1912/etc/bashrc
```
The exact path used will change depending on the OpenFOAM version.
Never attempt to embed the shell session wrapper as part of your
`~/.bashrc` - this may cause an infinite loop!
#### Package structure (RPM)
## Package structure (RPM, partly Debian)
To allow smooth installation and use of multiple OpenFOAM versions on
the same system, some installations use a meta-package structure:
| Package | Comments |
|---------------|---------------|
| openfoam | The top-level meta package that provides links and requirements for the most recent openfoam release
| openfoam-selector | Similar to mpi-selector, used to switch active openfoam versions
| openfoam1906 | The maintenance version for 1906 |
| openfoam1812 | The maintenance version for 1812 |
| openfoam | The top-level meta package that provides links and requirements for the most recent openfoam release |
| openfoam-selector | Similar to mpi-selector, used to switch active openfoam versions |
| openfoam2006 | The maintenance version for 2006 |
| openfoam1912 | The maintenance version for 1912 |
The version-specific packages (eg, `openfoam1906`, `openfoam1812`)
The version-specific packages (eg, `openfoam2006`, `openfoam1912`)
install into distinct directories so that it is possible to have
multiple versions available on your systems.
The top-level `openfoam` package registers which of the
version-specific packages corresponds to the current release.
<a name="openfoam-selector"></a>
Finally, the `openfoam-selector` package is used to register which
openfoam packages are installed on the system and allows the use to
select one of them.
To display which versions are installed:
```
$ openfoam-selector --list
openfoam
openfoam1806
openfoam1812
openfoam1906
```
To set a particular version
```
$ openfoam-selector --set openfoam1906
```
To query the current selection:
```
$ openfoam-selector --query
```
Most people will find the `openfoam-selector-menu` more convenient to
use.
```
WARNING: Changes made to the openfoam-selector defaults
will not be visible until you start a new shell!
```
***NOTE*** Similar to the behaviour of the mpi-selector, the values
registered via the `openfoam-selector` will not be activated until the
next full login. This is to avoid a possible clash of environments
when a parallel job still being launched. Of course, you can still
simply source the corresponding `bashrc` file directly. For example,
```
$ source /opt/openfoam1906/etc/bashrc
```
#### OpenFOAM session
<a name="openfoam-session"></a>
Depending on how your packaging system has done things, an `openfoam`
session command may be available as an alternative to the
`openfoam-selector` mechanism.
On the openSUSE installation, for example:
```
/usr/bin/openfoam -> openfoam1912
/usr/bin/openfoam1912
/usr/bin/openfoam-selector
/usr/bin/openfoam-selector-menu
```
Using `openfoam -help` displays some useful information.
Calling it without any arguments opens an interactive *bash* session
with an OpenFOAM environment and your usual `~/.bashrc` environment.
```
$ openfoam
Using: OpenFOAM-1912 - see www.openfoam.com
Arch: linux64GccDPInt32Opt (mpi=openmpi-system)
OpenFOAM shell session - use exit to quit
OpenFOAM-1912:~/
mark$
```
If 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:
...
```
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.
### Package Links
## Package Links
<a name="packaging"></a>
|System | Links | Status | Notes |
@ -229,7 +132,7 @@ references from within your `~/.bashrc` file.
| [Fedora/CentOS/RedHat copr](https://copr.fedorainfracloud.org/coprs/openfoam/) | package [openfoam](https://copr.fedorainfracloud.org/coprs/openfoam/openfoam/) | In development by OpenCFD | [notes](/precompiled/redhat) |
### Resources
## Resources
For precompiled packaging, the following content is provided for
reference purposes, and to help when scripting:
@ -240,14 +143,3 @@ reference purposes, and to help when scripting:
| openSUSE | | |
| CentOS/RedHat | [openfoam-selector.spec](/packaging/redhat/openfoam-selector.spec) | [copr fetch](/packaging/redhat/copr-fetch.sh) |
| debian/ubuntu | | [add repo](/packaging/debian/add-debian-repo.sh) |
--------
[foam-readme]: https://develop.openfoam.com/Development/openfoam/blob/develop/README.md
[latest-build]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Build.md
[latest-cross]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Cross-Compile-mingw.md
[v1906-notes]: https://www.openfoam.com/releases/openfoam-v1906/
[llvm9-opensuse]: https://software.opensuse.org//download.html?project=devel%3Atools%3Acompiler&package=llvm9

81
running.md Normal file

@ -0,0 +1,81 @@
<!-- --- 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.

@ -0,0 +1,50 @@
<!-- --- title: openfoam-selector -->
[![home](/icons/home.svg "wiki home")](/home)
[![running](/icons/play.svg "running")](/running)
The `openfoam-selector` package is used to register which
openfoam packages are installed on the system and allows the user or
system administrator select one of them.
[[_TOC_]]
Depending on your packaging system (or system administrator),
`openfoam-selector` and `openfoam-selector-menu` commands may be
available to define the preferred OpenFOAM version for the ***login***
shell.
To display which versions are installed:
```
$ openfoam-selector --list
openfoam
openfoam1812
openfoam1906
openfoam1912
openfoam2006
```
To set a particular version
```
$ openfoam-selector --set openfoam2006
```
To query the current selection:
```
$ openfoam-selector --query
```
Most people will find the `openfoam-selector-menu` more convenient to
use.
```
WARNING: Changes made to the openfoam-selector defaults
will not be visible until you start a new shell!
```
***NOTE*** Similar to the behaviour of the `mpi-selector`, the values
registered via the `openfoam-selector` will not be activated until the
next full login. This is to avoid a possible clash of environments
when a parallel job still being launched. Of course, you can still
simply source the corresponding `bashrc` file directly. For example,
```
$ source /usr/lib/openfoam/openfoam2006/etc/bashrc
```

95
running/shell-session.md Normal file

@ -0,0 +1,95 @@
<!-- --- 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!