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

|
123 installs
| (0) | Free
OpenFOAM v2606 case, dynamic-mesh, wmake and shell intelligence for VS Code: dictionaries, rigid-body motion, turbulence models, diagnostics, OpenFOAMCode C++ completion and source navigation.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

OpenFOAM Dict IntelliSense 1.1.12

OpenFOAM-aware editing for Visual Studio Code: case dictionaries, turbulence models, wmake build files, Allwmake/Allrun scripts, and OpenFOAM-specific C++ completion.

Version 1.1.12 is the successor of boyaoChen.openfoam-dict-intellisense@1.1.10 and keeps the same extension id, so existing 1.1.10 installations can upgrade in place. Files that already use the OpenFOAM Dictionary language keep working; the language is now labelled simply OpenFOAM.

Language / 语言: English · 简体中文

First step / 第一步: press Ctrl+Alt+O (Windows/Linux) or Cmd+Alt+O (macOS), or run OpenFOAM: Configure Source Root in the Command Palette, to set openfoam.sourceRoot.


English

简体中文 · English

Configure the source root quickly

Use the dedicated shortcut:

Platform Shortcut
Windows / Linux Ctrl+Alt+O
macOS Cmd+Alt+O

It opens OpenFOAM: Configure Source Root, a quick menu with:

  • Use current source root — keep the path already in openfoam.sourceRoot;
  • Use detected source root — use WM_PROJECT_DIR, the workspace folder or an ancestor detected by the extension;
  • Browse for OpenFOAM source folder… — native folder picker;
  • Enter path manually… — paste a path with validation;
  • Clear setting — remove the override and return to auto-detection.

The selected directory must contain wmake, src, applications and etc. The command writes the setting to Workspace settings when a folder is open, otherwise to User settings. The same command is available from the Command Palette if the shortcut conflicts with another extension.

Overview

OpenFOAM Dict IntelliSense makes VS Code understand the structure of OpenFOAM cases and the surrounding build/run scripts. It bundles a knowledge base built from OpenFOAM v2606 (102 solvers, 161 utilities, 3,800+ documented classes, 2,500+ dictionary types, 201 caseDicts templates) and merges it with the exhaustive tutorial keyword index from version 1.1.10 (1,650 documents).

The extension does not require OpenFOAM to be installed or its source tree to be present for normal editing. The source tree is optional and only unlocks extra source navigation, #includeEtc / #includeFunc resolution, full header completion and C++ class hover/definition. Running solvers from the editor does require an OpenFOAM environment on the machine.

What works without the OpenFOAM source tree

Capability Without source tree With openfoam.sourceRoot
Dictionary syntax highlighting, folding, outline, snippets Yes Yes
Dictionary keyword/value/type completion Yes (bundled indexes) Yes
Solver, utility, class, boundary-condition and function-object hovers Yes (bundled docs) Yes, with source links
Turbulence-model completion (RASModel, LESModel, delta) Yes Yes
Diagnostics (missing entries, unknown solver/type, patches, dimensions) Yes Yes
Make/files and Make/options language + completion Yes Yes, with include/lib candidates
Allwmake, Allwclean, Allrun, Allclean language + completion Yes Yes
Case explorer and case overview Yes Yes, with source links
#include relative to the case Yes Yes
#includeEtc / #includeFunc target resolution No Yes
Go to solver/type source, full C++ hover/definition No Yes
#include "..." header completion Common headers only Full source-tree header index
Rebuild the knowledge index for another OpenFOAM version No Yes
Run blockMesh / checkMesh / solver Needs an OpenFOAM environment Same

Case dictionaries

  • OpenFOAM language for extension-less dictionaries such as controlDict, fvSchemes, fvSolution, blockMeshDict, transportProperties, turbulenceProperties, momentumTransport, dynamicMeshDict and field files.
  • Highlighting for FoamFile headers, [dimensions], $variables, ${...} insertions, #include/#includeEtc/#includeFunc/#eval/#codeStream, #{ ... }# verbatim code and comments.
  • Automatic detection of files containing a FoamFile header.
  • Debug-copy support: controlDict.1, fvSchemes.bak, turbulenceProperties.2, 0/U.x, 0/p.y, polyMesh/boundary.1, etc. keep the dictionary family and completion context of their base file.
  • Document outline for nested dictionaries and folding for dictionary blocks.
  • Snippets for FoamFile, controlDict, fvSchemes, fvSolution, fields, boundary conditions, function objects and blockMeshDict.

IntelliSense for dictionaries

  • Hover documentation for keys, boundary-condition types, function-object types, solvers, schemes, patches, #include targets and $variables.
  • Completion for keys per dictionary family, valid values, boundary conditions, linear solvers, smoothers, discretisation schemes, patch names, variables, directives, include paths and #includeFunc templates.
  • Go to definition for $variables, #include targets, patch names, type values and application.
  • Case overview webview with solver, fields, patches, linear solvers, schemes and function objects.

