---
title: 'MetaOpenFOAM 2.0: Automating CFD Workflows'
url: https://www.emergentmind.com/topics/metaopenfoam-2-0
type: topic
---

# MetaOpenFOAM 2.0: Automating CFD Workflows

MetaOpenFOAM 2.0 is a large language model (LLM)-driven system for automating computational fluid dynamics (CFD) simulation and post-processing workflows based on OpenFOAM. It integrates chain-of-thought (COT) decomposition, retrieval-augmented generation (RAG), and iterative verification mechanisms to convert natural language requirements into executable CFD tasks for both simulations and complex post-processing. MetaOpenFOAM 2.0 demonstrates improved automation, accuracy, and cost-efficiency compared to previous approaches, significantly outperforming its predecessor across a standardized benchmark suite [2502.00498].

## 1. System Architecture

MetaOpenFOAM 2.0 features a multi-agent, modular pipeline that orchestrates automation of CFD workflows in the following stages:

- **Natural-Language Parser**: Normalizes free-form user requirements for downstream processing.
- **Retrieval-Augmented Generation (RAG)**: Embeds the normalized requirement in a FAISS vector store, retrieving the top-$k$ OpenFOAM tutorial/case exemplars to ground subsequent reasoning.
- **QDCOT Decomposer**: Applies a hierarchical, two-stage question decomposition, first partitioning the requirement into coarse tasks (simulation and post-processing), then further dividing into granular subtasks specific to OpenFOAM or post-processing routines.
- **Iterative COT (ICOT) Loop**: For each subtask, iterates between three agents—InputWriter (generates/edits inputs/scripts), Runner (executes shell commands, captures outputs/errors), and Reviewer (inspects, comments, triggers rewrites)—until the subtask is resolved or a maximum iteration cap is reached.
- **LLM-Assisted Final Verifier**: Checks global physical and numerical validity, verifying satisfaction of user intent, boundary conditions, flow characteristics, convergence, and physical consistency.

The backbone of the system is concisely presented in Algorithm 1:

```
1. {T₁, T₂} ← φ(Q)                  〈QDCOT‐1〉
2. For each Tᵢ, {sᵢ,₁, …} ← ψ(Tᵢ)   〈QDCOT‐2〉
3. For each subtask s:
   a. i ← 0
   b. repeat
        i ← i+1
        xᵢ ← InputWriter(s, eᵢ₋₁)
        eᵢ ← Runner(xᵢ)
      until eᵢ = ∅ or i ≥ Iₘₐₓ       〈ICOT〉
4. V ← FinalVerifier(all outputs)
5. if V indicates error in sⱼ: go to step 3 for sⱼ
6. Return R
```

Here, $φ$ denotes task-level decomposition, $ψ$ subtask-level decomposition, and $V$ the final verification step [2502.00498].

## 2. Chain-of-Thought (COT) Decomposition

COT in MetaOpenFOAM 2.0 is realized as a structured, two-level hierarchy:

- **Task-Level Decomposition $(φ)$:** The requirement $Q$ is divided into $\{T_1, T_2\}$ where $T_1$ is “CFD simulation,” $T_2$ is “CFD post-processing.”
- **Subtask-Level Decomposition $(ψ)$:** Each $T_i$ maps to an ordered list $S = ψ(T_i) = \{s_{i,1}, s_{i,2}, \ldots\}$, e.g., $ψ(T_1) = \{$write controlDict, run pimpleFoam, check convergence$\}$ and $ψ(T_2) = \{$run post-process commands, convert to VTK, run Python script$\}$.

This explicit task-subtask breakdown, summarized as $S = ψ(φ(Q))$, localizes computational and logical errors and mitigates cross-domain propagation between simulators, shell, and Python subsystems.

## 3. Iterative Verification and Correction Mechanism

Each subtask $s$ undergoes an Iterative Chain-of-Thought (ICOT) refinement loop defined as follows:

Given an initial state $x_0$, at each iteration $k \geq 1$:
\[
\begin{aligned}
e_k &= \text{Runner}(x_k) \quad (\text{error message or } \varnothing \text{ if success})\\
x_{k+1} &= 
  \begin{cases}
    \text{InputWriter}(x_k, e_k) & e_k \neq \varnothing,\, k < I_{\max} \\
    x_k & e_k = \varnothing \text{ or } k \geq I_{\max}
  \end{cases}
\end{aligned}
\]

