0% found this document useful (0 votes)
53 views

Porting Openfoam To Mac Os X: Bernhard F.W. Gschaider Hrvoje Jasak

The document discusses porting OpenFOAM to Mac OS X. It begins by explaining that Mac OS X is based on UNIX and has the necessary development tools. It then covers preparing a case-sensitive disk image, applying patches to address issues, and using MacPorts to install any missing software dependencies. The goal is to get OpenFOAM compiled and running on the Mac OS X platform.

Uploaded by

did
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Porting Openfoam To Mac Os X: Bernhard F.W. Gschaider Hrvoje Jasak

The document discusses porting OpenFOAM to Mac OS X. It begins by explaining that Mac OS X is based on UNIX and has the necessary development tools. It then covers preparing a case-sensitive disk image, applying patches to address issues, and using MacPorts to install any missing software dependencies. The goal is to get OpenFOAM compiled and running on the Mac OS X platform.

Uploaded by

did
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Basics

Porting
Unported and Future stuff

Porting OpenFOAM to Mac OS X

Bernhard F.W. Gschaider1 Hrvoje Jasak2

1 ICE Strömungsforschung
2 Wikki Ltd

June 9, 2007

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
Porting
Unported and Future stuff

Outline

1 Basics
It’s only UNIX (but I like it)
Vendor provided software

2 Porting
Preparing the port
Additional software
Compiling
Paraview

3 Unported and Future stuff


Problems
The Future

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
It’s only UNIX (but I like it)
Porting
Vendor provided software
Unported and Future stuff

The architecture of Mac OS X

• Starting with Mac OS X10.0 the AppleTM -OS is based on


(BSD)Unix
• Has a shell and all our beloved CLI-utilities
• Some differences to regular Unix-machines
• This layer is know as Darwin. Therefor the $WM_ARCH is
called darwin
• The AppleTM -specific interface and services are built on top
of the Unix-layer
• Origins in the NeXTTM -operating system
• None of these things are needed by OpenFOAM
• So it should be easy to port OpenFOAM to Mac OS X

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
It’s only UNIX (but I like it)
Porting
Vendor provided software
Unported and Future stuff

BSD vs System V

• Historically there are two types of Unix:


System V Stems from AT&T
BSD From the university of Berkley
• Both conform to the Posix-Standard. Sort of
• OpenFOAM was developed on LinuxTM
• More on the System V side
• Mac OS X is based on a BSD-kernel
• With a sugar coating by AppleTM

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
It’s only UNIX (but I like it)
Porting
Vendor provided software
Unported and Future stuff

Case-insensitive filesystems

