OpenFOAM 1.6.x on Windows 64-bit with Native MPI

For the latest version of our Windows patch for OpenFOAM visit "OpenFOAM 2.2.x on Windows".

The latest version of our Windows patch for OpenFOAM® 1.6.x now supports 64-bit compilation using the MinGW-w64 cross-compiler and parallel computation using the native Windows MPI implementation provided by the free Microsoft HPC SDK and also available on Microsoft Windows HPC Server 2008 for clusters. Be warned, as always, that to build OpenFOAM for Windows with a cross-compiler requires expert knowledge of Windows and Linux utilities and compilers.

OpenFOAM GUI

Are you looking for a GUI driven, integrated simulation environment for Windows, Linux, and Mac incorporating a selection of the RANS OpenFOAM solvers and various import/export filters?

Get Started With Caedium Now

Patch Build Process

The following steps are required to produce a native Windows version of OpenFOAM 1.6.x 64-bit with [optional] native Windows MPI:

  1. Install MinGW-w64 cross-compiler on Linux
  2. Add #include_next <float.h> to the end of
    <mingw-w64>/lib/gcc/x86_64-w64-mingw32/4.4.1-1a/include/float.h and remove it from
    <mingw-w64>/x86_64-w64-mingw32/include/float.h to include the right float.h
  3. [optional] Create libmsmpi.a from Microsoft HPC SDK
  4. Install the OpenFOAM 1.6.x source distribution on Linux - git commit 5e99c7bac54c85ae93babf825187247620968938 Date: Tue Jun 22 17:13:42 2010.
  5. [optional] Install the ThirdParty-1.6.x source and add PROJECT_LIBS = <blank> to the end of <ThirdParty-1.6.x>/scotch_5.1/src/libscotch/Make/options
  6. Patch (using the Linux patch command) the OpenFOAM 1.6.x source distribution with our MinGW Windows modifications [last updated July 2, 2010 to v11]
  7. Make the link: ln -s <OpenFOAM-1.6.x>/wmake/bin/linuxGcc <OpenFOAM-1.6.x>/wmake/bin/linuxmingw-w64 so the native Linux versions of wmkdep and dirToString are available to the MinGW-w64 build
  8. Export environment variables and source etc/bashrc. As an example:
    export FOAM_INST_DIR="$HOME/projects/of/of1.6"
    export WM_OSTYPE=MSwindows
    export WM_COMPILER=mingw-w64
    export WM_ARCH_OPTION=64
    export WM_CC='x86_64-w64-mingw32-gcc'
    export WM_CXX='x86_64-w64-mingw32-g++'
    export compilerInstall=System
    export WM_MPLIB='NONE' or [optional] export WM_MPLIB='MSMPI'
    [optional] export MPI_ARCH_PATH="$HOME/projects/msmpi/install"
    source "$FOAM_INST_DIR/OpenFOAM-1.6.x/etc/bashrc"
  9. To build:
    • cd <OpenFOAM-1.6.x>/wmake/src; ./Allwmake
    • [optional] cd <ThirdParty-1.6.x>/scotch_5.1; wmake libso src/libscotch
    • cd <OpenFOAM-1.6.x>;./Allwmake
  10. Transfer the OpenFOAM etc directory (<OpenFOAM-1.6.x>/etc), executables (<OpenFOAM-1.6.x>/applications/bin/linux64mingw-w64*/*.exe), and libraries (<OpenFOAM-1.6.x>/lib/linux64mingw-w64*/*.dll and <OpenFOAM-1.6.x>/lib/linux64mingw-w64*/*/*.dll) to the Windows computer
  11. Transfer the MinGW-w64 libraries (<mingw-w64>/bin/zlib1.dll and <mingw-w64>/bin/libgcc_s_sjlj-1.dll) to the Windows computer
  12. On the Windows computer ensure the following environment variables are set:
    • The WM_PROJECT_DIR and USERNAME variables are set.
    • The PATH variable is set to include the OpenFOAM executable and library locations (including <OpenFOAM-1.6.x>/lib/linux64mingw-w64*/dummy or [optional] <OpenFOAM-1.6.x>/lib/linux64mingw-w64*/msmpi).
  13. Launch a Windows command prompt to run OpenFOAM solvers and utilities, such as simpleFoam.exe.

Windows HPC Server 2008

job submit example on Windows HPC Server 2008 for simpleFoam:

job submit /jobname:simpleFoam-jobName /name:simpleFoam-taskName /numprocessors:16 /stdout:\\CRAY01\<of-case>\stdout.txt /stderr:\\CRAY01\<of-case>\stderr.txt mpiexec -env WM_PROJECT_DIR \\CRAY01\<OpenFOAM-1.6.x> -env MPI_BUFFER_SIZE 20000000 -env USERNAME openfoam -env PATH \\CRAY01\<OpenFOAM-1.6.x>\lib\linux64mingw-w64*;\\CRAY01\<OpenFOAM-1.6.x>\lib\linux64mingw-w64*\msmpi \\CRAY01\<OpenFOAM-1.6.x>\applications\bin\linux64mingw-w64*\simpleFoam -parallel -case \\CRAY01\<of-case>\pitzDaily

Note you need to share both the case (\\CRAY01\<of-case>) and application directories (\\CRAY01\<OpenFOAM-1.6.x>) so all nodes on the cluster can access them.

Constraints

With this method of building OpenFOAM for Windows the job control scripts in <OpenFOAM-1.6.x>/bin (such as foamSolverSweeps) are unavailable. Also the libccmio library is not built.

Notes

  • OpenFOAM is a registered trademark of OpenCFD and is unaffiliated with Symscape
  • The OpenFOAM Windows patch provided here is licensed under the GNU Public License (GPL)