Skip to content

Commit 3b95295

Browse files
committed
feat: Initial release v0.2.0 - PySide6 MUJI-style UI
0 parents  commit 3b95295

29 files changed

Lines changed: 2670 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# BlockMesh Studio CI/CD Pipeline
2+
# 確保 UTF-8 編碼支援正體中文
3+
4+
name: CI
5+
6+
on:
7+
push:
8+
branches: [main, master]
9+
pull_request:
10+
branches: [main, master]
11+
12+
env:
13+
# 全域 UTF-8 設定(Python 3.14 已內建 UTF-8 模式)
14+
PYTHONIOENCODING: "utf-8"
15+
16+
jobs:
17+
test-linux:
18+
runs-on: ubuntu-latest
19+
env:
20+
LANG: en_US.UTF-8
21+
LC_ALL: en_US.UTF-8
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up locale
27+
run: |
28+
sudo locale-gen en_US.UTF-8
29+
sudo update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
30+
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v4
33+
with:
34+
version: "latest"
35+
36+
- name: Set up Python 3.14
37+
run: uv python install 3.14
38+
39+
- name: Create virtual environment
40+
run: uv venv .venv314 --python 3.14
41+
42+
- name: Install dependencies
43+
run: |
44+
uv pip install -e ".[dev]"
45+
46+
- name: Run tests with UTF-8
47+
run: |
48+
uv run pytest -v --tb=short
49+
env:
50+
PYTHONIOENCODING: "utf-8"
51+
52+
test-windows:
53+
runs-on: windows-latest
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Set Windows UTF-8 codepage
59+
run: |
60+
chcp 65001
61+
shell: cmd
62+
63+
- name: Install uv
64+
uses: astral-sh/setup-uv@v4
65+
with:
66+
version: "latest"
67+
68+
- name: Set up Python 3.14
69+
run: uv python install 3.14
70+
71+
- name: Create virtual environment
72+
run: uv venv .venv314 --python 3.14
73+
74+
- name: Install dependencies
75+
run: |
76+
uv pip install -e ".[dev]"
77+
78+
- name: Run tests with UTF-8
79+
run: |
80+
uv run pytest -v --tb=short
81+
env:
82+
PYTHONIOENCODING: "utf-8"
83+
PYTHONLEGACYWINDOWSSTDIO: "0"

