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

openfoamparser_rust

An OpenFOAM parser based on the openfoamparser Python package

1 unstable release

0.1.0 Apr 22, 2021

#41 in #python-packages

Custom license

31KB
583 lines

OpenFOAM Parsing in Rust

openfoamparser_rust lets you parse OpenFOAM simulation results just like the Python library openfoamparser.


lib.rs:

OpenFOAM Parser

openfoamparser_rust lets you parse OpenFOAM simulation results just like the Python library openfoamparser.

Getting Started

The following example loads an existing vector field:

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();

//

Dependencies

~6.5MB
~121K SLoC