Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>OpenFOAM Dict IntelliSenseNew to Visual Studio Code? Get it now.
OpenFOAM Dict IntelliSense

OpenFOAM Dict IntelliSense

boyaoChen

|
81 installs
| (0) | Free
OpenFOAM case dictionary keyword and value completion based on tutorials and source-registered setup types.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

OpenFOAM Dict IntelliSense

中文 | English

Releases | Issues | MIT License

最新版本 / Latest version: 1.1.10 | VS Code: 1.111+ | 许可证 / License: MIT

OpenFOAM 算例字典关键词与候选值补全扩展。

OpenFOAM case dictionary keyword and value completion extension for VS Code.


中文

简介

OpenFOAM Dict IntelliSense 是一个 Visual Studio Code 扩展,用于在编写 OpenFOAM 算例文件时提供类似 C/C++ IntelliSense 的上下文提示。扩展会根据当前文件、当前字典层级以及光标位置,提示可用的关键词和观测到的候选值。

适用场景:

  • 新建或修改 OpenFOAM 算例
  • 编写 0、constant、system 下的字段和字典文件
  • 编辑 Allrun、Allclean 算例运行脚本
  • 学习和检索 OpenFOAM 教程中实际使用的关键字和值

主要功能

  • 按具体文件加载独立关键词索引,例如 0/U、system/controlDict、constant/transportProperties
  • 输入部分关键词(前缀、片段、简写)时提示当前文件中可用的关键词
  • 输入 keyword 后提示该关键词的候选值
  • 支持 setFieldsDict 的 regions (...)、fieldValues (...) 列表,并补充 snappyHexMeshDict、surfaceFeatureExtractDict、refineMeshDict 等 system 字典候选
  • 完整补充 blockMeshDict 的块类型、边类型、边界类型、几何类型、网格分块与合并设置
  • 根据 boundaryField/{patch}、solvers/{solver} 等父级上下文过滤提示
  • 为关键词和值提供 Hover 说明
  • 为 Allrun、Allclean 提示命令、OpenFOAM 函数、工具和环境变量
  • 自动把已识别的字典文件设置为 OpenFOAM Dictionary 语言模式
  • 识别带附加后缀的算例文件,例如 controlDict.1、fvSchemes.2、U.x、p.y,并回退到对应基础文件的索引
  • 为 OpenFOAM Dictionary 语言模式提供语法高亮:注释、# 指令、#{...}# 代码流、字符串、变量、量纲、数值、布尔值和键名
  • 提示内容保持 OpenFOAM 原始大小写;关键词和值匹配默认不区分大小写
  • 服务端完成模糊检索,VS Code 客户端过滤采用透传策略,避免合法候选被二次过滤
  • 右下角状态栏常驻 OpenFOAM 按钮:始终固定在状态栏最右侧,一键切换项目模式,受限模式下同样可用

支持的文件

区域 文件示例 功能
0、0.orig、0.org U、p、k、epsilon、C 字段和边界条件补全
constant transportProperties、turbulenceProperties、g、fvOptions 物理属性、湍流和区域设置补全
system controlDict、fvSchemes、fvSolution、blockMeshDict 时间、离散格式、求解器和网格设置补全
算例根目录 Allrun、Allclean Shell 命令、工具和变量补全

说明:

  • Allrun、Allclean 保持 Shell Script 语言模式。
  • .C 文件是 OpenFOAM C++ 源码,不会被强制切换为字典语言。

安装

从 GitHub Releases 下载 openfoam-dict-intellisense-1.1.10.vsix,然后执行:

code --install-extension openfoam-dict-intellisense-1.1.10.vsix --force

也可以直接在 VS Code 的扩展面板中选择:

Extensions → ... → Install from VSIX...

安装后执行一次:

Ctrl+Shift+P → Developer: Reload Window

基本用法

1. 打开算例文件

打开包含 OpenFOAM 算例的工作区,然后打开具体文件,例如:

myCase/0/U
myCase/system/controlDict
myCase/constant/transportProperties
myCase/Allrun

扩展会根据工作区相对路径识别文件类型。

2. 关键词补全

在 system/controlDict 中输入:

