Installation/Windows/Outdated/Tip Cross Compiling OpenFOAM in Linux For Windows with MinGW

From OpenFOAMWiki
Jump to: navigation, search

Contents

1 Introduction

This is an exhaustive step by step guide on how to fully cross-compile OpenFOAM in Linux for Windows, for both 32 and 64 bits architectures (from and to), using the patches made available in each respective page. NOTE: for cross-compiling in Cygwin for Windows, see the page Using Cygwin for cross-compiling OpenFOAM.

These patches were initially based on Symscape's "v3" patch for OpenFOAM 1.5.x available here, but as development evolves, occasional updates are made based on the latest patches by Symscape. Symscape's patches differ substantially from the patches available on this wiki; the main differences of the patches on this wiki are:

  • these aim to build OpenFOAM up to 100% of its original capabilities;
  • these also build most Third Party tools that OpenFOAM can use directly (Scotch, Metis);
  • provide additional scripts for building OpenFOAM and the maintenance of these patches;
  • target only Windows - Symscape's patches also have changes for Mac OS X;
  • these patches are only released for each major release of OpenFOAM - Symscape's patches are updated every 2-3 months.

The build scripts for mingw and mingw-w64 were also based on the build-mingw script available on the 1.5.x and 1.6.x links.

With this guide and available patches, you should be able to cross-compile the whole and complete OpenFOAM libraries and applications, using MPICH2 instead of Open MPI for parallel computing. You can cross-compile using mingw32 and/or mingw-w64.

2 Patch versions

With the release of OpenFOAM 1.7 and the separate evolution of the patches for each OpenFOAM version, the once single wiki page will now branch into 3 parts:

Support for these patches is available at OpenFOAM's forum here.

3 Information common to all patch versions

3.1 Building Paraview in Windows

Since ParaView 3.8.0 was released [1], it no longer seems necessary to put effort into building ParaView with MPICH2 and the native OpenFOAM reader. Kitware now provides ParaView with (and without) MS-MPI for parallel functionality, and the plugin from here is already integrated.

Either way, in case you really want to build ParaView, the following instructions are the ones initially written on this wiki page:

  1. This is a pain to do, and yet, quite simple once you get the handle of it. Nonetheless, here won't be described the full building procedure. You can follow the tutorial available here in this wiki and use that plug-in for reading .foam files directly from Paraview, without building the original plug-ins that come with OpenFOAM and be able to handle large and/or parallelized cases. On that tutorial page, you also have a link to an already built version of Paraview 3.4.0 with the plug-in. This way it is less one thing to worry about building.
  2. Tips for building a 64bit version of Paraview - Follow the instructions available here and here. This way you can get Visual Studio Express to build x64 applications and also build Qt 64bit for Windows, as well as Paraview with the multi-platform plug-in!

3.2 Using MPICH2 with OpenFOAM in Windows

This is valid for each computer with Windows, where you installed the cross-compiled OpenFOAM. Be advised that you should install OpenFOAM in an identical folder path on each machine, or in a network shared drive. User accounts of the same name and password will reduce the complexity of your system. Currently we haven't tested running with different user accounts.

NOTE: these steps depend on the MPICH2 version you choose to run, namely 32 or 64bit. So you might need to do them every time you need different architectures. Nonetheless, the SMPD service seemed to be compatible with both versions.

