0% found this document useful (0 votes)
120 views

Compilation of Openfoam in Redhat Linux: Tar XVF Openfoam-2.1.0.Tgz

A FULL DETAILED TUTORIAL DOCUMENT ON HOW TO BUILD ANY VERSION OF OPENFOAM LOCALLY ON A SYSTEM WITHOUT ADMINISTRATOR RIGHTS

Uploaded by

Awadh Kapoor
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

Compilation of Openfoam in Redhat Linux: Tar XVF Openfoam-2.1.0.Tgz

A FULL DETAILED TUTORIAL DOCUMENT ON HOW TO BUILD ANY VERSION OF OPENFOAM LOCALLY ON A SYSTEM WITHOUT ADMINISTRATOR RIGHTS

Uploaded by

Awadh Kapoor
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Compilation of OpenFOAM in RedHat Linux

Following files should be needed for compilation of OpenFOAM in RedHat linux:


OpenFOAMversion (Use Current version like OpenFOAM-2.1.0)
ThirdParty-2.1.0
Untar files using tar xvf OpenFOAM-2.1.0.tgz

There are some other Third party tools also required for compilation.
Gcc-4.4.3
Gmp-5.0.1
Mpfr-2.4.2
Cmake-2.8.3
Qt-4.6.2
Flex-2.5.35
Create one Directory. And that Directory should be named like OpenFOAM under
opt
Copy the OpenFOAM-2.0.1 and ThirdParty-2.1.0 and all other Thirdparty tools,
mentioned above in to newly
Created directory ( OpenFOAM).
Before compiling OpenFOAM,
check the gcc version. gcc

version Gcc is

nothing but

compiler.
And check the gcc version of
OpenFOAM. Those Information is
also available in the bashrc file.
By default it was set to Gcc. Then
see the
OpenFOAM2.1.0/etc/config/settings.sh file.
Here Gcc is like gcc-4.6.2.
According to OpenFOAM website,
they mentioned like gcc-4.4.3 is
recommended and gcc-4.3.3 is
also acceptable.
So, see the lines related to Gcc in
sttings .sh file. Pickup gcc-4.4.3
content, Under Gcc-4.4.3 there
are two more thirdparty tools like
gmp-5.0.1 and mpfr-2.4.2.
Change Gcc version from Gcc to
Gcc44 in the bashrc file.

One more change in the bashrc file. In the beginning of the lines there is a line called
foamInstall. By default it is set to $HOME/WM_PROJECT. Comment out that line
using # symbol. And uncomment out the line like opt/WM_PROJECT by removing the
# symbol. Because, All the OpenFOAM files are under opt.
In OpenFOAM-2.1.0/etc/bashrc , see the foamCompiler lines. By default it is set to
system. Change it to OpenFOAM. So that compiler will take the Gcc44 only.
Go to opt location and enter in to OpenFOAM directory. And Again enter in to
OpenFOAM-2.10 directory. Then source the settings file by using command like
source etc/bashrc
Then it will give the warning like gcc-4.4.3 is not available in the thirdParty Ignore this
warning and continue to the next step below:
Put compressed files of gcc-4.4.3, mpfr-2.4.2 and gmp-5.0.1 in the thirdparty directory.
First uncompress those folders. There is a makeGcc script in the thirdparty directory.
We need to edit this script. Change the gcc version from 4.5.2 to gcc-4.4.3. And there is
a n another thirdParty library called mpc. This library does not require for versions
before gcc-4.5. currently we are using gcc-4.4.3. So mpc does not require.
So comment all the information related to mpc . (i.e) delete all the information related
to mpc. And also comment out line No from 194 to 235 in the makeGcc script.
Then run the makeGcc script . It will take half an hour time approx. It depend up on the
processor speed.
Then source the OpenFOAM settings once again. Above mentioned warning will not
appear from this time. Because,l We compiled latest Gcc version. Now check the Gcc
version, Using command like gcc version . It should be like Gcc-4.4.3.