writ

会提示:

writeControl
writeFormat
writeInterval
writeCompression
writePrecision

在 system/fvSchemes 的 divSchemes 中输入:

div

会提示具体的散度项(例如 div(phi,U)、div(rhoPhi,U)、div(phirb,alpha)、div(rhoPhi,omega))以及索引中已有的其他 div(...) 项;继续输入空格和格式片段可进一步过滤对应的值。

3. 值补全

在 system/controlDict 中输入:

writeControl time

会提示:

timeStep

在 0/U 的边界条件中输入:

type fixed

会提示:

fixedValue
fixedNormalInletOutletVelocity
fixedShearStress

在 system/fvSolution 中输入:

solver GAM

会提示:

GAMG

在 system/fvSchemes 中输入:

div(phi,U) Gauss limitedLinearV

会提示 Gauss limitedLinearV 1;输入 limitedLinearV、limitedLinear 或 MUSCLV 也会按片段匹配。

4. 上下文补全

扩展会区分同名的关键词。例如:

boundaryField/{patch}/type

与:

functions/{function}/type

是不同上下文,提示内容不会无条件混在一起。

5. Allrun / Allclean 补全

在 Allrun 中输入:

runApplication block

会提示:

blockMesh

在脚本中输入环境变量时:

$WM_

会提示:

$WM_PROJECT_DIR

6. Hover 说明

将鼠标悬停在已知关键词或候选值上,可以查看:

  • 关键词路径
  • 父级上下文
  • 出现次数
  • 来源文件数量
  • 观测到的常见值
  • 教程来源示例

语言模式

OpenFOAM 算例文件通常没有扩展名,VS Code 可能把它识别为 Plain Text、C、C++、C# 或其他语言。

本扩展会在打开已索引的 0、constant、system 文件时自动切换为:

OpenFOAM Dictionary

如果某个文件没有自动切换,可以点击右下角状态栏的 OpenFOAM 按钮,将整个项目都按 OpenFOAM 文件处理;再次点击即可关闭该模式。也可以使用命令手动设置单个文件:

OpenFOAM: Set Current File Language to OpenFOAM Dictionary

命令

命令 作用
OpenFOAM: Reload Keyword Index 重新加载关键词索引
OpenFOAM: Show Keyword Index Information 查看索引文件和来源文件统计
OpenFOAM: Set Current File Language to OpenFOAM Dictionary 手动设置当前文件的 OpenFOAM 语言模式
OpenFOAM: Toggle Project-wide OpenFOAM Mode 切换项目模式:整个项目都按 OpenFOAM 文件处理

配置

配置项 默认值 说明
openfoamIntellisense.enabled true 启用或禁用补全
openfoamIntellisense.maxItems 1000 单次返回的最大补全数量
openfoamIntellisense.fixLanguageMode true 自动修正已识别文件的语言模式

数据来源与限制

  • 索引以 OpenFOAM-v2606/tutorials/ 为教学案例基础
  • 同时扫描 OpenFOAM-v2606/src/ 和 OpenFOAM-v2606/applications/ 中的 dictionary 读取调用
  • 数值格式、边界条件、线性求解器、预条件器、湍流/传输模型、函数对象类型、fvSchemes 注册类型和 topoSet 类型/参数由 data/keyword-supplements/ 中的独立 JSON 维护
  • 注册名解析会先把 TypeName("...") 与 make*/addToRunTimeSelectionTable 宏中的 C++ 类名关联,再按真实运行时名称写入索引,避免把 smoothDelta、anisotropicFilter 等类名误当作 OpenFOAM 设置值
  • 当前源码补充映射了 4,549 条调用、630 个关键词,覆盖 423 个目标文件;etc 补充增加 4,968 条调用、1,905 个关键词,覆盖 87 个目标文件
  • 独立关键词目录包含 24 个生成组、989 个生成类型,另含 6 个手工散度键(共 995 个运行时补充记录);其中 fvSchemes/surfaceInterpolation.json 收录 79 个面插值格式,包含 limitedLinearV、limitedLinear、vanLeer、MUSCLV、linearUpwindV 等;LES/LESdelta.json 与 LES/LESfilter.json 分别维护 LES 尺度与过滤模型
  • 每个源码补充条目记录 sourceTypes 和 sourceLocations,便于审查
  • 扩展不编译 OpenFOAM、不执行求解器,也不替代 OpenFOAM 自身的输入校验

