Foam-Agent: Automated CFD Workflow Framework
- Foam-Agent is a multi-agent framework that automates CFD workflows by converting natural language requirements into executable OpenFOAM simulations.
- It integrates hierarchical retrieval-augmented generation, dependency-aware file creation, and automated error correction to improve simulation accuracy and efficiency.
- The modular design enables composable API endpoints and HPC workflow automation, reducing the expertise required for high-fidelity CFD simulations.
Foam-Agent is a class of multi-agent AI frameworks designed to automate end-to-end computational fluid dynamics (CFD) workflows in OpenFOAM from natural language or high-level requirements. These systems are distinguished by their integration of hierarchical retrieval-augmented generation (RAG), dependency-aware file generation, and automated error correction, with modular orchestration that exposes individual services as composable API endpoints. Multiple research efforts have converged on the Foam-Agent paradigm, with notable implementations including "Foam-Agent: Towards Automated Intelligent CFD Workflows", "Foam-Agent 2.0: An End-to-End Composable Multi-Agent Framework for Automating CFD Simulation in OpenFOAM", and other closely related systems targeting specialized solvers such as FireFOAM. These frameworks substantially reduce the expertise required to execute high-fidelity CFD simulations, shifting much of the domain complexity into machine-interpretable workflows (Yue et al., 8 May 2025, Yue et al., 17 Sep 2025, Xu et al., 2024, Xiao et al., 12 Feb 2026).
1. System Architecture and Agent Composition
Foam-Agent frameworks are architected as closed-loop multi-agent systems. The canonical design is centered around a cyclical refinement loop among purpose-built sub-agents, typically including:
- Architect Agent: Converts user requirements into an explicit simulation plan, decomposing workflows into file-generation and mesh-construction tasks. It leverages hierarchical multi-index RAG to retrieve technical exemplars and templates relevant to each stage (Yue et al., 8 May 2025, Yue et al., 17 Sep 2025).
- Input Writer Agent: Generates OpenFOAM configuration files (blockMeshDict, snappyHexMeshDict, controlDict, fvSchemes, etc.) in dependency order, validating syntactic and contextual integrity at each generation step. The dependency graph for a case is modeled as a DAG, enforcing that upstream files (e.g., mesh dictionaries) are written prior to dependent files (e.g., solver settings).
- Meshing Agent: Handles the creation or ingestion of meshes, including converting external mesh formats (e.g., Gmsh, .msh) and supporting advanced mesh generation pipelines. Integration with external tools and geometric modeling utilities is built-in (Yue et al., 17 Sep 2025).
- Runner Agent: Manages environment setup (local or HPC), job submission (including auto-generation of submission scripts in SLURM or similar), execution, status monitoring, and output logging.
- Reviewer Agent: Parses simulation logs and the evolving case context to identify errors or inconsistencies, performing automated iterative refinement of configuration files until successful execution or an iteration limit is reached.
- Visualization Agent: Automates generation of post-processing visualizations using libraries such as PyVista or ParaView, producing publication-ready output and supporting iterative repair of visualization scripts.
- MCP Service Layer: All sub-agents expose their capabilities as typed functions under a Model Context Protocol (MCP) API, allowing orchestration by higher-level agent systems or external software. All agent interactions, control flow, and state transitions are managed by a workflow orchestrator (typically LangGraph).
The orchestrator cycles through planning, generation, execution, error review, and further generation until termination criteria (success or failure) are met. This modular agent design enables composability, integration into broader agent ecosystems, and hybrid workflows mixing autonomous and human-in-the-loop operations (Yue et al., 17 Sep 2025).
2. Retrieval-Augmented Generation and Contextual Retrieval
A foundational principle in Foam-Agent is stage-aware retrieval using hierarchical multi-index RAG:
- The knowledge base is partitioned into multiple FAISS indices, each dedicated to a specific simulation aspect: tutorial structures, detailed file exemplars, execution scripts, and command documentation.
- At every workflow stage , the relevant index is selected. The current query is embedded (e.g., text-embedding-3-small, ), and the top- semantically similar documents are retrieved by cosine similarity:
- Retrieved contexts are filtered and formatted relative to current stage and context, then condition the file/content generation LLM.
- Ablation studies demonstrate that hierarchical multi-index retrieval achieves 12–14 percentage points higher workflow completion than monolithic retrieval, and 36 percentage points higher than simple file-based or single-index approaches (Yue et al., 8 May 2025, Yue et al., 17 Sep 2025).
This retrieval architecture ensures that only technically relevant precedents and schema fragments are available at each agent invocation, minimizing off-topic context and hallucination frequency while supporting both standard and edge-case configurations.
3. Dependency-Aware File Generation and Configuration Consistency
OpenFOAM simulation cases are defined by interdependent dictionaries and directory structures; configuration consistency is critical. Foam-Agent approaches this by:
- Modeling configuration files as nodes in a directed acyclic graph , with edges for required precedence (e.g., geometry must be specified before mesh refinement parameters).
- Determining file generation order via topological sort of .
- At every step , generating given the context = union of all previously generated files and any strict dependencies.
- All generated files are validated for schema compliance (using, for example, Pydantic) and reference consistency across parameters.
- The process is outlined algorithmically as:
1 2 3 4 5 |
for each F_i in topo(G):
ctx = union of contents(F_j for j < i)
c_i = generate_file_content(case_id, F_i, ctx)
validate(c_i)
accumulate(c_i) |
- Parameter mismatches or missing fields are detected and corrected on the fly.
Empirical results show that the dependency-aware, context-driven approach yields superior cross-file consistency and reduces both error incidence and manual post-processing relative to baseline agent frameworks (Yue et al., 8 May 2025, Yue et al., 17 Sep 2025).
4. Automated Error Correction and Iterative Refinement
Foam-Agent incorporates an explicit error correction loop:
- After each run, the Runner Agent parses logs and captures exit status.
- The Reviewer Agent analyzes logs for patterns matching OpenFOAM error messages, referencing a corpus of known resolutions and past correction history.
- Minimal corrections to configuration files are computed with the goal:
- Corrections are applied, then the system reruns the failed step or the entire pipeline as dictated by dependency propagation.
- This process is repeated until the simulation executes successfully or a maximum iteration bound is reached.
- Ablation experiments demonstrate that this loop alone confers a 36–46 percentage point improvement in executable success rate relative to non-repairing agents, especially for nontrivial and edge-case tasks (Yue et al., 8 May 2025, Yue et al., 17 Sep 2025).
The approach successfully automates “debug cycles” that would otherwise consume expert time, particularly for resolving configuration and numerical inconsistencies.
5. Evaluation: Benchmarks, Success Rates, and Comparative Performance
Foam-Agent and its successors are evaluated on curated benchmarks such as the 110-case dataset in (Yue et al., 8 May 2025, Yue et al., 17 Sep 2025), spanning:
| Physics Category | Number of Cases |
|---|---|
| Laminar Flow | 30 |
| Turbulent Flow | 20 |
| Heat Transfer | 20 |
| Multiphase/Free Surface | 10 |
| Combustion/Reactive | 10 |
| Shallow Water/Geo | 10 |
| Shock Dynamics | 10 |
“Executable success rate” is defined as the percentage of cases running to completion. Table of results:
| Framework/LLM | MetaOpenFOAM | OpenFOAMGPT-Alt | Foam-Agent |
|---|---|---|---|
| Claude 3.5 Sonnet | 55.5% | 37.3% | 83.6–88.2% |
| GPT-4o | 17.3% | 45.5% | 59.1% |
These figures establish that Foam-Agent represents a major advance in workflow automation fidelity. The highest success rates are achieved for Claude 3.5 Sonnet with the most recent Foam-Agent 2.0, due to both hierarchical RAG and iterative repair (Yue et al., 17 Sep 2025).
Ablations indicate hierarchy in RAG and the Reviewer Agent are both essential; removing either drops performance below 60%. Mesh generation and geometry ingestion (notably with Gmsh or external .msh) are now robust. Nonetheless, cases outside the scope of the indexed tutorial corpus or involving exotic physics remain more challenging.
6. Applications, Impact, and Limitations
Foam-Agent fundamentally lowers the “CFD expertise threshold” for OpenFOAM-based simulation workflows. Key usage scenarios include:
- Natural-language–driven simulation setup, mesh generation (OpenFOAM/blockMesh, snappyHexMesh, or Gmsh pipelines), boundary and initial condition assignment, solver launch, and post-processing visualization, all without manual dictionary editing.
- Automated error correction, substantially reducing non-deterministic solver failures and cryptic OpenFOAM error loops prevalent among novice and intermediate users.
- Seamless composability: Foam-Agent’s MCP architecture enables integration within larger agentic and design-of-experiments pipelines, as implemented in Claude-code and AutoGen orchestrators.
- HPC workflow automation: empirical results cover successful SLURM script generation and parallel job monitoring, though some site-specific submission syntax may still require minimal post-hoc adjustment.
Identified limitations:
- Coverage is limited by the breadth of indexed tutorials and explicit command documentation.
- Handling of nonstandard solver physics (e.g., EDC, non-Newtonian fluids) is dependent on retrieval corpus enrichment.
- Mesh-quality diagnostics and AMR (adaptive mesh refinement) integration are open future directions.
- Reliance on the underlying LLM’s knowledge can lead to catastrophic error propagation if user prompts are underspecified or retrieval fails.
A plausible implication is that as domain-specific pretraining improves and indexed corpora expand, success rates for novel and multiphysics cases will further approach expert-level manual performance.
7. Variant Systems and Specializations
Several related frameworks targeting distinct OpenFOAM-based solvers illustrate variant strategies within the Foam-Agent paradigm:
- FoamPilot targets FireFOAM for fire dynamics and suppression scenario modeling, introducing three primary modules: code insight (RAG-powered source summarization), case configuration (prompt-driven dictionary edits), and job execution/analysis (local and HPC, including preliminary result plotting). FoamPilot is orchestrated via LangChain/LangGraph and achieves near-perfect task success for simple queries, with degraded reliability for multi-step or HPC tasks due to current LLM and orchestration constraints (Xu et al., 2024).
- Lightweight tool-using coding agents configured for OpenFOAM (as in (Xiao et al., 12 Feb 2026)) utilize tutorial-first retrieval and log-driven repair within a general-purpose agent loop, showing that even minimal configuration confers substantial performance gains if baseline infrastructure is robust.
- Early single-agent variants lack the automated Reviewer loop or composability of MCP-based Foam-Agent implementations, reflected in lower success rates and greater manual intervention requirements.
Each system highlights the transformative effect of LLM-centered agentic workflows on complex simulation science and illustrates ongoing progress in the field.
Foam-Agent is thus best understood as a robust, modular, and extensible multi-agent automation solution for OpenFOAM workflows, incorporating state-of-the-art LLM tooling, retrieval, dependency management, and error correction to democratize and accelerate high-fidelity CFD simulation (Yue et al., 8 May 2025, Yue et al., 17 Sep 2025, Xu et al., 2024, Xiao et al., 12 Feb 2026).