Table of Contents
Fetching ...

Foam-Agent 2.0: An End-to-End Composable Multi-Agent Framework for Automating CFD Simulation in OpenFOAM

Ling Yue, Nithin Somasekharan, Tingwen Zhang, Yadi Cao, Shaowu Pan

TL;DR

Foam-Agent tackles the barrier of deploying CFD by delivering an end-to-end, multi-agent framework that automates OpenFOAM workflows from natural language prompts. It couples modular agents with a composable Model Context Protocol, Retrieval-Augmented Generation, and LangGraph-based orchestration to jointly handle geometry/meshing, configuration generation, execution on local or HPC resources, and visualization. The system is validated on 110 OpenFOAM cases across 11 physics categories, achieving an 88.2% executable success rate with Claude 3.5 Sonnet, significantly outperforming baselines. This work lowers the CFD expertise barrier, demonstrates portability through external meshes and Gmsh-based meshing, and provides a scalable, auditable pipeline suitable for integration with other AI agents and workflows.

Abstract

Computational Fluid Dynamics (CFD) is an essential simulation tool in engineering, yet its steep learning curve and complex manual setup create significant barriers. To address these challenges, we introduce Foam-Agent, a multi-agent framework that automates the entire end-to-end OpenFOAM workflow from a single natural language prompt. Our key innovations address critical gaps in existing systems: 1. An Comprehensive End-to-End Simulation Automation: Foam-Agent is the first system to manage the full simulation pipeline, including advanced pre-processing with a versatile Meshing Agent capable of handling external mesh files and generating new geometries via Gmsh, automatic generation of HPC submission scripts, and post-simulation visualization via ParaView. 2. Composable Service Architecture: Going beyond a monolithic agent, the framework uses Model Context Protocol (MCP) to expose its core functions as discrete, callable tools. This allows for flexible integration and use by other agentic systems, such as Claude-code, for more exploratory workflows. 3. High-Fidelity Configuration Generation: We achieve superior accuracy through a Hierarchical Multi-Index RAG for precise context retrieval and a dependency-aware generation process that ensures configuration consistency. Evaluated on a benchmark of 110 simulation tasks, Foam-Agent achieves an 88.2% success rate with Claude 3.5 Sonnet, significantly outperforming existing frameworks (55.5% for MetaOpenFOAM). Foam-Agent dramatically lowers the expertise barrier for CFD, demonstrating how specialized multi-agent systems can democratize complex scientific computing. The code is public at https://github.com/csml-rpi/Foam-Agent.

Foam-Agent 2.0: An End-to-End Composable Multi-Agent Framework for Automating CFD Simulation in OpenFOAM

TL;DR

Foam-Agent tackles the barrier of deploying CFD by delivering an end-to-end, multi-agent framework that automates OpenFOAM workflows from natural language prompts. It couples modular agents with a composable Model Context Protocol, Retrieval-Augmented Generation, and LangGraph-based orchestration to jointly handle geometry/meshing, configuration generation, execution on local or HPC resources, and visualization. The system is validated on 110 OpenFOAM cases across 11 physics categories, achieving an 88.2% executable success rate with Claude 3.5 Sonnet, significantly outperforming baselines. This work lowers the CFD expertise barrier, demonstrates portability through external meshes and Gmsh-based meshing, and provides a scalable, auditable pipeline suitable for integration with other AI agents and workflows.

Abstract

Computational Fluid Dynamics (CFD) is an essential simulation tool in engineering, yet its steep learning curve and complex manual setup create significant barriers. To address these challenges, we introduce Foam-Agent, a multi-agent framework that automates the entire end-to-end OpenFOAM workflow from a single natural language prompt. Our key innovations address critical gaps in existing systems: 1. An Comprehensive End-to-End Simulation Automation: Foam-Agent is the first system to manage the full simulation pipeline, including advanced pre-processing with a versatile Meshing Agent capable of handling external mesh files and generating new geometries via Gmsh, automatic generation of HPC submission scripts, and post-simulation visualization via ParaView. 2. Composable Service Architecture: Going beyond a monolithic agent, the framework uses Model Context Protocol (MCP) to expose its core functions as discrete, callable tools. This allows for flexible integration and use by other agentic systems, such as Claude-code, for more exploratory workflows. 3. High-Fidelity Configuration Generation: We achieve superior accuracy through a Hierarchical Multi-Index RAG for precise context retrieval and a dependency-aware generation process that ensures configuration consistency. Evaluated on a benchmark of 110 simulation tasks, Foam-Agent achieves an 88.2% success rate with Claude 3.5 Sonnet, significantly outperforming existing frameworks (55.5% for MetaOpenFOAM). Foam-Agent dramatically lowers the expertise barrier for CFD, demonstrating how specialized multi-agent systems can democratize complex scientific computing. The code is public at https://github.com/csml-rpi/Foam-Agent.