Compilation of Flex

Flex compilation is required for the compilation of OpenFOAM-2.1.0. There is a


preprocessor for the OpenFOAM called snappyHexMesh. stl mesh is the base
mesh for this snappyHexMesh. Since stl is a ThirdParty, We need to compile flex to
work it out.
Download flex-2.5.35.tar.gz file. And uncompress this this file.
This file is also must be in the OpenFOAM directory. Create another folder called flex in
the same location.
Then enter in to flex-2.5.35 and there is a file name called INSTALL in that folder.
Read that file carefully.
1) Then type ./configure --prefix=/opt/OpenFOAM/flex
By using prefix, All the flex libraries are stored in the newly created folder called
flex.
2) Then type make.
3) Then type make installx
Then there are some subfolders like lib , bin , doc , doc , man , include etc under flex
directory.
Type command like pwd. It will show like /opt/OpenFOAM/flex/

Then type the following lines. These lines are nothing but setting the environment
variables of Flex for OpenFOAM compilation.
export LD_LIBRARY_PATH=/opt/OpenFOAM/flex/lib:$LD_LIBRARY_PATH
export PATH=/opt/OpenFOAM/flex/bin:PATH
Then check the version of Flex, Using command like flex version. It will show like
2.5.35.
As per mentioned in the above lines, Under newly created directory called flex, There is
a subfolder called include. In include directory, there is a file name called
FlexLexer.H. Copy that file in to the OpenFOAM-2.1.0/src/OpenFOAM/include.

OpenFOAM compilation:

After successful compilation of Flex, Go to compilation of OpenFOAM.


Enter in to OpenFOAM-2.1.0. There is an automated script called Allwmake.
Run that script. It will take minimum two hours.
While compiling the OpenFOAM. Observe the compilation. It should not give any
errors. Normally, It will not give any errors if We follow the above procedure.
First it wil compile Thirdparty and then It wil compile OpenFOAM. In OpenFOAM, First
all the libraries will compile. You can always see the compiled libraries. Compilation will
create one New folder called platforms. It will create another subfolder called
linux64Gcc44DPOpt . Under this directory, It should be like lib and bin. All the
libraries will sit under lib and all the applications are sit under bin.
By default it will compile for Double Precision. If anybody want OpenFOAM in Single
Precision means, There is an option in the bashrc file under etc. Change from DP to
SP. And compile the ThirdParty and OpenFOAM. While compiling the OpenFOAM in
Single Precision, No need to compile gcc again. Just set the environment variables of
flex and repeat the procedure as per the DP compilation.

Paraview Compilation.

For compiling the Paraview, Two more thirdparty tools will require. Those are like
Cmake-2.8.3 and Qt-4.6.2
Download Cmake-2.8.3.tar.gz and uncompress the file.
Compile the cmake-2.8.3 using makeCmake script. Be sure that, In makeCmake script,
version will be the same that what we are having current.
Ex: If we have cmake-2.8.3 means in the script itself version is like cmake-2.8.3 only.
Then run the makeCmake script. It will create libraries and binaries.
Then set the environment variables like
export PATH=/opt/OpenFOAM/ThirdParty-2.1.0/cmake-2.8..3/bin:PATH
Then compile qt . Download Qt-4.6.2 uncompress the file and start compilation using
makeQt script. Be sure that you should have the same version in that script.
Set the environment variables for qt like
export LD_LIBRARY_PATH= opt/OpenFOAM/ThirdParty2.1.0/platforms/linux64Gcc44/qt-4.6.2/lib:$LD_LIBRARY_PATH

export PATH= opt/OpenFOAM/ThirdParty-2.1.0/platforms/linux64Gcc44/qt-4.6.2/bin:


$PATH
Then compile paraview using makeParaview script. This will take another 20mins approx
based on the processors.
Next step is to compile paraFoam. Type paraFoam in the terminal. It will show the
instructions for compilation.

You might also like