A converter utility that translates OpenFOAM mesh and field data into the Exodus II database format.
foam2exodus is a tool designed to convert OpenFOAM computational fluid dynamics (CFD) cases into the Exodus II format, a widely-used database format for finite element analysis. The Exodus II format enables visualization and post-processing in various scientific visualization tools such as ParaView, VisIt, and others.
Currently Implemented:
- Serial OpenFOAM mesh conversion (ASCII and binary formats)
- Conversion of mesh geometry (points, cells, faces)
- Boundary patch export as Exodus sidesets
- Support for hexahedral, tetrahedral, and pyramid cell types
- Cell zones preservation
Planned Features:
- Field data conversion from all time directories
- Parallel OpenFOAM case support
- Option to generate single or decomposed Exodus database files according to user preference
- Time-series data export
-
CMake (version 3.10 or higher)
cmake --version # Check your version -
C++ Compiler with C++17 support
- GCC 7.0+ or
- Clang 5.0+ or
- Any C++17 compliant compiler
-
NetCDF Library (with C interface)
- Development headers and libraries are required
Installation on Ubuntu/Debian:
sudo apt-get install libnetcdf-dev pkg-config
Installation on Fedora/RHEL/CentOS:
sudo yum install netcdf-devel pkgconfig
Installation on macOS (using Homebrew):
brew install netcdf pkg-config
-
pkg-config
- Used by CMake to locate NetCDF installation
- Usually comes pre-installed on Linux systems
- On macOS:
brew install pkg-config
cd /path/to/foam2exodusmkdir build
cd buildcmake ..If NetCDF is installed in a non-standard location, you may need to help CMake find it:
export PKG_CONFIG_PATH=/path/to/netcdf/lib/pkgconfig:$PKG_CONFIG_PATH
cmake ..makeFor faster compilation on multi-core systems:
make -j$(nproc) # Linux
make -j$(sysctl -n hw.ncpu) # macOSsudo make installThis will install the foam2exodus executable to /usr/local/bin by default.
foam2exodus <OpenFOAM_case_dir> <output.exo>Convert multiple meshes and merge into single exodus file
foam2exodus --multiple <OpenFOAM_case_dir_1> <OpenFOAM_case_dir_2> <output.exo><OpenFOAM_case_dir>: Path to the OpenFOAM case directory containing theconstant/polyMeshfolder<output.exo>: Desired path and filename for the output Exodus II database file
Convert a serial OpenFOAM case:
./foam2exodus /path/to/openfoam/case myMesh.exoConvert and specify full output path:
./foam2exodus ~/simulations/cavity ~/results/cavity_mesh.exoThe converter will display:
- Mesh statistics (number of points, cells, boundary patches)
- Progress information
- Success/error messages
Boundary patches from OpenFOAM are automatically exported as sidesets in the Exodus file, preserving their names and topology.
- ASCII format (human-readable text files)
- Binary format (OpenFOAM binary mesh files)
- Hexahedra (hex)
- Tetrahedra (tet)
- Pyramids (pyramid)
- Points (vertices)
- Faces
- Cell connectivity
- Boundary patches
- Cell zones
- Owner/neighbour cell relationships
foam2exodus/
├── CMakeLists.txt # CMake build configuration
├── README.md # This file
├── foam2exodus/
│ ├── main.cpp # Main entry point
│ ├── src/
│ │ ├── OpenFOAMMeshReader.h # OpenFOAM mesh reader interface
│ │ ├── OpenFOAMMeshReader.cpp # OpenFOAM mesh parser implementation
│ │ ├── ExodusWriter.h # Exodus II writer interface
│ │ └── ExodusWriter.cpp # Exodus II database writer
│ └── examples/ # Example test cases
└── build/ # Build directory (created by user)
If you encounter:
Could not find module FindNetCDF.cmake
Ensure:
- NetCDF development packages are installed
- pkg-config is installed and functional
- PKG_CONFIG_PATH includes the NetCDF pkgconfig directory
Test NetCDF installation:
pkg-config --modversion netcdfIf you see C++17-related errors, ensure your compiler supports C++17:
g++ --version # Should be 7.0 or higher
clang++ --version # Should be 5.0 or higher"Cannot find polyMesh directory"
- Ensure the OpenFOAM case directory contains
constant/polyMesh/ - Verify the case path is correct
"Error reading mesh files"
- Check that mesh files (points, faces, owner, neighbour, boundary) exist
- Verify file permissions are readable
This project is under active development. Contributions, bug reports, and feature requests are welcome.
BSD-3-Clause. See file headers for details.
Copyright (c) 2026 CCFNUM, Lucerne University of Applied Sciences and Arts.
- Project Maintainer: Lucian Hanimann (lucian.hanimann@hslu.ch)