#python #python-packages #parser #open-foam #package #openfoamparser

openfoamparser_rust

基于 openfoamparser Python 包的 OpenFOAM 解析器

1 个不稳定版本

0.1.0 2021年4月22日

#41 in #python-packages

自定义许可证

31KB
583 代码行(不包括注释)

Rust 中的 OpenFOAM 解析

openfoamparser_rust 允许您像使用 Python 库 openfoamparser 一样解析 OpenFOAM 模拟结果。


lib.rs:

OpenFOAM 解析器

openfoamparser_rust 允许您像使用 Python 库 openfoamparser 一样解析 OpenFOAM 模拟结果。

入门指南

以下示例加载现有的矢量场

use std::path::PathBuf;
use na::{Vector3, Point3};

use openfoamparser_rust as ofp;

let d = PathBuf::from("/path/to/simulation/case/");

// Load the mesh (and nothing else):
let mut fm = ofp::FoamMesh::new(&d).unwrap();

// Load the cell centers from time step 0.8 s.
// This requires that the following or a similar command has been run:
// `runApplication postProcess -func writeCellCentres -latestTime`
fm.read_cell_centers(d.join("0.8/C")).unwrap();

// Load the flow speeds from the same time step:
let flow: Vec<Vector3<f64>> = ofp::parse_internal_field(
    fm.path.join("0.8/U"),
    |s| ofp::parse_vector3(s)
).unwrap();

//

依赖项

~6.5MB
~121K SLoC