企业知识库搭建全攻略:从选型到落地,帮你少走90%的弯路
2026/6/14 23:37:08
Cassiopee
Cassiopee是一个由法国航空航天研究院(ONERA)开发的开源 Python 库,主要用于CFD(计算流体力学)前处理、后处理、网格操作与可视化。它尤其擅长处理结构化和非结构化网格,并支持多种主流 CFD 格式(如 CGNS、VTK、SU2、Plot3D 等),广泛应用于科研和工程领域。
网格读写与转换
网格操作
前处理
后处理与可视化
脚本化与自动化
并行支持(MPI)
Converter.PyTree模块支持分布式内存并行(基于 MPI)。Cassiopee 依赖于 Python(通常 3.7+)和一些底层 C/Fortran 库(如 CGNS、HDF5)。推荐使用Conda安装:
# 添加 conda-forge 和 ONERA 通道(如有)condainstall-c conda-forge -c onera cassiopee或者从源码编译(需先安装 CGNS、HDF5、Tk 等):
gitclone https://git.onera.fr/occigene/cassiopee.gitcdcassiopee python setup.pyinstall⚠️ 注意:官方推荐在 Linux 或 macOS 上使用;Windows 支持有限,可能需要 WSL。
importCassiopeeasCimportConverterasCGimportGeneratorasG# 读取 CGNS 网格a=C.convertFile2PyTree('mesh.cgns')# 显示网格结构C.convertPyTree2File(a,'output.vtk')# 转为 VTK 供 ParaView 查看# 或直接用内置查看器(需 Tk 支持)C.display(a)importCassiopeeasCimportConnectorasX t1=C.convertFile2PyTree('zone1.cgns')t2=C.convertFile2PyTree('zone2.cgns')# 自动匹配连接t=X.connectMatch([t1,t2])C.convertPyTree2File(t,'merged.cgns')importPostasP# 假设 a 包含流场(如 Density, Momentum 等)# 在点集上插值points=[[0.1,0.2,0.0],[0.3,0.4,0.0]]result=P.extractPoint(a,points)print(result)# 返回插值后的流场变量Examples/目录)。