fluidfoam.readof¶
Read OpenFoam Files for Python¶
This module provides functions to read OpenFoam Files:

fluidfoam.readof.
readmesh
(rep, structured=False, boundary=None, order='F', precision=15)[source]¶ Read OpenFoam mesh and reshape if necessary (in cartesian structured mesh).
 Args:
rep: str
structured: False or True
boundary: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15). If decimals is negative, it specifies the number of positions to the left of the decimal point.
 Returns:
 array: array of vector (Mesh X, Y, Z); size of the array is the size of the interior domain (or of the size of the boundary in case of not None boundary)
A way you might use me is:
X, Y, Z = fluidfoam.readmesh(‘path_of_OpenFoam_case’) So X, Y and Z are 1D numpy array with size = nb_cellIf you play with structured mesh you can shape the X, Y and Z output :
X, Y, Z = fluidfoam.readmesh(‘path_of_OpenFoam_case’, structured=True) So X, Y and Z are 3D numpy array with shape = (nx, ny, nz)

fluidfoam.readof.
readfield
(path, time_name=None, name=None, structured=False, boundary=None, order='F', precision=15)[source]¶ Read OpenFoam field and reshape if necessary (structured mesh) and possible (not uniform field).
 Args:
path: str
time_name: str (‘latestTime’ is supported)
name: str
structured: False or True
boundary: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15). If decimals is negative, it specifies the number of positions to the left of the decimal point.
 Returns:
 array: array of type of the field; size of the array is the size of the interior domain (or of the size of the boundary in case of not None boundary)
A way you might use me is:
field = fluidfoam.readfield(‘path_of_OpenFoam_case’, ‘0’, ‘alpha’)

fluidfoam.readof.
readscalar
(path, time_name=None, name=None, structured=False, boundary=None, order='F', precision=15, mode=None)[source]¶ Read OpenFoam scalar field and reshape if necessary and possible (not uniform field).
 Args:
path: str
time_name: str (‘latestTime’ is supported)
name: str
structured: False or True
boundary: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15). If decimals is negative, it specifies the number of positions to the left of the decimal point.
 Returns:
 array: array of scalar field; size of the array is the size of the interior domain (or of the size of the boundary in case of not None boundary)
A way you might use me is:
scalar_a = fluidfoam.readscalar(‘path_of_OpenFoam_case’, ‘0’, ‘alpha’)

fluidfoam.readof.
readvector
(path, time_name=None, name=None, structured=False, boundary=None, order='F', precision=15)[source]¶ Read OpenFoam vector field and reshape if necessary and possible (not uniform field).
 Args:
path: str
time_name: str (‘latestTime’ is supported)
name: str
structured: False or True
boundary: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15). If decimals is negative, it specifies the number of positions to the left of the decimal point.
 Returns:
 array: array of vector field; size of the array is the size of the interior domain (or of the size of the boundary in case of not None boundary)
A way you might use me is:
U = fluidfoam.readvector(‘path_of_OpenFoam_case’, ‘0’, ‘U’)

fluidfoam.readof.
readsymmtensor
(path, time_name=None, name=None, structured=False, boundary=None, order='F', precision=15)[source]¶ Read OpenFoam symmetrical tensor field and reshape if necessary and possible (not uniform field).
 Args:
path: str
time_name: str (‘latestTime’ is supported)
name: str
structured: False or True
boundary: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15). If decimals is negative, it specifies the number of positions to the left of the decimal point.
 Returns:
 array: array of symmetrical tensor field; size of the array is the size of the interior domain (or of the size of the boundary in case of not None boundary)
A way you might use me is:
sigma = fluidfoam.readsymmtensor(‘path_of_OpenFoam_case’, ‘0’, ‘sigma’)

fluidfoam.readof.
readtensor
(path, time_name=None, name=None, structured=False, boundary=None, order='F', precision=15)[source]¶ Read OpenFoam tensor field and reshape if necessary and possible (not uniform field).
 Args:
path: str
time_name: str (‘latestTime’ is supported)
name: str
structured: False or True
boundary: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15). If decimals is negative, it specifies the number of positions to the left of the decimal point.
 Returns:
 array: array of tensor field; size of the array is the size of the interior domain (or of the size of the boundary in case of not None boundary)
A way you might use me is:
tens = fluidfoam.readtensor(‘path_of_OpenFoam_case’, ‘0’, ‘tens’)

fluidfoam.readof.
typefield
(path, time_name=None, name=None)[source]¶ Read OpenFoam field and returns type of field.
 Args:
path: str
time_name: str (‘latestTime’ is supported)
name: str
 Returns:
 str: type of field
A way you might use me is:
print(“type of alpha field is”, fluidfoam.typefield(‘path_of_OpenFoam_case’, ‘0’, ‘alpha’))
Functions
readfield (path[, time_name, name, …]) 
Read OpenFoam field and reshape if necessary (structured mesh) and possible (not uniform field). 
readmesh (rep[, structured, boundary, order, …]) 
Read OpenFoam mesh and reshape if necessary (in cartesian structured mesh). 
readscalar (path[, time_name, name, …]) 
Read OpenFoam scalar field and reshape if necessary and possible (not uniform field). 
readsymmtensor (path[, time_name, name, …]) 
Read OpenFoam symmetrical tensor field and reshape if necessary and possible (not uniform field). 
readtensor (path[, time_name, name, …]) 
Read OpenFoam tensor field and reshape if necessary and possible (not uniform field). 
readvector (path[, time_name, name, …]) 
Read OpenFoam vector field and reshape if necessary and possible (not uniform field). 
typefield (path[, time_name, name]) 
Read OpenFoam field and returns type of field. 
Classes
OpenFoamFile (path[, time_name, name, …]) 
OpenFoam file parser. 