.gitignore

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.nox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
*.py,cover
48+
.hypothesis/
49+
.pytest_cache/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Environments
56+
.env
57+
.venv
58+
.venv*/
59+
env/
60+
venv/
61+
ENV/
62+
env.bak/
63+
venv.bak/
64+
65+
# IDE
66+
.idea/
67+
.vscode/
68+
*.swp
69+
*.swo
70+
*~
71+
72+
# OS
73+
.DS_Store
74+
Thumbs.db
75+
76+
# Project specific - exclude backup files
77+
excel2blockMesh004.1.1_addLayer_GUI(Main_work)_backUp.py
78+
blockMeshDict_X.m4
79+
80+
# Logs
81+
*.log

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.14

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 LostSunset
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# BlockMesh Studio
2+
3+
[![CI](https://github.com/LostSunset/blockmesh-studio/actions/workflows/ci.yml/badge.svg)](https://github.com/LostSunset/blockmesh-studio/actions/workflows/ci.yml)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
6+
[![GitHub stars](https://img.shields.io/github/stars/LostSunset/blockmesh-studio.svg)](https://github.com/LostSunset/blockmesh-studio/stargazers)
7+
[![GitHub forks](https://img.shields.io/github/forks/LostSunset/blockmesh-studio.svg)](https://github.com/LostSunset/blockmesh-studio/network)
8+
[![GitHub issues](https://img.shields.io/github/issues/LostSunset/blockmesh-studio.svg)](https://github.com/LostSunset/blockmesh-studio/issues)
9+
10+
OpenFOAM blockMeshDict 網格生成工具
11+
12+
採用 **PySide6** 開發,**無印良品風格**設計
13+
14+
## ✨ 功能
15+
16+
- 📊 **Excel 轉換**:將 2D 流道數據轉換為 3D 圓柱網格
17+
- 🔵 **圓柱網格**:參數化圓柱形網格生成
18+
- 🎛️ **邊界層控制**:內外壁邊界層網格設定
19+
20+
## 📋 系統需求
21+
22+
- Python 3.10+
23+
- [uv](https://docs.astral.sh/uv/) 套件管理器(推薦)
24+
25+
## 🚀 快速開始
26+
27+
### 1. 建立環境
28+
29+
```bash
30+
# 建立虛擬環境
31+
uv venv .venv --python 3.10
32+
33+
# 啟動環境
34+
.venv\Scripts\activate # Windows
35+
source .venv/bin/activate # Linux/macOS
36+
37+
# 安裝依賴
38+
uv pip install PySide6 pandas numpy scipy openpyxl
39+
```
40+
41+
### 2. 啟動應用程式
42+
43+
```bash
44+
python -m src.main
45+
```
46+
47+
## 📁 專案結構
48+
49+
```
50+
src/
51+
├── main.py # 入口點
52+
├── core/ # 核心邏輯
53+
│ ├── mesh_generator.py
54+
│ ├── cylinder_mesh.py
55+
│ └── excel_reader.py
56+
├── models/ # 資料模型
57+
│ └── mesh_params.py
58+
└── ui/ # 使用者介面
59+
├── main_window.py
60+
├── widgets/
61+
└── resources/
62+
└── muji_style.qss
63+
```
64+
65+
## 📖 使用說明
66+
67+
### Excel 轉換
68+
69+
1. 選擇包含 X, Y, Z 座標的 Excel 檔案
70+
2. 設定網格參數(層數、徑向/圓周/軸向網格數)
71+
3. 可選:啟用邊界層控制
72+
4. 點擊「生成」產生 blockMeshDict
73+
74+
### 圓柱網格
75+
76+
1. 設定幾何參數(半徑、高度、內方形邊長)
77+
2. 設定網格參數
78+
3. 點擊「生成」產生 blockMeshDict
79+
80+
## 🌐 正體中文支援
81+
82+
- 所有檔案使用 UTF-8 編碼
83+
- 完整支援正體中文介面
84+
85+
## 📈 Star History
86+
87+
[![Star History Chart](https://api.star-history.com/svg?repos=LostSunset/blockmesh-studio&type=Date)](https://star-history.com/#LostSunset/blockmesh-studio&Date)
88+
89+
## 🤝 貢獻
90+
91+
歡迎提交 Issue 和 Pull Request!
92+
93+
## 📄 授權
94+
95+
[MIT License](LICENSE)

conftest.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
pytest 全域配置
4+
確保 UTF-8 編碼支援正體中文
5+
"""
6+
import os
7+
import sys
8+
9+
10+
def pytest_configure(config):
11+
"""
12+
pytest 啟動時設定環境變數,確保 UTF-8 輸出
13+
Python 3.14 預設已使用 UTF-8 模式
14+
"""
15+
# 設定 IO 編碼(Python 3.14 中 PYTHONUTF8 可能無需設定)
16+
os.environ["PYTHONIOENCODING"] = "utf-8"
17+
18+
# Windows 終端編碼設定
19+
if sys.platform == "win32":
20+
os.environ["PYTHONLEGACYWINDOWSSTDIO"] = "0"
21+
# 嘗試設定 Windows 終端為 UTF-8
22+
try:
23+
import subprocess
24+
subprocess.run(["chcp", "65001"], shell=True, capture_output=True)
25+
except Exception:
26+
pass
27+

main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def main():
2+
print("Hello from 00-blockmesh-studio!")
3+
4+
5+
if __name__ == "__main__":
6+
main()

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[project]
2+
name = "blockmesh-studio"
3+
version = "0.2.0"
4+
description = "BlockMesh Studio - OpenFOAM blockMeshDict 網格生成工具"
5+
readme = "README.md"
6+
requires-python = ">=3.14"
7+
dependencies = [
8+
"PySide6>=6.6.0",
9+
"pandas>=2.0.0",
10+
"numpy>=1.24.0",
11+
"scipy>=1.10.0",
12+
"openpyxl>=3.1.0",
13+
]
14+
15+
[project.optional-dependencies]
16+
dev = [
17+
"pytest>=8.0",
18+
"pytest-cov>=4.0",
19+
]
20+
21+
[tool.pytest.ini_options]
22+
testpaths = ["tests"]
23+
python_files = ["test_*.py", "*_test.py"]
24+
python_functions = ["test_*"]
25+
addopts = "-v --tb=short"
26+
filterwarnings = ["ignore::DeprecationWarning"]
27+
28+
# [tool.uv] 配置已移除,使用 UV_VENV_NAME 環境變數或手動指定

run_tests.bat

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@echo off
2+
chcp 65001 >nul
3+
REM BlockMesh Studio 測試執行腳本
4+
REM 確保 UTF-8 編碼支援正體中文
5+
6+
echo ============================================
7+
echo BlockMesh Studio 測試執行器
8+
echo ============================================
9+
10+
REM 設定 UTF-8 環境變數(Python 3.14 已內建 UTF-8 模式)
11+
set PYTHONIOENCODING=utf-8
12+
set PYTHONLEGACYWINDOWSSTDIO=0
13+
14+
REM 啟動虛擬環境並執行測試
15+
echo.
16+
echo 正在執行測試...
17+
echo.
18+
19+
uv run pytest -v --tb=short %*
20+
21+
echo.
22+
echo ============================================
23+
echo 測試執行完成
24+
echo ============================================

run_tests.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# BlockMesh Studio 測試執行腳本
3+
# 確保 UTF-8 編碼支援正體中文
4+
5+
echo "============================================"
6+
echo " BlockMesh Studio 測試執行器"
7+
echo "============================================"
8+
9+
# 設定 UTF-8 環境變數(Python 3.14 已內建 UTF-8 模式)
10+
export PYTHONIOENCODING=utf-8
11+
export LANG=en_US.UTF-8
12+
export LC_ALL=en_US.UTF-8
13+
14+
echo ""
15+
echo "正在執行測試..."
16+
echo ""
17+
18+
uv run pytest -v --tb=short "$@"
19+
20+
echo ""
21+
echo "============================================"
22+
echo " 測試執行完成"
23+
echo "============================================"

0 commit comments

Comments
 (0)