h1

Compiling OpenFOAM 1.7.x for OS X 10.6

September 16, 2010

This is a short guide for installing the Developer version of OpenFOAM for Snow Leopard. I have tried to include all details.

What you need:

A mac with OS 10.6 and  approximately 10 GB of HD space.

Preliminary steps:

Install the OS X developer tools

Install GCC 4.3 , 4.4 or 4.5 from either Macports or Fink. (4.5 will only work with 1.7.x) and git. I will presume 4.5

Once this you may start building OpenFOAM. The Mac PS file system is not file sensitive by default. Therefore you need to make a case-sensitive disk image for OpenFOAM.

Open Disk Utility (/Applications/Utilities/Disk Utility)

Menu > File > New > Blank disk image ..

You may save the image wherever you want, however, name the image ‘OpenFOAM’.

Using the drop box change the format to ‘Mac OS Extended (Case sensitive)’

Change the size to at least 5 GB. you may increase this later if required.

Create the image and close Disk Utility.

To keep the installation nice and clean we are going to mount the image at $HOME/OpenFOAM

This is the default OpenFOAM install site which will make your life easier in the long run.

To do this add the following to your .bashrc file (if you don’t have one you will need to create one):

hdiutil attach "/path/to/your/disk_image.dmg" -mountpoint "$HOME/OpenFOAM" > /dev/null

This will mount the image when your first open the terminal from now on.
Also add the following which sources the OpenFOAM bash files. This will create errors until you download OpenFOAM.

. $HOME/OpenFOAM/OpenFOAM-1.7.x/etc/bashrc

After you have saved your .bashrc file open a new window in the terminal. You will get the following error:

-bash: /Users/yourusername/OpenFOAM/OpenFOAM-1.7.x/etc/bashrc: No such file or directory

Download the following files and move them to $Home/OpenFOAM;
The 1.7.1 Third party software pack .
The openFOAM 1.7.x patch by Bernhard Gschaider.

The third party patch Bernhard Gschaider.

Check the thread for any updates.

Move these files to $HOME/OpenFOAM. Now we need to edit OpenFOAM-1.7.x-Mac_v2.patch. Open up the file in a text editor and check that the versions of gcc / g++ match what you have installed.
If you installed from macports you will have gcc-mp-4.5 and g++-mp-4.5 Whereas from fink it is gcc-fsf-4.5 and g++-fsf-4.5. Search through the file for ‘-mp-‘ and make sure the version and distribution strings match what you have installed.

At the terminal execute the following:

cd $HOME/OpenFOAM
git clone git://github.com/OpenCFD/OpenFOAM-1.7.x.git
tar -xfz ThirdParty-1.7.1.gtgz
mv ThirdParty-1.7.1 ThirdParty-1.7.x
cd ./ThirdParty-1.7.x
patch -p1 <../ThirdParty-1.7-Mac.patch
cd ../OpenFOAM.1.7.x
patch -p1 <../OpenFOAM-1.7.x-Mac_v2.patch
. $HOME/OpenFOAM/OpenFOAM-1.7.x/etc/bashrc
./Allwmake

This should give you a working OpenFOAM distributions with a few exceptions:
foamToTec360 does not work
parafoam does not work. To address this do the following:
Download and install the Paraview application.
In your case directories ‘touch’ the foam file.
i.e. in a case called ‘isofoam_case’

touch isofoam_case.foam

Open this file with the binary install of Paraview.

Enjoy

Advertisements

