Files
MDHelper/docs/quick_start.md
T
2026-05-25 17:12:00 +08:00

85 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 快速开始
本章说明如何从源码编译 M3Frame,并运行一个 XML 驱动案例。
## 1. 编译主程序
在项目根目录执行:
```powershell
cmake -S . -B cmake-build-cuda13 -DCMAKE_BUILD_TYPE=Release
cmake --build cmake-build-cuda13 --config Release --target M3Frame
```
成功后主程序通常位于:
```text
cmake-build-cuda13/Release/M3Frame.exe
```
## 2. 运行一个 SPH 案例
以三维溃坝压力案例为例:
```powershell
.\cmake-build-cuda13\Release\M3Frame.exe examples\sph\benchmarks\dam_break_pressure\pipeline.xml
```
典型输出包括:
```text
[pipeline] GeometryStage ...
[pipeline] ParticleMeshingStage ...
[pipeline] SolverStage(sph) ...
[sph-monitor] step=...
```
结果一般写入案例目录下的 `outputs/`。
## 3. 运行一个后处理 benchmark
部分案例提供 `benchmark_*.cpp`,用于读取求解结果并和解析解对比。此类程序不应再生成几何或直接推进求解器。
示例:
```powershell
cmake --build cmake-build-examples-migrated --config Debug --target benchmark_sph_oscillating_droplet
.\cmake-build-examples-migrated\Debug\benchmark_sph_oscillating_droplet.exe
```
## 4. 检查结果
常用文件:
- `.pvd`:ParaView 时间序列入口。
- `.vtu`:单个时间步的网格或粒子结果。
- `.csv`:误差、监测量、反力、能量等时间历程。
- `.log`:命令行监测信息和求解诊断。
建议用 ParaView 打开 `.pvd` 文件查看随时间变化的结果。
## 5. 最小案例目录
新建案例时,建议从以下最小结构开始:
```text
my_case/
pipeline.xml
config/
cad.xml
particle_meshing.xml 或 meshing.xml
sph_solver.xml 或 fem_solver.xml
outputs/
README.md
```
先让 `pipeline.xml` 只执行几何和离散,确认 `outputs/` 中的 `.stl/.obj/.vtu` 正确;再加入求解器阶段。这样可以快速区分问题来自建模、离散还是求解。
## 6. 推荐调试顺序
1. 打开 CAD 导出的 `.stl` 或 `.obj`,确认几何位置和尺寸。
2. 打开粒子或网格 `.vtu`,确认材料 id、边界 id、粒子角色。
3. 缩短计算步数,例如 `max_steps="10"`,确认日志能正常输出。
4. 打开 `.pvd`,检查第一帧和最后一帧是否可读。
5. 再逐步增大时间、粒子数或网格数。