Paper Structure

This paper contains 46 sections, 6 figures, 5 tables, 2 algorithms.

Figures (6)

  • Figure 1: Foam-Agent system architecture illustrating the complete end-to-end workflow from natural language input to post-processing visualization. The system features six primary agents with dynamic adaptive workflow topology: 1. Architect Agent: interprets user query and plans file and folder structures to be generated, 2. Meshing Agent: generates the OpenFOAM compatible mesh required to perform the simulation. Mesh can be produced by the agent itself using OpenFOAM native meshing modules or by using Gmsh meshing library. The user also has the option to provide the agent with externally developed mesh files in the form of .msh files or OpenFOAM native blockMeshDict/snappyHexMeshDict. 3. Input Writer Agent: generates OpenFOAM configuration files required to run the simulation like 0/U, 0/p, constant/physicalProperties, system/controlDict etc. 4. Runner Agent executes simulation either in the local environment of the user or in high performance computing environment as requested by the user in the prompt, 5. Reviewer Agent: diagnoses errors and proposes corrections through iterative debugging cycles. 6. Visualization Agent: generates visuals of physical quantities, if requested by the user within the user prompt, using Paraview/Pyvista python libraries. This adaptive workflow allows agents to autonomously determine execution paths based on intermediate results and problem complexity.
  • Figure 2: Modularized Foam-Agent architecture using model context protocol (MCP).
  • Figure 3: Comparison of simulation results produced by MetaOpenFOAM and Foam-Agent for CounterFlowFlame, wedge and forwardStep cases against the human expert generated ground truth. The top row shows the CH$_4$ mass fraction distribution comparison in CounterFlowFlame case at t=0.5s, the middle row shows the temperature distribution at a timestep of 0.2s for the wedge case and the bottom row shows the velocity magnitude distribution for forwardStep case at a timestep of 4s. Ground truth (left), MetaOpenFOAM (middle) and Foam-Agent (right). The visuals for Foam-Agent are auto generated by the agent. Foam-Agent generates a python script, which upon running loads the case and produces the visual as a .png file. The same python script is used to generate the visuals for ground truth and MetaOpenFOAM results.
  • Figure 4: External mesh file processing ability of Foam-Agent analyzed through a 2D multi-element airfoil (top) and tandem wing case (bottom). The prompt describing the case along with path of the .msh file is given to Foam-Agent. The prompt also mentions that Foam-Agent needs to generate visuals at the final timestep for the velocity magnitude \ref{['prompt:multi_airfoil']} and \ref{['prompt:tandem_wing']}. The architect agent plans the required files needed for the simulation. The external mesh is converted to OpenFOAM compatible format by the meshing agent. With other agentic nodes handling the generation of input files, execution, error correction etc. At the end of workflow, the visualization agent generates a python file, which is also run by the agent to create visuals of the velocity magnitude. The same python file is used in generating the visuals of the human expert generated result to maintain consistency of the qualitative visualization.
  • Figure 5: Flow over a cylinder (top) and flow over two square obstacle (bottom) simulated by Foam-Agent using gmsh meshing library. The user prompt describes that the mesh is to be made using Gmsh and the meshing agent generates the python file required to generate the mesh file utilizing the Gmsh library in python. The execution of the python creates the mesh in .msh format, which is then converted to OpenFOAM compatible format. The flow then proceeds to the other agents handling the generation of input files, running, error correction etc. Finally the agent creates the visuals of the velocity magnitude at the final magnitude as requested by the user within the prompt (\ref{['prompt:cylinder_flow']} and \ref{['prompt:two_squares']}) to Foam-Agent. To emphasize the necessity of Gmsh based mesh generation within the meshing agent, we show the mesh generated by OpenFOAM's native meshing modules given the description of the flow domain. The native meshing modules are unable to capture the obstacles in the domain and produces incorrect simulation result as shown the visualization of the velocity magnitude.
  • ...and 1 more figures