foamlib: A modern Python interface for interacting with OpenFOAM
Keywords:
OpenFOAM, Python, testing, SlurmAbstract
We introduce foamlib, an open-source Python library developed for the purpose of interacting with OpenFOAM. foamlib provides an object-oriented interface for pre-processing, executing, and post-processing OpenFOAM cases, with capabilities for accessing and editing their related files. foamlib is mainly targeted towards testing and optimization runs, which commonly require executing a large number of different cases and analyzing their results programmatically. It has the capability to autodetect the steps needed to run a case, and will automatically arrange tasks so that multiple cases can run simultaneously without oversubscribing the available CPUs. It can even orchestrate runs across computing nodes in a Slurm-based cluster environment. foamlib includes its own custom parser and serializer for OpenFOAM files, which allows reading and writing these files even on systems without an OpenFOAM installation.In comparison with other related libraries also available, foamlib supports Python versions from 3.7 up to the latest release, and allows users to take advantage of modern Python features such as type checking and asynchronous programming. It can also read and write fields stored in files using OpenFOAM's optional mixed text/binary format. foamlib is distributed under a GPLv3 license as a registered Python package, as well as in the form of Docker images. It is compatible with the two major distributions of OpenFOAM.
Downloads
Published
Issue
Section
License
Copyright (c) 2024 Argentine Association for Computational Mechanics

This work is licensed under a Creative Commons Attribution 4.0 International License.
This publication is open access diamond, with no cost to authors or readers.
Only those abstracts that have been accepted for publication and have been presented at the AMCA congress will be published.