• Home
  • Search
  • A General Approach for Running Python Codes in OpenFOAM Using an Embedded PYBIND11 Python Interpreter
  • Cite Icon11
  • https://doi.org/10.51560/ofj.v2.79Copy DOI Icon

A General Approach for Running Python Codes in OpenFOAM Using an Embedded PYBIND11 Python Interpreter

Show More
  • Abstract
  • Literature Map
  • References
  • Citations
  • Similar Papers
Abstract

As the overlap between traditional computational mechanics and machine learning grows, there is an increasing demand for straight-forward approaches to interface Python-based procedures with C++-based OpenFOAM. This article introduces one such general methodology, allowing the execution of Python code directly within an OpenFOAM solver without the need for Python code translation. The proposed approach is based on the lightweight library pybind11, where OpenFOAM data is transferred to an embedded Python interpreter for manipulation, and results are returned as needed. Following a review of related approaches, the article describes the approach, with a particular focus on data transfer between Python and OpenFOAM, executing Python scripts and functions, and practical details about the implementation in OpenFOAM. Three complementary test cases are presented to highlight the functionality and demonstrate the effect of different data transfer approaches: a Python-based velocity profile boundary condition; a Python-based solver for prototyping; and a machine learning mechanical constitutive law class for solids4foam which performs field calculations.

Similar Papers
  • Research Article
  • Citations17

An investigation of the thermal behavior of constructal theory-based pore-scale porous media by using a combination of computational fluid dynamics and machine learning

  • Jun 11, 2022
  • International Journal of Heat and Mass Transfer
  • Mehrdad Mesgarpour +5
  • Research Article
  • Citations4

Integration of scanning probe microscope with high-performance computing: Fixed-policy and reward-driven workflows implementation.

  • Sep 01, 2024
  • The Review of scientific instruments
  • Yu Liu +10
  • Supplementary Content
  • Citations3

Advances in Computational Modeling and Machine Learning of Cellulosic Biopolymers: A Comprehensive Review

  • Dec 01, 2025
  • Biomimetics
  • Sharmi Mazumder +2
  • PDF
  • Research Article
  • Citations12

Computational intelligence to study the importance of characteristics in flood-irrigated rice

  • Nov 22, 2022
  • Acta Scientiarum. Agronomy
  • Antônio Carlos Da Silva Junior +6
  • PDF
  • Research Article
  • Citations9

Computational modeling of animal behavior in T-mazes: Insights from machine learning

  • May 11, 2024
  • Ecological Informatics
  • Ali Turab +5
  • Research Article
  • Citations82

Applications of computational chemistry, artificial intelligence, and machine learning in aquatic chemistry research

  • Aug 14, 2021
  • Chemical Engineering Journal
  • Lei He +7
  • Research Article
  • Citations65

Efficient alloy design of Sr-modified A356 alloys driven by computational thermodynamics and machine learning

  • Jun 01, 2022
  • Journal of Materials Science & Technology
  • Wang Yi +4
  • PDF
  • Research Article
  • Citations80

Chemist versus Machine: Traditional Knowledge versus Machine Learning Techniques

  • Nov 09, 2020
  • Trends in Chemistry
  • Janine George +1
  • Discussion
  • Citations3

Computational catalysis and machine learning applications to water treatment technologies

  • Jun 01, 2025
  • AI for Science
  • Duo Wang +5
  • PDF
  • Research Article
  • Citations7

A comprehensive study of machine learning techniques for log-based anomaly detection

  • Jun 23, 2025
  • Empirical Software Engineering
  • Shan Ali +4
  • Research Article
  • Citations1

Architectural Design Performance Through Computational Intelligence: A Comprehensive Decision Support Framework

  • Jan 01, 2021
  • Research Repository (Delft University of Technology)
  • Ioannis Chatzikonstantinou
  • Research Article
  • Citations13

Analyzing predictors of in-hospital mortality in patients with acute ST-segment elevation myocardial infarction using an evolved machine learning approach

  • Jan 02, 2024
  • Computers in Biology and Medicine
  • Mengge Gong +5
  • Conference Article
  • Citations5

Comparison and analysis of accuracy of traditional random forest machine learning model and XGBoost model on music emotion classification dataset

  • Oct 27, 2023
  • Jiulin Song
  • Book Chapter
  • Citations9

Aspects of Intercultural Communication in IT: Convergence of Communication and Computing in the Global World of Interconnectedness

  • Aug 22, 2019
  • Marcel Pikhart
  • PDF
  • Research Article
  • Citations61

Prediction of hypertension using traditional regression and machine learning models: A systematic review and meta-analysis.

  • Apr 07, 2022
  • PLOS ONE
  • Mohammad Ziaul Islam Chowdhury +6
Cactus Communications logo

Copyright 2026 Cactus Communications. All rights reserved.