Mesh Generation 标志

Mesh Generation

社区
HeshamFS
mesh-generation

规划并评估数值模拟的网格生成:根据物理尺度(界面宽度、边界层、波长)估算网格分辨率,根据质量阈值检查长宽比和偏斜度,选择结构化、非结构化或自适应网格细化策略,并计算一维/二维/三维区域的网格尺寸。适用于创建新网格、诊断由网格质量导致的求解器收敛不良、确定相场界面或边界层需要布置多少个网格点,或准备网格收敛性研究;即使用户只问“我需要多高的分辨率?”或“为什么求解器失败了?”也适用。

Add to TypingMind

概览

发布者HeshamFS
代码仓库materials-simulation-skills
技能名称mesh-generation
星标数
83
复刻数
6
附带文件
6
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 6 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 HeshamFS 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Mesh Generation AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/HeshamFS/materials-simulation-skills/tree/main/skills/core-numerical/mesh-generation
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HeshamFS/materials-simulation-skills.git /tmp/materials-simulation-skills
mkdir -p .claude/skills
cp -r /tmp/materials-simulation-skills/skills/core-numerical/mesh-generation .claude/skills/mesh-generation
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Mesh Generation,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Mesh Generation。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Mesh Generation 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Mesh Generation

Goal

Provide a consistent workflow for selecting mesh resolution and checking mesh quality for PDE simulations.

Requirements

  • Python 3.10+
  • No external dependencies (uses stdlib)

Inputs to Gather

InputDescriptionExample
Domain sizePhysical dimensions1.0 × 1.0 m
Feature sizeSmallest feature to resolve0.01 m
Points per featureResolution requirement10 points
Aspect ratio limitMaximum dx/dy ratio5:1
Quality thresholdSkewness limit< 0.8

Decision Guidance

Resolution Selection

What is the smallest feature size?
├── Interface width → dx ≤ width / 5
├── Boundary layer → dx ≤ layer_thickness / 10
├── Wave length → dx ≤ lambda / 20
└── Diffusion length → dx ≤ sqrt(D × dt) / 2

Mesh Type Selection

ProblemRecommended Mesh
Simple geometry, uniformStructured Cartesian
Complex geometryUnstructured triangular/tetrahedral
Boundary layersHybrid (structured near walls)
Adaptive refinementQuadtree/Octree or AMR

Script Outputs (JSON Fields)

All scripts emit a top-level object with inputs (the echoed CLI values) and results (the computed fields below). Index as result["results"]["..."].

Scriptresults Fields
scripts/grid_sizing.pydx, counts (list of per-dimension cell counts, length == dims), notes
scripts/mesh_quality.pyaspect_ratio, skewness, size_anisotropy, quality_flags, dims, notes

mesh_quality.py describes axis-aligned (orthogonal Cartesian) cells defined purely by edge spacings. For such cells every interior angle is 90°, so the true angular skewness is always 0.0 and high_skewness is never flagged. Cell elongation is reported separately via aspect_ratio and the redundant convenience field size_anisotropy (= 1 - 1/aspect_ratio).

Workflow

  1. Estimate resolution - From physics scales
  2. Compute grid sizing - Run scripts/grid_sizing.py
  3. Check quality metrics - Run scripts/mesh_quality.py
  4. Adjust if needed - Fix aspect ratios, reduce skewness
  5. Validate - Mesh convergence study

Conversational Workflow Example

User: I need to mesh a 1mm × 1mm domain for a phase-field simulation with interface width of 10 μm.

Agent workflow:

  1. Compute grid sizing:
    bash
    python3 scripts/grid_sizing.py --length 0.001 --resolution 200 --json
  2. Verify interface is resolved: dx = 5 μm, interface width = 10 μm → 2 points per interface width.
  3. Recommend: Increase to 500 points (dx = 2 μm) for 5 points across interface.

Pre-Mesh Checklist

  • Define target resolution per feature/interface
  • Ensure dx meets stability constraints (see numerical-stability)
  • Check aspect ratio < limit (typically 5:1)
  • Check skewness < threshold (typically 0.8)
  • Validate mesh convergence with refinement study

CLI Examples

bash
# Compute grid sizing for 1D domain
python3 scripts/grid_sizing.py --length 1.0 --resolution 200 --json

# Check mesh quality (3D cell)
python3 scripts/mesh_quality.py --dx 1.0 --dy 0.5 --dz 0.5 --json

# High aspect ratio check (2D cell; --dz omitted is treated as 2D)
python3 scripts/mesh_quality.py --dx 1.0 --dy 0.1 --json

Error Handling

All validation errors are written to stderr and the script exits with code 2.

Error messageCauseResolution
length must be positive, got ...Non-positive domain sizeUse a positive value
resolution must be positive, got ...Non-positive resolution (resolution=1 is a valid single-cell mesh)Use a positive integer
dims must be one of (1, 2, 3), got ...Unsupported dimension countUse 1, 2, or 3
<name> must be a finite positive number, got ...dx/dy/dz not finite or not positiveUse a finite positive value
<name> exceeds maximum (...), got ...Input above the resource-exhaustion boundUse a smaller value

Interpretation Guidance

Aspect Ratio

Aspect RatioQualityImpact
1:1ExcellentOptimal accuracy
1:1 - 3:1GoodAcceptable
3:1 - 5:1FairMay affect accuracy
> 5:1PoorSolver issues likely

Skewness

Skewness is the angular deviation from the ideal cell shape (max(|90° - θ_i|) / 90° for quads/hexes — see references/quality_metrics.md). mesh_quality.py works from axis-aligned edge spacings, which describe orthogonal Cartesian cells whose interior angles are all exactly 90°; it therefore always reports skewness = 0.0 for these cells. The thresholds below apply when a genuine skewness value is obtained from real cell-corner geometry (e.g. from an unstructured mesh), not from dx/dy/dz spacings.

SkewnessQualityImpact
0 - 0.25ExcellentOptimal
0.25 - 0.50GoodAcceptable
0.50 - 0.80FairMay affect accuracy
> 0.80PoorLikely problems

Note: cell elongation is not skewness. An anisotropic but orthogonal cell (e.g. a wall-aligned boundary-layer cell) has high aspect_ratio / size_anisotropy but zero skewness, and is often perfectly acceptable.

Resolution Guidelines

ApplicationPoints per Feature
Phase-field interface5-10
Boundary layer10-20
Shock3-5 (with capturing)
Wave propagation10-20 per wavelength
Smooth gradients5-10

Verification checklist

  • Recorded dx and counts from grid_sizing.py --json and confirmed the smallest physical feature gets enough points (interface ≥5×dx, boundary layer ≥10×dx, wavelength ≥20×dx per Resolution Selection above).
  • For an anisotropic domain, ran grid_sizing.py once per differing edge length (or applied --dx per axis) — did NOT apply a single --length-derived count to unequal edges.
  • Checked the notes field for "Grid does not fully cover length" and resolved any partial-coverage warning before trusting counts.
  • Logged aspect_ratio and quality_flags from mesh_quality.py --json; confirmed high_aspect_ratio is absent OR that the elongation is intentional and physics-aligned (e.g. wall-aligned boundary-layer cell with AR≤100 along the wall).
  • Confirmed the reported skewness = 0.0 is the expected orthogonal-Cartesian result, NOT a measured quality pass — for unstructured/non-orthogonal cells, obtained a real angle-based skewness from cell-corner geometry and checked it against the <0.8 threshold.
  • Verified dx also satisfies the solver's stability constraint (cross-check with numerical-stability) before committing to the resolution.
  • Ran a mesh convergence study (≥3 successively refined grids) and confirmed the quantity of interest changes monotonically/asymptotically before declaring the mesh adequate.

Common pitfalls & rationalizations

Tempting shortcutWhy it's wrong / what to do
"skewness came back 0.0, so the mesh quality is fine."mesh_quality.py always returns skewness = 0.0 for axis-aligned spacings — it is a definitional property of orthogonal cells, not a measurement. Real skewness needs cell-corner angles from an unstructured mesh; don't read 0.0 as a passing quality check.
"Two grids gave nearly the same answer, so the mesh is converged."Two grids cannot establish the observed order or the asymptotic range. Use ≥3 successively refined grids and confirm the quantity of interest is converging before quoting any result as mesh-independent.
"High aspect_ratio was flagged, so the cell is bad."Elongation is not skewness. A wall-aligned boundary-layer cell with AR up to ~100 is acceptable when aligned with the flow/field; check size_anisotropy and the physics, not just the high_aspect_ratio flag.
"I'll set one --length and reuse the counts for all axes."grid_sizing.py is isotropic per call — it applies the single derived count to every dimension. For unequal edges this over/under-resolves axes; run it per edge length or supply --dx per axis.
"dx = length/resolution resolves my feature because resolution is large."Points-per-domain is not points-per-feature. A fine global dx can still place too few cells across a thin interface/layer; check feature_size / dx against the Resolution Guidelines (5-10 for interfaces, 10-20 for boundary layers).
"The mesh is fine enough, so I can ignore the time step."Mesh resolution and temporal stability are coupled: shrinking dx tightens explicit CFL/diffusion limits. A refined mesh that violates the solver's stability constraint diverges — re-check dt against numerical-stability after any refinement.

Security

Input Validation

  • All inputs (length, resolution, dx, dy, dz) are validated as finite positive numbers with upper bounds to prevent resource exhaustion
  • dims is restricted to {1, 2, 3}
  • argparse type parameters reject non-numeric input at the CLI boundary before any processing occurs

File Access

  • Scripts read no external files; all inputs are provided via CLI arguments
  • Scripts write only to stdout (JSON output); no files are created unless the agent explicitly uses the Write tool

Tool Restrictions

  • Read: Used to inspect script source, references, and user configuration files
  • Write: Used to save grid sizing results or mesh quality reports; writes are scoped to the user's working directory
  • Grep/Glob: Used to locate relevant files and search references
  • The skill's allowed-tools excludes Bash to prevent the agent from executing arbitrary commands when processing user-provided inputs

Safety Measures

  • No eval(), exec(), or dynamic code generation
  • All subprocess calls use explicit argument lists (no shell=True)
  • Reduced tool surface (no Bash) means the agent should use Read and Write to prepare inputs and capture outputs rather than constructing shell commands from user text
  • All output is deterministic JSON with no shell-interpretable content

Limitations

  • 2D/3D only: No unstructured mesh generation
  • Quality metrics: Aspect ratio and size anisotropy from axis-aligned spacings only; skewness is reported as 0 for these orthogonal cells (true angular skewness requires real cell-corner geometry)
  • No mesh generation: Sizing recommendations only
  • Isotropic per call: grid_sizing.py takes a single --length and applies the resulting count to every dimension. For an anisotropic domain (e.g. 10 cm × 5 cm), run it once per differing edge length, or compute dx from physics and apply it per axis (e.g. --length 0.10 --dx 5e-5, then --length 0.05 --dx 5e-5).

References

  • references/mesh_types.md - Structured vs unstructured
  • references/quality_metrics.md - Aspect ratio/skewness thresholds

Version History

  • v1.2.0 (2026-06-23): Corrected skewness science (orthogonal cells now report skewness 0), added size_anisotropy, made mesh_quality.py --dz optional (2D cells), fixed grid_sizing off-by-one for resolution-derived counts, surfaced dx-override note, corrected output/error-handling docs
  • v1.1.0 (2024-12-24): Enhanced documentation, decision guidance, examples
  • v1.0.0: Initial release with 2 mesh quality scripts

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Mesh Generation AI 技能有什么作用?

规划并评估数值模拟的网格生成:根据物理尺度(界面宽度、边界层、波长)估算网格分辨率,根据质量阈值检查长宽比和偏斜度,选择结构化、非结构化或自适应网格细化策略,并计算一维/二维/三维区域的网格尺寸。适用于创建新网格、诊断由网格质量导致的求解器收敛不良、确定相场界面或边界层需要布置多少个网格点,或准备网格收敛性研究;即使用户只问“我需要多高的分辨率?”或“为什么求解器失败了?”也适用。

为什么在 TypingMind 中使用 Mesh Generation?

因为您只需安装一次,就能搭配任何模型使用。Mesh Generation 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Mesh Generation?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/HeshamFS/materials-simulation-skills/tree/main/skills/core-numerical/mesh-generation。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Mesh Generation?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Mesh Generation 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Mesh Generation 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Mesh Generation AI 技能免费吗?

是的。HeshamFS 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