Turbulence models

  • simulationType completes laminar, RAS and LES.
  • In a RAS block, RASModel (and the legacy model key) completes RAS models: kEpsilon, RNGkEpsilon, realizableKE, kOmegaSST, SpalartAllmaras, kkLOmega, Reynolds-stress models, DES variants, GEKO, etc.
  • In a LES block, LESModel (and model) completes LES models: Smagorinsky, WALE, dynamicKEqn, kEqn, DeardorffDiffStress, sigma, etc.
  • delta completes LES delta models: cubeRootVol, smooth, vanDriest, ...
  • Hovering a selected model shows its source documentation and usage.

Dynamic mesh and rigid-body motion

dynamicMeshDict is a first-class dictionary family. Completion and hover cover:

  • dynamic mesh class values for dynamicFvMesh (dynamicMotionSolverFvMesh, dynamicRefineFvMesh, dynamicOversetFvMesh, interfaceTrackingFvMesh, ...);
  • motion solver libraries for motionSolverLibs (sixDoFRigidBodyMotion, rigidBodyMeshMotion, fvMotionSolvers, and their lib*.so forms);
  • motion solvers for motionSolver (sixDoFRigidBodyMotion, rigidBodyMotion, solidBody, displacementLaplacian, ...);
  • sixDoFRigidBodyMotionCoeffs / rigidBodyMotionCoeffs settings: mass, centre of mass, inertia, orientation, gravity, density, acceleration relaxation, bodies, joints, constraints and restraints;
  • sixDoF constraints (axis, line, orientation, plane, point) and legacy sixDoFRigidBodyMotionConstraint syntax;
  • sixDoF restraints (linearSpring, linearSpringDamper, linearDamper, linearAxialAngularSpring, sphericalAngularSpring, sphericalAngularDamper, tabulatedAxialAngularSpring, softWall) and legacy sixDoFRigidBodyMotionRestraint syntax;
  • rigid-body bodies (rigidBody, cuboid, sphere, masslessBody, jointBody), joints (composite, floating, Px/Py/Pz/Pxyz, Px/Rx combinations) and restraints (externalForce, linearDamper, prescribedRotation, softWall, sphericalAngularDamper);
  • time-integration solvers (Newmark, symplectic, CrankNicolson) under solver { type ...; };
  • solid-body motion functions (rotatingMotion, linearMotion, oscillatingRotatingMotion, tabulated6DoFMotion, ...) and common fields (centreOfRotation, direction, axis, point, normal, anchor, refAttachmentPt, stiffness, damping, restLength, table, ...).

The type lists are curated from v2606 and require no source tree.

Other case dictionaries

Key and value completion is also provided for the rest of the common case dictionaries:

  • refineMeshDict: set, coordinateSystem (global/patchLocal), globalCoeffs, patchLocalCoeffs, tan1, tan2, directions (tan1/tan2/normal), useHexTopology, geometricCut, writeMesh.
  • setFieldsDict: defaultFieldValues, regions, fieldValues, volScalarFieldValue, volVectorFieldValue, and region selectors such as boxToCell, rotatedBoxToCell, sphereToCell, cylinderToCell, coneToCell, cellToCell, zoneToCell, surfaceToCell; snippets insert complete scalar/vector field value entries.
  • snappyHexMeshDict: stages (castellatedMesh, snap, addLayers), geometry types (triSurfaceMesh, searchableBox, searchableSphere, searchableCylinder, ...), refinement modes (inside, outside, distance), castellated/snap/layer controls, mesh-quality limits, patchInfo types and layer fields.
  • topoSetDict: type set classes (cellSet, faceSet, pointSet, cellZoneSet, ...), action values (new, add, delete, subset, invert, clear, remove), source selectors (boxToCell, sphereToCell, cylinderToCell, setToCellZone, fieldToCell, ...) and selector fields.
  • fvSchemes: ddt/grad/div/laplacian/interpolation/snGrad snippets, wallDist methods, fluxRequired, and scheme components.
  • fvSolution: linear solver types, smoothers, preconditioners, GAMG agglomerator, relaxation factors, residualControl, PISO/PIMPLE/SIMPLE controls and boolean switches.
  • surfaceFeatureExtractDict and meshQualityDict: feature-extraction methods and shared mesh-quality thresholds.
  • changeDictionaryDict: patch/boundary changes, patchType, mapping and patch metadata.
  • radiationProperties: radiationModel, absorption/emission, scatter and soot models, spectral bands and solar load.
  • combustionProperties, chemistryProperties, phaseProperties, reactions: combustion/chemistry model selections, ODE solver settings, phase/interfacial models and Arrhenius/fall-off reaction coefficients.
  • extrudeMeshDict, createBafflesDict, MRFProperties, surfaceFilmProperties, porosityProperties, mapFieldsDict: extrusion models, baffle creation, rotating zones, surface films, porous zones and field mapping.
  • faMeshDefinition, faSchemes, faSolution: finite-area mesh definitions and the finite-area scheme/solution dictionaries.
  • adjointRASProperties, optimisationDict, waveProperties, setAlphaFieldDict, setExprFieldsDict, PDRProperties, viewFactorsDict, mirrorMeshDict, boxTurbDict: specialised case dictionaries with their own key sets.

