Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

MeshFile.Write writes a 3 21 header for meshes with 6- or 8-node elements

未关闭
#68 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

Start with mikecore/MeshFile.py:345-348 and the element-writing loop to see how the header is chosen; compare that with element creation in mikecore/MeshBuilder.py:150-153 and mikecore/MeshFile.py:390-393. Reproduce with a 6-node mesh and MeshFile.ReadMesh(path). Done means unsupported element widths are rejected rather than written with a mismatched header; the suggested read-side exception is also worth checking at mikecore/MeshFile.py:305-313.

由索引模型根据 Issue 内容生成。

描述

Summary

MeshFile.Write() picks the element header line from _hasQuads alone (mikecore/MeshFile.py:345-348):

if not self._hasQuads:
    maxNodesPerElmt, elmtType = 3, 21
else:
    maxNodesPerElmt, elmtType = 4, 25

Elements with 6 or 8 nodes (types 32/33) are never considered. MeshBuilder.CreateMesh() accepts them (mikecore/MeshBuilder.py:150-153), and MeshFile.Create() only sets _hasQuads for 4-node elements (mikecore/MeshFile.py:390-393). So a mesh of quadratic elements is written with the header <n> 3 21, while the row loop still writes every node, which makes the rows 6 or 8 values wide.

Reproduce

Build a mesh with 6-node triangles via MeshBuilder, call CreateMesh().Write(path), then MeshFile.ReadMesh(path).

  • The written header claims max 3 nodes per element, code 21, and doesn't match the rows.
  • On read, Read() only recognises 3 and 4 nodes per element (mikecore/MeshFile.py:305-313), so those elements get ElementType = 0.

mikeio can reach this too: it writes .mesh through MeshBuilder().CreateMesh().Write(), e.g. to_mesh on a quadratic mesh.

Background

The .mesh format documents only codes 21 (all triangles) and 25 (quads present) for the element header. There's no documented quadratic form (32/33 are dfsu element types).

Suggested fix

  • In Write(), derive maxNodesPerElmt from the widest element instead of _hasQuads, and raise on any element with other than 3 or 4 nodes, since .mesh can't represent it.
  • Probably make Read() raise on such elements too, instead of the silent ElementType = 0 (there's a # TODO: Throw an exception? there).

Found while reviewing #53.

🤖 Generated with Claude Code

主要语言
Python
星标
5
派生
1
平均合并
1 小时 19 分钟
30 天内合并 PR
6

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DHI/mikecore-python 的其他 Issue

查看 DHI/mikecore-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。