PointNetCFD / README.md
Zhongning's picture
Add Chinese README section
b9d026b verified
|
Raw History Blame Contribute Delete
12 kB
metadata
license: mit
language:
  - en
tags:
  - OneScience
  - fluid-mechanics
  - flow-field-prediction
  - point-cloud
frameworks: PyTorch

PointNetCFD

Model Introduction

PointNetCFD is a point-cloud model for flow-field prediction proposed by Ali Kashefi, Davis Rempe, and Leonidas J. Guibas. It directly represents nodes of unstructured CFD meshes in irregular geometries as point clouds, uses PointNet to encode geometry and spatial position, and predicts two velocity components and pressure at each point. This repository is an independent reproduction based on the paper and implemented through the OneScience skill workflow.

Paper: A Point-Cloud Deep Learning Framework for Prediction of Fluid Flow Fields on Irregular Geometries

Model Description

PointNetCFD is a pointwise CFD regression model for unstructured meshes. Each sample contains 1,024 points. It takes node coordinates (x, y) as input and predicts (u, v, p) at every point. T-Nets align the inputs and features; shared MLPs and global max pooling extract local and global features; and a 512 → 256 → 128 → 128 → 3 decoder predicts the flow field from the fused representation. Coordinates retain their original physical scale, while output variables are normalized to [0, 1] using training-set statistics.

Use Cases

Use case Description
CFD flow-field prediction Predicts velocity components (u, v) and pressure p point by point from the two-dimensional coordinates (x, y) of unstructured-mesh nodes.
Irregular-geometry modeling Directly represents object boundaries and unstructured meshes as point clouds without interpolating CFD data onto a regular grid.
Geometry generalization The corresponding experiment evaluates predictive performance on previously unseen geometries.

Usage

1. Using OneCode

Try intelligent, one-click AI4S programming in the OneCode online environment:

Try intelligent, one-click AI4S programming

2. Manual Installation and Usage

Hardware requirements

  • A GPU or DCU is recommended.
  • A CPU can be used for import checks and small-scale connectivity tests, but full training and inference will be slow.
  • DCU users must install DTK in advance. DTK 25.04.2 or later, or the OneScience-recommended version for the current cluster, is recommended.

Download the Model Package

modelscope download --model OneScience/PointNetCFD --local_dir ./PointNetCFD
cd PointNetCFD

Set Up the Runtime Environment

DCU environment

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU environment

# Activate Conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

Training Data

The OneScience community provides PointNetCFD training data. Download it with the command below, then make sure paths.data_dir in config/config.yaml points to the downloaded data directory:

modelscope download --dataset OneScience/pointnet_cfd --local_dir ./data

Each sample in CFDdata.npy is a 1,024 × 5 point-cloud data matrix with columns [x, y, p, u, v]. Index files for the training, validation, and test sets are also provided.

Training

The default config/config.yaml corresponds to the main experimental setup in the paper.

python scripts/train.py --config config/config.yaml

During training, the training loss, validation loss, and evaluation metrics for each epoch are printed to standard output. The checkpoint with the best validation MSE is saved to:

weight/best_model.pth

The training history, effective configuration, and training summary are stored in the results/ directory. For an environment-connectivity check, run the minimal smoke test, which uses a separate output path:

python scripts/train.py --smoke-test

Trained Weights

The weight/ directory contains weights pretrained on the PointNetCFD data and ready for inference.

Inference

Before running inference, make sure the data path in config/config.yaml is valid and weight/best_model.pth exists. The following command runs inference on the fixed test set and prints the normalized MSE, RMSE for each physical variable, and relative L2 error in real time:

python scripts/inference.py \
  --config config/config.yaml \
  --checkpoint weight/best_model.pth \
  --device auto \
  --output-dir results

Inference outputs are saved as:

  • results/test_metrics.json: test metrics and reference metrics from the paper;
  • results/predictions.npz: coordinates, predictions, ground truth, and sample indices.

Evaluation and Visualization

Numerical evaluation is performed by scripts/inference.py during inference. The visualization script depends on results/predictions.npz, so complete the inference step above before running:

python scripts/result.py \
  --predictions results/predictions.npz \
  --output-dir results/figures \
  --num-cases 3

Official OneScience Resources

Citation and License


中文说明

模型简介

PointNetCFD 是由 Ali Kashefi、Davis Rempe 和 Leonidas J. Guibas 提出的流场预测点云模型。它直接将不规则几何域中非结构化计算流体力学(CFD)网格的节点表述为点云,使用 PointNet 编码几何和空间位置,并预测各点的两个速度分量和压力。本仓库以论文为依据,通过 OneScience 技能工作流独立复现。

论文:面向不规则几何域流场预测的点云深度学习框架

模型描述

PointNetCFD 是面向非结构化网格的逐点计算流体力学回归模型。每个样本包含 1,024 个点。模型接收节点坐标 (x, y),并预测各点的 (u, v, p)。T-Nets 对齐输入及特征,共享 MLP 与全局最大池化提取局部和全局特征,512 → 256 → 128 → 128 → 3 解码器从融合表征预测流场。坐标保留原始物理尺度,输出变量使用训练集统计量归一化到 [0, 1]。

使用场景

使用场景 说明
计算流体力学流场预测 根据非结构化网格节点的二维坐标 (x, y),逐点预测速度分量 (u, v) 和压力 p。
不规则几何域建模 直接以点云表征物体边界及非结构化网格,无需将计算流体力学数据插值到规则网格。
几何泛化 相应实验评估模型在先前未见过的几何形状上的预测性能。

使用指南

1. 使用 OneCode

通过 OneCode 在线环境体验智能一键 AI4S 编程。

体验智能一键 AI4S 编程

2. 手动安装与使用

硬件要求

  • 建议使用 GPU 或 DCU。
  • CPU 可用于导入检查和小规模连通性测试,完整训练和推理(inference)速度较慢。
  • DCU 用户须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐的适配当前集群的版本。

下载模型包

modelscope download --model OneScience/PointNetCFD --local_dir ./PointNetCFD
cd PointNetCFD

配置运行环境

DCU 环境

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU 环境

# Activate Conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# Installation with uv is also supported
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

训练数据

OneScience 社区提供 PointNetCFD 训练数据。使用以下命令下载,并确保 config/config.yaml 中的 paths.data_dir 指向下载的数据目录。

modelscope download --dataset OneScience/pointnet_cfd --local_dir ./data

CFDdata.npy 的每个样本都是 1,024 × 5 点云数据矩阵,包含列 [x, y, p, u, v]。同时提供训练集、验证集和测试集的索引文件。

训练

默认 config/config.yaml 对应论文主要实验设置。

python scripts/train.py --config config/config.yaml

训练期间,将每轮的训练损失、验证损失和评估指标打印到标准输出。验证 MSE 最佳的模型权重(检查点)(checkpoint)保存到以下位置。

weight/best_model.pth

训练历史、实际采用的配置和训练摘要均存放于 results/ 目录。若要检查环境连通性,请运行使用独立输出路径的最小冒烟测试。

python scripts/train.py --smoke-test

训练权重

weight/ 目录包含在 PointNetCFD 数据上预训练得到的权重,可直接用于推理。

推理

运行推理前,请确认 config/config.yaml 中的数据路径有效,而且 weight/best_model.pth 存在。以下命令对固定测试集运行推理,并实时打印归一化 MSE、各物理变量的 RMSE 及相对 L2 误差。

python scripts/inference.py \
  --config config/config.yaml \
  --checkpoint weight/best_model.pth \
  --device auto \
  --output-dir results

推理输出保存为以下文件。

  • results/test_metrics.json 包含测试指标及论文参考指标
  • results/predictions.npz 包含坐标、预测结果、真值和样本索引。

评估与可视化

数值评估由 scripts/inference.py 在推理过程中执行。可视化脚本依赖 results/predictions.npz,因此请先完成上述推理步骤,再运行下列命令。

python scripts/result.py \
  --predictions results/predictions.npz \
  --output-dir results/figures \
  --num-cases 3

OneScience 官方资源

引用与许可证