fluidfoam API Reference
Full documentation for fluidfoam (0.2.9)
fluidfoam.MeshVisu
Python Library Documentation: class MeshVisu in module fluidfoam.meshvisu
class MeshVisu(builtins.object)
| MeshVisu(path, box=None, plane='xy', time_name=None, verbose=True)
|
| Read OpenFoam mesh of 2D planar simulation and
| list all the edges contained in a box.
|
| Args:
| path: str
|
| box: tuple of box's dimension: ((xmin, ymin, zmin), (xmax, ymax, zmax))
|
| (if None, includes the whole mesh)
|
| plane: str plane in which the mesh is contained, either:
|
| 'xy': the xy-plane of outgoing normal z (default value)
|
| 'xz': the xz-plane of outgoing normal -y
|
| 'yz': the yz-plane of outgoing normal x
|
| time_name: str ('latestTime' is supported)
|
| verbose : True or False (default: True)
|
|
| A way you might use me is:
| MyMesh = fluidfoam.MeshVisu(path = 'path_of_OpenFoam_case')
|
|
| Then a minimal example to generate and save vectorial mesh figure could be:
| import matplotlib.pyplot as plt
|
| from matplotlib.collections import LineCollection
|
| fig, ax = plt.subplots()
|
| ln_coll = LineCollection(MyMesh.get_all_edgesInBox())
|
| ax.add_collection(ln_coll, autolim=True)
|
| plt.savefig('./myMesh.svg', dpi=fig.dpi, transparent = True, bbox_inches = 'tight')
|
| Methods defined here:
|
| __init__(self, path, box=None, plane='xy', time_name=None, verbose=True)
| by_default we expect the 2D mesh to be in xy-plane:
|
| get_all_edgesInBox(self)
| return the list of all edges in box.
|
| Eatch edge is describe by a tuple of tuples of float: ((x0, y0), (x1, y1)).
|
| (x0, y0) being the coordonates of the fisrt point, (x1, y1), the
| coordinates of the second point.
|
| This list can be given as an argument to the matplotlib LineCollection
| function, which allows to display a large number of segments on an image.
|
| Returns:
| list of tuples
|
| get_box(self)
| return the mesh visualization box
|
| Returns:
| tuple: ((xmin, ymin, zmin), (xmax, ymax, zmax))
|
| get_xlim(self)
| returns the x limits of the mesh visualization box.
|
| Returns:
| tuple of floats: (xmin, xmax)
|
| get_ylim(self)
| returns the y limits of the mesh visualization box.
|
| Returns:
| tuple of floats: (ymin, ymax)
|
| get_zlim(self)
| returns the z limits of the mesh visualization box.
|
| Returns:
| tuple of floats: (zmin, zmax)
|
| set_box_to_mesh_size(self, verbose=False)
| Set the mesh visualization box to mesh size.
|
| update_box(self, box, verbose=True)
| updates the mesh visualization box
|
| Args:
| box: tuple ((xmin, ymin, zmin), (xmax, ymax, zmax))
|
| A way you might use me is:
|
| MyMesh.update(box = ((0, 0, -1), (0.05, 0.05, 1)))
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
fluidfoam.OpenFoamFile
Python Library Documentation: class OpenFoamFile in module fluidfoam.readof class OpenFoamFile(builtins.object) | OpenFoamFile(path, time_name=None, name=None, structured=False, boundary=None, sets=None, order='F', precision=15, datatype=None, verbose=True) | | OpenFoam file parser. | | Methods defined here: | | __init__(self, path, time_name=None, name=None, structured=False, boundary=None, sets=None, order='F', precision=15, datatype=None, verbose=True) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
fluidfoam.OpenFoamSimu
Python Library Documentation: class OpenFoamSimu in module fluidfoam.openfoamsimu class OpenFoamSimu(builtins.object) | OpenFoamSimu(path=None, simu=None, timeStep=None, structured=False, dataToLoad=None, precision=10, order='F') | | Class to load all data saved at timeStep of an openFoam simulation | | Args: | path: str, reference path where simulations are stored. | | You may want to provide path if all your simulations are located | inside path and subfolders of path. You can do it by modifying | in the __init__ path='/path/to/the/simulations/' | | simu: str, name of the simu that has to be loaded. | | If simu=None, it will lists all existing simulation names in path | and ask you to choose. | | timeStep: str, timeStep to load. If None, load the last time step | | structured: bool, true if the mesh is structured | | dataToLoad: list of str, list containing the name of the varaibles | to read and load. If None, read and load all saved variables. | | Methods defined here: | | __init__(self, path=None, simu=None, timeStep=None, structured=False, dataToLoad=None, precision=10, order='F') | Initialize self. See help(type(self)) for accurate signature. | | keys(self) | Print the name of all variables loaded from simulation results | | readmesh(self, structured=False, precision=10, order='F') | | readopenfoam(self, timeStep=None, structured=False, dataToLoad=None, precision=10, order='F') | Reading SedFoam results | Load the last time step saved of the simulation | | Args: | timeStep : str or int, timeStep to load. If None, load the last time step | | structured : bool, true if the mesh is structured | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
fluidfoam.create1dprofil
Python Library Documentation: function create1dprofil in module fluidfoam.processing1d
create1dprofil(pathr, pathw, timename, axis, varlist)
This function provides way to read 1D profiles at time timename of pathr
and write them in OpenFoam Format in the 1d_profil folder of pathw
(for BC imposition in 2D or 3D case for example).
Args:
pathr: str
pathw: str
timename: str
axis: str
varlist: list of str
Returns:
status: 'create 1D profiles: done' if ok
A way you might use me is:
status = fluidfoam.create1dprofil("path_of_case", "pathw", time, 'Y',
['Ua', 'Ub'])
Please note that the 1d_profil directory must be existing in the pathw
directory
fluidfoam.create1dprofilDFSEM
Python Library Documentation: function create1dprofilDFSEM in module fluidfoam.processing1d
create1dprofilDFSEM(pathr, pathw, boundaryname, timename, axis, Uname, kname, omeganame, Rname, axisW)
This function provides way to read 1D profiles at time timename of pathr
and write them in OpenFoam Format in the 1d_profil folder of pathw
(for BC imposition in 2D or 3D case for example).
Args:
pathr: str
pathw: str
boundaryname: str
timename: str
axis: str
Uname : str
kname : str
omeganame : str
Rname : str
axisW : str
Returns:
status: 'create 1D profiles for DFSEM: done' if ok
A way you might use me is:
status = fluidfoam.create1dprofil("path_of_case", "pathw", time, 'Y',
Uname,kname,omeganame,Rname)
Please note that the boundaryname directory must be existing in the pathw
directory
fluidfoam.create1dprofil_spe
Python Library Documentation: function create1dprofil_spe in module fluidfoam.processing1d
create1dprofil_spe(pathw, waxis, var, varname, typevar)
This function provides way to write specific 1D profil (var array)
in OpenFoam Format in the 1d_profil folder of pathw
(for BC imposition in 2D or 3D case for example).
Args:
pathw: str
waxis: numpy array
var: numpy array
varname: str
typevar: str
Returns:
status: 'create specific 1D profil: done' if ok
A way you might use me is:
status = fluidfoam.create1dprofil_spe("pathw", z, epsilon,
"epsilon", "scalar")
Please note that the 1d_profil directory must be existing in the pathw
directory
fluidfoam.getVolumes
Python Library Documentation: function getVolumes in module fluidfoam.readof
getVolumes(path, time_name=None, structured=False, sets=None, region=None, order='F', precision=15, verbose=True, box=None)
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
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.getdzs
Python Library Documentation: function getdzs in module fluidfoam.meshdesign
getdzs(h, gz, N)
Given a domain size h, a grading factor gz and a number of points N
this function returns the grid size of the first and the last
points.
Usage: dz1,dzN=getdzs(h,gz,N)
fluidfoam.getgz
Python Library Documentation: function getgz in module fluidfoam.meshdesign
getgz(h, dz1, N)
Given a domain size h, a first grid size dz1 and a number of points N
this function returns the common ratio, the grading gz to enter
in blockMesk and the z and dz vectors.
Usage: z,dz,gz=getgz(h,dz1,N)
fluidfoam.meshdesign
Python Library Documentation: module fluidfoam.meshdesign in fluidfoam
NAME
fluidfoam.meshdesign
DESCRIPTION
Compute mesh grading and cell sizes
===========================================
This module provides functions to design OpenFoam mesh using blockMesh:
.. autofunction:: getgz
.. autofunction:: getdzs
FUNCTIONS
getdzs(h, gz, N)
Given a domain size h, a grading factor gz and a number of points N
this function returns the grid size of the first and the last
points.
Usage: dz1,dzN=getdzs(h,gz,N)
getgz(h, dz1, N)
Given a domain size h, a first grid size dz1 and a number of points N
this function returns the common ratio, the grading gz to enter
in blockMesk and the z and dz vectors.
Usage: z,dz,gz=getgz(h,dz1,N)
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\fluidfoam\meshdesign.py
fluidfoam.meshvisu
Python Library Documentation: module fluidfoam.meshvisu in fluidfoam
NAME
fluidfoam.meshvisu
DESCRIPTION
Visualisation of 2D OpenFoam Mesh with Python
================================================
This module provides functions to read 2D OpenFoam Mesh:
.. autoclass:: MeshVisu
.. automethod:: MeshVisu.get_xlim
.. automethod:: MeshVisu.get_ylim
.. automethod:: MeshVisu.get_zlim
.. automethod:: MeshVisu.get_all_edgesInBox
.. automethod:: MeshVisu.update_box
.. automethod:: MeshVisu.get_box
.. automethod:: MeshVisu.set_box_to_mesh_size
CLASSES
builtins.object
MeshVisu
class MeshVisu(builtins.object)
| MeshVisu(path, box=None, plane='xy', time_name=None, verbose=True)
|
| Read OpenFoam mesh of 2D planar simulation and
| list all the edges contained in a box.
|
| Args:
| path: str
|
| box: tuple of box's dimension: ((xmin, ymin, zmin), (xmax, ymax, zmax))
|
| (if None, includes the whole mesh)
|
| plane: str plane in which the mesh is contained, either:
|
| 'xy': the xy-plane of outgoing normal z (default value)
|
| 'xz': the xz-plane of outgoing normal -y
|
| 'yz': the yz-plane of outgoing normal x
|
| time_name: str ('latestTime' is supported)
|
| verbose : True or False (default: True)
|
|
| A way you might use me is:
| MyMesh = fluidfoam.MeshVisu(path = 'path_of_OpenFoam_case')
|
|
| Then a minimal example to generate and save vectorial mesh figure could be:
| import matplotlib.pyplot as plt
|
| from matplotlib.collections import LineCollection
|
| fig, ax = plt.subplots()
|
| ln_coll = LineCollection(MyMesh.get_all_edgesInBox())
|
| ax.add_collection(ln_coll, autolim=True)
|
| plt.savefig('./myMesh.svg', dpi=fig.dpi, transparent = True, bbox_inches = 'tight')
|
| Methods defined here:
|
| __init__(self, path, box=None, plane='xy', time_name=None, verbose=True)
| by_default we expect the 2D mesh to be in xy-plane:
|
| get_all_edgesInBox(self)
| return the list of all edges in box.
|
| Eatch edge is describe by a tuple of tuples of float: ((x0, y0), (x1, y1)).
|
| (x0, y0) being the coordonates of the fisrt point, (x1, y1), the
| coordinates of the second point.
|
| This list can be given as an argument to the matplotlib LineCollection
| function, which allows to display a large number of segments on an image.
|
| Returns:
| list of tuples
|
| get_box(self)
| return the mesh visualization box
|
| Returns:
| tuple: ((xmin, ymin, zmin), (xmax, ymax, zmax))
|
| get_xlim(self)
| returns the x limits of the mesh visualization box.
|
| Returns:
| tuple of floats: (xmin, xmax)
|
| get_ylim(self)
| returns the y limits of the mesh visualization box.
|
| Returns:
| tuple of floats: (ymin, ymax)
|
| get_zlim(self)
| returns the z limits of the mesh visualization box.
|
| Returns:
| tuple of floats: (zmin, zmax)
|
| set_box_to_mesh_size(self, verbose=False)
| Set the mesh visualization box to mesh size.
|
| update_box(self, box, verbose=True)
| updates the mesh visualization box
|
| Args:
| box: tuple ((xmin, ymin, zmin), (xmax, ymax, zmax))
|
| A way you might use me is:
|
| MyMesh.update(box = ((0, 0, -1), (0.05, 0.05, 1)))
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\fluidfoam\meshvisu.py
fluidfoam.openfoamsimu
Python Library Documentation: module fluidfoam.openfoamsimu in fluidfoam
NAME
fluidfoam.openfoamsimu
DESCRIPTION
Class to load all data saved at timeStep of an openFoam simulation
=====================================================================
.. autoclass:: OpenFoamSimu
.. automethod:: OpenFoamSimu.keys
.. automethod:: OpenFoamSimu.readopenfoam
CLASSES
builtins.Exception(builtins.BaseException)
Error
DirectorySimuError
builtins.object
OpenFoamSimu
class DirectorySimuError(Error)
| DirectorySimuError(simu)
|
| Method resolution order:
| DirectorySimuError
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, simu)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class Error(builtins.Exception)
| Method resolution order:
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class OpenFoamSimu(builtins.object)
| OpenFoamSimu(path=None, simu=None, timeStep=None, structured=False, dataToLoad=None, precision=10, order='F')
|
| Class to load all data saved at timeStep of an openFoam simulation
|
| Args:
| path: str, reference path where simulations are stored.
|
| You may want to provide path if all your simulations are located
| inside path and subfolders of path. You can do it by modifying
| in the __init__ path='/path/to/the/simulations/'
|
| simu: str, name of the simu that has to be loaded.
|
| If simu=None, it will lists all existing simulation names in path
| and ask you to choose.
|
| timeStep: str, timeStep to load. If None, load the last time step
|
| structured: bool, true if the mesh is structured
|
| dataToLoad: list of str, list containing the name of the varaibles
| to read and load. If None, read and load all saved variables.
|
| Methods defined here:
|
| __init__(self, path=None, simu=None, timeStep=None, structured=False, dataToLoad=None, precision=10, order='F')
| Initialize self. See help(type(self)) for accurate signature.
|
| keys(self)
| Print the name of all variables loaded from simulation results
|
| readmesh(self, structured=False, precision=10, order='F')
|
| readopenfoam(self, timeStep=None, structured=False, dataToLoad=None, precision=10, order='F')
| Reading SedFoam results
| Load the last time step saved of the simulation
|
| Args:
| timeStep : str or int, timeStep to load. If None, load the last time step
|
| structured : bool, true if the mesh is structured
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\fluidfoam\openfoamsimu.py
fluidfoam.plot1dprofil
Python Library Documentation: function plot1dprofil in module fluidfoam.processing1d
plot1dprofil(pathr, varlist)
This function provides way to plot 1D profiles created by the
create1dprofil function.
Args:
pathr: str (must be the full path of the 1d_profil directory)
varlist: list of str
A way you might use me is:
fluidfoam.plot1dprofil("path_of_case/1d_profil", ['Ua', 'Ub', 'alpha'])
fluidfoam.processing1d
Python Library Documentation: module fluidfoam.processing1d in fluidfoam
NAME
fluidfoam.processing1d
DESCRIPTION
Write, Read and Plot 1D input files for swak4foam
==========================================================================
This module allows to read OpenFoam output of one dimensional computation
and then write, plot and read input files for Boundary and Initial
Conditions imposition in 3D computation (via swak4foam):
.. autofunction:: create1dprofil
.. autofunction:: read1dprofil
.. autofunction:: plot1dprofil
FUNCTIONS
create1dprofil(pathr, pathw, timename, axis, varlist)
This function provides way to read 1D profiles at time timename of pathr
and write them in OpenFoam Format in the 1d_profil folder of pathw
(for BC imposition in 2D or 3D case for example).
Args:
pathr: str
pathw: str
timename: str
axis: str
varlist: list of str
Returns:
status: 'create 1D profiles: done' if ok
A way you might use me is:
status = fluidfoam.create1dprofil("path_of_case", "pathw", time, 'Y',
['Ua', 'Ub'])
Please note that the 1d_profil directory must be existing in the pathw
directory
create1dprofilDFSEM(pathr, pathw, boundaryname, timename, axis, Uname, kname, omeganame, Rname, axisW)
This function provides way to read 1D profiles at time timename of pathr
and write them in OpenFoam Format in the 1d_profil folder of pathw
(for BC imposition in 2D or 3D case for example).
Args:
pathr: str
pathw: str
boundaryname: str
timename: str
axis: str
Uname : str
kname : str
omeganame : str
Rname : str
axisW : str
Returns:
status: 'create 1D profiles for DFSEM: done' if ok
A way you might use me is:
status = fluidfoam.create1dprofil("path_of_case", "pathw", time, 'Y',
Uname,kname,omeganame,Rname)
Please note that the boundaryname directory must be existing in the pathw
directory
create1dprofil_spe(pathw, waxis, var, varname, typevar)
This function provides way to write specific 1D profil (var array)
in OpenFoam Format in the 1d_profil folder of pathw
(for BC imposition in 2D or 3D case for example).
Args:
pathw: str
waxis: numpy array
var: numpy array
varname: str
typevar: str
Returns:
status: 'create specific 1D profil: done' if ok
A way you might use me is:
status = fluidfoam.create1dprofil_spe("pathw", z, epsilon,
"epsilon", "scalar")
Please note that the 1d_profil directory must be existing in the pathw
directory
plot1dprofil(pathr, varlist)
This function provides way to plot 1D profiles created by the
create1dprofil function.
Args:
pathr: str (must be the full path of the 1d_profil directory)
varlist: list of str
A way you might use me is:
fluidfoam.plot1dprofil("path_of_case/1d_profil", ['Ua', 'Ub', 'alpha'])
read1dprofil(file_name)
This function provides way to read and return 1D profil created by the
create1dprofil function. file_name can be a complete path.
Args:
filename: str
Returns:
z: 1d mesh corresponding to 1d profil
field: scalar value of the field specified via filename
size1d: size of the 1d profil
A way you might use me is:
z, a, size1d = fluidfoam.read1dprofil("path_of_case/1d_profil/a.xy")
read1dprofilDFSEM(file_name, boundary_name, time_name, axis)
This function provides way to read and return 1D profil created by the
create1dprofilDFSEM function. file_name can be a complete path.
Args:
file_name: str
boundary_name: str
time_name: str
axis: str
Returns:
coord: 1d mesh corresponding to 1d profil
U: Velocity field profile (x-component)
L: Turbulent length scale
R: Reynolds shear stress
size1d: size of the 1d profil
A way you might use me is:
pos, U, k, omega, R, size1d = fluidfoam.read1dprofilDFSEM("path_of_case","boundaryName")
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\fluidfoam\processing1d.py
fluidfoam.read1dprofil
Python Library Documentation: function read1dprofil in module fluidfoam.processing1d
read1dprofil(file_name)
This function provides way to read and return 1D profil created by the
create1dprofil function. file_name can be a complete path.
Args:
filename: str
Returns:
z: 1d mesh corresponding to 1d profil
field: scalar value of the field specified via filename
size1d: size of the 1d profil
A way you might use me is:
z, a, size1d = fluidfoam.read1dprofil("path_of_case/1d_profil/a.xy")
fluidfoam.read1dprofilDFSEM
Python Library Documentation: function read1dprofilDFSEM in module fluidfoam.processing1d
read1dprofilDFSEM(file_name, boundary_name, time_name, axis)
This function provides way to read and return 1D profil created by the
create1dprofilDFSEM function. file_name can be a complete path.
Args:
file_name: str
boundary_name: str
time_name: str
axis: str
Returns:
coord: 1d mesh corresponding to 1d profil
U: Velocity field profile (x-component)
L: Turbulent length scale
R: Reynolds shear stress
size1d: size of the 1d profil
A way you might use me is:
pos, U, k, omega, R, size1d = fluidfoam.read1dprofilDFSEM("path_of_case","boundaryName")
fluidfoam.readarray
Python Library Documentation: function readarray in module fluidfoam readarray(*args, **kargs)
fluidfoam.readfield
Python Library Documentation: function readfield in module 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)
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.readforce
Python Library Documentation: function readforce in module fluidfoam.readpostpro
readforce(path, namepatch='forces', time_name='0', name='forces')
read the data contained in the force file .
create the forces variables in the Forcesfile object
Args:
path: str
namepatch: str
time_name: str ('latestTime' and 'mergeTime' are supported)
name: str
Returns:
array: array of force field; size of the array is the size of the
time
A way you might use me is:
force = readforce(path='path_of_OpenFoam_case', namepatch='forces',
time_name='0', name='forces')
fluidfoam.readmesh
Python Library Documentation: function readmesh in module fluidfoam.readof
readmesh(path, time_name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True)
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
Python Library Documentation: module fluidfoam.readof in fluidfoam
NAME
fluidfoam.readof
DESCRIPTION
Reading OpenFoam Files with Python
=====================================
This module provides functions to read OpenFoam Files:
.. autofunction:: readmesh
.. autofunction:: readfield
.. autofunction:: readscalar
.. autofunction:: readvector
.. autofunction:: readsymmtensor
.. autofunction:: readtensor
.. autofunction:: getVolumes
.. autofunction:: typefield
CLASSES
builtins.object
OpenFoamFile
class OpenFoamFile(builtins.object)
| OpenFoamFile(path, time_name=None, name=None, structured=False, boundary=None, sets=None, order='F', precision=15, datatype=None, verbose=True)
|
| OpenFoam file parser.
|
| Methods defined here:
|
| __init__(self, path, time_name=None, name=None, structured=False, boundary=None, sets=None, order='F', precision=15, datatype=None, verbose=True)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
FUNCTIONS
getVolumes(path, time_name=None, structured=False, sets=None, region=None, order='F', precision=15, verbose=True, box=None)
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
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.
readfield(path, time_name=None, name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, datatype=None, verbose=True)
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')
readmesh(path, time_name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True)
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
readscalar(path, time_name=None, name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, mode=None, verbose=True)
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')
readsymmtensor(path, time_name=None, name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True)
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')
readtensor(path, time_name=None, name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True)
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')
readvector(path, time_name=None, name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True)
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')
typefield(path, time_name=None, name=None, verbose=True)
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'))
DATA
B = '\x1b[34m'
G = '\x1b[32m'
O = '\x1b[33m'
P = '\x1b[35m'
R = '\x1b[31m'
W = '\x1b[0m'
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\fluidfoam\readof.py
fluidfoam.readpostpro
Python Library Documentation: module fluidfoam.readpostpro in fluidfoam
NAME
fluidfoam.readpostpro
DESCRIPTION
Read OpenFoam PostProcessing Files for Python
=======================================================================
This module provides functions to list and read OpenFoam PostProcessing Files:
.. autofunction:: readforce
.. autofunction:: readprobes
FUNCTIONS
readforce(path, namepatch='forces', time_name='0', name='forces')
read the data contained in the force file .
create the forces variables in the Forcesfile object
Args:
path: str
namepatch: str
time_name: str ('latestTime' and 'mergeTime' are supported)
name: str
Returns:
array: array of force field; size of the array is the size of the
time
A way you might use me is:
force = readforce(path='path_of_OpenFoam_case', namepatch='forces',
time_name='0', name='forces')
readprobes(path, probes_name='probes', time_name='0', name='U')
read the data contained in the force file .
create the forces variables in the Forcesfile object
Args:
path: str
probes_name: str
time_name: str ('latestTime' and 'mergeTime' are supported)
name: str
Returns:
array: array of time values and array of probes data;
A way you might use me is:
probe_data = read('path_of_OpenFoam_case', '0', 'probes', 'U')
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\fluidfoam\readpostpro.py
fluidfoam.readprobes
Python Library Documentation: function readprobes in module fluidfoam.readpostpro
readprobes(path, probes_name='probes', time_name='0', name='U')
read the data contained in the force file .
create the forces variables in the Forcesfile object
Args:
path: str
probes_name: str
time_name: str ('latestTime' and 'mergeTime' are supported)
name: str
Returns:
array: array of time values and array of probes data;
A way you might use me is:
probe_data = read('path_of_OpenFoam_case', '0', 'probes', 'U')
fluidfoam.readscalar
Python Library Documentation: function readscalar in module 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)
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.readsymmtensor
Python Library Documentation: function readsymmtensor in module fluidfoam.readof
readsymmtensor(path, time_name=None, name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True)
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.readtensor
Python Library Documentation: function readtensor in module fluidfoam.readof
readtensor(path, time_name=None, name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True)
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.readvector
Python Library Documentation: function readvector in module fluidfoam.readof
readvector(path, time_name=None, name=None, structured=False, boundary=None, sets=None, region=None, order='F', precision=15, verbose=True)
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.typefield
Python Library Documentation: function typefield in module fluidfoam.readof
typefield(path, time_name=None, name=None, verbose=True)
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'))
fluidfoam.warnings
Python Library Documentation: module warnings
NAME
warnings - Python part of the warnings subsystem.
MODULE REFERENCE
https://docs.python.org/3.12/library/warnings.html
The following documentation is automatically generated from the Python
source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.
CLASSES
builtins.object
catch_warnings
class catch_warnings(builtins.object)
| catch_warnings(*, record=False, module=None, action=None, category=<class 'Warning'>, lineno=0, append=False)
|
| A context manager that copies and restores the warnings filter upon
| exiting the context.
|
| The 'record' argument specifies whether warnings should be captured by a
| custom implementation of warnings.showwarning() and be appended to a list
| returned by the context manager. Otherwise None is returned by the context
| manager. The objects appended to the list are arguments whose attributes
| mirror the arguments to showwarning().
|
| The 'module' argument is to specify an alternative module to the module
| named 'warnings' and imported under that name. This argument is only useful
| when testing the warnings module itself.
|
| If the 'action' argument is not None, the remaining arguments are passed
| to warnings.simplefilter() as if it were called immediately on entering the
| context.
|
| Methods defined here:
|
| __enter__(self)
|
| __exit__(self, *exc_info)
|
| __init__(self, *, record=False, module=None, action=None, category=<class 'Warning'>, lineno=0, append=False)
| Specify whether to record warnings and if an alternative module
| should be used other than sys.modules['warnings'].
|
| For compatibility with Python 3.0, please consider all arguments to be
| keyword-only.
|
| __repr__(self)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
FUNCTIONS
filterwarnings(action, message='', category=<class 'Warning'>, module='', lineno=0, append=False)
Insert an entry into the list of warnings filters (at the front).
'action' -- one of "error", "ignore", "always", "default", "module",
or "once"
'message' -- a regex that the warning message must match
'category' -- a class that the warning must be a subclass of
'module' -- a regex that the module name must match
'lineno' -- an integer line number, 0 matches all warnings
'append' -- if true, append to the list of filters
formatwarning(message, category, filename, lineno, line=None)
Function to format a warning the standard way.
resetwarnings()
Clear the list of warning filters, so that no filters are active.
showwarning(message, category, filename, lineno, file=None, line=None)
Hook to write a warning to a file; replace if you like.
simplefilter(action, category=<class 'Warning'>, lineno=0, append=False)
Insert a simple entry into the list of warnings filters (at the front).
A simple filter matches all modules and messages.
'action' -- one of "error", "ignore", "always", "default", "module",
or "once"
'category' -- a class that the warning must be a subclass of
'lineno' -- an integer line number, 0 matches all warnings
'append' -- if true, append to the list of filters
warn(...)
Issue a warning, or maybe ignore it or raise an exception.
message
Text of the warning message.
category
The Warning category subclass. Defaults to UserWarning.
stacklevel
How far up the call stack to make this warning appear. A value of 2 for
example attributes the warning to the caller of the code calling warn().
source
If supplied, the destroyed object which emitted a ResourceWarning
skip_file_prefixes
An optional tuple of module filename prefixes indicating frames to skip
during stacklevel computations for stack frame attribution.
warn_explicit(...)
Issue a warning, or maybe ignore it or raise an exception.
DATA
__all__ = ['warn', 'warn_explicit', 'showwarning', 'formatwarning', 'f...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\warnings.py