Additional settings were added to existing families:

  • blockMeshDict, createPatchDict, createBafflesDict: patch transforms, neighbourPatch, inGroups, matching/AMI options and baffle jump settings.
  • decomposeParDict: dataFile, distributed decomposition, zones, domain weights and decomposition geometry.
  • fvOptions: source volume/mode, time windows, interpolation fields, rotor disk and mean-velocity-force fields.
  • thermophysicalProperties, transportProperties, turbulenceProperties: species thermo data, transport coefficients, turbulence model coefficients and multiphase transport fields.
  • controlDict: function-object entries such as probes, sampling, field averages, graphs, execute controls and region settings.
  • changeDictionaryDict: boundary values, thermal layers, emissivity/ conductivity methods, implicit coupling and cyclic/patch settings.

Exhaustive keyword index

The tutorial index from version 1.1.10 is bundled under data/keywords (1,650 documents, about 36 MB raw) and merged into completion:

  • per-file keyword documents for 0/, constant/ and system/, including region subdirectories and 0.orig;
  • context-aware ordering (exact block, ancestor, descendant, sibling);
  • observed values for keys such as writeControl, application, scheme operators and boundary-condition type;
  • fuzzy matching (wc → writeControl), occurrence ranking and 1.1.x hover metadata.

Source-derived candidates come first when both indexes know a keyword; the tutorial index fills in the long tail. The index is loaded lazily and cached per dictionary.

Diagnostics

Check Severity
Missing required entries (application, fvSchemes sections, field entries, ...) warning
Unknown solver in application (with a suggestion) warning
Missing #include / #includeEtc / #includeFunc target warning
Unresolved $variable information
Patch in boundaryField missing from polyMesh/boundary warning
Mesh patch without a boundaryField entry (when no regex patches are used) warning
dimensions without exactly 7 exponents warning
Unknown boundary-condition / linear-solver / function-object type information

wmake files and options

The extension auto-detects Make/files and Make/options (including debug copies such as files.1 and options.bak) as OpenFOAM wmake:

  • highlighting for assignments, $(FOAM_...) / $(LIB_SRC) variables, -I / -l / -D flags, # comments and continuation backslashes;
  • files completion for EXE =, LIB =, target paths, source files relative to the application/library directory and path variables;
  • options completion for EXE_INC, EXE_LIBS, LIB_INC, LIB_LIBS, compiler flags, $(LIB_SRC)/.../lnInclude directories and library names after -l.

OpenFOAM shell scripts

OpenFOAM Shell language for Allwmake, Allwclean, Allrun, Allclean, Alltest, Allmake and debug copies such as Allrun.1:

  • shell highlighting from VS Code's shell grammar, # comments and brackets;
  • completion for OpenFOAM environment variables ($FOAM_APPBIN, $WM_PROJECT_DIR, $LIB_SRC, ...), commands (wmake, wclean, wmakeLnInclude, runApplication, runParallel, foamRun, ...), utilities and solvers after runApplication/runParallel, and wmake/wclean options/targets.

OpenFOAMCode: opt-in C++ completion

The right side of the status bar has an OpenFOAMCode button, separate from the OpenFOAM project-mode button:

  • off by default; state is stored per workspace;
  • click to enable, click again to disable;
  • when enabled, provides C++ completion for OpenFOAM class/type names from the bundled v2606 index, common types and macros (Info, WarningInFunction, FatalErrorInFunction, tmp, autoPtr, IOobject, volScalarField, ...), and header names inside #include "...";
  • completion items include documentation and source paths;
  • full header candidates come from openfoam.sourceRoot; common headers such as fvCFD.H and fvMesh.H work without a source tree;
  • it complements clangd/cpptools and does not replace full semantic analysis.

C++ hover and go to definition for documented OpenFOAM classes and solvers are available when a source tree is detected.

Case explorer and running the case

The OpenFOAM Case view in the Explorer shows:

  • the solver (application from system/controlDict);
  • system and constant files, including patches and their types;
  • time directories with fields, classes and dimensions;
  • runtime function objects, including #includeFunc entries.

Commands run blockMesh, checkMesh or the solver in an integrated terminal whose working directory is the case. An optional prefix such as wsl supports Windows setups where OpenFOAM runs inside WSL.

Installation

Requirements: VS Code 1.80 or newer.

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

Then run Developer: Reload Window from the Command Palette.

Verify the installation:

code --list-extensions --show-versions | Select-String openfoam

Expected:

boyaochen.openfoam-dict-intellisense@1.1.12

The build is covered by 61 automated tests and includes the complete v2606 knowledge base as well as the 1.1.10 tutorial keyword index.

If another OpenFOAM Dict IntelliSense version is installed, --force replaces it with this build. The extension id is unchanged from 1.1.10, so settings and existing files are preserved.