• ext2 (the standard LinuxTM -filesystem is case-sensitive:


1 touch theCase
touch TheCase

Yields two files: theCase and TheCase


• Apple HFS is case-insensitive: The above commands yield
only theCase
• Case of the file is known
• ... but not used to distinguish files
• Variant Apple HFSX is case-sensitive
• but using it on your system-disk kills the system
• Well, actually we never dared to try
• OpenFOAM has source file that only differ by case
• Example: Scalar.H, scalar.H

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
It’s only UNIX (but I like it)
Porting
Vendor provided software
Unported and Future stuff

Development tools

• Every Mac comes with media that install a complete


development system
g++, gcc Compiler (currently in version 4.0.1)
make A GNU Make
flex, bison Compiler generators
JDK JavaTM (currently 1.5)
• These are the most important tools to port OpenFOAM

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
It’s only UNIX (but I like it)
Porting
Vendor provided software
Unported and Future stuff

X-Windows
• The Mac’s GUI is called Aqua - programmed with the API
Cocao
• The standard API in the Unix-world is X11 (X-Windows)
• AppleTM provides a X-Server (and the X11-API)

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Preparing the port
Basics
Additional software
Porting
Compiling
Unported and Future stuff
Paraview

Getting a case-sensitive filesystem

(Sorry. I only have a german system. Therefor the names of the


GUI-elements are “back-translations”)
1 Open the program Applications-Utilities - Disk Utility
2 Click on New Image
• Select a name and a location for the image
• Select a size (1 GB should be sufficient. Can be grown later)
3 Click in the pane on the left on the created image
4 Go to the Erase-tab
• For Volume-Format select one of the case-sensitive Mac OS
Extend-variations
• Click the Erase-button
5 Try to mount the image by double-clicking it
• Try the touch-test described above

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Preparing the port
Basics
Additional software
Porting
Compiling
Unported and Future stuff
Paraview

Permanently adding the disk image


If you want your OpenFOAM-installation to be permanent:
• Mount the Image at login
1 Go to your User-settings in Sytem Preferences
2 Select the Start Objects-tab
3 Click on the Plus-button and add your image
• Symlink the image to the “usual” place
• In a shell say
ln -s / Volumes / Foam ~/ OpenFOAM

(assuming your image mounts as Foam)


• Modify the .bashrc
1 Add a call to the OF-initialization file (described in the
Readme-file)
2 Add the line
1 ulimit -S -n 2048

(this prevents an exhaustion of file-handles with wmkdep)


bgschaid, hjasak Porting OpenFOAM to Mac OS X
Preparing the port
Basics
Additional software
Porting
Compiling
Unported and Future stuff
Paraview

Preparing the sources

1 Go to the disk image


1 cd ~/ OpenFOAM

2 Untar the source-distribution there (nothing else is needed)


1 tar xvzf ~/ Downloads / OpenFOAM -1.4 - General . tgz

3 Download from http://openfoamwiki.net/index.php/Howto_compile_OpenFOAM_Mac

• A tar with the wmake-rules for the darwin-architecture. To be


untarred
• Two patches. To be applied in order. To apply a patch do
1 cd ~/ OpenFOAM / OpenFOAM -1.4
patch - p0 -b <~/ Download / thePatch

• A new version of error.C (allows backtraces)

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Preparing the port
Basics
Additional software
Porting
Compiling
Unported and Future stuff
Paraview

What the patches do

Issues the patches take care of:


• Add Darwin to the known architectures
• Deficits in the AppleTM -headers (missing math-stuff)
• malloc.h is in a different place
• Libraries that are missing in the options-files of some utilities
• Reset the MICO to the darwinPorts one (thus enabling
the compilation of FoamX and patchTool)
• Help to compile the paraview-filter without human
intervention
• Remove warnings about unsupported options for the
head-command from some scripts
These patches will be inserted into the Subversion-repository

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Preparing the port
Basics
Additional software
Porting
Compiling
Unported and Future stuff
Paraview

MacPorts (FKA DarwinPorts)


To get the missing software:
1 Go to http://www.macports.org/ and install it
• A similar project is http://www.finkproject.org/ (provides binaries
as well)
2 Install the missing packages:
Mico If you don’t want to use the version that comes with
OpenFOAM
sudo port install mico

The sources (and everything they depend on) are


automagically downloaded and compiled
binutils If you want to use the backtrace-facility
1 sudo port install binutils

MPI The MPI-implementation of your choice. For instance


1 sudo port install openmpi

The files in OpenFOAM-1.4/.OpenFOAM-1.4 have to be


adapted acordingly
bgschaid, hjasak Porting OpenFOAM to Mac OS X
Preparing the port
Basics
Additional software
Porting
Compiling
Unported and Future stuff
Paraview

Do it like the README says


This is the “hardest” part
1 Check whether everything is in place
2 Do
1 cd ~/ OpenFOAM / OpenFOAM -1.4
./ Allwmake

3 Get some coffee


4 Wait
5 Get more coffee
6 Watch PVReader-compilation fail (should be the only failure
at that stage)
7 Celebrate the end of the compilation with a cup of coffee
8 Try some utilities (blockMesh, interFoam) to make sure it
worked
bgschaid, hjasak Porting OpenFOAM to Mac OS X
Preparing the port
Basics
Additional software
Porting
Compiling
Unported and Future stuff
Paraview

Why compile ParaViewTM

• paraFoam is a script that adds a plugin to ParaViewTM and


