Installation/Outdated/Howto compile OpenFOAM the easy way
From OpenFOAMWiki
< Installation | Outdated
Contents
1 Introduction
This is a step-by-step guide that tries to make the installation of OpenFOAM development version as easy as possible. It is extracted from the detailed post of Jaswinder Pal Singh that you can read here [1].
1.1 Notes
- The guide provides information on how to compile the development version of OpenFOAM, without visualization tools. For more information on how to perform this task, or if you meet problems while using this procedure, please refer to the detailed compilation procedure.
- This procedure is known to work with OpenFOAM 1.4.1 on openSUSE 10.3 and 11.0
2 Preparation
- Open the SVN repository in your browser and find the URL to the most recent version of OpenFOAM-dev available in the repository or of the one you want to install. For example, for OpenFOAM 1.4.1, the URL is
http://svn.code.sf.net/p/openfoam-extend/svn/trunk/Core/OpenFOAM-1.4.1-dev/
- Use svn checkout command to download the files contained in the repository to your workstation:
svn co http://svn.code.sf.net/p/openfoam-extend/svn/trunk/Core/OpenFOAM-1.4.1-dev/
- Download gcc and java from the OpenCFD download page for the corresponding version of OpenFOAM.
- Be sure to have the following directory structure in your home directory:
OpenFOAM |_OpenFOAM-1.4.1-dev |_linux (linux64 for 64 bit systems) |_gcc-4.2.1 (or the version of gcc you downloaded) |_java (the actual directory name depends on the version of java)
3 Setting your system up for compilation
You first need to modify the script which sets the working environment for OpenFOAM as follows:
- Open the ~/OpenFOAM/OpenFOAM-1.4.1-dev/.OpenFOAM-1.4.1-dev/bashrc and edit make the following changes:
- Set the compilation option to
- opt if you want the optimized version of the code
- debug if you want the debug version of the code
- Set the environment variable WM_64 to on if you are working on a 64 bit system with
- Set the compilation option to
export WM_64=on
- Comment out the commands sourcing the script files for 3rd-party post processing utilities
- Copy the ~/OpenFOAM/OpenFOAM-1.4.1-dev/.OpenFOAM-1.4.1-dev (hidden) to your home directory
Then
- Open the file ~/.bashrc
- Add the line
. ~/.OpenFOAM-1.4.1-dev/bashrc
4 Compiling OpenFOAM-dev in steps
The approach suggested here is interactive, as a consequence it requires some patience, but it allows the errors to be found faster. The sequence to follow is:
- Compile only /src
- Compile /applications/solvers
- Compile each of the folders in the /utilities
4.1 Compiling /src
- Edit the /src/Allwmake file and comment out the compilation of applications in the first run
- Execute ./Allwmake in the /src directory
- Once the /src is compiled , re run the ./Allwmake and it will show that the there id nothing tobe done and all you core libraries are up to date.
4.2 Compiling solvers
- Edit the /applications/Allwmake and comment out the compilation of /utilities.
- Execute ./Allwmake in the applications directory. This will compile your solvers.
- Run the script one more time to be sure there are no errors.
4.3 Compiling the applications
- Open the /applications/utilities directory in a terminal.
- You will have to have to issue
wmake all <foldername>
for each folder in the /utilities .
- Special caution is required when you are compiling the /postProcessing subdirectory as it has the graphics folder which is the source cause of most of the errors and is not required in our case. Removing it is not recommended, so just skip its compilation.
- The /postProcessing directory also has the /dataConversion subdirectory, which has all the format conversion tools. All should compile correctly except the foamToVTK, because it requires the lnInclude folder from the /postProcessing/graphics/PVfoamreader/vtkFOAM/ and it is missing. Simply enter the /postProcessing/graphics/PVfoamreader/vtkFOAM/ directory and create the lnInclude folder and in there create the soft links to all the .C and .H files in the vtkFOAM folder.
5 Conclusion
At this point OpenFOAM-dev should work on your system. You can try it in this way:
- cd ~/home/alberto/OpenFOAM/OpenFOAM-1.4.1-dev/tutorials/icoFoam
- blockMesh . cavity
- icoFoam . cavity
If the tutorial case runs without problems, they installation is successful.