Quick start

  1. Open a folder containing an OpenFOAM case (system/, constant/, 0/).

  2. Open system/controlDict; it is detected as OpenFOAM automatically.

  3. Hover over keys, values, patches or $variables; press Ctrl+Space for completion; press F12 for definitions.

  4. Open OpenFOAM Case in the Explorer for the case overview.

  5. To enable the extra source features, press Ctrl+Alt+O (Windows/Linux) or Cmd+Alt+O (macOS) and choose the OpenFOAM root, or set it manually:

    {
      "openfoam.sourceRoot": "D:/path/to/OpenFOAM-v2606"
    }
    

    For another OpenFOAM version, set its path and run OpenFOAM: Rebuild Source Knowledge Index.

  6. Open a Make/files or Make/options file and an Allwmake script to see the new languages.

  7. Open a .C/.H file and click OpenFOAMCode in the status bar to test C++ completion.

Commands

Command Description
OpenFOAM: Configure Source Root (openfoam.sourceRoot) Choose, browse, enter or clear the OpenFOAM source root (Ctrl+Alt+O)
OpenFOAM: Show Case Overview Open the case summary webview
OpenFOAM: Refresh Case Explorer Rescan the workspace for cases
OpenFOAM: Open OpenFOAM File Open a file path used by the case view
OpenFOAM: Reveal Case Folder Open the case directory in the OS file manager
OpenFOAM: Run blockMesh in Case Run blockMesh in the selected case
OpenFOAM: Run checkMesh in Case Run checkMesh in the selected case
OpenFOAM: Run Solver in Case Run the case application binary
OpenFOAM: Show Solver Sources Open the solver source
OpenFOAM: Rebuild Source Knowledge Index Re-scan an OpenFOAM source tree
OpenFOAM: Apply Highlighting Colors Apply the light/dark OpenFOAM token palette
OpenFOAM: Toggle OpenFOAMCode C++ Completion Enable/disable OpenFOAMCode
OpenFOAM: Reload Keyword Index Refresh the case explorer and keyword information
OpenFOAM: Show Keyword Index Information Show knowledge-base statistics
OpenFOAM: Set Current File Language to OpenFOAM Dictionary Force the current file to OpenFOAM
OpenFOAM: Toggle Project-wide OpenFOAM Mode Treat case dictionaries in the project as OpenFOAM

Settings

Setting Default Description
openfoam.sourceRoot "" Optional OpenFOAM checkout containing wmake, src, applications, etc
openfoam.detectLanguage true Auto-switch FoamFile documents and OpenFOAM scripts
openfoam.diagnostics.enable true Validate dictionaries while editing
openfoam.diagnostics.unknownTypes true Report unknown BC/solver/function-object types
openfoam.cppAssist.enable true C++ hover/definition inside an OpenFOAM source tree
openfoam.extraSolvers [] Additional accepted solver names for custom solvers
openfoam.run.bashCommand "" Optional prefix for run commands (for example wsl)
openfoam.run.blockMesh blockMesh Command used by the blockMesh action
openfoam.run.checkMesh checkMesh Command used by the checkMesh action
openfoam.run.solver {solver} Solver command; supports {solver} and {case}
openfoamIntellisense.enabled true 1.1.x compatibility: enable completion and detection
openfoamIntellisense.maxItems 1000 1.1.x compatibility: maximum completion items
openfoamIntellisense.fixLanguageMode true 1.1.x compatibility: auto-set dictionary language

Highlighting colors

  • Structural blocks (FoamFile, boundaryField, functions, solvers, scheme sections, RAS/LES, blockMesh/snappy blocks) use a dedicated bold section scope.
  • Token palettes are provided for Visual Studio Light/Dark, Default Light/Dark Modern and Light+/Dark+.
  • For any other theme, run OpenFOAM: Apply Highlighting Colors; it detects the active light/dark theme and merges the OpenFOAM rules into the global editor.tokenColorCustomizations.

Limitations

  • Syntax highlighting is TextMate-based; navigation is provided by language providers, not semantic tokens.
  • OpenFOAMCode completion is name/type/macro/header based, not full C++ semantic analysis (no overload or member resolution). Use clangd/cpptools for full C++ IntelliSense.
  • C++ hover/definition and full header completion need the source tree.
  • Running solvers requires an OpenFOAM environment; the extension only sends the configured command to a terminal.
  • Very large nonuniform field files are parsed partially; the case explorer still lists them with reduced detail.
  • The bundled source documentation is from OpenFOAM v2606; the tutorial keyword index is also from v2606 tutorials and can contain newer keys than an older local source tree.
  • wmake and shell completion is candidate-based, not a complete build-system or shell parser.

License and third-party notices

MIT. OpenFOAM is a trademark of OpenCFD Ltd.; this extension is an independent community tool and is not affiliated with OpenCFD.

The bundled 1.1.10 tutorial keyword index and its loader are derived from OpenFOAM Dict IntelliSense 1.1.10 by boyaoChen (MIT). See THIRD_PARTY_NOTICES.md.


