HowTo Use OpenFOAM with Eclipse

From OpenFOAMWiki
Revision as of 12:41, 5 May 2010 by Amahrla (Talk | contribs)

Using Eclipse CDT for developing OpenFOAM

Please note: This offering is not approved or endorsed by OpenCFD® Limited, the producer of OpenFOAM® software and owner of the OpenFOAM® and OpenCFD® trademarks.

1 Thanks to ..

Patrik Eder for his help with setting up Eclipse and Holger Marschall for proofreading.

2 Versions

Operating system: openSuse 10.2

OpenFOAM version: OpenFOAM-1.6.x

Eclipse version: eclipse 3.5.1 (eclipse Galileo)

3 Eclipse Capabilities

"Eclipse is an open source community whose projects are focused on building an extensible development platform, runtimes and application frameworks for building, deploying and managing software across the entire software lifecycle. Many people know us, and hopefully love us, as a Java IDE but Eclipse is much more than a Java IDE." - www.eclipse.org

Eclipse is a powerful integrated development environment IDE originally developed for Java programming. But with the CDT extension Eclipse becomes a very common IDE for C++ programming.

If you want to work on a project in OpenFOAM, it is even not necessary to import the whole OpenFOAM-folder. Only import the project you are working on and the rest of the code will be linked for developing and debugging.

4 Aim of the tutorial

In this tutorial we will import a standard OpenFOAM solver and set up Eclipse for OpenFOAM. After a short introduction in Eclipse's developing features for applications and libraries, debugging in the Eclipse environment using the GNU Debugger GDB will be presented. Everything will be carried out with simpleFoam on the test case pitzDaily while having a look at the turbulence models as libraries.

5 Download and set up Eclipse

To start developing OpenFOAM with Eclipse just download the current version for C/C++ from www.eclipse.org/downloads/. This version already contains the C++ extension CDT (C/C++ Development Tools). Unpack the downloaded file and start Eclipse by clicking on the executable or start Eclipse from the terminal after setting the path variable.

For more information on CDT and CDT installation refer to Further information.

While launching create your own workspace or use the default workspace (for further information refer to Limit number of sources). Change developing environment to C++ in the menu bar under Window -> Show View -> C/C++ Projects. Create a new C++ project in the menu bar under Files -> New -> C++ Project. A C++ project can be a test case, an application or a library of OpenFOAM. Deactivate Use default location, then select the folder you want to import. Set a name for your project. Click Finish.

Import simpleFoam

Now, set the OpenFOAM compiler properties for Eclipse. Right-click on your new project in the project explorer on the left side, select properties. Set the compiler command under C/C++-Build. Deactivate the default build command and type in OpenFOAM's wmake. Deactivate Generate Makefiles automatically. Set the build directory – maybe you have to remove the /Release or /Debug. Click OK. Make sure, that Project -> Automatically build in the menu bar is deactivated.

Set build command

6 Developing and compiling