fluidfoam.readof
Reading OpenFoam Files with Python
This module provides functions to read OpenFoam Files:
- fluidfoam.readof.readmesh(path, time_name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True)[source]
Read OpenFoam mesh and reshape if necessary (in cartesian structured mesh).
- Args:
path: str
time_name: str (‘latestTime’ is supported)
structured: False or True
boundary: None or str
sets: None or str
region: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15)
verbose : True or False (default: True).
- 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_cell
If 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)
And if you play with dynamic mesh the time_name option is for you
- fluidfoam.readof.readfield(path, time_name=None, name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, datatype=None, verbose=True)[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
sets: None or str
region: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15)
datatype: None (default) or str (“scalar”, “vector”…) necessary in case of files without header
verbose : True or False (default: True).
- 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, sets=None, region=None, order='F', precision=15, mode=None, verbose=True)[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
sets: None or str
region: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15)
verbose : True or False (default: True).
- 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, sets=None, region=None, order='F', precision=15, verbose=True)[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
sets: None or str
region: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15)
verbose : True or False (default: True).
- 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, sets=None, region=None, order='F', precision=15, verbose=True)[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
sets: None or str
region: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15)
verbose : True or False (default: True).
- 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, sets=None, region=None, order='F', precision=15, verbose=True)[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
sets: None or str
region: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15)
verbose : True or False (default: True).
- 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.getVolumes(path, time_name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True, box=None)[source]
Reads OpenFoam mesh and returns the cell centroids and cell volumes of a given box.
- Args:
path: str
time_name: str (‘latestTime’ is supported)
structured: False or True
boundary: None or str
sets: None or str
region: None or str
order: “F” (default) or “C”
precision : Number of decimal places to round to (default: 15)
verbose : True or False (default: True) box : tuple of box’s dimension: ((xmin, ymin, zmin), (xmax, ymax, zmax))
(if None, includes the whole mesh)
- Returns:
array: two arrays that contain the cell centroids and cell volumes
A way you might use me is:
centroidList,vol = fluidfoam.getVolumes(‘path_of_OpenFoam_case’) So centroidList and vol are the cell centroid and cell volume arrays.
- fluidfoam.readof.typefield(path, time_name=None, name=None, verbose=True)[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
|
Reads OpenFoam mesh and returns the cell centroids and cell volumes of a given box. |
|
Read OpenFoam field and reshape if necessary (structured mesh) and possible (not uniform field). |
|
Read OpenFoam mesh and reshape if necessary (in cartesian structured mesh). |
|
Read OpenFoam scalar field and reshape if necessary and possible (not uniform field). |
|
Read OpenFoam symmetrical tensor field and reshape if necessary and possible (not uniform field). |
|
Read OpenFoam tensor field and reshape if necessary and possible (not uniform field). |
|
Read OpenFoam vector field and reshape if necessary and possible (not uniform field). |
|
Read OpenFoam field and returns type of field. |
Classes
|
OpenFoam file parser. |