calls the original paraview
• This plugin is the PVReader that failed during our first
compilation
• To compile a plugin for ParaViewTM you have to have the
source-code
• ... or know the settings with which your binary was compiled
• The surest way to know the settings is to compile
ParaViewTM yourself
Q.E.D.

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Preparing the port
Basics
Additional software
Porting
Compiling
Unported and Future stuff
Paraview

Compiling it

1 Download the source code (2.4.x is “supported” but 2.6.x


works as well. No 3.x-versions)
2 Untar and compile it
• Doesn’t have to be on a case-sensitive filesystem
• For details look at the Wiki-page
3 Adapt the initialization files so that $ParaView_Dir is correct
4 Open a new shell and in that retry Allwmake
• Now PVReader should compile
5 Try paraFoam

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Preparing the port
Basics
Additional software
Porting
Compiling
Unported and Future stuff
Paraview

An alternative: ParaView3TM

• ParaView3TM already has reader for OpenFOAM included

• But it is not represented in the Open File-Dialog of the GUI


• Reader can be added to the Dialog with a .... plugin
• http://openfoamwiki.net/index.php/Tip_Build_A_Paraview3_Plugin
• ParaView3TM has to be compiled from source

Disadvantages
Advantages
• Reader seems to be a bit
• Cool new features
unstable
• X11 no longer needed (native
• Works only if there are no
Aqua-GUI
.gz-files in the case

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
Problems
Porting
The Future
Unported and Future stuff

Problem: FoamX won’t kill its sub-processes

• After running FoamX some processes remain


• FoamXHostBrowser
• nsd
• Should be killed by the FoamX-script
• Are not (because of the different output of the BSD-ps)
• Workaround: manually kill the processes
• Or rewrite the scripts
• The same is true for patchTool

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
Problems
Porting
The Future
Unported and Future stuff

Problem: No right-click in FoamX

• Two contradicting concepts:


• Macs only have one mouse-button
• Unix-software usually assumes three mouse-buttons
• Right mouse-button is emulated by Ctrl-Click
• This doesn’t work in FoamX
• Theory: The Java virtual machine “swallows” the Ctrl-key
• Workaround: Use an external USB-mouse (with three buttons)
• Same is true for patchTool

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
Problems
Porting
The Future
Unported and Future stuff

A Tale of two Architectures

• Currently Mac OS X exists on two processor architectures:


ppc The PowerPC-architecture (no longer used by
AppleTM )
i386 The IntelTM processors
• Currently only ppc-compilations are known (though i386
shouldn’t be a problem)
• Using both compile options -arch ppc -arch i386
produces Universal binaries
• Currently untested (lack of time, diskspace and an
IntelTM -Mac)
• Disadvantage: Binaries are twice the size they should be

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
Problems
Porting
The Future
Unported and Future stuff

How will it be distributed?

Two basic ways of distribution


1 In source form
• On the forthcoming
openfoam-extend-Subversion-Repository
• Disadvantage: the preparation of the environment has to be
done by the user
• Propably will not be incorporated in the official distribution
2 As disk images
• Have been provided by Hrv in the past
• Disadvantage: Updates will only be available when someone
has the time to produce a new image
• Problem: for which architecture (ppc, i386 or Universal)
• Proposal: prepare disk image for Svn-access (in other words:
give the image the possibility to update itself)

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
Problems
Porting
The Future
Unported and Future stuff

Acknowledgments

People who contributed to this port by providing


contributions/feedback:
Michael Wild Pointed out that the Disk Utility can produce
case-sensitive file-systems
Doug Hunsaker Asked a lot of questions that told me what is
“not so trivial”
Simon Stapleton Who pointed out that the FoamX-orphans are
a BSD-problem and promised a fix
Bouke Got foamInstallationTest to run
James Turner Found a problem with the wmkdep-tool
Petr Vita For having nothing to do with this port
... these are the ones I remember. Sorry for everyone I forgot

bgschaid, hjasak Porting OpenFOAM to Mac OS X


Basics
Problems
Porting
The Future
Unported and Future stuff

The End

Thanks for listening!

Questions?

bgschaid, hjasak Porting OpenFOAM to Mac OS X

You might also like