This repository contains the OpenFOAM source code, differentiated using automatic differentiation (AD) in both forward and reverse modes. OpenFOAM is a free, open source CFD software released and developed primarily by OpenCFD Ltd.
We only differentiate certain versions of OpenFOAM releases. Please check the branches (e.g., v2506-ad) in this repository; the main branch does not contain any AD code.
The default build will be for the reverse mode AD (export WM_AD_MODE=ADR). To compile the forward mode AD, change WM_AD_MODE to ADF in OpenFOAM-AD/etc/bashrc, source it, and rebuild.
NOTE: OpenFOAM-AD only differentiates necessary libraries for computing partial derivatives and matrix-vector products for DAFoam; it has NOT differentiated the entire OpenFOAM code yet. In other words, some functionalities are still missing (e.g., functionObjects and Thirdparty-related libs).
OpenFOAM-AD uses the AD tools CoDiPack and MeDiPack, developed by Dr. Nicolas Gauger's group at TU Kaiserslautern. In addition, the differentiation is inspired by discreteAdjointOpenFOAM, developed by Dr. Markus Towara et al. from RWTH Aachen University.
Distributed using the GNU General Public License (GPL), version 3; see the COPYING file for details.