Installation of OpenFOAM into MAC This tutorial explains how to install OpenFOAM into MacOS operating system. It is already tested under Mac OS Yosemite version 10.10.5 and completed successfully. If you are running the Yosemite beta or DP, you cannot use the MacPorts 2.3.1 DMG file, or the "sudo port -v selfupdate" command in the terminal. Therefore, you must first install a fresh copy of Xcode and MacPorts under Yosemite. It will then also allow you to update your ports as well. You can download Xcode and Macport easily by taking Apple Developer ID. NOTE: If you installed Xcode and Macports tools before you upgraded your MAC version, you have to uninstall and clean all dependencies and then install the new versions of Xcode and Macports again according to your new upgraded MAC version. To uninstall the Macports, and port functions, first uninstall all the installed ports by running this command in the Terminal: sudo port -fp uninstall installed To remove all remaining traces of MacPorts, run the following command in the Terminal. If you have changed prefix, applications_dir or frameworks_dir from their default values, then replace /opt/local with your prefix, replace /Applications/MacPorts with your applications_dir, and/or add your frameworks_dir to the list, respectively. sudo rm -rf \ /opt/local \ /Applications/DarwinPorts \ /Applications/MacPorts \ /Library/LaunchDaemons/org.macports.* \ /Library/Receipts/DarwinPorts*.pkg \ /Library/Receipts/MacPorts*.pkg \ /Library/StartupItems/DarwinPortsStartup \ /Library/Tcl/darwinports1.0 \ /Library/Tcl/macports1.0 \ ~/.macports Prepared by Baris BICER - SoftFlow Co., Ltd. 1
1. Then, go to following page and install last version of Xcode and Macport again: https://trac.macports.org/wiki/migration After the installation of Xcode you will use the license of the software. 2. Open the a new terminal window and run sudo xcodebuild license After this, you will be asked the administrator password input I agree with the input in view license the (English). 2.1 To check first whether you installed Xcode or not: xcode-select -p You should get reply such as: /Application/Xcode.app/Contents/Developer 2.2 Which version of Xcode do you use? To check it cd /usr/bin xcodebuild -version You should get reply such as: Xcode 7.0.1 Build version 7A1001 2.3 To check the CommandLineTools whether you installed or not xcode-select install ls /Library/Developer/ You should get reply such as: xcode-select: error: command line tools are already installed, use software Update to install updates CommandLineTools 3. After installation the Macports and Third Parties to update the information of the port. Open a terminal window sudo port selfupdate Prepared by Baris BICER - SoftFlow Co., Ltd. 2
You should get following message: ---> Updating MacPorts base sources using rsync MacPorts base version 2.3.4 installed, MacPorts base version 2.3.4 downloaded. ---> Updating the ports tree ---> MacPorts base is already the latest version The ports tree has been updated. To upgrade your installed ports, you should run port upgrade outdated 4. To upgrade already installed ports sudo port upgrade outdated You should get at the end such a reply: ----> No broken files found. 5. Install dependencies one by one 5.1.A: To install gcc49 version sudo port install gcc49 If you correctly installed the gcc49, you should get at the end such a reply: Password: ---> Computing dependencies for gcc49 ---> Cleaning gcc49 ---> Scanning binaries for linking errors ---> No broken files found 5.1.B: To set the gcc49 active you can run one of the following commands: sudo port select --set gcc mp-gcc49 (or) sudo port select gcc mp-gcc-49 You should get at the end such a reply: Selecting 'mp-gcc49' for 'gcc' succeeded. 'mp-gcc49' is now active. To check the gcc version (optional): gcc --version 5.2 Then install the OpenMPI Prepared by Baris BICER - SoftFlow Co., Ltd. 3
sudo port install openmpi-gcc49 If you correctly installed the openmpi-gcc49, you should get at the end such a reply: ---> Computing dependencies for openmpi-gcc49 ---> Cleaning openmpi-gcc49 ---> Scanning binaries for linking errors ---> No broken files found. sudo port select --set mpi openmpi-gcc49-fortran (to set the openmpi like mpi) You should get at the end such a reply: Selecting'openmpi-gcc49-fortran' for 'mpi' succeeded. 'openmpi-gcc49-fortran' is now active. 5.3 Also other dependencies can be installed one by one sudo port install cgal sudo port install ccache sudo port install flex sudo port install scotch sudo port install boost +openmpi sudo port install scotch -mpich +gcc49 +openmpi sudo port install metis +gcc49 5.4 For completeness sudo port select --set llvm mp-llvm-3.5 sudo port select --set python python27 sudo port select --set db db49 5.5 Before installing to check the dependencies run: port select --summary Prepared by Baris BICER - SoftFlow Co., Ltd. 4
6. To create a volume and mount it: hdiutil create -size 8.3g -type SPARSEBUNDLE -fs HFSX -volname OpenFOAM -fsargs -s OpenFOAM.sparsebundle mkdir -p OpenFOAM hdiutil attach -mountpoint $HOME/OpenFOAM OpenFOAM.sparsebundle cd OpenFOAM git clone https://github.com/openfoam/openfoam-2.3.x cd OpenFOAM-2.3.x 6.1 To get the patch: http://sourceforge.net/p/openfoamextend/svn/head/tree/trunk/breeder_2.3/distropatches/macpatch/openfoa M-2.3.x-Mac.patch Download the above file and place it in the OpenFOAM-2.3.x directory. 6.2 To apply patch: patch -p1<openfoam-2.3.x-mac.patch 6.3 To update the OpenFOAM-2.3.x/etc/bashrc (Append these lines to the /path/to/openfoam-2.3.x/etc/bashrc (change the "/path/to" to whatever your fully qualified path would be) echo "WM_CC=mpicc" >> /path/to/openfoam-2.3.x/etc/bashrc echo "WM_CXX=mpicxx" >> /path/to/openfoam-2.3.x/etc/bashrc 7. To install OpenFOAM run: source etc/bashrc && WM_NCOMPPROCS=$(sysctl -n hw.ncpu) =>if this doesn t work just run: source etc/bashrc Prepared by Baris BICER - SoftFlow Co., Ltd. 5
./Allwmake > log.allwmake 2>&1 7.1 To update the bash profile (open a terminal window) and enter open ~/.bash_profile This will open the.bash_profile file in TextEdit(the default text editor included on your Mac). This file allows you to customize the environment your user runs in. 7.2 And add following lines into.bash_profile file: if [ -f $HOME/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc ]; then. $HOME/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc fi Force the.bash_profile to execute. This loads the values immediately without having to reboot. 7.3 To execute the bash_profile run the following command. source ~/.bash_profile This will load the openfoam bashrc file and setup your environment 7.4 You can confirm the new path by executing the following command: echo $PATH Now you will see the changes which you have made. 8. To install ParaView follow the following steps: 8.1 First install the Paraview for the Mac operation system from this page: http://www.paraview.org/download/ Prepared by Baris BICER - SoftFlow Co., Ltd. 6
8.2 Then install it in a normal way. Then, the the resulting installation will provide the paraview binary at: /Applications/paraview.app/Contents/MacOS/paraview 8.3 Create a symbolic link to ParaView into your OpenFOAM installation, by running this command (adjust accordingly to your ParaView version): ln s /Applications/paraview.app/Contents/MacOS/paraview $WM_PROJECT_DIR/bin/paraview Note: $WM_PROJECT_DIR is where OpenFOAM is installed. 9. Edit the file ~/.alias (e. g. Text Wrangler, pico or nano); for example: nano ~/.alias If this requires root entry and gives error use (sudo s nano ~/.alias) 10. And add the following lines into alias file: alias parax="touch case.foam && paraview --data=case.foam &" alias parafoam="parafoam -builtin" 11. After that open new terminal and run:. ~/.alias 12. After that it is ready to use it. Whenever you need to run parafoam, you can run either one of the following commands parax parafoam It is ready to try it in your case Good luck!!! Prepared by Baris BICER - SoftFlow Co., Ltd. 7