Skip to main content
Cornell University
We gratefully acknowledge support from the Simons Foundation, member institutions, and all contributors. Donate
arxiv logo > cs > arXiv:2203.16394

Help | Advanced Search

arXiv logo
Cornell University Logo

quick links

  • Login
  • Help Pages
  • About

Computer Science > Computational Engineering, Finance, and Science

arXiv:2203.16394 (cs)
[Submitted on 30 Mar 2022]

Title:A general approach for running Python codes in OpenFOAM using an embedded pybind11 Python interpreter

Authors:Simon Rodriguez, Philip Cardiff (School of Mechanical and Materials Engineering, University College Dublin, Ireland)
View a PDF of the paper titled A general approach for running Python codes in OpenFOAM using an embedded pybind11 Python interpreter, by Simon Rodriguez and Philip Cardiff (School of Mechanical and Materials Engineering and 2 other authors
View PDF
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.
Comments: Preprint submitted to OpenFOAM Journal
Subjects: Computational Engineering, Finance, and Science (cs.CE)
Cite as: arXiv:2203.16394 [cs.CE]
  (or arXiv:2203.16394v1 [cs.CE] for this version)
  https://doi.org/10.48550/arXiv.2203.16394
arXiv-issued DOI via DataCite
Related DOI: https://doi.org/10.51560/ofj.v2.79
DOI(s) linking to related resources

Submission history

From: Simon Antonio Rodriguez Luzardo [view email]
[v1] Wed, 30 Mar 2022 15:25:03 UTC (928 KB)
Full-text links:

Access Paper:

    View a PDF of the paper titled A general approach for running Python codes in OpenFOAM using an embedded pybind11 Python interpreter, by Simon Rodriguez and Philip Cardiff (School of Mechanical and Materials Engineering and 2 other authors
  • View PDF
  • TeX Source
license icon view license
Current browse context:
cs.CE
< prev   |   next >
new | recent | 2022-03
Change to browse by:
cs

References & Citations

  • NASA ADS
  • Google Scholar
  • Semantic Scholar
export BibTeX citation Loading...

BibTeX formatted citation

×
Data provided by:

Bookmark

BibSonomy logo Reddit logo

Bibliographic and Citation Tools

Bibliographic Explorer (What is the Explorer?)
Connected Papers (What is Connected Papers?)
Litmaps (What is Litmaps?)
scite Smart Citations (What are Smart Citations?)

Code, Data and Media Associated with this Article

alphaXiv (What is alphaXiv?)
CatalyzeX Code Finder for Papers (What is CatalyzeX?)
DagsHub (What is DagsHub?)
Gotit.pub (What is GotitPub?)
Hugging Face (What is Huggingface?)
Papers with Code (What is Papers with Code?)
ScienceCast (What is ScienceCast?)

Demos

Replicate (What is Replicate?)
Hugging Face Spaces (What is Spaces?)
TXYZ.AI (What is TXYZ.AI?)

Recommenders and Search Tools

Influence Flower (What are Influence Flowers?)
CORE Recommender (What is CORE?)
  • Author
  • Venue
  • Institution
  • Topic

arXivLabs: experimental projects with community collaborators

arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.

Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.

Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.

Which authors of this paper are endorsers? | Disable MathJax (What is MathJax?)
  • About
  • Help
  • contact arXivClick here to contact arXiv Contact
  • subscribe to arXiv mailingsClick here to subscribe Subscribe
  • Copyright
  • Privacy Policy
  • Web Accessibility Assistance
  • arXiv Operational Status