中文说明

English · 简体中文

快速设置源码目录

专用快捷键:

平台 快捷键
Windows / Linux Ctrl+Alt+O
macOS Cmd+Alt+O

按下后会打开 OpenFOAM: Configure Source Root 快速菜单,提供:

  • Use current source root:保留当前 openfoam.sourceRoot;
  • Use detected source root:使用 WM_PROJECT_DIR、工作区目录或自动检测到的上级目录;
  • Browse for OpenFOAM source folder…:系统文件夹选择器;
  • Enter path manually…:手动输入路径并校验;
  • Clear setting:删除设置,恢复自动检测。

选中的目录必须包含 wmake、src、applications、etc。有打开的工作区时, 命令写入 Workspace 设置;否则写入 User 设置。如果快捷键冲突,也可以在 命令面板执行同一命令。

概述

OpenFOAM Dict IntelliSense 是一个 VS Code 扩展,用来编辑 OpenFOAM 算例字典、 湍流模型、wmake 构建文件、Allwmake/Allrun 脚本,并提供 OpenFOAM 专用 C++ 补全。

1.1.12 是 boyaoChen.openfoam-dict-intellisense@1.1.10 的后续版本,扩展 ID 保持不变,因此已有的 1.1.10 可以直接升级,原来的设置和已切换为 OpenFOAM Dictionary 的文件都继续可用;语言模式现在简称为 OpenFOAM。

扩展内置两类数据:

  • 用 OpenFOAM v2606 源码生成的知识库:102 个 solver、161 个 utility、 3,800+ 个有文档的 class、2,500+ 个字典类型、201 个 caseDicts 模板;
  • 1.1.10 的教程关键词索引:1,650 个文档。

是否需要 OpenFOAM 源码

编辑算例不需要安装 OpenFOAM,也不需要源码目录。源码目录是可选的,只用于 增强功能。

功能 无源码 设置 openfoam.sourceRoot 后
字典高亮、折叠、大纲、代码片段 支持 支持
字典关键词/值/类型补全 支持(内置索引) 支持
solver、utility、class、边界条件、函数对象悬浮文档 支持(内置文档) 支持,并带源码链接
湍流模型补全(RASModel、LESModel、delta) 支持 支持
诊断(缺条目、未知 solver/type、patch、量纲) 支持 支持
Make/files、Make/options 语言与补全 支持 支持,含 include/lib 候选
Allwmake、Allwclean、Allrun、Allclean 语言与补全 支持 支持
算例浏览器和算例总览 支持 支持,并带源码链接
算例内的 #include 支持 支持
#includeEtc / #includeFunc 目标解析 不支持 支持
跳转 solver/type 源码、完整 C++ 悬浮/定义 不支持 支持
#include "..." 头文件补全 仅常用头文件 完整源码树头文件索引
为其他 OpenFOAM 版本重建知识库 不支持 支持
运行 blockMesh / checkMesh / solver 需要本机 OpenFOAM 环境 同左

算例字典

  • OpenFOAM 语言支持无扩展名的算例字典:controlDict、fvSchemes、 fvSolution、blockMeshDict、transportProperties、 turbulenceProperties、momentumTransport、dynamicMeshDict、场文件等。
  • 高亮 FoamFile 头、[dimensions]、$变量、${...}、#include / #includeEtc / #includeFunc / #eval / #codeStream、#{ ... }# 代码块和注释。
  • 包含 FoamFile 头的文件会自动识别为 OpenFOAM。
  • 支持调试副本:controlDict.1、fvSchemes.bak、 turbulenceProperties.2、0/U.x、0/p.y、polyMesh/boundary.1 等, 仍按原字典的类型和上下文补全。
  • 嵌套字典大纲和字典块折叠。
  • FoamFile、controlDict、fvSchemes、fvSolution、场、边界条件、 函数对象、blockMeshDict 的代码片段。

字典智能补全

  • 悬浮文档:键、边界条件类型、函数对象类型、solver、scheme、patch、 #include 目标和 $变量。
  • 补全:按字典类型补全键、合法值、边界条件、线性求解器、光滑器、 离散格式、patch 名、变量、指令、include 路径和 #includeFunc 模板。
  • 跳转定义:$变量、#include 目标、patch 名、type 值、application。
  • 算例总览:solver、场、patch、线性求解器、离散格式、函数对象。

湍流模型

  • simulationType 补全 laminar、RAS、LES。
  • RAS 块内 RASModel(以及旧写法 model)只提示 RAS 模型: kEpsilon、RNGkEpsilon、realizableKE、kOmegaSST、SpalartAllmaras、 kkLOmega、雷诺应力模型、DES、GEKO 等。
  • LES 块内 LESModel(以及 model)只提示 LES 模型: Smagorinsky、WALE、dynamicKEqn、kEqn、DeardorffDiffStress、 sigma 等。
  • delta 补全 LES delta 模型:cubeRootVol、smooth、vanDriest 等。
  • 悬浮模型时显示对应源码文档和用法。

