Installation/Windows/Outdated/Cross Compiling OpenFOAM 1.6 in Linux For Windows with MinGW
The parent page of this page is Tip Cross Compiling OpenFOAM in Linux For Windows with MinGW - please visit it for more information.
Contents
- 1 Introduction
- 2 Get OpenFOAM packages
- 3 Things needed for properly cross-compiling OpenFOAM 1.6
- 4 Using a specific gcc version for building the wmake binaries (Optional)
- 5 Applying patches
- 6 Getting Windows version of MPICH2 into the ThirdParty-1.6 folder in Linux
- 7 Tweaking environment options
- 8 Build the cross compiler
- 9 Cross-Compile OpenFOAM in Linux for Windows
- 10 Copying the files to your Windows installation
- 11 Creating a Compiled HTML file for the code documentation
- 12 Notes on what doesn't work and why
- 12.1 chtMultiRegionFoam doesn't work properly
- 12.2 motorBike case and foamToVTK in Windows
- 12.3 motorBike case in the package OpenFOAM-1.6.General.gtgz doesn't work well
- 12.4 foamToVTK made .vtk files that Paraview can't read
- 12.5 Can't build cross-compiler version mingw32 in Linux x86_64
- 12.6 libscotch is limited in Windows
- 12.7 Fast memory allocation issues in Windows
- 12.8 Symbolic links in the tutorials
- 12.9 Building OpenFOAM with gcc-4.4.? and gcc-4.5.0
- 12.10 Open MPI in Windows
- 12.11 Cross-compiled version mingw-w64 takes longer to start applications
- 12.12 Some tutorials don't work in Windows
- 12.13 Tutorial scripts don't work in Windows
- 12.14 DOS_Mode.bat won't allow choosing which version to use
- 13 Notes on added functionalities with these patches
- 13.1 Building ccm26ToFoam
- 13.2 Keeping track of symbolic links in tutorials
- 13.3 Changes in settings.sh
- 13.4 Building locally with multiple cores
- 13.5 Building mingw cross-compilers
- 13.6 Getting MPICH2 automatically in Linux
- 13.7 Compiling HTML files into CHM
- 13.8 Creating new patches
- 13.9 MPFR 2.4.1 was missing 3 files
- 13.10 Profiling OpenFOAM applications with mingw cross-compiled version
- 13.11 Backing up development folders
- 14 History
1 Introduction
This is an exhaustive step by step guide on how to fully cross-compile OpenFOAM 1.6.0 in Linux for Windows, for both 32 and 64 bits architectures (from and to), using the patches available here. NOTE: for cross-compiling in Cygwin for Windows, see the section Using Cygwin for cross-compiling OpenFOAM.
These patches were initially based on Symscape's "v3" patch for OpenFOAM 1.5.x available here, but the latest version is based on Symscape's "v9" patch for OpenFOAM 1.6.x available here. These differ substantially from those patches. 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. These enable you to build OpenFOAM 1.6 for Windows 32 and 64 bit versions, from Linux 32 and 64bit architectures. See the chapter Notes on what doesn't work and why, for information on things that don't work properly.
Versions these patches apply to:
Other versions and common information to all MinGW cross-compiled versions is available in the page Tip Cross Compiling OpenFOAM in Linux For Windows with MinGW.
Support for this page is available at OpenFOAM's forum here.
2 Get OpenFOAM packages
- In your Linux machine, open a terminal window (example) and create the folder $HOME/OpenFOAM:
mkdir $HOME/OpenFOAM cd $HOME/OpenFOAM
- Get OpenFOAM-1.6.General.gtgz and ThirdParty-1.6.General.gtgz from the OpenFOAM's sourceforge.net project page and copy/move them to the folder $HOME/OpenFOAM. If you want direct download from the terminal, then do:
wget http://downloads.sourceforge.net/foam/OpenFOAM-1.6.General.gtgz?use_mirror=mesh wget http://downloads.sourceforge.net/foam/ThirdParty-1.6.General.gtgz?use_mirror=mesh
- Extract both files, by running in a terminal:
tar xzf OpenFOAM-1.6.General.gtgz tar xzf ThirdParty-1.6.General.gtgz
3 Things needed for properly cross-compiling OpenFOAM 1.6
- The packages needed in Linux (these are Ubuntu package names) are: flex git git-core build-essential python-dev libqt4-dev libreadline5-dev wget zlib1g-dev texinfo byacc bison.
- For the x86_64 Linux platform, you will also need: gcc-multilib
- The packages required for documentation are: doxygen graphviz.
The reference script for installing most of theses packages was this.
4 Using a specific gcc version for building the wmake binaries (Optional)
This is optional, because the current patch will use the system's gcc for building them (more specifically gcc as compiler name).
- Edit $HOME/.bashrc and add the following line to the end of it:
. $HOME/OpenFOAM/OpenFOAM-1.6/etc/bashrc
WARNING: sometimes the leading dot doesn't work, so use the following instead:source $HOME/OpenFOAM/OpenFOAM-1.6/etc/bashrc
NOTE:You might want to edit $HOME/OpenFOAM/OpenFOAM-1.6/etc/bashrc and set the Linux architecture correctly, namely WM_ARCH_OPTION to 32 or 64.
- Two possibilities are now available:
- Use the system's gcc - edit $HOME/OpenFOAM/OpenFOAM-1.6/etc/settings.sh and change compilerInstall=OpenFOAM to compilerInstall=System.
- Or use the gcc that comes with the ThirdParty-1.6.General.gtgz package - again, two choices:
- You can compile the gcc by running the following line:
(cd $HOME/OpenFOAM/ThirdParty-1.6 && makeGcc gcc-4.3.3)
- Or by getting the available compiled version for your Linux version ( ThirdParty-1.6.linuxGcc.gtgz or ThirdParty-1.6.linux64Gcc.gtgz from OpenCFD's website).
- You can compile the gcc by running the following line:
- Launch a new terminal and run the following line, thus building wmkdep and dirToString:
(cd $HOME/OpenFOAM/OpenFOAM-1.6/wmake/src && make)
5 Applying patches
- Copy/move the PatchesNBatches.tar.gz file into the $HOME/OpenFOAM folder. Then unpack it by running:
tar -xzf PatchesNBatches.tar.gz
- A new folder is created, named pnb. Now to apply the patches, run from the $HOME/OpenFOAM folder:
patch -p0 < pnb/OpenFOAM-1.6_patch patch -p0 < pnb/ThirdParty-1.6_patch
- Still have to do some chmodding, for new scripts to run properly. Run the following lines in the terminal:
chmod 744 $HOME/OpenFOAM/ThirdParty-1.6/build-mingw32 chmod 744 $HOME/OpenFOAM/ThirdParty-1.6/build-mingw-w32 chmod 744 $HOME/OpenFOAM/ThirdParty-1.6/build-mingw-w64 chmod 744 $HOME/OpenFOAM/ThirdParty-1.6/build-mingw-w64-45 chmod 744 $HOME/OpenFOAM/ThirdParty-1.6/makeGcc44 chmod 744 $HOME/OpenFOAM/ThirdParty-1.6/get-mpich2 chmod 744 $HOME/OpenFOAM/OpenFOAM-1.6/src/Allclean chmod 744 $HOME/OpenFOAM/OpenFOAM-1.6/applications/utilities/parallelProcessing/Allwmake chmod 744 $HOME/OpenFOAM/OpenFOAM-1.6/bin/tutowin chmod 744 $HOME/OpenFOAM/OpenFOAM-1.6/bin/foamDiff chmod 744 $HOME/OpenFOAM/OpenFOAM-1.6/bin/backupSourceFolder chmod 744 $HOME/OpenFOAM/OpenFOAM-1.6/bin/backupFullFolder
6 Getting Windows version of MPICH2 into the ThirdParty-1.6 folder in Linux
There are two ways of getting OpenFOAM to compile with MPICH2:
- Use the get-mpich2 script - the current patch has the include files and library definition files necessary to be able to link OpenFOAM to MPICH2. No need for changes, unless you want to build with a version of MPICH2 different from 1.1.1p1.
- Copy MPICH2 files from a Windows Installation. Three steps for this part:
- Download and install in Windows the MPICH2, version 1.1.1p1 Win32 IA32 from here. Also get and install the 64bit version, if you wish to build OpenFOAM for Windows x64.
- Create the folder $HOME/OpenFOAM/ThirdParty-1.6/mpich2-1.1.1p1 in your Linux set up:
mkdir $HOME/OpenFOAM/ThirdParty-1.6/mpich2-1.1.1p1
- Copy the folders bin, include and lib from the installed version of MPICH2 in Windows, into the folder ThirdParty-1.6/mpich2-1.1.1p1 in Linux.
- The Allwmake script at the folder ThirdParty-1.6 will take care of the rest. For now, the tough part is that, this way, you can only build one version of OpenFOAM (32 or 64bit) at a time.
In the next chapter, you will learn how to configure the variable that is responsible for these two choices.
7 Tweaking environment options
- Choose which version you want to use:
- mingw32: for getting a 32bit version of OpenFOAM, that builds on Linux i?86, using mingw;
- mingw-w32: for getting a 32bit version of OpenFOAM, that builds on Linux i686 and x86_64, using mingw-w64;
- mingw-w64: for getting a 64bit version of OpenFOAM, that builds on Linux i686 and x86_64, using mingw-w64;
- sample - <bashrc-version>
- configured for <compiler>, <mingw version>, <MPI option>, <WM_COMPILE_OPTION>, <WM_ARCH_OPTION>
- bashrc-mingw32
- configured for gcc-4.3.3, mingw32, MPI with MPICH2, Opt, DP, 32
- bashrc-mingw-w32
- configured for gcc-4.4.2, mingw-w32, MPI with MPICH2, Opt, DP, 32
- bashrc-mingw-w32-prof
- configured for gcc-4.4.2, mingw-w32, No MPI, Prof, DP, 32
- bashrc-mingw-w32S
- configured for gcc-4.4.2, mingw-w32, MPI with MPICH2, Opt, SP, 32
- bashrc-mingw-w64
- configured for gcc-4.4.2, mingw-w64, MPI with MPICH2, Opt, DP, 64
- bashrc-mingw-w64-prof
- configured for gcc-4.4.2, mingw-w64, No MPI, Prof, DP, 64
- bashrc-mingw-w64-45
- configured for gcc-4.5.0, mingw-w64, MPI with MPICH2, Opt, DP, 64
- After choosing the version you wish to build, edit the file $HOME/.bashrc and add to the end of it, a line analogous to the following line:
. $HOME/OpenFOAM/OpenFOAM-1.6/etc/bashrc-mingw32
WARNING: sometimes the leading dot doesn't work, so use the following instead:
source $HOME/OpenFOAM/OpenFOAM-1.6/etc/bashrc-mingw32
- Before launching a new terminal, edit the picked file $HOME/OpenFOAM/OpenFOAM-1.6/etc/bashrc-mingw version. You have two additional variables that are configurable and non standard to the original OpenFOAM version:
- WM_PSTREAMLINK - this variable allows control over the linking method that is with the Pstream library. Two options are available:
- If set to DONTLINKTOPSTREAM, then depending on the variable WM_MPLIB being set to NONE or MPICH, then OpenFOAM will be statically linked with that version; that means that it will only run without MPI capabilities or only run with MPICH2 installed, respectively.
- If LINKTOPSTREAM, then DLLs of the library Pstream are created, both dummy and MPICH2 versions; this allows you to choose which version to use in Windows, without rebuilding OpenFOAM again. This way you get 2 versions of OpenFOAM with just one build, which is useful for various installation environments.
- WM_GETMPICH2 - this variable controls whether MPICH2 is setup automatically or manually (see Getting Windows version of MPICH2 into the ThirdParty-1.6 folder in Linux). The two options are:
- If set to GETMPICH2, then wget is used for downloading the MPICH2 installation packages, and Wine will be used to unpack the ".msi" files.
- If DONTGETMPICH2, then the script will assume that MPICH2 was set up manually.
- WM_PSTREAMLINK - this variable allows control over the linking method that is with the Pstream library. Two options are available:
8 Build the cross compiler
- Open a new terminal window or tab, so the edited file $HOME/.bashrc is executed, thus setting up the chosen OpenFOAM development environment (see Tweaking environment options).
- Now go to the ThirdParty-1.6 folder, in your new terminal:
cd $WM_THIRD_PARTY_DIR
- Now you have to build the cross-compiler. Accordingly to the version you picked, you have type one of the following versions:
- to build the mingw32 version, run:
./build-mingw32 gcc-4.3.3
- to build the mingw-w32 version, run:
./build-mingw-w32
- to build the mingw-w64 version, run:
./build-mingw-w64
- to build the mingw-w64-45 version, run:
./build-mingw-w64-45
./makeGcc gcc-4.3.3
This will launch the respective build-mingw* script, according to the environment settings, but gcc-4.3.3 will only be used for mingw32; and the script build-mingw-w64-45 isn't called from makeGcc.
NOTE: updates are bound to be done to the packages that these scripts use. Therefore, you should edit the script you have chosen, and check accordingly:- mingw32 - search for:
BINUTILS_ARCHIVE="binutils-2.19.1-src.tar.gz" MINGW_ARCHIVE="mingwrt-3.15.2-mingw32-dev.tar.gz" W32API_ARCHIVE="w32api-3.13-mingw32-dev.tar.gz" REGEX_ARCHIVE="mingw-libgnurx-2.5.1-bin.tar.gz" REGEX2_ARCHIVE="mingw-libgnurx-2.5.1-dev.tar.gz"
And check if they still exist or newer exists, on their website.
WARNING Glitches in build-mingw32 have been found - these will be fixed in a future patch version: in case you are unable to build the cross-compiler, then you need to do the following fixes:
- edit the build-mingw32 script;
- go to the line 64, that has
TARGET=mingw32
and change toTARGET=i686-pc-mingw32
- add in the next line:
GCCVERSION=$1
- mingw-w?? - search for:
MINGW64PACKAGE="mingw-w64-src_4.4.1-1"
And check here for new versions. Usually the package is around 80MB in size. The line:
MINGW64PACKAGE2="mingw-w64-crt-release-1.0"
Relates to the stable run-time source version, available at cadforte. For the package mingw-w64-src_4.4.1-1, this was necessary, because this wasn't the stable version yet. You can change either variables; you might even want to comment MINGW64PACKAGE2 and related items to it, if you deem the package indicated in MINGW64PACKAGE to be stable enough.
NOTE: if cadforte is offline, then search for the source snapshots available here, and you might need to change two lines at build-mingw-w?? that have:
MINGW64_URL2="http://www.cadforte.com/downloads/crt/stable_branch" (...) cp -rf mingw-w64/trunk/* mingw/
To:
MINGW64_URL2=MINGW64_URL (...) cp -rf mingw-w64/* mingw/
The ellipsis (...) indicated that there are dozens of lines separating the two lines to be changed.
- to build the mingw32 version, run:
9 Cross-Compile OpenFOAM in Linux for Windows
- Open a new terminal window or tab, so it will reset environment variables and add the newly built cross-compiling gcc into the executable path variable (see Tweaking environment options). Go to the project folder as so:
cd $WM_PROJECT_DIR
- Go to the folder "OpenFOAM-1.6" and run "Allwmake":
./Allwmake
This will build the entire OpenFOAM package. This does not include: Paraview, ccm26ToFoam, OpenMPI and code documentation. - Optional - If you want to create a CHM file in Windows, which will have the whole documentation in a single Compressed HTML index.chm file, then copy the file at the folder pnb, as such:
cp ../pnb/Doxyfile ./doc/Doxygen/
Now, to recompile the code documentation, you should have added doc to ./Allwmake, as so:
./Allwmake doc
Or, after ./Allwmake is all done, run:
./doc/Allwmake
In the chapter Creating a Compiled HTML file for the code documentation is explained how to finish this step.
- Optional - To build the mesh conversion utility ccm26ToFoam, just run:
$FOAM_APP/utilities/mesh/conversion/Optional/Allwmake
The rest is done automatically, including downloading the libraries used for handling ccm files, and patching where necessary. - Optional, but essential for testing MPICH2, as described in this parent's page chapter Using MPICH2 with OpenFOAM in Windows - Build the parallel test application:
cd $WM_PROJECT_DIR wmake applications/test/parallel
The built executable will be placed in the folder $HOME/OpenFOAM/$USER-1.6/application/bin/$WM_OPTIONS, or $FOAM_USER_APPBIN for short.
10 Copying the files to your Windows installation
- The folders from $HOME/OpenFOAM that you have to copy are:
- OpenFOAM-1.6/applications/bin/$WM_OPTIONS
- OpenFOAM-1.6/etc
- OpenFOAM-1.6/bin
- OpenFOAM-1.6/tutorials
- OpenFOAM-1.6/lib/$WM_OPTIONS
- OpenFOAM-1.6/doc (optional)
- ThirdParty-1.6/mpich2-1.1.1p1/platforms/$WM_OPTIONS (or one of the versions you chose)
- ThirdParty-1.6/mpich2-1.1.1p1/source (optional, only if get-mpich2 is used)
- $USER-1.6/applications/bin/$WM_OPTIONS (created in step 5 of the chapter Cross-Compile OpenFOAM in Linux for Windows)
tar -chjf OpenFOAM.$WM_OPTIONS.tar.bz2 OpenFOAM-1.6/applications/bin/$WM_OPTIONS \ OpenFOAM-1.6/etc OpenFOAM-1.6/bin OpenFOAM-1.6/tutorials OpenFOAM-1.6/lib/$WM_OPTIONS \ OpenFOAM-1.6/doc ThirdParty-1.6/mpich2-1.1.1p1/platforms/$WM_OPTIONS \ $USER-1.6/applications/bin/$WM_OPTIONS ThirdParty-1.6/mpich2-1.1.1p1/source
Or for an even smaller package:
tar --lzma -chf OpenFOAM.$WM_OPTIONS.tar.lzma OpenFOAM-1.6/applications/bin/$WM_OPTIONS \ OpenFOAM-1.6/etc OpenFOAM-1.6/bin OpenFOAM-1.6/tutorials OpenFOAM-1.6/lib/$WM_OPTIONS \ OpenFOAM-1.6/doc ThirdParty-1.6/mpich2-1.1.1p1/platforms/$WM_OPTIONS \ $USER-1.6/applications/bin/$WM_OPTIONS ThirdParty-1.6/mpich2-1.1.1p1/source
-
Optional - In case you have built more than one OpenFOAM version (mingw32 mingw-w32 mingw-w64), pack the whole bin and lib folders as so:
tar --lzma -chf OpenFOAM.mingw.tar.lzma OpenFOAM-1.6/applications/bin OpenFOAM-1.6/etc \ OpenFOAM-1.6/bin OpenFOAM-1.6/tutorials OpenFOAM-1.6/lib OpenFOAM-1.6/doc \ ThirdParty-1.6/mpich2-1.1.1p1/platforms $USER-1.6/applications/bin
- In order to recreate a folder base folder similar to the Linux setup, do the following steps:
- Copy the resulting compressed file to your Windows installation.
- Create a folder named OpenFOAM, wherever you wish to have OpenFOAM running in Windows.
- Copy/Move the file compressed file into that folder.
- Unpack it using a compatible application. In case you don't know or have any, a suggestion is 7zip, available here.
- Unpack the PatchesNBatches.tar.gz file to your OpenFOAM base folder in Windows. The following files should be copied from the folder pnb to the base folder OpenFOAM:
- DOS_Mode.bat
- setvars.bat
- set USER=ofuser
- set USERNAME=ofuser
- rem PICK ONE: dummy or MPICH
- rem set WM_MPLIB=dummy
- set WM_MPLIB=MPICH
- In order to get MPICH2 batch file to run in this command line, you'll have to copy the file pnb\gompi.bat to the folder OpenFOAM-1.6\bin.
MPICH2 will only work properly if you install it in Windows. If you used get-mpich2 script in Linux (see Getting Windows version of MPICH2 into the ThirdParty-1.6 folder in Linux), you should have the installation file(s) in the folder ThirdParty-1.6\mpich2-1.1.1p1\source, that came with the compressed file that has the cross-compiled OpenFOAM.
Now, you have (at least) two possible solutions:
- Replicate the structure as in Linux - After installing MPICH2 in Windows, you can copy the binary folder to the respective version of cross-compiled OpenFOAM. For example C:\Program Files\MPICH2\bin or C:\Program Files (x86)\MPICH2\bin for the 32bit version in Windows x64.
The targeted folders to hold the contents of the MPICH2 bin folder, are:
- ThirdParty-1.6\mpich2-1.1.1p1\platforms\linuxmingw32DPOpt\bin
- ThirdParty-1.6\mpich2-1.1.1p1\platforms\linuxmingw-w32SPOpt\bin
- ThirdParty-1.6\mpich2-1.1.1p1\platforms\linuxmingw-w32DPOpt\bin
- ThirdParty-1.6\mpich2-1.1.1p1\platforms\linuxmingw-w64DPOpt\bin - this should have the 64bit version of MPICH2
- Edit the file setvars.bat and add the bin folder of your MPICH2 installation to the PATH variable near the end of the batch file. For example, add
;C:\Program Files\MPICH2\bin
to the end of line that starts with:set PATH=%PATH%;
CAUTION: on Windows x64, this solution will require additional tweaking to the setvars.bat, in case you want to run both versions (32 and 64bit) of OpenFOAM, in order to add;C:\Program Files\MPICH2\bin
or;C:\Program Files (x86)\MPICH2\bin
accordingly to the desired version.
- Replicate the structure as in Linux - After installing MPICH2 in Windows, you can copy the binary folder to the respective version of cross-compiled OpenFOAM. For example C:\Program Files\MPICH2\bin or C:\Program Files (x86)\MPICH2\bin for the 32bit version in Windows x64.
The targeted folders to hold the contents of the MPICH2 bin folder, are:
- In order to get Paraview batch file to run in this command line, you'll have to copy the file pnb\paraFoam.bat to the folder OpenFOAM-1.6\bin.
Paraview should be installed in, or copied to, one of the following folders, according to the versions installed:
- ThirdParty-1.6\paraview-3.6.1\platforms\linuxmingw32
- ThirdParty-1.6\paraview-3.6.1\platforms\linuxmingw-w32
- ThirdParty-1.6\paraview-3.6.1\platforms\linuxmingw-w64
For more information on how to build Paraview for Windows with OpenFOAM file handling, see the chapter Building Paraview in Windows. - Tip: with some tweaking of the OpenFOAM scripts in the folder OpenFOAM-1.6\bin, it is possible to run OpenFOAM with MSys. This way you have more functionalities and a near Linux experience with OpenFOAM. And for MPICH2, you might want to make a copy of mpiexec.exe to mpirun.exe.
11 Creating a Compiled HTML file for the code documentation
As described in the chapter Cross-Compile OpenFOAM in Linux for Windows, you can created a Compiled HTML file of the code documentation, from the Doxygen files re-compiled in that chapter. Keep in mind that this is an optional feature. The code documentation can prove useful in situations where the manuals prove to be insufficient to explain the more intrinsic details about the case dictionaries.
- When you packed the files for transport from Linux to Windows (see Copying the files to your Windows installation), you should have included the OpenFOAM-1.6/doc folder, and it should be available in your Windows installation.
So, check if you have the files index.hhp, index.hhc and index.hhk in the folder OpenFOAM-1.6\doc\Doxygen\html. If:
- Only these 3 files seem to be missing, you'll have to go back to the chapter Cross-Compile OpenFOAM in Linux for Windows and follow the steps that talk about code documentation.
- No files exist in that folder, go back to the chapter Copying the files to your Windows installation and check if you copied the doc folder.
- Get and install the HTML Help Workshop, which is available here, so you can use it to compile the HTML files into a single CHM file.
- Now launch the OpenFOAM Command Window (run DOS_Mode.bat). Do:
cd OpenFOAM-1.6\doc\Doxygen subst K: .
This will make the folder OpenFOAM-1.6\doc\Doxygen be also a virtual drive, letter K. Use another letter if that is already occupied. Don't close the command window.
NOTE:This step is required, because HTML Help Workshop is a very old application (copyright 1996-1999) and is very picky and simple application. So long path names aren't very tolerable.
- Launch the application HTML Help Workshop from Windows. On the window HTML Help Workshop, go to the menu command File->Open and open the file K:\html\index.hhp.
- Optional - you can change the target path and name for the index.chm file in the left side bar, that appears when you open the project. Double click on the line Compiled file=index.chm. As said before, keep paths simple. Best advice would be ..\index.chm, since it is a short relative path, and will be away from the +46700 files that exist inside the html folder.
- Run the Compile command (File->Compile). It will take some time to compile. Hopefully it won't crash.
- If it hasn't crashed, then you will have a brand new 74MiB [1] index.chm file, with added index and search functions. NOTE: the Search for edit box in the top right of the page won't work. Use the left side bar that comes with the index.chm help window.
- Cleaning up:
- In the Command Window that you opened a while ago, remove the virtual drive letter, by running:
subst K: /D
You can now close that command window. - Copy the index.chm file to a safe place, and remove the html folder in OpenFOAM-1.6\doc\Doxygen. WARNING: to remove the +46700 files that exist therein, will take a very long time.
- In the Command Window that you opened a while ago, remove the virtual drive letter, by running:
12 Notes on what doesn't work and why
12.1 chtMultiRegionFoam doesn't work properly
The solver chtMultiRegionFoam now does work properly on Windows, but you have to do some tweaking to the files that refer to the file K. This is due to a file name conflict of k and K. The field name K is hard-coded in the executable, and it isn't changeable via the case files changeDictionaryDict. But the current patches take care of this, by defining for the Windows build that the K field is written on the KK file.
The changes necessary to the naming of the field K, on the chtMultiRegionFoam cases, taking as an example the tutorial case heatTransfer/chtMultiRegionFoam/multiRegionHeater:
- If at the folder 0 there is only one file k or K and no KK, then you need to rename the K file to KK before packaging in Linux.
- Inside the folder system, there are 5 folders of the regions of the heater, namely: bottomAir heater leftSolid rightSolid topAir. For each region, edit the changeDictionaryDict file, and change (only when found):
neighbourFieldName T; K K; (...) } K {
To:
neighbourFieldName T; K KK; (...) } KK {
- While still inside the folder of each region, also edit the files fvSchemes and change (where needed):
laplacian(KK,T) Gauss linear limited 0.333;
To:
laplacian(K,T) Gauss linear limited 0.333;
- Edit the file Allrun at the base of the case folder, and change:
rm -f 0*/$i/{cp,K,rho}
To:
rm -f 0*/$i/{cp,KK,rho}
The source code change that was implemented, and that you should keep in mind when making your OpenFOAM applications was done in the files:
OpenFOAM-1.6/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H OpenFOAM-1.6-1/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H
And just modified the reference to K like this:
#if defined( WIN32 ) || defined( WIN64 ) "KK", #else "K", #endif
12.2 motorBike case and foamToVTK in Windows
If you want to use foamToVTK on the tutorial case motorBike, you will have to run the script fixToWindows available at the motorBike case, so it can fix the surface names with "%" in the STL file and in some of the case dictionaries. The script can be executed on MSys or on Linux.
12.3 motorBike case in the package OpenFOAM-1.6.General.gtgz doesn't work well
The motorBike case available with the original 1.6 package doesn't work properly. These patches will not fix it. Please get the OpenFOAM 1.6.x git version, if you want a working motorBike case.
12.4 foamToVTK made .vtk files that Paraview can't read
This is likely still a bug that occurs in creating binary VTK files in Windows. Please use the switch -ascii for creating these files:
foamToVTK -ascii
Additionally, sometimes the folder 0 (the start time for the simulation), doesn't have valid mesh information. For these situations, use the switch -time or -latestTime, for retrieving specific time snapshots. For example, for 500s, use:
foamToVTK -time 500
For the latest time snapshot, use:
foamToVTK -latestTime
12.5 Can't build cross-compiler version mingw32 in Linux x86_64
With the build script for mingw32, that comes in these patches, can't build its cross-compiler under Linux x86_64 out-of-the-box.
Solution: instructions are already available in the section Build the cross compiler.
12.6 libscotch is limited in Windows
The library libscotch can't handle compression in Windows, due to nonexistent native Windows pipe and fork functions. MSys and Cygwin have these implemented, but effort has not been invested in re-implementing them here.
12.7 Fast memory allocation issues in Windows
Hoard and fbsdmalloc are not enabled for the mingw versions.
Solution:There is a native build winhoard library online, but effort was not put into this for now. An implementation of fbsdmalloc wasn't found for mingw nor native Windows.
12.8 Symbolic links in the tutorials
To copy the tutorials properly to Windows, use the command:
tar -chjf ../tutorials.tar.bz2 tutorials
at the folder $HOME/OpenFOAM/OpenFOAM-1.6. The h switch will make copies of the symbolically linked folders and files, thus removing the symbolic links. You can then uncompress the tutorials.tar.bz2 file in your Windows installation.
12.9 Building OpenFOAM with gcc-4.4.? and gcc-4.5.0
To get OpenFOAM to build with gcc-4.4.? and gcc-4.5.0, I used the information available here.
12.10 Open MPI in Windows
Building Open MPI with the mingw cross-compilers was not tested. References to it currently running in Windows using mingw have not been found.
Solution: For MPI functionality, MPICH2 is used in these patches.
NOTE: Since OpenMPI's version 1.3.3, it's officially possible to build it using Visual Studio. But since MPICH2 is already available in ready to use packages, and no comparison between both has been found so far (14:43, 22 July 2010 (UTC)) then no effort has been put into place into integrating this method. Nonetheless, if someone desires to try this, check the patches available in this wiki page, since they have script code for exporting symbols from already built Windows DLLs and generating the library interface compatible with gcc.
12.11 Cross-compiled version mingw-w64 takes longer to start applications
After some investigation, it seems that due to mingw-w64 still being in fierce development (still considered somewhat like beta), the mingw-w64 version of OpenFOAM takes about 12 seconds (much more if executed in virtual machines) to start each application in Windows x64. The 32bit versions take 3 seconds or less, depending the machine type (virtual or real). During that period, the Task Manager shows that the memory is being slowly filled. Profiling blockMesh was also tested, to try to isolate the problem (see Profiling OpenFOAM applications with mingw cross-compiled version), but the statically built profiling version of blockMesh, booted in less than a second. So, there are at least two possible conclusions:
- The OpenFOAM libraries do some matrix/memory allocations and/or re-allocations, when they are loaded by the applications;
- The mingw-w64 version still has issues with loading multiple DLLs from within DLLs and all that...
12.12 Some tutorials don't work in Windows
Some tutorials require building auxiliary executables or libraries. These have to be cross-compiled in Linux.
The tutorials are:
basic\potentialFoam\cylinder compressible\rhoCentralFoam\biconic25-55Run35 heatTransfer\buoyantPisoFoam\hotRoom incompressible\MRFSimpleFoam incompressible\simpleSRFFoam lagrangian\rhoPisoTwinParcelFoam multiphase\interDyMFoam\ras\sloshingTank3D6DoF multiphase\interFoam\MRFInterFoam
12.13 Tutorial scripts don't work in Windows
Actually, they work, but only if you use the MSys terminal. If you want to stick to the Windows Command Line, then use the sh.exe executable that comes with MSys (should be visible in the search PATH, i.e., add the MSys bin folder to the setvars.bat file). For example, running the Allrun script in a tutorial case, do like so:
sh Allrun
12.14 DOS_Mode.bat won't allow choosing which version to use
Apparently, choice.exe isn't installed by default on all Windows versions. You have two choices:
- Install the resource kit that should be in your Windows CD/DVD.
- Download the version that came with the Windows 98 resource kit from here, and put it in the base folder of your OpenFOAM installation.
13 Notes on added functionalities with these patches
13.1 Building ccm26ToFoam
ccm26ToFoam builds properly with these patches, because the fixes in the git version are also in these patches; the missing Make files for the ccm26io library are also in a patch file created in the ThirdParty-1.6 folder. The Make files came from this post. To build ccm26ToFoam, run the script in Linux:
$FOAM_APP/utilities/mesh/conversion/Optional/Allwmake
13.2 Keeping track of symbolic links in tutorials
Running the script tutowin at the folder $HOME/OpenFOAM/OpenFOAM-1.6, you will be shown the tutorial folders that are symbolically linked. Use this list as a reference to where you should create README files, indicating where folders will be copied from. For the tutorials available in the OpenFOAM 1.6, this is already done by these patches. So you can use tutowin for future updates.
13.3 Changes in settings.sh
The script settings.sh has been modified quite a bit. The platform build names for gcc have been changed to include the architecture, and gcc-4.4.2 has been added to the list of compilers. The dummy libPstream has been added as an MPI library named NONE, so libPstream will be added to the library search path.
13.4 Building locally with multiple cores
The bashrc-* scripts have integrated in them the automatic selection of how many cores to use to build. This was copied from the makeGcc build script available in the $HOME/OpenFOAM/ThirdParty-1.6.
13.5 Building mingw cross-compilers
Build scripts have been added to the folder $HOME/OpenFOAM/ThirdParty-1.6, to aid in building mingw32, mingw-w32 and mingw-w64 cross-compilers.
13.6 Getting MPICH2 automatically in Linux
A script named get-mpich2 for creating a library link object for MPICH2MPI.DLL. This way it doesn't need to download the files into your Linux machine nor does it need Wine to unpack. To update the definition files and header files, check the contents of the folder ThirdParty-1.6/mpich2-1.1.1p1 and see what header files are needed and copy them from an MPICH2 installation folder in your Windows machine. The definition files were retrieved from the source package of MPICH2.
The other hypothesis, is to install MPICH2 firstly in Windows and copy the files to your Linux+OpenFOAM setup (see Getting Windows version of MPICH2 into the ThirdParty-1.6 folder in Linux).
13.7 Compiling HTML files into CHM
Doxyfile is available as a separate file, inside the package PatchesNBatches.tar.gz. See chapter Creating a Compiled HTML file for the code documentation for more information.
13.8 Creating new patches
$HOME/OpenFOAM/OpenFOAM-1.6/bin/foamDiff is a script created specifically for creating these patches, without requiring to cleanup the binaries and lnIncludes. It requires that you have a second mint condition folder with the original files. In other words, your $HOME/OpenFOAM folder should have, for example, the folders:
OpenFOAM-1.6 OpenFOAM-1.6-orig ThirdParty-1.6 ThirdParty-1.6-orig
Then use foamDiff from the folder $HOME/OpenFOAM as so:
foamDiff OpenFOAM-1.6 OpenFOAM-1.6-orig OpenFOAM-1.6_patch_new foamDiff ThirdParty-1.6 ThirdParty-1.6-orig ThirdParty-1.6_patch_new
Legend: foamDiff <FolderNew> <FolderOrig> <patch_name>
13.9 MPFR 2.4.1 was missing 3 files
The mpfr-2.4.1 folder that comes with the original ThirdParty-1.6.General.gtgz package is missing 3 files: log2.c, log1p.c and log10.c. These are added by the patches.
13.10 Profiling OpenFOAM applications with mingw cross-compiled version
Profiling with mingw isn't as clean as with Linux, since mingw doesn't support DLL profiling. So some tweaks have been made to make it possible to build fully static executables... but for now, only blockMesh and potentialFoam are working with the Prof option. See the options file in the Make folder on each of these application source code folders, to see what needs to be done on the other applications.
13.11 Backing up development folders
Although OpenFOAM already comes with scripts for packing the source codes and builds, it doesn't suit every type of backing up solution. These patches give you two additional scripts for backing up:
backupFullFolder the_folder
This will do a full backup of your folder to the file the_folder.Full.mingw.(date).tar.bz2 where (date) is the date of when you do the backup. It is designed to do a full backup of the folders ThirdParty-1.6 and OpenFOAM-1.6, but should work with any folder.backupSourceFolder the_folder
This will do a backup of only the source files of your folder to the file the_folder.Source.mingw.(date).tar.lzma where (date) is the date of when you do the backup. It is designed to do a full backup of only the files that are source codes and aren't downloadable without additional independent patching, without the need to remove files and folders from your builds. Once again, this script is designed to work with the folders ThirdParty-1.6 and OpenFOAM-1.6, but should work with any folder that exists in the workspace of OpenFOAM.
14 History
Wyldckat 14:48, 22 July 2010 (UTC) - Finished updating information. Hopefully these patches will be updated in the near future...
Wyldckat 13:46, 22 July 2010 (UTC) - Moved from Cross Compiling OpenFOAM in Linux For Windows with MinGW.