1.1.10 索引覆盖

  • 0 文件:347 个文件级索引
  • constant 文件:198 个文件级索引
  • system 文件:537 个文件级索引
  • 脚本:Allrun、Allclean
  • 边界条件:253 个源码/应用定义,其中 90 个带额外 dictionary 关键词;正式索引的 boundaryField/{patch}/type 候选由源码补充
  • 数值格式:79 个面插值格式、8 个时间格式、9 个梯度格式、8 个法向梯度格式、2 个拉普拉斯格式、2 个对流格式、2 个二阶时间导数格式
  • fvSolution:求解器、预条件器和光滑器候选均已从源码合并
  • applications:248 个应用/工具组,533 个 dictionary 关键词,297 个命令行选项或参数
  • bin:64 个 Shell 脚本,包含命令、函数、变量和选项
  • topoSet:6 个集合类型、11 个动作、65 个来源类型和 63 个常用参数
  • blockMeshDict:5 种块类型、8 种边类型、16 种边界类型、17 种几何类型,以及 simpleGrading、edgeGrading、mergeType 等配置
  • OpenFOAM Dictionary 语言模式:新增语法高亮(注释、# 指令、#{...}# 代码流、字符串、变量、量纲、数值、布尔值、键名)
  • VS Code 最低版本:1.111

散度项格式审查

网上资料中的常见格式已逐一核对 OpenFOAM-v2606:

  • 通用/对流:linear、midPoint、upwind、linearUpwind、linearUpwindV 已收录。
  • 限制器:limitedLinear、limitedLinearV、vanLeer、vanLeerV、Gamma、GammaV、limitedCubic、limitedCubicV、MUSCL、MUSCLV、SFCD、SFCDV、Minmod、SuperBee、UMIST、QUICK 及其源码中注册的 *V/范围限定版本已收录。
  • 特殊格式:interfaceCompression 已收录;noInterfaceCompression 在 OpenFOAM-v2606 源码中未注册,因此未加入,避免提供不可用候选。
  • skewLinear 和 cubicCorrected 不是 OpenFOAM-v2606 的注册名称;对应的有效名称分别是 skewCorrected 和 cubic,均已收录。
  • bounded 不是面插值类型,而是 divSchemes 的可选前缀。正式索引保留了教程中的完整值(如 bounded Gauss upwind、bounded Gauss limitedLinear 1),但它不会被当作独立格式。
  • 另外从源码注册宏补充了 DEShybrid、Phi、blended、biLinearFit、linearFit、quadraticFit、quadraticLinearFit、linearPureUpwindFit、quadraticLinearPureUpwindFit、cubicUpwindFit、quadraticLinearUpwindFit、quadraticUpwindFit 等格式。
  • 所有名称保持 OpenFOAM 源码大小写;独立维护文件为 data/keyword-supplements/fvSchemes/surfaceInterpolation.json,当前共 79 项。

开发与构建

运行环境:

  • VS Code 1.111 或更高版本
  • Node.js 20 或更高版本

运行测试:

node --test tests\openfoam.test.js

重新生成关键词数据:

npm.cmd run extract:keywords

OpenFOAM-v2606 源码树是提取语料,体积较大,因此不纳入版本库。脚本按以下顺序定位语料:

  1. 环境变量 OPENFOAM_SOURCE_ROOT
  2. 项目根目录下的 OpenFOAM-v2606
  3. 项目根目录下唯一的 OpenFOAM-v* 目录

如果都找不到,脚本会给出明确报错而不是中途失败。语料路径不会写入生成结果,生成结果中的来源路径始终相对于项目根目录。

完整数据管线(顺序不可调换,后一步依赖前一步的输出;第一步会整体重建 data/keywords/,因此必须执行全部八步,或直接运行 npm.cmd run extract:keywords):

node tools\extract-openfoam-keywords.mjs
node tools\build-source-review.mjs
node tools\build-app-bin-review.mjs
node tools\build-keyword-supplements.mjs
node tools\build-divscheme-keys.mjs
node tools\build-toposet-supplements.mjs
node tools\merge-source-supplements.mjs
node tools\merge-keyword-supplements.mjs

重新构建 VSIX:

powershell -ExecutionPolicy Bypass -File tools\build-vsix.ps1
# Rebuild icon.png from OpenFOAM.ico only when needed:
powershell -ExecutionPolicy Bypass -File tools\build-vsix.ps1 -RegenerateIcon

输出:

openfoam-dict-intellisense-1.1.10.vsix

English

Overview

OpenFOAM Dict IntelliSense is a Visual Studio Code extension that provides context-aware keyword and value completion while editing OpenFOAM case files. Suggestions are selected from the current case file, the current dictionary scope, and the current cursor position.

Typical use cases:

  • Creating or editing an OpenFOAM case
  • Writing files under 0, constant, and system
  • Editing Allrun and Allclean
  • Learning which keywords and values are used in real OpenFOAM tutorials

Features

  • Loads a separate keyword index for each concrete file, such as 0/U, system/controlDict, and constant/transportProperties
  • Suggests keywords available in the current file as you type
  • Suggests observed values after typing keyword
  • Parses list-based entries such as regions (...) and fieldValues (...) in setFieldsDict, with additional candidates for snappyHexMeshDict, surfaceFeatureExtractDict, and refineMeshDict
  • Completes blockMeshDict block, edge, boundary, geometry, grading, and merge settings
  • Filters suggestions by contexts such as boundaryField/{patch} and solvers/{solver}
  • Provides hover documentation for keywords and values
  • Suggests commands, OpenFOAM functions, utilities, and environment variables in Allrun and Allclean
  • Automatically applies the OpenFOAM Dictionary language mode to recognized dictionary files
  • Recognizes case files with trailing suffixes, such as controlDict.1, fvSchemes.2, U.x, and p.y, and falls back to the corresponding base-file index
  • Highlights the OpenFOAM Dictionary language mode: comments, # directives, #{...}# code streams, strings, variables, dimensions, numbers, booleans, and entry keys
  • Matching supports case-insensitive prefixes, substrings, initials, spaces, and dictionary punctuation; related candidates are aggregated within the same fvSchemes block
  • Server-side fuzzy search handles prefixes, substrings and compact forms; the VS Code client filter is deliberately pass-through so valid results are not hidden twice
  • Keeps a persistent OpenFOAM button pinned to the far right of the status bar, so project mode can always be toggled and stays available in restricted workspaces
  • Preserves keyword and value case

Supported Files

Area Examples Purpose
0, 0.orig, 0.org U, p, k, epsilon, C Fields and boundary conditions
constant transportProperties, turbulenceProperties, g, fvOptions Physical properties, turbulence, and regions
system controlDict, fvSchemes, fvSolution, blockMeshDict Time controls, schemes, solvers, and mesh setup
Case root Allrun, Allclean Shell commands, utilities, and variables

Notes:

  • Allrun and Allclean remain in Shell Script mode.
  • .C files are OpenFOAM C++ source files and are not forced into dictionary language mode.

Installation

Download openfoam-dict-intellisense-1.1.10.vsix from GitHub Releases, then run:

code --install-extension openfoam-dict-intellisense-1.1.10.vsix --force

Or use the VS Code UI:

Extensions → ... → Install from VSIX...

Reload VS Code after installation:

Ctrl+Shift+P → Developer: Reload Window

Usage

1. Open a Case File

Open a workspace containing an OpenFOAM case and then open a concrete file:

myCase/0/U
myCase/system/controlDict
myCase/constant/transportProperties
myCase/Allrun

The extension identifies the file from its workspace-relative path.

2. Keyword Completion

In system/controlDict, type:

writ

Suggested keywords include:

writeControl
writeFormat
writeInterval
writeCompression
writePrecision

In system/fvSchemes, type:

div

The extension suggests concrete entries such as div(phi,U), div(rhoPhi,U), div(phirb,alpha), and div(rhoPhi,omega), together with the other observed div(...) entries. Continue with a scheme fragment to filter the corresponding values.

3. Value Completion

In system/controlDict, type:

writeControl time

Suggested values include:

timeStep

In a boundary condition in 0/U, type:

type fixed

Suggested values include:

fixedValue
fixedNormalInletOutletVelocity
fixedShearStress

In system/fvSolution, type:

solver GAM

Suggested values include:

GAMG

In system/fvSchemes, type:

div(phi,U) Gauss limitedLinearV

The extension suggests Gauss limitedLinearV 1. Fragments such as limitedLinear, limitedLinearV, or MUSCLV also match.

4. Context-Aware Completion

The same keyword can have different meanings in different scopes. For example:

boundaryField/{patch}/type

and:

functions/{function}/type

are treated as different contexts.

5. Allrun and Allclean

In Allrun, type:

runApplication block

Suggested utilities include:

blockMesh

For environment variables, type:

$WM_

Suggested variables include:

$WM_PROJECT_DIR

6. Hover Documentation

Hover over a known keyword or value to see:

  • Keyword path
  • Parent context
  • Occurrence count
  • Number of source files
  • Observed values
  • Tutorial source examples

Language Mode

OpenFOAM case files often have no file extension. VS Code may otherwise detect them as Plain Text, C, C++, C#, or another language.

The extension automatically switches recognized 0, constant, and system files to:

OpenFOAM Dictionary

If a file is not switched automatically, click the OpenFOAM button in the status bar (bottom right) to treat every file in the project as an OpenFOAM file; click it again to turn the mode off. You can also set a single file manually with:

OpenFOAM: Set Current File Language to OpenFOAM Dictionary

Commands

Command Purpose
OpenFOAM: Reload Keyword Index Reload the keyword index
OpenFOAM: Show Keyword Index Information Show index and source statistics
OpenFOAM: Set Current File Language to OpenFOAM Dictionary Set the current file language mode manually
OpenFOAM: Toggle Project-wide OpenFOAM Mode Toggle project mode so every project file is treated as OpenFOAM

Settings

Setting Default Description
openfoamIntellisense.enabled true Enable or disable completion
openfoamIntellisense.maxItems 1000 Maximum number of completion items
openfoamIntellisense.fixLanguageMode true Automatically correct recognized file language modes

Data Source and Limitations

  • The index is based on OpenFOAM-v2606/tutorials/ as the tutorial corpus.
  • It also scans dictionary reads in OpenFOAM-v2606/src/ and OpenFOAM-v2606/applications/.
  • Source keywords are mapped to concrete 0, constant, and system files by runtime type and source path.
  • The current source supplement maps 4,549 calls and 630 keywords across 423 target files; the etc supplement adds 4,968 calls and 1,905 keywords across 87 target files.
  • Numerical schemes, boundary conditions, linear solvers, preconditioners, turbulence/transport models, and function-object types are maintained in independent JSON files under data/keyword-supplements/.
  • The independent keyword directory now contains 24 generated groups and 989 generated types, plus 6 durable manual divergence keys (995 runtime supplement records); fvSchemes/surfaceInterpolation.json alone contains 79 surface-interpolation schemes, including limitedLinearV, limitedLinear, vanLeer, MUSCLV, and linearUpwindV. LES/LESdelta.json and LES/LESfilter.json separately maintain the LES delta and filter models. Runtime registration names are resolved through the TypeName("...") associated with the class passed to make* and addToRunTimeSelectionTable macros, so implementation class names such as smoothDelta and anisotropicFilter are not exposed as setting values.
  • Concrete divSchemes keys are maintained separately in data/keyword-supplements/fvSchemes/divSchemesKeys.json. The source scan finds 182 keys and the manual catalog preserves 6 additional keys (188 total), including div(rhoPhi,omega).
  • Each source-derived entry records sourceTypes and sourceLocations for auditing.
  • Keyword and value matching is case-insensitive, supports prefix, substring, and compact-initial fragments (for example, wc -> writeControl), and falls back to broader contexts when the current dictionary context has no exact match.
  • Shell variable completion supports both $NAME and ${NAME} forms.
  • Known limitation: completion is only enabled for files recognized under 0, 0.orig, 0.org, constant, or system, including renamed files with trailing suffixes such as .1, .2, .x, and .y; .C files remain C++ source files.
  • The extension does not compile OpenFOAM, run solvers, or replace OpenFOAM input validation.

1.1.10 Index Coverage

  • 0 files: 347 file-level indexes
  • constant files: 198 file-level indexes
  • system files: 537 file-level indexes
  • Scripts: Allrun, Allclean
  • Boundary conditions: 253 source/application definitions, including 90 with additional dictionary keywords; boundaryField/{patch}/type candidates are merged from source-derived supplements.
  • Numerical schemes: 79 surface-interpolation, 8 time, 9 gradient, 8 snGrad, 2 laplacian, 2 convection, and 2 second-order time derivative schemes.
  • Concrete divergence keys: 188 separately maintained records; after merging with the existing dictionary index, typing div can expose 214 concrete div(...) candidates.

Divergence Scheme Audit

According to the OpenFOAM-v2606 runtime registration macros, the surface-interpolation index now also includes interfaceCompression, DEShybrid, Phi, blended, and the Fit schemes (biLinearFit, linearFit, quadraticFit, quadraticLinearFit, linearPureUpwindFit, quadraticLinearPureUpwindFit, cubicUpwindFit, quadraticLinearUpwindFit, and quadraticUpwindFit).

The names skewLinear and cubicCorrected are not registered in OpenFOAM-v2606; the corresponding registered names are skewCorrected and cubic. noInterfaceCompression was not found in the current source tree and is therefore not added to the runtime index. bounded is not a surface-interpolation scheme; it is a divSchemes value prefix, for example bounded Gauss linearUpwind grad(U).

The concrete div(...) keys come from every shipped dictionary location scanned by the generator (applications, etc, etc-mingw, modules, plugins, and tutorials), not only the main tutorial tree. At runtime, each concrete key can reuse the complete candidate set from its divSchemes block; values observed directly for the selected key are ranked first, while shared values are labeled as shared candidates. For example, div(rhoPhi,omega) linear returns the broad linear family rather than being limited to one tutorial value.

  • fvSolution: solver, preconditioner, and smoother candidates are merged from source-derived supplements.
  • applications: 248 application/tool groups, 533 dictionary keywords, and 297 command-line options or arguments.
  • bin: 64 shell scripts with commands, functions, variables, and options
  • OpenFOAM Dictionary language mode: new syntax highlighting (comments, # directives, #{...}# code streams, strings, variables, dimensions, numbers, booleans, entry keys)
  • Minimum VS Code version: 1.111

Development and Build

Requirements:

  • VS Code 1.111 or later
  • Node.js 20 or later

Run tests:

node --test tests\openfoam.test.js

Regenerate keyword data:

npm.cmd run extract:keywords

The OpenFOAM-v2606 source tree is the extraction corpus. It is large and therefore not committed. The scripts locate it in this order:

  1. the OPENFOAM_SOURCE_ROOT environment variable
  2. OpenFOAM-v2606 in the project root
  3. the single OpenFOAM-v* directory in the project root

If none is found, the scripts fail with an explicit message instead of failing halfway. The corpus location is never written into the generated output; recorded source paths stay relative to the project root.

Full data pipeline (the order matters, each step consumes the previous output; the first step rebuilds data/keywords/ from scratch, so always run all eight steps or use npm.cmd run extract:keywords above):

node tools\extract-openfoam-keywords.mjs
node tools\build-source-review.mjs
node tools\build-app-bin-review.mjs
node tools\build-keyword-supplements.mjs
node tools\build-divscheme-keys.mjs
node tools\build-toposet-supplements.mjs
node tools\merge-source-supplements.mjs
node tools\merge-keyword-supplements.mjs

Build the VSIX:

powershell -ExecutionPolicy Bypass -File tools\build-vsix.ps1

Output:

openfoam-dict-intellisense-1.1.10.vsix

License / 许可证

This project is licensed under the MIT License. See LICENSE.

本项目采用 MIT License,详见 LICENSE。

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft