DataFile#
The DataFile class provides a reader for Fluent data files.
Sample usage#
You can use the DataFile class by importing it and passing a data file path.
For some case file dependent features, the case file handle from
the CaseFile class needs to be passed as shown in the following code snippet.
This example shows how to have the DataFile class read a data file (.cas.h5)
from the examples
repository:
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.filereader.data_file import DataFile
>>> from ansys.fluent.core.filereader.case_file import CaseFile
>>> data_filepath = examples.download_file("elbow1.dat.h5", "pyfluent/file_session")
>>> reader = DataFile(data_filepath=data_filepath, case_file_handle=CaseFile(case_filepath))
>>> reader.case_file
'elbow1.cas.h5'
>>> reader.variables()
{'flow-time': 0.0,
'solvertime': 43.13454608435059,
'time-step': 0,
.....
'vbm/trim': []}
>>> reader.get_phases()
['phase-1']
>>> reader.get_face_variables("phase-1")
['SV_ARTIFICIAL_WALL_FLAG',
'SV_D',
'SV_DENSITY',
.....
'SV_WALL_YPLUS_UTAU',
'']
>>> reader.get_cell_variables("phase-1")
['SV_BF_V',
'SV_D',
'SV_DENSITY',
.....
'SV_V',
'SV_W',
'']
>>> reader.get_face_scalar_field_data("phase-1", "SV_T", 4)
array([293.14999, 293.14999, 293.14999, ..., 293.14999, 293.14999,
293.14999])
>>> reader.get_face_vector_field_data("phase-1", 4)
array([ 3.32643010e-01, 6.64311343e-03, 0.00000000e+00, ...,
4.56052223e-01, 2.45034248e-01, -1.24726618e-15])
Reader for Fluent data files.
Example#
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.filereader.data_file import DataFile
>>> data_filepath = examples.download_file("elbow1.dat.h5", "pyfluent/file_session", return_only_filename=False)
>>> reader = DataFile(data_filepath=data_filepath) # Instantiate a DataFile class
Classes:
|
Class to read a Fluent case file. |
- class ansys.fluent.core.filereader.data_file.DataFile(data_filepath=None, project_filepath=None, case_file_handle=None)#
Bases:
object
Class to read a Fluent case file.
Methods
Returns the name of the associated case file in string format.
get_face_variables
(phase_name)Extracts face variables available for a particular phase.
Returns list of phases available.
get_cell_variables
(phase_name)Extracts cell variables available for a particular phase.
get_face_scalar_field_data
(phase_name, ...)Gets scalar field data for face.
get_face_vector_field_data
(phase_name, ...)Gets vector field data for face.
Methods:
__init__
([data_filepath, project_filepath, ...])__init__ method of CaseFile class.
get_cell_variables
(phase_name)Extracts cell variables available for a particular phase.
get_face_scalar_field_data
(phase_name, ...)Gets scalar field data for face.
get_face_variables
(phase_name)Extracts face variables available for a particular phase.
get_face_vector_field_data
(phase_name, ...)Gets vector field data for face.
Returns list of phases available.
Returns all associated data variables in form of a dictionary.
Attributes:
Returns the name of the associated case file in string format.
- __init__(data_filepath=None, project_filepath=None, case_file_handle=None)#
__init__ method of CaseFile class.
- get_cell_variables(phase_name)#
Extracts cell variables available for a particular phase.
- Parameters:
- phase_name
str
Name of the phase.
- phase_name
- Returns:
List
of
cell
variables.
- get_face_scalar_field_data(phase_name, field_name, surface_id)#
Gets scalar field data for face.
- get_face_variables(phase_name)#
Extracts face variables available for a particular phase.
- Parameters:
- phase_name
str
Name of the phase.
- phase_name
- Returns:
List
of
face
variables.
- get_face_vector_field_data(phase_name, surface_id)#
Gets vector field data for face.
- get_phases()#
Returns list of phases available.
- variables()#
Returns all associated data variables in form of a dictionary.