动网格与刚体运动

dynamicMeshDict 已作为独立字典类型支持,补全和悬浮文档包括:

  • dynamicFvMesh 的动态网格类型:dynamicMotionSolverFvMesh、 dynamicRefineFvMesh、dynamicOversetFvMesh、interfaceTrackingFvMesh 等;
  • motionSolverLibs 的运动求解器库:sixDoFRigidBodyMotion、 rigidBodyMeshMotion、fvMotionSolvers 以及对应的 lib*.so 形式;
  • motionSolver 的求解器:sixDoFRigidBodyMotion、rigidBodyMotion、 solidBody、displacementLaplacian 等;
  • sixDoFRigidBodyMotionCoeffs / rigidBodyMotionCoeffs 的设置: 质量、质心、惯量、初始姿态、重力、密度、加速度松弛、bodies、joints、 constraints、restraints;
  • sixDoF 约束类型:axis、line、orientation、plane、point, 以及旧写法 sixDoFRigidBodyMotionConstraint;
  • sixDoF 约束/弹簧类型:linearSpring、linearSpringDamper、 linearDamper、linearAxialAngularSpring、sphericalAngularSpring、 sphericalAngularDamper、tabulatedAxialAngularSpring、softWall, 以及旧写法 sixDoFRigidBodyMotionRestraint;
  • rigidBodyMotion 的 body 类型(rigidBody、cuboid、sphere、 masslessBody、jointBody)、joint 类型(composite、floating、 Px/Py/Pz/Pxyz、Rx/Ry/Rz 组合)以及 restraint 类型 (externalForce、linearDamper、prescribedRotation、softWall、 sphericalAngularDamper);
  • solver { type ...; } 的时间积分类型:Newmark、symplectic、 CrankNicolson;
  • solidBodyMotionFunction 运动函数(rotatingMotion、linearMotion、 oscillatingRotatingMotion、tabulated6DoFMotion 等)和常用字段 (centreOfRotation、direction、axis、point、normal、anchor、 refAttachmentPt、stiffness、damping、restLength、table 等)。

类型列表按 v2606 整理,不需要源码目录。

其他算例字典

常见算例字典也提供完整的键/值补全:

  • refineMeshDict:set、coordinateSystem(global/patchLocal)、 globalCoeffs、patchLocalCoeffs、tan1、tan2、directions (tan1/tan2/normal)、useHexTopology、geometricCut、writeMesh。
  • setFieldsDict:defaultFieldValues、regions、fieldValues、 volScalarFieldValue、volVectorFieldValue,以及 boxToCell、 rotatedBoxToCell、sphereToCell、cylinderToCell、coneToCell、 cellToCell、zoneToCell、surfaceToCell 等区域选择器;标量/向量场值 可直接插入完整片段。
  • snappyHexMeshDict:阶段开关(castellatedMesh、snap、addLayers)、 几何类型(triSurfaceMesh、searchableBox、searchableSphere、 searchableCylinder 等)、细化模式(inside、outside、distance)、 各阶段控制参数、网格质量限制、patchInfo 类型和层参数。
  • topoSetDict:type 集合类型(cellSet、faceSet、pointSet、 cellZoneSet 等)、action(new、add、delete、subset、invert、 clear、remove)、source 选择器(boxToCell、sphereToCell、 cylinderToCell、setToCellZone、fieldToCell 等)及选择器字段。
  • fvSchemes:ddt/grad/div/laplacian/interpolation/snGrad 片段、 wallDist 方法、fluxRequired 和格式组成。
  • fvSolution:线性求解器类型、光滑器、预条件器、GAMG agglomerator、松弛因子、residualControl、PISO/PIMPLE/SIMPLE 控制参数 和布尔开关。
  • surfaceFeatureExtractDict 和 meshQualityDict:特征提取方法及 通用网格质量阈值。
  • changeDictionaryDict:patch/边界修改、patchType、mapping 和 patch 元数据。
  • radiationProperties:radiationModel、吸收/发射、散射、soot 模型、 光谱带和太阳辐射。
  • combustionProperties、chemistryProperties、phaseProperties、 reactions:燃烧/化学模型、ODE 求解器、相间模型和 Arrhenius/fall-off 反应系数。
  • extrudeMeshDict、createBafflesDict、MRFProperties、 surfaceFilmProperties、porosityProperties、mapFieldsDict: 拉伸网格、baffle、旋转区域、表面膜、多孔区和场映射。
  • faMeshDefinition、faSchemes、faSolution:有限面积网格定义 和对应的格式/求解设置。
  • adjointRASProperties、optimisationDict、waveProperties、 setAlphaFieldDict、setExprFieldsDict、PDRProperties、 viewFactorsDict、mirrorMeshDict、boxTurbDict:专用算例字典 的键集。