21 comments

  1. […] in order to have OpenFOAM-1.7 up and running on Mac Snow Leopard machine? Thank you! Try this: https://chrisjbutler.wordpress.com/20…for-os-x-10-6/ Chris […]


  2. Warning: You will still see many error messages.


  3. […] Bernhard, I have tried to follow the procedures at: https://chrisjbutler.wordpress.com/20…for-os-x-10-6/ Using OSX tiger versions of Xcode and Macport but no success get. At the latest executions in […]


  4. Hi Chris
    Thanks for the explanation, however I have the following question.
    In case I have my Home folder in another partition, how should I write this: hdiutil attach “/path/to/your/disk_image.dmg” -mountpoint “$HOME/OpenFOAM” > /dev/null
    so it points to the write partition?
    What if I want to put it in another partition in an external hard disk?
    How do I start the openFoam environment in such partition?
    THanks,
    Felipe


    • Hi Felipe,
      My appologies for the delayed reply, however, this is how I think you should be able to have the openFOAM diskimage on a separate partition.
      External Volumes are mounted at /Volumes
      Therefore if the disk image was inside a volume called ‘external’ the mount call would be:
      hdiutil attach “/Volumes/external/disk_image.dmg” -mountpoint “$HOME/OpenFOAM” > /dev/null

      Cheers
      CB


      • Hey Chris

        I tried like that, and it does not work.

        I even tried in an external disk, so I did not have to create an image, and nothing…

        What do you suggest?


      • Hi Felipe I am not quite sure what the problem is you are having. Is it to do with creating the disk image, mounting it, or compiling?

        Perhaps attach any error messages you are seeing and perhaps i can help.

        Chris Butler


  5. Hi, I am also having problems with osx. touch cavity.foam does make a new .foam file. I then open the paraview program from applications but am not able to view the mesh. It is really strange that such a good program is made so hard to access, Is there no package for OSX with paraview and openfoam integrated into one ? a GUI instad of command window would also have been nice. Open Foams tutorials are really lacking a lot,, hmm .


    • Hi Dave,
      I guess there are some sacrifices when you get something for ‘free’ (r.e. command line vs. gui).

      Paraview (as distributed with openFOAM) does not compile on a mac with the same compilers as openFOAM does (I don’t know why).

      Cavity example
      Make sure of the following things;

      the cavity.foam file is within the case root directory by this i mean

      >> cd cavity
      >> ls
      # LS MUST SHOW THE constant and system folders
      touch cavity.foam

      However in the cavity example you must have already run blockmesh to view the mesh. The script in the directory above the cavity example (../Allrun) will run the simulations and set up the mesh for you.

      Chris Butleer


  6. Hi,

    Excellent instructions, really made the build process straightforward. I think one of the reasons for a redistributable binary of OpenFOAM for the Mac to not be available is the huge file size. However I managed to put together a compiled version on a case-sensitive disk image, deleted all the source files, documentation, build files and tutorials, erased the free space on it with disk utility and compressed the dmg into a zip to get a 104 MB fully working (w/ parallel) binary for OF ready and tested on Snow Leopard 10.6.5. Thanks to your instructions.

    If anyone has trouble building this yourself, please take a look at http://macof17x.blogspot.com where you can download a prebuilt disk image. (sans ParaView of course)


    • I like the idea Sushant,
      I think I have need to do something similar (with my solvers) for some colleagues who are less experienced with the command line.

      P.S.
      The way that openFOAM alters your $LD_LIBRARY_PATH and $PATH can stuff up software packages build against OS X libraries which are overridden (i.e. MPI). My new methodology is to put a bash script ‘openFOAM’ in /usr/local/bin which mounts the image and exports the path (so the path is only changed when you need it too be).


  7. Hey Chris – first off thanks for the pointers.

    I did not have a .bashrc file so I created one in TextEdit and saved it as Documents/.bashrc. When I open a terminal window – I do not get the below message…

    -bash: /Users/yourusername/OpenFOAM/OpenFOAM-1.7.x/etc/bashrc: No such file or directory

    and so I’m pretty sure that my .bashrc file is doing nothing… can you please tell me how a screwed up this seemingly basic instruction! I think it has to do with where I’ve saved it… Thanks G


  8. Problem fixed by using .profile instead… as described by Sushant at http://macof17x.blogspot.com/p/detailed-setup.html. Thanks for making your experience available for everyone to learn from. G


    • BTW, for os x 10.6.7 I had to edit the .bash_profile file instead of .bashrc or .profile.


      • Brian,
        That is a good point! I forgot that I sourced my .bashrc file in my .bash_profile!


  9. I observed during the process of ./Allwmake that many files weren’t found
    usually solver functions. At the the end i had this message:
    Is this normal?
    target application not remade because of errors


    • “target application not remade because of errors” which application was this for? If it’s Tecplot360Writer or similar, you can safely ignore it for now. Look at a few lines above and below the error message to tell which application was not remade.

      In general, if you run:
      ./Allwmake 2>&1 | grep -w error

      nothing should show up (except the Tecplot360 error). If it does, it may mean something isn’t being built. Try to find out exactly which application is causing the problem.


  10. hey Chris:
    When i make openfoam with allwmake….. i observed several archives that Could not be open… usually solvers…. is this normal?.
    Please help me


    • Ricardo,
      There will be MANY messages about not finding files. Check if the binaries actually build. If they do you are ok.

      Chris
      P.S. I have fallen a little behind keeping up with OF on OS X. This is as I have a linux cluster i am running on currently 🙂


  11. Hey Chris,

    I was just googling for OS X OpenFOAM installation instructions and came across your blog. Perfect! I have to do some simulations to compare to our synchrotron experiments, and I’d like to build meshes on my mac, and then port the cases over to the lab’s linux cluster for actually running them, and bring the results back to paraview on the mac. If only I could get an excuse to run stuff on the Blue Gene…. 😛 (http://en.wikipedia.org/wiki/File:IBM_Blue_Gene_P_supercomputer.jpg)

    Hope everything’s going well back in Australia. Check out my blog if you get time, I put photos up occasionally (daniel-duke.net)

    Cheers!
    – Dan


    • Hey Dan,
      Good to hear things are going well. I have a few utilities to help building basic meshes / cases etc.. email my Monash address if you want to talk about them.

      Chris

      P.S. OpenFOAM runs like a dog on the blue gene. OpenFOAMS MPI programming leaves something to be desired…



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: