Installation/Mac OS/Outdated/Howto compile OpenFOAM 1.3 and 1.4 on Mac OS X

From OpenFOAMWiki

This page is work in progress

1 Compiling 1.4.1

This patch Media:OpenFOAM-1.4.1-MacOSX.patch.gz replaces all the downloads specified in the 1.4 section. To apply do in the Directory with the sources

mkdir wmake/rules/darwin
patch -p0 <OpenFOAM-1.4.1-MacOSX.patch

The first command is necessary because patch doesn't create a directory by itself.

The uploaded patch used to be broken. It is fixed now. I hope

2 Compiling on 1.4

This is just a sketch. More will come

2.1 Preparing for Compilation

  • Install latest XCode
  • Generate a disk-image with a Case-sensitive filesystem
    • Using the command-line tool hdiutil (the GUI-tool can't do this as far as I remember). Details will follow
      • REMARK: It actually can. Open the Disk Utility, create a new image as usual, then in the "Erase"-tab select one of the case sensitive file systems from the "Volume Format" drop-down and click on "erase".
  • Install additional Utilities via darwinports
    • sudo port install mico to enable the compilation of FoamX
    • the MPI-implementation of your choice (this is untested and unsupported by the patches)
    • the binutils if you want to use the backtrace in the new error.C (gaddr2line from that package is needed)

2.2 Preparing the sources

  • Extract the sources into the disk-image
  • Apply the patch Media:OpenFOAM1.4-forMac.v1.patch
    • Fix to readSTLASCII.L is already in more current versions of the Sources. The patch may fail here. Ignore it
  • Untar Media:DarwinWmakeRules.1.4.v1.tgz to get compilation rules for darwin
  • Apply a second patch Media:OpenFOAM1.4-forMac.v2.patch. This patch is not strictly necessary. It
    • resets the MICO to the darwinPorts one (thus enabling the compilation of FoamX and patchTool)
    • helps to compile the paraview-Filter without human intervention
    • removes warnings about unsupported options for the head-command from some scripts
  • Unzip Media:Error.C.backtrace4darwin.gz and move it to $FOAM_SRC/OpenFOAM/db/error/error.C to enable backtraces for programs that abort due to failures
    • this is only tested for a OF compiled with Release-options. For a Debug-Version it should give sourcefiles and linenumbers of the called functions

2.3 Compilation

See the regular README

2.4 Comments on the patch

  • the stuff in doubleFloat.H repairs the fact that the Apple-headers don't have prototypes for those functions (don't know if they exist in the Library)
    • Should be guarded with a #ifdef darwin
  • Most of the other stuff is described in the section about 1.3 below
  • I compiled with the compiler Apple provides (gcc 4.0,1). If you get a newer one from darwinports some of the changes might not be needed

2.5 Compile with paraview 2.6

This is a bit messy.

  • Compile Paraview according to http://www.paraview.org/Wiki/ParaView:FAQ#How_do_I_compile_ParaView_for_Mac_OS_X .3F (doesn't have to be on the case sensitve file system)
    • install it
  • Point apps/paraview/??rc to that installation
    • You might have to copy the header file to the place where they are expected ($ParaView_Dir/include)
  • If you didn't apply the second patch (if you did: the patch will take care of it):
    • Go to $FOAM_UTILITIES/postprocessing/graphics/PVReader
    • Start the Allwmake there. It will fail at linking the libPVReader.so
    • Go to PVReader/Make/darwinOpt
      • Under that directory you will find (sorry I'm not at my Computer so I don't know the exact location) a file link.txt
      • In link.txt append -undefined dynamic_lookup
        • This change will be lost with every subsequent call to cmake
      • Call make (in PVReader/Make/darwinOpt). It should link
    • now paraFoam should be usable

2.6 Future plans

  • Support at least one MPI-implementation (propably OpenMPI)

2.7 Tested systems

This has only been tried on a PowerPC iBook yet.

2.8 Known issues

  • right clicking (Ctrl+Click) does not work in FoamX on the trackpad of Apple-Notebooks. It works with a USB-Mouse. Propably a problem with the JVM

3 Old Stuff: Verbose description on 1.3

Currently this page only gives a description which files have been modified to compile the vanilla-1.3-sources (this is basically a transcript of my notes). A more detailed description will be given when I have the time (plus I want to wait for 1.4 until I do that)

Stuff with a question mark are things I don't know without looking at the source what I have done

  • basrc and cshrc in .OpenFOAM and paraview modified to recognize darwin
  • applications//utilities/miscellaneous/foamFlex/flexdef.h: malloc.h is in different location
  • OSSpecific/Unix/fileStat.C: sysmacros
  • error.C: special case for darwin Darwin
  • wmake/Makefile: rules for darwin-dylib
  • .cshrc and .bashrc ?
  • rusles/darwin (Changes on LINKEXE - there's got to be another way)
  • TODO: DYLIB_PATH in normale Files
  • sonicFoamAutoMotion: Addition in options (meshTools must be linked to it)
    • moveMesh: ditto
    • boxTurb: ditto
    • mapFields: ditto
  • financialFoam: finiteVolume
    • icoErrorEstimate: detto
    • momentScalarError: detto
    • icoMomentError: detto
  • in /applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/darwinDPOpt CMakeFiles/PVFoamReader.dir/build.make for the linking command the option "-undefined dynamic_lookup" has to be added


--Bgschaid 14:36, 22 Mar 2007 (CET)