Difference between revisions of "Installation/Mac OS/OpenFOAM 2.2.2"
Tidusuper91 (Talk | contribs) |
Tidusuper91 (Talk | contribs) |
||
Line 23: | Line 23: | ||
==== Command Line Tools for OSX 10.9 "Mavericks" ==== | ==== Command Line Tools for OSX 10.9 "Mavericks" ==== | ||
To install CLT on OSX 10.9 open a terminal application (for example <i>Terminal.app</i>) and run | To install CLT on OSX 10.9 open a terminal application (for example <i>Terminal.app</i>) and run | ||
− | < | + | <pre> |
xcode-select --install | xcode-select --install | ||
− | </ | + | </pre> |
a window will be prompted where you can confirm installation. | a window will be prompted where you can confirm installation. | ||
Line 33: | Line 33: | ||
==== xCode License ==== | ==== xCode License ==== | ||
Now you should accept the xCode License so run, always in the Terminal (this could be needed only on OSX 10.9) | Now you should accept the xCode License so run, always in the Terminal (this could be needed only on OSX 10.9) | ||
− | < | + | <pre> |
sudo xcodebuild -license | sudo xcodebuild -license | ||
− | </ | + | </pre> |
and when asked type "agree" to accept the license. Now xCode "things" should work correctly. | and when asked type "agree" to accept the license. Now xCode "things" should work correctly. | ||
Line 42: | Line 42: | ||
=== Build and Install the necessary software === | === Build and Install the necessary software === | ||
− | To install all the tools we'll need run in Terminal:< | + | To install all the tools we'll need run in Terminal:<pre> |
sudo port selfupdate | sudo port selfupdate | ||
− | </ | + | </pre> |
− | Wait for the end of all operations then do:< | + | Wait for the end of all operations then do:<pre> |
sudo port install gcc46 openmpi boost cgal ccache flex bison | sudo port install gcc46 openmpi boost cgal ccache flex bison | ||
− | </ | + | </pre> |
Now wait (a bit...) | Now wait (a bit...) | ||
Line 71: | Line 71: | ||
Download OpenFOAM 2.2.2 sources from [http://www.openfoam.org/download/source.php here] and patches ([http://tidusuper91.altervista.org/blog/download/mac/OpenFOAM-2.2.x_Mac-20130309.patch OpenFOAM-2.2.2 Patch] || [http://tidusuper91.altervista.org/blog/download/mac/SurfaceCGALFix.patch SurfaceCGAL Fix] || [http://tidusuper91.altervista.org/blog/download/mac/ThirdParty-2.2_Mac-20130309.patch ThirdParty Patch]) <ref>More updated patches could be possibly found on [http://www.cfd-online.com/Forums/openfoam-installation-windows-mac/ this CFD Online Thread]</ref> and put everything inside the .sparseimage (you probably saved in ~/Documents). | Download OpenFOAM 2.2.2 sources from [http://www.openfoam.org/download/source.php here] and patches ([http://tidusuper91.altervista.org/blog/download/mac/OpenFOAM-2.2.x_Mac-20130309.patch OpenFOAM-2.2.2 Patch] || [http://tidusuper91.altervista.org/blog/download/mac/SurfaceCGALFix.patch SurfaceCGAL Fix] || [http://tidusuper91.altervista.org/blog/download/mac/ThirdParty-2.2_Mac-20130309.patch ThirdParty Patch]) <ref>More updated patches could be possibly found on [http://www.cfd-online.com/Forums/openfoam-installation-windows-mac/ this CFD Online Thread]</ref> and put everything inside the .sparseimage (you probably saved in ~/Documents). | ||
− | Open a Terminal, create a symlink to the OF image:< | + | Open a Terminal, create a symlink to the OF image:<pre> ln -s /Volumes/OpenFOAM-v2.2.2 OpenFOAM </pre>now we can go to OF directory just doing (from home directory)<pre>cd OpenFOAM</pre> |
− | Let's extract the two archives:< | + | Let's extract the two archives:<pre>tar -xvf OpenFOAM-2.2.2.tgz |
− | tar -xvf ThirdParty-2.2.2.tgz</ | + | tar -xvf ThirdParty-2.2.2.tgz</pre> |
− | Now your OF directory should look like this< | + | Now your OF directory should look like this<pre>****@mbp-di-ruben: ~/OpenFOAM$ ls -al |
total 182688 | total 182688 | ||
drwxr-xr-x 8 **** staff 612 13 Nov 02:49 . | drwxr-xr-x 8 **** staff 612 13 Nov 02:49 . | ||
Line 90: | Line 90: | ||
-rw-r--r--@ 1 **** staff 58193818 12 Nov 21:09 ThirdParty-2.2.2.tgz | -rw-r--r--@ 1 **** staff 58193818 12 Nov 21:09 ThirdParty-2.2.2.tgz | ||
-rw-r--r--@ 1 **** staff 2686 12 Nov 21:12 ThirdParty-2.2_patch | -rw-r--r--@ 1 **** staff 2686 12 Nov 21:12 ThirdParty-2.2_patch | ||
− | </ | + | </pre> |
− | Let's move the patches inside the right folders< | + | Let's move the patches inside the right folders<pre># Current Folder: ~/OpenFOAM$ |
mv OpenFOAM-2.2.x_Mac-20130309 OpenFOAM-2.2.2 | mv OpenFOAM-2.2.x_Mac-20130309 OpenFOAM-2.2.2 | ||
mv SurfaceCGALFix.patch OpenFOAM-2.2.2 | mv SurfaceCGALFix.patch OpenFOAM-2.2.2 | ||
− | mv ThirdParty-2.2_Mac-20130309.patch Thirdparty-2.2.2</ | + | mv ThirdParty-2.2_Mac-20130309.patch Thirdparty-2.2.2</pre> |
− | + | ||
− | Let's apply them< | + | Let's apply them<pre>#Current Folder: ~/OpenFOAM |
cd OpenFOAM-2.2.2 | cd OpenFOAM-2.2.2 | ||
#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 | #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 | ||
Line 109: | Line 108: | ||
patch -p1<ThirdParty-2.2_patch | patch -p1<ThirdParty-2.2_patch | ||
cd .. | cd .. | ||
− | #Current Folder: ~/OpenFOAM/</ | + | #Current Folder: ~/OpenFOAM/</pre> |
− | OpenFoam patch badly writes compilers symlinks so we have to | + | OpenFoam patch badly writes compilers symlinks so we have to fix:<pre>#Current Folder: ~/OpenFOAM/ |
cd OpenFOAM-2.2.2 | cd OpenFOAM-2.2.2 | ||
#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 | #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 | ||
Line 119: | Line 118: | ||
ln -s darwinIntel64Gcc/ darwinIntel64Gcc46 | ln -s darwinIntel64Gcc/ darwinIntel64Gcc46 | ||
cd ../.. | cd ../.. | ||
− | #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2</ | + | #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2</pre> |
− | Let's give write permission to '''addr2line4Mac.py'''< | + | === Final Steps === |
− | #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 | + | |
− | chmod a+x bin/addr2line4Mac.py</bash> | + | Let's give write permission to '''addr2line4Mac.py'''<pre>#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 |
+ | chmod a+x bin/addr2line4Mac.py</pre> | ||
+ | |||
+ | Now we have to edit the bashrc file<pre>sudo nano etc/bashrc</pre> | ||
+ | Use '''CTRL+W''' to find those lines<bash>export WM_COMPILER=Gcc | ||
+ | export WM_MPLIB=OPENMPI</bash> and change them with<bash>export WM_COMPILER=Gcc46 | ||
+ | export WM_MPLIB=SYSTEMOPENMPI</bash> | ||
+ | |||
+ | at the end of this file, add <bash> | ||
+ | export WM_CC='gcc-mp-4.6' | ||
+ | export WM_CXX='g++-mp-4.6' | ||
+ | export WM_NCOMPPROCS=4 | ||
+ | ulimit -n 1024</bash> | ||
+ | Save ('''CTRL+O''' and exit '''CTRL+X''') | ||
+ | |||
+ | A few notes about these two lines<ref>From [[Installation/Mac_OS/OpenFOAM_2.1.x]]</ref> | ||
+ | * 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 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> | ||
+ | |||
+ | Now we need a symlink for openmpirun (this can be useful with snappyHexMesh)<pre>#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 | ||
+ | cd OpenFOAM/OpenFOAM-2.2.2/bin | ||
+ | #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2/bin | ||
+ | ln -s /opt/local/bin/openmpirun mpirun | ||
+ | cd .. | ||
+ | #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2</pre> | ||
+ | |||
+ | There's some hardcoding to do on a file<pre>#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 | ||
+ | sudo nano src/renumber/SloanRenumber/Make/options</pre> | ||
+ | |||
+ | Change this line:<bash> -L$(BOOST_ARCH_PATH)/lib -lboost_thread \</bash> | ||
+ | into this:<bash>-L$(BOOST_ARCH_PATH)/lib -lboost_thread-mt \</bash> save and exit. | ||
+ | |||
+ | |||
+ | Source the bashrc file:<pre>#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 | ||
+ | . etc/bashrc </pre> | ||
+ | |||
+ | Now we're ready to compile. Cross your fingers and do:<pre>#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 | ||
+ | ./Allwmake 2>&1 | tee logName.log</pre> | ||
+ | where to '''logName''' you should replace a name for your log :P. Now take your time, call your mum, cook, take a shower and then come back to see if something went wrong. | ||
+ | ---- | ||
<references/> | <references/> |
Revision as of 15:48, 15 November 2013
1 Introduction and Notes
This guide is derived from OpenFOAM 2.1.x Installation with some modifications derived thanks to help provided on this thread of CFD Online Forum . The format of the page is based on OpenFOAM 1.7.x Installation.
These compilation instructions have only been tested on the following system:
Macbook (version 6,2) Intel Core i7 2.66Ghz Mac OS X Mavericks (version 10.9)
These instructions may need to be tailored as required to fit your specific system if they deviate from the above; you would be able to ask support on this thread if you needed it.
Many thanks go to Bernhard Gschaider (a.k.a. gschaider) of CFD Online for maintaining the latest OpenFOAM Mac OS X patches and for the big help that he provided me.
2 Prepare your Mac OS X Environment
2.1 Macports
To install Macports you need to install xCode, you can find it on the App Store. After XCode you need to install the Command Line Tools. Installing Command Line Tools for Mavericks is different from what you would do with previous OSX versions.
2.1.1 Command Line Tools for OSX 10.9 "Mavericks"
To install CLT on OSX 10.9 open a terminal application (for example Terminal.app) and run
xcode-select --install
a window will be prompted where you can confirm installation.
2.1.2 Command Line Tools for OSX version < 10.9
In previous versions of OSX (and of xCode) you can download CLT directly from xCode Preferences > Downloads > Components
2.1.3 xCode License
Now you should accept the xCode License so run, always in the Terminal (this could be needed only on OSX 10.9)
sudo xcodebuild -license
and when asked type "agree" to accept the license. Now xCode "things" should work correctly.
2.1.4 MacPorts Installation
Now to install Macports you can download the pre-compiled package from the Official Website.
2.2 Build and Install the necessary software
To install all the tools we'll need run in Terminal:sudo port selfupdateWait for the end of all operations then do:
sudo port install gcc46 openmpi boost cgal ccache flex bison
Now wait (a bit...)
3 OpenFOAM Building
3.1 Creation of Case Sensitive .sparseimage
Note: Images here shown are taken from Installation/Mac_OS/OpenFOAM_2.1.x, you could change the name of the sparseimage from OpenFOAM-v2.1 to OpenFOAM-v2.2.2 (and this will be assumed from here on)
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):
3.2 OpenFOAM sources and patches
Note: Rember that when you're inside the terminal you can auto-complete your commands pressing the TAB button
Download OpenFOAM 2.2.2 sources from here and patches (OpenFOAM-2.2.2 Patch || SurfaceCGAL Fix || ThirdParty Patch) [1] and put everything inside the .sparseimage (you probably saved in ~/Documents).
ln -s /Volumes/OpenFOAM-v2.2.2 OpenFOAMnow we can go to OF directory just doing (from home directory)
cd OpenFOAMLet's extract the two archives:
tar -xvf OpenFOAM-2.2.2.tgz tar -xvf ThirdParty-2.2.2.tgzNow your OF directory should look like this
****@mbp-di-ruben: ~/OpenFOAM$ ls -al total 182688 drwxr-xr-x 8 **** staff 612 13 Nov 02:49 . drwxrwxrwt@ 5 root admin 170 15 Nov 15:40 .. -rw-r--r--@ 1 **** staff 12292 13 Nov 03:13 .DS_Store d--x--x--x 6 **** staff 238 15 Nov 15:40 .DocumentRevisions-V100 drwxrwxrwt@ 3 **** staff 102 12 Nov 23:29 .TemporaryItems d-wx-wx-wt 2 **** staff 68 12 Nov 14:43 .Trashes drwx------ 2 **** staff 2822 15 Nov 12:03 .fseventsd drwxr-xr-x@ 10 **** staff 680 13 Nov 02:55 OpenFOAM-2.2.2 -rw-r--r--@ 1 **** staff 32536146 12 Nov 21:09 OpenFOAM-2.2.2.tgz -rw-r--r--@ 1 **** staff 41620 13 Nov 02:49 OpenFOAM-2.2.x_Mac-20130309.patch -rw-r--r--@ 1 **** staff 691 13 Nov 02:49 SurfaceCGALFix.patch drwxr-x---@ 7 **** staff 782 13 Nov 02:54 ThirdParty-2.2.2 -rw-r--r--@ 1 **** staff 58193818 12 Nov 21:09 ThirdParty-2.2.2.tgz -rw-r--r--@ 1 **** staff 2686 12 Nov 21:12 ThirdParty-2.2_patchLet's move the patches inside the right folders
# Current Folder: ~/OpenFOAM$ mv OpenFOAM-2.2.x_Mac-20130309 OpenFOAM-2.2.2 mv SurfaceCGALFix.patch OpenFOAM-2.2.2 mv ThirdParty-2.2_Mac-20130309.patch Thirdparty-2.2.2Let's apply them
#Current Folder: ~/OpenFOAM cd OpenFOAM-2.2.2 #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 patch -p1<OpenFOAM-2.2.x_Mac-20130309.patch patch -p1<SurfaCGALFix.patch cd .. #Current Folder: ~/OpenFOAM/ cd ThirdParty-2.2.2 #Current Folder: ~/OpenFOAM/ThirdParty-2.2.2 patch -p1<ThirdParty-2.2_patch cd .. #Current Folder: ~/OpenFOAM/OpenFoam patch badly writes compilers symlinks so we have to fix:
#Current Folder: ~/OpenFOAM/ cd OpenFOAM-2.2.2 #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 rm wmake/rules/darwinIntel64Gcc4* cd wmake/rules #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2/wmake/rules ln -s darwinIntel64Gcc/ darwinIntel64Gcc46 cd ../.. #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2
3.3 Final Steps
Let's give write permission to addr2line4Mac.py#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 chmod a+x bin/addr2line4Mac.pyNow we have to edit the bashrc file
sudo nano etc/bashrcUse CTRL+W to find those lines
export WM_COMPILER=Gcc export WM_MPLIB=OPENMPIand change them with
export WM_COMPILER=Gcc46 export WM_MPLIB=SYSTEMOPENMPIat the end of this file, add
export WM_CC='gcc-mp-4.6' export WM_CXX='g++-mp-4.6' export WM_NCOMPPROCS=4 ulimit -n 1024
Save (CTRL+O and exit CTRL+X)
A few notes about these two lines[2]
- 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
#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 cd OpenFOAM/OpenFOAM-2.2.2/bin #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2/bin ln -s /opt/local/bin/openmpirun mpirun cd .. #Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2There's some hardcoding to do on a file
#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 sudo nano src/renumber/SloanRenumber/Make/optionsChange this line:
-L$(BOOST_ARCH_PATH)/lib -lboost_thread \into this:
-L$(BOOST_ARCH_PATH)/lib -lboost_thread-mt \save and exit.
#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 . etc/bashrcNow we're ready to compile. Cross your fingers and do:
#Current Folder: ~/OpenFOAM/OpenFOAM-2.2.2 ./Allwmake 2>&1 | tee logName.log
where to logName you should replace a name for your log :P. Now take your time, call your mum, cook, take a shower and then come back to see if something went wrong.
- ↑ More updated patches could be possibly found on this CFD Online Thread
- ↑ From Installation/Mac_OS/OpenFOAM_2.1.x