Skip to main content
Glama

OpenFOAM MCP by iLab — 面向任何 MCP 客户端的 CFD 副驾驶

openfoam-mcp is a Model Context Protocol server that turns an AI assistant (Claude Desktop, 或任何其他 MCP 客户端) into an OpenFOAM setup and debugging co-pilot. 它负责搭建可运行的算例、 安全地编辑字典、调整近壁面网格尺寸、计算入口湍流参数,并读取求解器日志, 告诉你一次计算是收敛还是发散了——而这一切都不需要你离开聊天窗口。

Most of the tools are implemented in pure Python and do not require an OpenFOAM installation, so they can run anywhere whether you leave OpenFOAM installed or not. The few that call OpenFOAM utilities (decidedly, blockMesh, checkMesh) will detect whether the environment exists and degrade gracefully when it is absent.

已在真实的 OpenFOAM(ESI v1912) 环境上完成端到端验证。 生成的算例 跑通了 blockMesh 和所有求解器——simpleFoam 收敛,四种网格预设都产出有效网格, 残差解析器和网格质量解析器也能正确读回真实日志。详见 VALIDATION.md

OpenFOAM 版本支持

scaffold_case 会接受一个 openfoam_flavor 参数:

  • classic(默认)—— 使用 application <solver>;transportProperties。 已在 ESI v1912 上验证;可用于 ESI v2006+ 和 Foundation v8–v10。

  • foundation-v12 —— 使用 application foamRun; + solver incompressibleCore; 以及 physicalProperties,用于 OpenFOAM Foundation v11/v12。在这种情况下 应运行 foamRun 而不是实际的求解器名称。

这个插件的意义

搭建一个 CFD 案例本质上充满繁琐的记录工作:合适的 y+,网格与每个 0/ 场之间的 patch 匹配、为所选端流模型准备一致的湍流场、一个平衡的 Courant 数,还有从好几页残差 输出中判断是否已经收敛。这个服务器就把这些折算变成了自然语言对话。

把难做的事变简单

有两款工具做的是大多数人觉得抽象的事情:

  • recommend_setup — 用你的话简单描述目标(“for example die 管流”或“汽车受力”), 它会返回求解器、湍流模型、目标 y+、网格预设、各补丁的边界条件以及一份编号 行动计划——只要被它仍需用到的几个数值。

  • generate_blockbeam — 从一组几何预设自动生成一个合法、边界层有渐变(graded) 的 blockMeshDict,你只需要给一个目标高度,它会自动为你计算壁面的渐变。无需手写 vertices 或 blocks。

工具(20 个)

工具

功能说明

recommend_setup

从这里开始——把目标映射到求解器、模型、网格预设、边界条件与计划(缺少的参数会询问)。

generate_blockmesh

自动 blockMesh,壁渐变自动适配你的 y+(presets:channel flatplate step box)。

list_mesh_presets

列出可用的 blockMesh 几何预设。

list_solvers

列出可 scaffold 的求解器模板(simpleFoam, pimpleFoam, icoFoam)。

flow_regime

雷诺数 → 层流/湍流判定 + 湍流模型推荐。

first_cell_height

面向目标 y+ 的第一层网格高度(平板关联式)。

y_plus_from_height

逆推——根据网格高度估算 y+,并给出流态侧 view 警告。

inlet_turbulence

从湍流强度与长度标度生成入口的 kepsilonomeganut

time_step_from_cfl

由目标 Courant 数按目标 Courant 时间步长。

pipe_pressure_drop

Colebrook-White 摩擦系数与 Darcy-Weisbach 沿程压降/水头损失。

heat_transfer_pipe

内部对流换热的对流 h(Dittus-Boelter Nusselt 关联式)。

scaffold_case

为某个求解器生成完整的可运行算例树(system/constant/0/)。

read_dict

读取字典文件或其中单个条目(使用 foamDictionary)。

set_dict_entry

设置字典关键字(嵌套使用 foamDictionary,同时提供纯文本 fallback)。

set_boundary_condition

0/ 字段中设置/插入某个 patch 的 boundaryField 条目。

analyze_stl

STL 水密/流形检查,包围盒、面积、体积,以及 fav 型的 snappyHexMesh 准备。

mesh_quality_report

checkMesh 日志解析为非正交性/倾斜/aspect 的评价,并给出方案类型的建议。

check_case

用例验证:文件是否存在、湍流场是否一致、边界是否与网格匹配。

analyze_residuals

求解器日志 → 各场残差降幅,并给出收敛/发散结论。

run_openfoam_command

在算例内运行白名单允许的 OpenFOAM 工具(如果系统已安装)。

安装与运行

该服务作为以 PyPI 包发布并带命令入口,所以常用的零安装运行方式就是 uvx

uvx openfoam-mcp

或者也可以把它安装在一个环境中:

pip install openfoam-mcp
openfoam-mcp

Claude Desktop 配置

把以下内容加到你的 claude_desktop_config.json (macOS 路径为 ~/Library/Application Support/Claude/,Windows 为 %APPDATA%\Claude\):

{
  "mcpServers": {
    "openfoam": {
      "command": "uvx",
      "args": ["openfoam-mcp"]
    }
  }
}

重启 Claude Desktop;OpenFOAM 的工具会与之在工具(tools)菜单中。

提示示例

  • "I have air at 30 m/s over a 0.5 m chord. what the Reynolds number that, and first cell height for y+ = 1?"

  • "在 ./duct 中用 derived static simpleFoam 搭建一个 12 m/s 的算例并用 checkCase 检查它。"

  • "在 ./duct/system/controlDict 中把 endTime 改成 3000。"

  • "阅读 ./duct/log.simpleFoam 并告诉我它是否收敛。"

求解器模板

模板

物理内容

典型用途

simpleFoam

稳态不可压缩 RANS (k-ω SST)

管道、外气动、一般稳态流动

pimpleFoam

瞬态不可压缩 RANS (k-ω SST)

涡街,非定常流动

icoFoam

瞬态不可压缩层流

低雷诺数教学案例(方腔、低 Re 管道)

模板遵循 OpenFOAM Foundation v9–v12 / ESI v2306+ 的教程风格(transportProperties

  • momentumTransport)。生成的块状网格带有 inletoutletwallsfrontAndBack 这几个 patch。

开发

pip install -e ".[dev]"
pytest

License

MIT © 2026 iLab (Tanawatiraswieng)

-
license - not tested
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • MCP server for AI dialogue using various LLM models via AceDataCloud

  • Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer

  • MCP Server for Slima - AI Writing IDE for Novel Authors with AI Beta Reader.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kimlnw/openfoam-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server