menu

Basic OpenFOAM Programming

One of the greatest strengths of open-source software is its adaptability, made possible through access to the source code. This flexibility allows users to modify, expand, and customize the software to meet specific needs, making OpenFOAM® one of the most popular tools for developing new Computational Fluid Dynamics (CFD) functionalities. Whether you're an experienced programmer or just starting, the ability to access and work with OpenFOAM's source code opens up endless possibilities for learning, innovation, and solving unique problems.

To help you explore OpenFOAM® programming, we've created a series of tutorials that serve as complementary materials for the online lecture "Basic OpenFOAM Programming." This lecture series is carefully designed to guide you step by step through the core principles of working with OpenFOAM® code. By following these tutorials, you'll gain practical experience in understanding how OpenFOAM® works under the hood and learn how to modify and extend its capabilities to suit your projects.

The tutorials are based on OpenFOAM-12, the latest version at the time of writing, providing you with up-to-date insights into its features and structure. However, the skills and knowledge you’ll gain from these tutorials are not limited to a single version—they are broadly applicable to other OpenFOAM® versions, ensuring that you can apply what you learn to different setups and future releases. Whether you're using OpenFOAM® for academic research, industrial projects, or personal development, these resources are here to help you get started and grow your expertise.

Level: Beginner

Prerequisites: Basic to intermediate knowledge of Linux, OpenFOAM, and C++

Tutorial 1

keyboard_arrow_down

Adding a New Material Model to OpenFOAM

Steps:

  • Create a new viscosity library
  • Program and compile the viscosity model
  • Integrate the library into a simulation

OpenFOAM Version: 12

Solver: foamRun

Tutorial case: pitzDaily

Tutorial 2

keyboard_arrow_down

Adding a New Boundary Condition to OpenFOAM

Steps:

  • Create a new boundary condition
  • Program and compile the boundary condition
  • Integrate the library into a simulation

OpenFOAM Version: 12

Solver: foamRun

Tutorial case: pitzDaily

Tutorial 3

keyboard_arrow_down

Modifying an OpenFOAM solver by adding a tracer equation

Steps:

  • Creating the required fields and access to the dictionaries
  • Implementing scalar transport equation and compiling
  • Testing it on the provided tutorial

OpenFOAM Version: 12

Solver: myFoamRun

Tutorial case: pitzDaily

License:

Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)

This is a human-readable summary of the Legal Code (the full license).

Disclaimer

You are free:

  • to Share — to copy, distribute and transmit the work
  • to Remix — to adapt the work

Under the following conditions:

  • Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
  • Noncommercial — You may not use this work for commercial purposes.
  • Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

With the understanding that:

  • Waiver — Any of the above conditions can be waived if you get permission from the copyright holder.
  • Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license.
  • Other Rights — In no way are any of the following rights affected by the license:
  • Your fair dealing or fair use rights, or other applicable copyright exceptions and

limitations;

  • The author's moral rights;
  • Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.
  • Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.