已有字典也补充了设置项:

  • blockMeshDict、createPatchDict、createBafflesDict: patch 变换、neighbourPatch、inGroups、匹配/AMI 选项和 baffle jump。
  • decomposeParDict:dataFile、分布式分解、zones、domain weights 和 分解几何。
  • fvOptions:source 的 volume/mode、时间窗口、interpolation field、 rotor disk 和 meanVelocityForce 字段。
  • thermophysicalProperties、transportProperties、 turbulenceProperties:组分热物性、输运系数、湍流模型系数和多相 输运字段。
  • controlDict:probes、sampling、fieldAverage、graphs、executeControl、 region 等函数对象设置。
  • changeDictionaryDict:边界值、热层、发射率/导热方法、隐式耦合和 周期/patch 设置。

完整关键词索引

1.1.10 的教程关键词索引位于 data/keywords(1,650 个文档,原始约 36 MB), 已经合并到补全中:

  • 0/、constant/、system/ 的按文件关键词文档,包括 region 子目录和 0.orig;
  • 上下文排序(当前块、祖先、后代、兄弟);
  • writeControl、application、离散格式操作符、边界条件 type 等键的 实际出现值;
  • 模糊匹配(例如 wc → writeControl)、出现次数排序和 1.1.x 悬浮信息。

当源码知识库和教程索引都认识某个关键词时,优先显示源码候选;教程索引补充 大量真实算例中的长尾关键词。索引按需加载并按字典缓存。

诊断

检查 级别
缺少必需条目(application、fvSchemes 段、场条目等) warning
application 中未知 solver(附建议) warning
缺少 #include / #includeEtc / #includeFunc 目标 warning
未解析的 $变量 information
boundaryField 中的 patch 不在 polyMesh/boundary 中 warning
网格 patch 没有 boundaryField 条目(未使用正则 patch 时) warning
dimensions 不是恰好 7 个指数 warning
未知边界条件 / 线性求解器 / 函数对象类型 information

wmake files 和 options

自动识别 Make/files、Make/options(包括 files.1、options.bak 等副本) 为 OpenFOAM wmake:

  • 高亮赋值、$(FOAM_...) / $(LIB_SRC) 变量、-I / -l / -D 选项、 # 注释和续行反斜杠;
  • files 补全 EXE =、LIB =、目标路径、相对于应用/库目录的源文件名和 路径变量;
  • options 补全 EXE_INC、EXE_LIBS、LIB_INC、LIB_LIBS、编译选项、 $(LIB_SRC)/.../lnInclude 目录以及 -l 后的库名。

OpenFOAM Shell 脚本

支持 Allwmake、Allwclean、Allrun、Allclean、Alltest、Allmake 以及 Allrun.1 等副本,语言模式为 OpenFOAM Shell:

  • VS Code 内置 shell 语法高亮、# 注释和括号;
  • 补全 OpenFOAM 环境变量($FOAM_APPBIN、$WM_PROJECT_DIR、$LIB_SRC 等)、 命令(wmake、wclean、wmakeLnInclude、runApplication、 runParallel、foamRun 等)、runApplication / runParallel 后的 utility 和 solver,以及 wmake / wclean 的选项和目标。

OpenFOAMCode:可选的 C++ 补全

右下角状态栏有一个独立的 OpenFOAMCode 按钮:

  • 默认关闭,按工作区保存开关状态;
  • 点击开启,再点击关闭;
  • 开启后为 C++ 文件提供:
    • 内置 v2606 知识库中的 OpenFOAM 类名和类型名;
    • 常用类型和宏:Info、WarningInFunction、FatalErrorInFunction、 tmp、autoPtr、IOobject、volScalarField 等;
    • #include "..." 内的头文件名;
    • 补全详情中的文档和源码路径;
  • 设置 openfoam.sourceRoot 后使用完整头文件索引;未设置时也提供 fvCFD.H、fvMesh.H 等常用头文件;
  • 它和 clangd/cpptools 并存,不替代完整的 C++ 语义分析。

检测到源码树时,还支持 OpenFOAM 类和 solver 的 C++ 悬浮文档与跳转定义。

算例浏览器与运行