The loop continues until either $e_k = \varnothing$ or $k$ saturates $I_{\max}$ (default 10). Upon subtask completion, the LLM-driven FinalVerifier checks assembled outputs for requirement satisfaction, physical and numerical accuracy (e.g., $y^+$ range, convergence), and boundary consistency. Detected errors route the process back to the offending subtask [2502.00498].

## 4. Benchmarking and Metrics

MetaOpenFOAM 2.0’s assessment employs a 13-task benchmark suite with seven simulation cases (e.g., incompressible RANS flows, DNS-HIT, reactingFoam) and six post-processing cases (extractions like max $y^+$, TKE, plus visualization outputs).

Key metrics include:

- **Executability $A \in \{0,\ldots, 7\}$**: Ranging from simulation-only completion (0–3), through mix CLI/Python post-processing (4–5), numerical/physical validation (6), to human-judged flawless execution (7).
- **Cost Metrics**: Total agent iterations $(I_{\text{sim}}, I_{\text{CLI}}, I_{\text{Py}})$, token usage $T = T_{\text{prompt}} + T_{\text{completion}}$, and USD-equivalent cost (average \$0.15/case).
- **Pass@k**: Fraction of $n$ generated samples with $A=7$ among the top-$k$, e.g., for $n=10, k=1$, $\text{pass@1}$ represents single-shot success:
\[
\text{pass@}k = \mathbb{E}_{\text{problems}}\left[1 - \frac{\binom{n-c}{k}}{\binom{n}{k}}\right]
\]

This evaluation framework quantifies both accuracy and cost-efficiency [2502.00498].

## 5. Experimental Performance and Ablation Studies

MetaOpenFOAM 2.0 demonstrates significant gains over MetaOpenFOAM 1.0 in all core metrics. Averaged across 13 tasks and 10 runs, the results are:

| Metric                | MetaOpenFOAM 1.0 | MetaOpenFOAM 2.0 |
|-----------------------|------------------|------------------|
| Executability $A$     | 2.1/7            | 6.3/7            |
| Pass@1 (%)            | 0%               | 86.9%            |
| Avg. token usage      | 47,426           | 36,448           |
| Avg. cost (USD)       | \$0.22           | \$0.15           |
| Avg. iterations       | 6.7              | 3.7              |

Ablation results underscore that both COT decompositions and ICOT iterative correction are essential. Removal of CLI/Python post-processing in the QDCOT ablations drops $A$ to around 2.1, while omitting the ICOT reviewer loop reduces $A$ to 1.4. Full system synergy provides a $\sim$+4 increase in $A$ over monolithic (non-modular) approaches. Simulation-only tasks typically reach $A \approx 7$ in near-minimal ICOT iterations, whereas more challenging DNS or complex post-processing tasks achieve lower, but still robust scores [2502.00498].

## 6. Post-Training Scaling Laws

The system exhibits two post-training scaling regularities:

- **Executability versus QDCOT steps $(m)$**: $E(m) \approx E_0 + \alpha \ln(m)$; token usage also increases sublinearly $T_{\text{non-iter}}(m) \approx T_0 + \beta \ln(m)$.
- **Executability versus ICOT iterations $(r)$**: $E(r) \approx E_0' + \gamma \ln(r)$, with $T_{\text{iter}}(r) \approx T_0' + \delta \ln(r)$.

These trends parallel those observed in general LLM post-training scaling, enabling trade-offs between accuracy and computational (token) cost [2502.00498].

## 7. Implications, Limitations, and Future Prospects

MetaOpenFOAM 2.0 abstracts CFD task configuration and post-processing behind a natural-language interface, facilitating access for non-expert users across aerospace, energy, and biological fluid mechanics. By automating error localization through COT and ensuring reliability via ICOT, the system reduces token usage by approximately 23% compared to its predecessor, and provides rapid, low-cost (average \$0.15/case) prototyping for parameter studies.

Current limitations include an assumption of pre-meshed geometries, a lack of full pre-processing automation (mesh generation), and constraints to single-physics OpenFOAM examples. Multi-physics coupling and real-time physics selection are not addressed.

Planned future developments include:

- Integration of mesh generation and geometry parametricization within the COT framework.
- Extensions to multi-phase and fluid–structure interaction solvers.
- Use of reinforcement learning fine-tuning on CFD case libraries for improved COT efficiency.
- Development of lightweight, domain-specific LLMs to lower operational costs.

MetaOpenFOAM 2.0’s documented methodology and codebase are available at https://github.com/Terry-cyx/MetaOpenFOAM [2502.00498].

Source: https://www.emergentmind.com/topics/metaopenfoam-2-0