The steps are:

  1. Go to into your administrative account (if your user account doesn't have administrative capabilities) and:
    1. Open a command line (Start->Run... or Winkey+R and run cmd.exe).
    2. Go to the bin folder where MPICH2 is installed (e.g. cd C:\Program Files\MPICH2\bin).
    3. Type:
      smpd -install
      to install the MPICH2 smpd service.
  2. Go back to your OpenFOAM user account.
    1. Now run the OpenFOAM terminal (double click on the file DOS_Mode.bat).
    2. Type:
      mpiexec.exe -register

      And when it asks your user name just press Enter key; and when it asks your user password, introduce your password... it'll ask you twice to make sure. This will allow future calls to mpiexec to be done without requiring password. MPICH will encrypt your password into the Windows Registry, so it should be safe.

      CAUTION: the MSys terminal version will make your password visible on screen!
    3. Test the parallel system. For that, you'll have to:
      1. In the OpenFOAM terminal, go to the folder ofuser-1.6 (or $USER-1.6) and unpack the test case PTestCase.tar.gz;
      2. Go into the pTestCase case folder;
      3. Type:
        gompi parallelTest
        It will test communications between two instances of parallelTest.exe. If successful, it should display something like this:
      C:\Program Files\blueCFD\ofuser-1.6\PTestCase>mpiexec -n 2 -genvlist HOME,PATH,
      USERNAME,WM_PROJECT_DIR,WM_PROJECT_INST_DIR,WM_OPTIONS,FOAM_LIBBIN,FOAM_APPBIN,
      FOAM_USER_APPBIN,MPI_BUFFER_SIZE parallelTest -parallel
      /*---------------------------------------------------------------------------*\
      | =========                 |                                                 |
      | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
      |  \\    /   O peration     | Version:  1.6                                   |
      |   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
      |    \\/     M anipulation  |                                                 |
      \*---------------------------------------------------------------------------*/
      /*   Windows 32 and 64 bit porting by blueCAPE: http://www.bluecape.com.pt   *\
      |  Based on Windows porting (1.5.x v3) by Symscape: http://www.symscape.com/  |
      \*---------------------------------------------------------------------------*/
      Build  : 1.6-f802ff2d6c5a
      Exec   : C:\Program Files\blueCFD\ofuser-1.6\applications\bin\linuxmingw-w32DP
      Opt\parallelTest.exe -parallel
      Date   : Oct 23 2009
      Time   : 16:21:16
      Host   : THE_MACHINE
      PID    : 712
      Case   : C:/Program Files/blueCFD/ofuser-1.6/pTestCase
      nProcs : 2
      Slaves :
      1
      (
      THE_MACHINE.5024
      )
      
      Pstream initialized with:
          floatTransfer     : 0
          nProcsSimpleSum   : 0
          commsType         : nonBlocking
      
      // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
      Create time
      
      [1]
      Starting transfers
      [1]
      [1] slave sending to master 0
      [1] slave receiving from master 0
      [0]
      Starting transfers
      [0]
      [0] master receiving from slave 1
      [0] (0 1 2)
      [0] master sending to slave 1
      End
      
      [1] (0 1 2)
      Finalising parallel run
      

4 Miscellaneous information

4.1 Differences between mingw32 and mingw-w32 versions

MinGW is the true name of mingw32. As for mingw-w32 (32bit version of mingw-w64), as cited from here (dead link):

Mingw-w64 began as a spin-off from the mingw.org project, with the original intent of building for 64-bit targets.

Nonetheless, mingw-w64 has retro-compatibility with the 32bit MinGW version, thus enabling a 2-in-1 build package for 32 and 64bit Windows systems.

The main difference between mingw32 and mingw-w32, is that MinGW is a stable and proven build tool and run-time for Windows, while the mingw-w64 project is still under fierce development and only in October 29th of 2010 they released their first stable version. Therefore, it is only estimated that the mingw32 version could provide less headaches than mingw-w32.

4.2 Using Cygwin for cross-compiling OpenFOAM

For cross-compiling in Cygwin for Windows, see the page Using Cygwin for cross-compiling OpenFOAM.

5 Other Important Links

5.1 List of known building instructions

This is a list of links of build instructions of cross-compiled and natively compiled versions of OpenFOAM, using mingw and/or mingw-w64:

  • Symscape's cross-compilations:
    • OpenFOAM 1.4.1 mingw32 version [2]
    • OpenFOAM 1.5.x mingw32 version [3]
    • OpenFOAM 1.6.x mingw32 (no MPI) version [4] and OpenFOAM 1.6.x mingw-64 (with MS-MPI) version [5]
    • OpenFOAM 1.7.x mingw-64 (with MS-MPI) version [6]
    • OpenFOAM 2.0.x mingw-64 (with MS-MPI) version [7]
    • OpenFOAM 2.1.x mingw-64 (with MS-MPI) version [8]
  • Julian's OpenFOAM 1.5 files for native build in Windows [9] with mingw32 and CodeBlocks (instructions included inside files)
  • blueCAPE's cross-compilations:
    • OpenFOAM 1.5.x mingw32 version with MPICH1 [10] and MPICH2 [11]
    • OpenFOAM 1.6 and 1.7.0 mingw32, mingw-w32 and mingw-w64 (all with MPICH2)... is this tutorial you are reading...
    • OpenFOAM 2.0.x and 2.1.x mingw32, mingw-w32 and mingw-w64 with Open-MPI, MPICH2 and MS-MPI: [12]
  • Yuu Kasuga's blog (in Japanese). It use to have a few entries about cross-compiling and using OpenFOAM in Windows. Only recover link so far is for OpenFOAM 1.7.x using Symscape's patches: [13]
  • Kojani's blog (available in English, Japanese and Korean). Provides instructions and source code for compiling OpenFOAM 1.7.1 directly on Windows while using MSys: [14]

5.2 List of known binaries for Windows

Distributable binaries:

5.3 List of benchmarks on Windows

Benchmarks and run-times running OpenFOAM cross-compiled with mingw:

  • OF version 141.png icoDyMFoam (movingCone) OpenFOAM tutorial [23]
  • OF version 141.png Xoodles pitzDaily3D OpenFOAM tutorial [24]
  • OF version 16.png simpleFoam motorBike OpenFOAM tutorial from 1.6.x, running with OpenFOAM 1.6 [25]
  • OF version 17.png simpleFoam motorBike OpenFOAM tutorial from 1.6.x, running with OpenFOAM 1.6 in Linux and 1.7.0 in Windows [26]
  • OF Version 20.png OF Version 21.png simpleFoam motorBike OpenFOAM tutorial from 2.0.x, running with OpenFOAM 2.0.x and 2.1.x in Linux and in Windows [27]

5.4 Tutorials known to work on Windows

Tutorials known to work with cross-compiled versions of OpenFOAM:

5.5 Forums for more information

Threads at CFD-Online Forum for OpenFOAM, for discussing and questions about this page:

  • Announcement of this page [30]
  • Announcement of the patches for the 1.7 version [31]
  • Support for this page is available here.

6 History

Note to readers and editors: feel free to update this page. You can use this History section for helping other readers stay updated on major changes.

Wyldckat 20:45, 7 November 2012 (CET) - Updated the "Important Links" section

Wyldckat 10:15, 20 December 2011 (CET) - Updated the "Important Links" section

Wyldckat 15:13, 1 September 2010 (CEST) - Updated the "Important Links" section.

Wyldckat 15:46, 22 July 2010 (UTC) - Changes complete to this wiki page. Still have to create the page for the 1.7 version...

Wyldckat 11:31, 22 July 2010 (UTC) - Changes have begun to be made to this wiki page to incorporate the patches for OpenFOAM 1.7. Most of the content has branched into separate pages.

Wyldckat 14:34, 18 February 2010 (UTC) - Glitches were found in build-mingw32, and the fix is now provided inline with the tutorial. A bit later, a thread has been added to give support to this page.

Wyldckat 20:25, 19 January 2010 (UTC) - Updates to patches and wiki page:

  • fixes made based on Symscape's version v9 for 1.6.x, because many of the solvers that use LES and RAS turbulence models need their libraries to be forced to load under Windows.
  • chtMultiRegionFoam now works, with KK instead of K for Windows builds.
  • Instructions on how to get OpenFOAM 1.6.x directly from repository using git under cygwin.
  • reconstructParMesh wasn't being built because it wasn't in the respective Allwmake script.
  • Linking OpenFOAM to MPICH2 no longer requires Wine to work straight out of the boxed up patch.
  • Added link to tutorials that are known to work with these patches.

Wyldckat 22:20, 22 November 2009 (UTC) - Added information about cross-compiling in Cygwin

Wyldckat 01:41, 21 November 2009 (UTC) - Added thread link for discussion about this page

Wyldckat 18:20, 19 November 2009 (UTC) - Added info on cross-compiling with MPICH2, without Wine nor copying from Windows

Wyldckat 11:58, 18 November 2009 (UTC) - Added info about using CHOICE.EXE with DOS_Mode.bat

Wyldckat 18:21, 11 November 2009 (UTC) - First version of this step by step wiki page