EUVIMEDEUVIMED entdecken
Open Access · CC BY-SA 4.0

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

SIMON ANTONIO RODRIGUEZ LUZARDO, Philip Cardiff

OpenFOAM® Journal · 2022

DOI: 10.51560/ofj.v2.79 ↗

Kurz gefasst

Fachartikel in der Zeitschrift OpenFOAM® Journal, 2022. Verfasst von SIMON ANTONIO RODRIGUEZ LUZARDO und 1 weiteren Autor:innen. Die Arbeit wurde bisher 7-mal zitiert (Crossref). Der Volltext ist frei zugänglich (Open Access, CC BY-SA 4.0).

AbstractBibliografische AngabenZitierenVerwandte Studien

Abstract (Originalsprache)

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.

Zitieren

APA

LUZARDO, S. A. R., & Cardiff, P. (2022). A General Approach for Running Python Codes in OpenFOAM Using an Embedded PYBIND11 Python Interpreter. OpenFOAM® Journal. https://doi.org/10.51560/ofj.v2.79

Vancouver

LUZARDO SAR, Cardiff P. A General Approach for Running Python Codes in OpenFOAM Using an Embedded PYBIND11 Python Interpreter. OpenFOAM® Journal. 2022. doi:10.51560/ofj.v2.79

BibTeX
@article{LUZARDO2022,
  author = {LUZARDO, SIMON ANTONIO RODRIGUEZ and Cardiff, Philip},
  title = {A General Approach for Running Python Codes in OpenFOAM Using an Embedded PYBIND11 Python Interpreter},
  journal = {OpenFOAM® Journal},
  year = {2022},
  doi = {10.51560/ofj.v2.79}
}
Kostenlos starten →