OpenFOAM 2.2.x on Windows

For the latest version of our Windows patch for OpenFOAM visit "OpenFOAM v3.0+ on Windows".

We have updated our free Windows source code patch for the latest OpenFOAM® release (v2.2.x). As with the previous version this patch also supports 64-bit compilation using the MinGW-w64 cross-compiler and parallel computation using the native Windows MS MPI implementation provided by the free Microsoft MPI Redistributable and also available on Microsoft Windows HPC Server 2012 for clusters.

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?

Caedium Professional

Get Started With Caedium Now

Patch Build Process

To build OpenFOAM for Windows with a cross-compiler requires expert knowledge of Windows and Linux utilities and compilers.

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

  1. Install MinGW-w64 cross-compiler and zlib on Linux
  2. Install zlib files into following locations:
    • <mingw-w64>/x86_64-w64-mingw32/include/zconf.h
    • <mingw-w64>/x86_64-w64-mingw32/include/zlib.h
    • <mingw-w64>/bin/zlib1.dll
    • <mingw-w64>/x86_64-w64-mingw32/lib/libz.a
    • <mingw-w64>/x86_64-w64-mingw32/lib/libzdll.a
  3. If you see an error while compiling like:
    signals/sigFpe.C:45:15: error: '_clearfp' was not declared in this scope
    You need to add #include_next <float.h> to the end of
    <mingw-w64>/lib/gcc/x86_64-w64-mingw32/<gcc-version>/include/float.h and remove it from
    <mingw-w64>/x86_64-w64-mingw32/include/float.h to include the right float.h
  4. [optional] Create libmsmpi.a from Microsoft MPI Redistributable
  5. Install the OpenFOAM 2.2.x source distribution on Linux - git commit: 8a983dba63b246772c69ed0fa9cc3b3e33a10f92, Date: Wed Jan 8 15:36:30 2014 +0000.
  6. Patch (using the Linux patch command) the OpenFOAM 2.2.x source distribution with our MinGW Windows modifications [last updated January 31, 2014 to v3]
  7. At various stages during this process you will need to set OpenFOAM MinGW-w64 environment variables and source etc/bashrc. As an example:
    export FOAM_INST_DIR="$(HOME)/projects/of/2.2"; source $(FOAM_INST_DIR)/OpenFOAM-2.2.x/etc/bashrc WM_OSTYPE=MSwindows WM_COMPILER=mingw-w64 WM_ARCH_OPTION=64 WM_PRECISION_OPTION=SP WM_CC=x86_64-w64-mingw32-gcc WM_CXX=x86_64-w64-mingw32-g++ compilerInstall=system [optional] WM_MPLIB=MSMPI [optional] MPI_ARCH_PATH="$(HOME)/projects/msmpi/install"
  8. [optional] Install the ThirdParty-2.2.1 source and build scotch according to:
    1. ln -s ThirdParty-2.2.1 $(WM_THIRD_PARTY_DIR)
    2. ln -s $(WM_THIRD_PARTY_DIR)/scotch<version> $(WM_THIRD_PARTY_DIR)/scotch
    3. ln -s $(WM_PROJECT_DIR)/extra/scotch/src/Make.inc/Makefile.inc.mingw-w64 $(WM_THIRD_PARTY_DIR)/scotch/src/Makefile.inc
    4. cp $(WM_PROJECT_DIR)/extra/scotch/src/libscotch/* $(WM_THIRD_PARTY_DIR)/scotch/src/libscotch/.
    5. cd $(WM_THIRD_PARTY_DIR)/scotch/src
    6. cp $(WM_PROJECT_DIR)/extra/scotch/src/Makefile .
    7. make libscotch
    8. mkdir -p $(FOAM_LIBBIN)
    9. cd $(WM_THIRD_PARTY_DIR)/scotch/src/libscotch
    10. cp libscotch.* $(FOAM_LIBBIN)
  9. To build OpenFOAM:
    1. source the OpenFOAM native linux environment variables
    2. cd $(WM_PROJECT_DIR)/wmake/src; make
    3. ln -s $(WM_PROJECT_DIR)/wmake/platforms/linux64Gcc $(WM_PROJECT_DIR)/wmake/platforms/linux64mingw-w64
    4. source the OpenFOAM MinGW-w64 environment variables
    5. cd $(WM_PROJECT_DIR);./Allwmake
  10. Transfer the OpenFOAM etc directory ($(WM_PROJECT_DIR)/etc), executables ($(WM_PROJECT_DIR)/platforms/linux64mingw-w64*/bin/*.exe), and libraries ($(WM_PROJECT_DIR)/platforms/linux64mingw-w64*/lib/*.dll and $(WM_PROJECT_DIR)/platforms/linux64mingw-w64*/lib/*/*.dll) to the Windows computer
  11. Transfer the MinGW-w64 libraries:
    • <mingw-w64>/bin/zlib1.dll
    • <mingw-w64>/bin/libgcc_s_sjlj-1.dll
    • <mingw-w64>/bin/libstdc++-6.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 $(WM_PROJECT_DIR)/lib/linux64mingw-w64*/dummy or [optional] $(WM_PROJECT_DIR)/lib/linux64mingw-w64*/msmpi).
  13. Launch a Windows command prompt to run OpenFOAM solvers and utilities, such as simpleFoam.exe.

Windows HPC Server 2012

job submit example on Windows HPC Server 2012 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\$(WM_PROJECT_DIR) -env MPI_BUFFER_SIZE 20000000 -env USERNAME openfoam -env PATH \\CRAY01\$(WM_PROJECT_DIR)\platforms\linux64mingw-w64*\lib;\\CRAY01\$(WM_PROJECT_DIR)\platforms\linux64mingw-w64*\lib\msmpi \\CRAY01\$(WM_PROJECT_DIR)\platforms\linux64mingw-w64*\bin\simpleFoam -parallel -case \\CRAY01\<of-case>\pitzDaily

Note you need to share both the case (\\CRAY01\<of-case> - arbitrary name of your choosing) and application directories (\\CRAY01\$(WM_PROJECT_DIR)) so all nodes on the cluster can access them.

Constraints

  • With this method of building OpenFOAM for Windows the job control scripts in $(WM_PROJECT_DIR)/bin (such as foamSolverSweeps) are unavailable.
  • The libccmio library is not built.
  • Supports bashrc only, i.e., no cshrc support.

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)

Comments

Good day, I don't know how to

Good day,

I don't know how to setup the system environment (like "$(WM_THIRD_PARTY_DIR)", $(WM_PROJECT_DIR), and the others) when I follow the procedure and do this same thing on my ubuntu 12.04 system. could you modify this procedure clearly ?

I finish the steps including the step 1, 2. And I guess that I also finish the step 4, 5 and 6.
But I am confused to do the step 7, 8, 9, ... , 13

See Step 7

Environment variable setting is covered in Step 7.

build errors

Hi,

I did everything, but I still get the errors when compiling. It starts with this one:

make: *** No rule to make target 'meshes/primitiveMesh/primitivePatch/PrimitivePatch.H', needed by 'meshes/primitiveMesh/primitivePatch/walkPatch.dep'. Stop.

Do you know what may be wrong?