How to compile and install OpenFOAM on Mac OS X - OpenFOAMWiki
How to compile and install OpenFOAM on Mac OS X - OpenFOAMWiki
How to compile and install OpenFOAM on Mac OS X - OpenFOAMWiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Michael Plagge<br />
<str<strong>on</strong>g>How</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>compile</str<strong>on</strong>g> <str<strong>on</strong>g>and</str<strong>on</strong>g> <str<strong>on</strong>g>install</str<strong>on</strong>g> <str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g> <strong>on</strong> <strong>Mac</strong> <strong>OS</strong> X<br />
Last changed: January 22nd, 2012<br />
Revisi<strong>on</strong>: 0.1
C<strong>on</strong>tents<br />
1 Basic requirements 4<br />
2 Installing <str<strong>on</strong>g>and</str<strong>on</strong>g> compiling <str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g> 2.1 with GCC 4.2 <str<strong>on</strong>g>and</str<strong>on</strong>g> OpenMPI 1.5.4 7<br />
3
1 Basic requirements<br />
This manual assumes that the reader is familiar with <strong>Mac</strong> <strong>OS</strong> X, the <str<strong>on</strong>g>install</str<strong>on</strong>g>ati<strong>on</strong> of<br />
applicati<strong>on</strong>s as well as with basic comm<str<strong>on</strong>g>and</str<strong>on</strong>g>s in the Terminal.app. This manual covers<br />
the <str<strong>on</strong>g>install</str<strong>on</strong>g>ati<strong>on</strong> of <str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g> <strong>on</strong> <strong>Mac</strong> <strong>OS</strong> X 10.6.8, also called Snow Leopard.<br />
What do you need?<br />
• Apple <strong>Mac</strong> <strong>OS</strong> X 10.6.8<br />
• Apple Developer Tools 3.2.6 (delivered <strong>on</strong> the DVDs you’ve got with your mac, or<br />
you can download this here: http://developer.apple.com/)<br />
• <strong>Mac</strong>Ports software, you can download this here: http://www.macports.org<br />
For downloading the Apple Developer Tools you might have <str<strong>on</strong>g>to</str<strong>on</strong>g> become a member of<br />
the Apple developer site, it is for free yet.<br />
<str<strong>on</strong>g>How</str<strong>on</strong>g> do I know if the above meti<strong>on</strong>ed software is already <str<strong>on</strong>g>install</str<strong>on</strong>g>ed?<br />
Open the Terminal.app you find in your /Applicati<strong>on</strong>s/Utilities folder:<br />
4
Type gcc -v, the output should look like this:<br />
Check for the MPI <str<strong>on</strong>g>install</str<strong>on</strong>g>ati<strong>on</strong> as well by typing mpirun -V, please note that the<br />
opti<strong>on</strong> is different (-V instead of -v):<br />
After <str<strong>on</strong>g>install</str<strong>on</strong>g>ing the <strong>Mac</strong>Port software, see http://www.macports.org/<str<strong>on</strong>g>install</str<strong>on</strong>g>.php for<br />
<str<strong>on</strong>g>install</str<strong>on</strong>g>ati<strong>on</strong> guide, we check the <str<strong>on</strong>g>install</str<strong>on</strong>g>ati<strong>on</strong> with sudo port selfupdate, you have <str<strong>on</strong>g>to</str<strong>on</strong>g><br />
c<strong>on</strong>firm the sudo with your password:<br />
5
Now we are <str<strong>on</strong>g>install</str<strong>on</strong>g>ing the GCC 4.6 by entering<br />
sudo port <str<strong>on</strong>g>install</str<strong>on</strong>g> gcc46<br />
<strong>on</strong> the comm<str<strong>on</strong>g>and</str<strong>on</strong>g> line. After the operati<strong>on</strong> is d<strong>on</strong>e you could check the versi<strong>on</strong> <str<strong>on</strong>g>and</str<strong>on</strong>g> it<br />
should look like this:<br />
6
2 Installing <str<strong>on</strong>g>and</str<strong>on</strong>g> compiling<br />
<str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g> 2.1 with GCC 4.2<br />
<str<strong>on</strong>g>and</str<strong>on</strong>g> OpenMPI 1.5.4<br />
First, we create a disk image with the Apple Disk Utility. Open /Applicati<strong>on</strong>s/Utilities/Disk<br />
Utility. Click New Image:<br />
7
It is important <str<strong>on</strong>g>to</str<strong>on</strong>g> set as Format: <strong>Mac</strong> <strong>OS</strong> Extended (Case-sensitive,Journaled). The<br />
sparseimage will grow with the place used inside the image. Create a sparseimage with<br />
the following settings (examples, you could change the values):<br />
Go <str<strong>on</strong>g>to</str<strong>on</strong>g> the direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry of the image by typing cd /Volumes/<str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g>-v2.1:<br />
Use a browser <str<strong>on</strong>g>to</str<strong>on</strong>g> download the archives of OpenFoam 2.1 <str<strong>on</strong>g>and</str<strong>on</strong>g> ThirdParty 2.1 from<br />
8
http://openfoam.org/download/source.php <str<strong>on</strong>g>and</str<strong>on</strong>g> copy the archives in<str<strong>on</strong>g>to</str<strong>on</strong>g> the image. Extract<br />
the archives by double clicking <strong>on</strong> each <strong>on</strong>e.<br />
Then download the patches created by Bernhard Gschaider, see<br />
http://www.cfd-<strong>on</strong>line.com/Forums/openfoam-<str<strong>on</strong>g>install</str<strong>on</strong>g>ati<strong>on</strong>-windows-mac/95763-1-9-aka-<br />
2-1-mac-os-x.html#post340297<br />
Copy or move them in<str<strong>on</strong>g>to</str<strong>on</strong>g> the image. Your image c<strong>on</strong>tent should look like this:<br />
Move the appropriate patches in<str<strong>on</strong>g>to</str<strong>on</strong>g> the direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries, see below:<br />
9
Change in<str<strong>on</strong>g>to</str<strong>on</strong>g> the <str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry <str<strong>on</strong>g>and</str<strong>on</strong>g> apply the first patche via patch -p1 <<br />
*.patch:<br />
The end of the output should look like this:<br />
Add executive rights <str<strong>on</strong>g>to</str<strong>on</strong>g> a pyth<strong>on</strong> script like this:<br />
10
Apply the sec<strong>on</strong>d patch for the <str<strong>on</strong>g>compile</str<strong>on</strong>g>r, in this case we use the GCC 4.6 so choose<br />
the right patch by typing<br />
patch -p1 < <str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g>-2.1.x-<strong>Mac</strong>-gcc46.patch<br />
Open the file /etc/bashrc with a text edi<str<strong>on</strong>g>to</str<strong>on</strong>g>r, e. g. Text Wrangler or pico <str<strong>on</strong>g>and</str<strong>on</strong>g> add<br />
these lines:<br />
u l i m i t −n 1024<br />
export WM_NCOMPPROCS=20<br />
The first entry is <str<strong>on</strong>g>to</str<strong>on</strong>g> increase the number of files which <strong>on</strong>e process may open at a<br />
time, the sec<strong>on</strong>d you should set <str<strong>on</strong>g>to</str<strong>on</strong>g> the number of processes your CPU could manage in<br />
parallel, e. g. 4, 8, 16, ...<br />
11
It should look like this:<br />
Go back <str<strong>on</strong>g>to</str<strong>on</strong>g> your home direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry by simply typing cd. Then create a symbolic link<br />
with ln -s /Volumes/<str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g>-v2.1 <str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g>.<br />
Go back <str<strong>on</strong>g>to</str<strong>on</strong>g> your home direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry again. Now you have <str<strong>on</strong>g>to</str<strong>on</strong>g> source the settings by .<br />
<str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g>/<str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g>-2.1.0/etc/bashrc:<br />
12
No error or other output should occur.<br />
13
Now we go <str<strong>on</strong>g>to</str<strong>on</strong>g> the <str<strong>on</strong>g>OpenFOAM</str<strong>on</strong>g> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry <str<strong>on</strong>g>and</str<strong>on</strong>g> start compilati<strong>on</strong>. Take a coffee. And a<br />
cookie. Or two:<br />
If you want <str<strong>on</strong>g>to</str<strong>on</strong>g> keep a logfile in case of errors, type ./Allwmake | tee Allwmake.log.<br />
You’re d<strong>on</strong>e.<br />
14