资源管理器中的 OpenFOAM Case 视图显示:

  • solver(system/controlDict 的 application);
  • system、constant 文件(包括 patch 及类型);
  • 时间目录中的场、class 和量纲;
  • 运行时函数对象(包括 #includeFunc)。

可以在集成终端中运行 blockMesh、checkMesh 或 solver,工作目录为当前算例; 可选 wsl 等命令前缀,方便 Windows 用户在 WSL 中运行 OpenFOAM。

安装

要求:VS Code 1.80 或更高版本。

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

然后在命令面板执行 Developer: Reload Window。

验证:

code --list-extensions --show-versions | Select-String openfoam

应显示:

boyaochen.openfoam-dict-intellisense@1.1.12

该版本通过 61 个自动化测试,并内置完整的 v2606 知识库和 1.1.10 教程关键词索引。

如果已经安装了其他版本,--force 会替换为当前版本;扩展 ID 与 1.1.10 相同, 原来的设置和文件会保留。

快速开始

  1. 打开包含算例的文件夹(含 system/、constant/、0/)。

  2. 打开 system/controlDict,文件会自动识别为 OpenFOAM。

  3. 把鼠标放在键、值、patch 或 $变量 上查看文档;按 Ctrl+Space 补全; 按 F12 跳转定义。

  4. 在资源管理器打开 OpenFOAM Case 查看算例总览。

  5. 如需源码增强,按 Ctrl+Alt+O(Windows/Linux)或 Cmd+Alt+O(macOS), 选择 OpenFOAM 根目录;也可以手动设置:

    {
      "openfoam.sourceRoot": "D:/path/to/OpenFOAM-v2606"
    }
    

    使用其他 OpenFOAM 版本时,设置对应目录后执行 OpenFOAM: Rebuild Source Knowledge Index。

  6. 打开 Make/files、Make/options 和 Allwmake,检查新语言模式与补全。

  7. 打开 .C / .H 文件,点击右下角 OpenFOAMCode 测试 C++ 补全。

命令

命令 说明
OpenFOAM: Configure Source Root (openfoam.sourceRoot) 选择、浏览、输入或清除 OpenFOAM 源码目录(Ctrl+Alt+O)
OpenFOAM: Show Case Overview 打开算例总览界面
OpenFOAM: Refresh Case Explorer 重新扫描工作区中的算例
OpenFOAM: Open OpenFOAM File 打开算例视图引用的文件
OpenFOAM: Reveal Case Folder 在系统文件管理器中打开算例目录
OpenFOAM: Run blockMesh in Case 在算例中运行 blockMesh
OpenFOAM: Run checkMesh in Case 在算例中运行 checkMesh
OpenFOAM: Run Solver in Case 运行算例的 application
OpenFOAM: Show Solver Sources 打开 solver 源码
OpenFOAM: Rebuild Source Knowledge Index 重新扫描 OpenFOAM 源码树
OpenFOAM: Apply Highlighting Colors 应用明/暗主题的 OpenFOAM 配色
OpenFOAM: Toggle OpenFOAMCode C++ Completion 开启/关闭 OpenFOAMCode
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 语言

设置

设置 默认值 说明
openfoam.sourceRoot "" 可选的 OpenFOAM 源码目录(含 wmake、src、applications、etc)
openfoam.detectLanguage true 自动识别 FoamFile 文件和 OpenFOAM 脚本
openfoam.diagnostics.enable true 编辑时启用字典诊断
openfoam.diagnostics.unknownTypes true 报告未知边界条件/solver/函数对象类型
openfoam.cppAssist.enable true 源码树内 C++ 悬浮/跳转
openfoam.extraSolvers [] 额外允许的自定义 solver 名
openfoam.run.bashCommand "" 运行命令的可选前缀(例如 wsl)
openfoam.run.blockMesh blockMesh blockMesh 命令
openfoam.run.checkMesh checkMesh checkMesh 命令
openfoam.run.solver {solver} solver 命令,支持 {solver} 和 {case}
openfoamIntellisense.enabled true 1.1.x 兼容:启用补全和自动检测
openfoamIntellisense.maxItems 1000 1.1.x 兼容:最大补全项数
openfoamIntellisense.fixLanguageMode true 1.1.x 兼容:自动设置字典语言

配色

  • FoamFile、boundaryField、functions、solvers、各 scheme 段、 RAS/LES、blockMesh/snappy 块使用加粗的章节颜色。
  • 为 Visual Studio Light/Dark、Default Light/Dark Modern、Light+/Dark+ 提供 默认 OpenFOAM token 配色。
  • 使用其他主题时,执行 OpenFOAM: Apply Highlighting Colors,扩展会根据 当前明/暗主题把规则合并到全局 editor.tokenColorCustomizations。

限制

  • 语法高亮基于 TextMate;导航由语言 Provider 提供,不使用语义 token。
  • OpenFOAMCode 补全是名称/类型/宏/头文件级补全,不是完整 C++ 语义分析 (不做重载或成员解析);完整 C++ IntelliSense 请使用 clangd/cpptools。
  • C++ 悬浮/定义和完整头文件补全需要源码树。
  • 运行 solver 需要本机 OpenFOAM 环境;扩展只负责把命令发送到终端。
  • 很大的 nonuniform 场文件只做部分解析,算例浏览器仍会列出但细节较少。
  • 内置源码文档来自 OpenFOAM v2606;教程关键词索引也来自 v2606 教程, 可能包含比本地旧源码更新的键。
  • wmake 和 shell 补全是候选式补全,不是完整构建系统/shell 解析器。

许可证与第三方说明

MIT。OpenFOAM 是 OpenCFD Ltd. 的商标;本扩展是独立社区工具,与 OpenCFD 无隶属关系。

内置的 1.1.10 教程关键词索引及其加载器来自 boyaoChen 的 OpenFOAM Dict IntelliSense 1.1.10(MIT)。详见 THIRD_PARTY_NOTICES.md。

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