Difference between revisions of "Installation/Mac OS/OpenFOAM 2.1.x"
m (→Get the OpenFOAM source code and patches: bad link found and fixed) |
(→Apply patches and tweaks: added missing intructions...) |
||
Line 73: | Line 73: | ||
<pre>patch -p1 < OpenFOAM-2.1.x-Mac-gcc46.patch</pre> | <pre>patch -p1 < OpenFOAM-2.1.x-Mac-gcc46.patch</pre> | ||
− | Open the file <tt>OpenFOAM-2.1.0/etc/bashrc</tt> with a text editor, e. g. Text Wrangler, <tt>pico</tt> or <tt>nano</tt> and | + | Open the file <tt>OpenFOAM-2.1.0/etc/bashrc</tt> with a text editor, e. g. Text Wrangler, <tt>pico</tt> or <tt>nano</tt> and: |
+ | <ol> | ||
+ | <li>Find this line: | ||
+ | <pre>export WM_COMPILER=Gcc</pre> | ||
+ | And change to this: | ||
+ | <pre>export WM_COMPILER=Gcc46</pre></li> | ||
+ | <li>Add these lines: | ||
<pre>ulimit −n 1024 | <pre>ulimit −n 1024 | ||
− | export WM_NCOMPPROCS= | + | export WM_NCOMPPROCS=4</pre> |
A few notes about these two lines: | A few notes about these two lines: | ||
* Apparently it's best that you manually write these two lines instead of copy-pasting, because apparently some ''weird characters'' will show up on your file ([http://www.cfd-online.com/Forums/openfoam-installation-windows-mac/95763-1-9-aka-2-1-mac-os-x-4.html#post358504 source]). | * Apparently it's best that you manually write these two lines instead of copy-pasting, because apparently some ''weird characters'' will show up on your file ([http://www.cfd-online.com/Forums/openfoam-installation-windows-mac/95763-1-9-aka-2-1-mac-os-x-4.html#post358504 source]). | ||
− | * The first entry is to increase the number of files which one process may open at a time; | + | * The first entry is to increase the number of files which one process may open at a time; |
+ | * The second entry you should set to the number of processes your CPU could manage in parallel, e.g. 4, 8, 16, ... | ||
* If you don't know how many your machine can handle, then run: <pre>sysctl -n hw.ncpu</pre> | * If you don't know how many your machine can handle, then run: <pre>sysctl -n hw.ncpu</pre> | ||
− | + | </li> | |
+ | </ol> | ||
<br> | <br> | ||
The resulting <tt>OpenFOAM-2.1.0/etc/bashrc</tt> file should look similar to this: | The resulting <tt>OpenFOAM-2.1.0/etc/bashrc</tt> file should look similar to this: |
Revision as of 13:00, 10 May 2012
This is a transcript and subsequent improvements on the guide made by Michael Plagge. The original PDF: Compiling Manual OpenFOAm Mac OS X.pdf
Contents
1 Basic requirements
This manual assumes that the reader is familiar with Mac OS X, the installation of applications as well as with basic commands in the Terminal.app. This manual covers the installation of OpenFOAM on Mac OS X 10.6.8, also called Snow Leopard.
What do you need?
- Apple Mac OS X 10.6.8
- Apple Developer Tools 3.2.6 (delivered on the DVDs you’ve got with your mac, or you can download this here: developer.apple.com)
- MacPorts software, you can download this here: www.macports.org
For downloading the Apple Developer Tools you might have to become a member of the Apple developer site, it is still free.
How do I know if the above mentioned software is already installed?
- Open the Terminal.app, which you will find in your /Applications/Utilities folder:
- Type:
gcc -v
the output should look like this:
- Check for the MPI installation as well by typing:
mpirun -V
- After installing the MacPorts software - see www.macports.org/install.php for installation guide - we check the installation with:
sudo port selfupdate
- Now we are installing the GCC 4.6 by entering:
sudo port install gcc46
on the command line. After the operation is done you could check the version and it should look like this:
2 Installing and compiling OpenFOAM 2.1 with GCC 4.6 and OpenMPI 1.5.4
This section is divided into various sub-sections, detailing each step.
2.1 Create a disk image
First, we create a disk image with the Apple Disk Utility. Open /Applications/Utilities/Disk Utility. Click New Image:
It is important to set as Format: Mac OS Extended (Case-sensitive,Journaled). The sparse image will grow with the place used inside the image. Create a sparse image with the following settings (examples, you could change the values):
2.2 Get the OpenFOAM source code and patches
Go to the directory of the image by typing:
Use a browser to download the archives of OpenFoam 2.1 and ThirdParty 2.1 from here and copy the archives into the image. Extract the archives by double clicking on each one. Then download the patches created by Bernhard Gschaider, available here.
Copy or move them into the image. Your image content should look like this:
Move the appropriate patches into the directories, see below:
2.3 Apply patches and tweaks
Change into the OpenFOAM directory and apply the first patch via:
patch -p1 < *.patch
The end of the output should look like this:
Add executive rights to a python script like this:
Apply the second patch for the compiler, in this case we use the GCC 4.6 so choose the right patch by typing:
patch -p1 < OpenFOAM-2.1.x-Mac-gcc46.patch
Open the file OpenFOAM-2.1.0/etc/bashrc with a text editor, e. g. Text Wrangler, pico or nano and:
- Find this line:
export WM_COMPILER=Gcc
And change to this:
export WM_COMPILER=Gcc46
- Add these lines:
ulimit −n 1024 export WM_NCOMPPROCS=4
A few notes about these two lines:
- Apparently it's best that you manually write these two lines instead of copy-pasting, because apparently some weird characters will show up on your file (source).
- The first entry is to increase the number of files which one process may open at a time;
- The second entry you should set to the number of processes your CPU could manage in parallel, e.g. 4, 8, 16, ...
- If you don't know how many your machine can handle, then run:
sysctl -n hw.ncpu
The resulting OpenFOAM-2.1.0/etc/bashrc file should look similar to this:
2.4 Final preparations before building
Go back to your home directory by simply typing:
cd
Then create a symbolic link with:
ln -s /Volumes/OpenFOAM-v2.1 OpenFOAM
2.5 Source bashrc
Go back to your home directory again. Now you have to source the settings by running:
. OpenFOAM/OpenFOAM-2.1.0/etc/bashrc
No error or other output should occur.
2.6 Building OpenFOAM
Now we go to the OpenFOAM directory and start compilation. Take a coffee. And a cookie. Or two:
If you also want to keep a log-file in case of errors, type:
./Allwmake 2>&1 | tee make.log
If don't want to see what is happening during the build until it's completed, run:
./Allwmake > make.log 2>&1
When the command returns control to you, then you should be done... but first:
2.6.1 Diagnosing problems
You can check if there are any errors by opening the file Allwmake.log with a text editor and search for lines have the expression "Error " (including the space after the word "Error").
Keep in mind that if your terminal is returning error messages in another language, then you should search for the respective word for "Error".
If you do find errors, the first one is usually the one to blame for all of the other errors.
If you are unable to figure out what's wrong, then:
- Edit the file make.log with a text editor, search and replace any sensitive information, such as user names and folder paths.
- Pack the log file. For example, you can tarball it:
tar -czf make.log.tar.gz make.log
- Go to the chapter Got Questions? and post the file make.log.tar.gz in the mentioned forum thread, along with your question(s).
3 Installing and using ParaView
Note: Part of these instructions were retrieved from here.
Follow these steps:
- Install ParaView from here.
- Edit the file ~/.alias and add the following two lines:
alias paraview="/Applications/ParaView\ 3.14.0-RC2.app/Contents/MacOS/paraview" alias parax="touch case.foam && paraview --data=case.foam &"
Note: Adapt the first line to the real path of your ParaView installation!
- Either start a new terminal or source the file by running:
. ~/.alias
- Whenever you need to run paraFoam, run parax instead! Or you can also run:
paraFoam -builtin
4 Got Questions?
If you've got questions about this installation process, go to the thread OF 1.9 (aka OF 2.1) on Mac OS X, read it from beginning to end and if you still have a question, ask it on that thread!