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

openfoamparser

An OpenFOAM parser based on the openfoamparser Python package

3 releases

0.1.2 Apr 22, 2021
0.1.1 Apr 22, 2021
0.1.0 Apr 22, 2021

#34 in #python-packages

45 downloads per month

Custom license

31KB
583 lines

OpenFOAM Parsing in Rust

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

Known limitations:

  • Parsing binary files is not supported yet.

Links:


lib.rs:

OpenFOAM Parser

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

Known limitations:

  • Parsing binary files is not supported yet.

Getting Started

The following example loads an existing vector field:

extern crate nalgebra as na;
use std::path::PathBuf;
use na::{Vector3, Point3};

use openfoamparser as ofp;

let d: PathBuf = [
    env!("CARGO_MANIFEST_DIR"),
    "resources/test/cavity/"
].iter().collect();

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

// Load the cell centers from time step 0.5 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.5/C")).unwrap();

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

//

Dependencies

~6.5MB
~122K SLoC