CaseFile#
The CaseFile class provides a reader for Fluent case files.
Sample usage#
You can use the CaseFile class by importing it and passing a case file path.
This example shows how to have the CaseFile class read a case file (.cas.h5)
from the examples
repository:
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.filereader.casereader import CaseReader
>>> case_filepath = examples.download_file("Static_Mixer_Parameters.cas.h5", "pyfluent/static_mixer")
>>> reader = CaseReader(case_filepath=case_filepath)
>>> reader.precision()
2
>>> reader.num_dimensions()
3
>>> {p.name: p.value for p in reader.input_parameters()}
{'inlet1_vel': '1 [m/s]', 'inlet1_temp': '300 [K]', 'inlet2_vel': '1 [m/s]', 'inlet2_temp': '350 [K]'}
>>> {p.name: p.units for p in reader.output_parameters()}
{'outlet-temp-avg-op': 'K', 'outlet-vel-avg-op': 'm s^-1'}
Additional features#
Along with basic functionality, the CaseFile class provides many additional features, including these:
Supports multiple file formats The CaseFile class can read Fluent case files (CAS, CAS.HF, and CAS.GZ) in both text and binary formats.
Takes a project path as an argument The CaseFile class has an option for taking a Fluent project path (FLPRJ) as an argument and locating the case file path:
>>> reader = CaseReader(project_filepath="Dir1/Dir2/project.flprj")
Reads ``rp_vars`` and ``config_vars`` variables The CaseFile class can provide the
rp_vars
andconfig_vars
variables:>>> reader.rp_vars() >>> reader.config_vars()
Reader for Fluent case files.
Example#
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.core.filereader.casereader import CaseReader
>>> case_filepath = examples.download_file("Static_Mixer_Parameters.cas.h5", "pyfluent/static_mixer")
>>> reader = CaseReader(case_filepath=case_filepath) # Instantiate a CaseFile class
>>> input_parameters = reader.input_parameters() # Get lists of input parameters
>>> output_parameters = reader.output_parameters() # Get lists of output parameters
Classes:
|
Class to read a Fluent case file. |
|
Class to represent an input parameter. |
|
Class to represent an output parameter. |
- class ansys.fluent.core.filereader.case_file.CaseFile(case_filepath=None, project_filepath=None)#
Bases:
object
Class to read a Fluent case file.
Methods
input_parameters
Get a list of input parameter objects
output_parameters
Get a list of output parameter objects
num_dimensions
Get the dimensionality of the case (2 or 3)
precision
Get the precision (1 or 2 for 1D of 2D)
iter_count
Get the number of iterations
rp_vars
Get dictionary of all RP vars
rp_var
Get specific RP var by name, either by providing the Scheme name: reader.rp_var(“rad/enable-netm?”) or a pythonic version: reader.rp_var.rad.enable_netm__q()
has_rp_var
Whether case has particular RP var
config_vars
Get dictionary of all RP vars
config_var
Get specific config var by name, either by providing the Scheme name: reader.config_var(“rp-3d?”) or a pythonic version: reader.config_var.rp_3d__q()
has_config_var
Whether case has particular config var
Methods:
__init__
([case_filepath, project_filepath])has_config_var
(name)has_rp_var
(name)- rtype:
- rtype:
- rtype:
- rtype:
- rtype:
rp_vars
()- rtype:
Attributes:
- __init__(case_filepath=None, project_filepath=None)#
- property config_var#
- config_vars()#
- has_config_var(name)#
- has_rp_var(name)#
- input_parameters()#
- Return type:
- output_parameters()#
- Return type:
- property rp_var#
- class ansys.fluent.core.filereader.case_file.InputParameter(raw_data)#
Bases:
object
Class to represent an input parameter.
- Attributes:
- name
str
- value
The value of this input parameter, usually a string, qualified by units
- name
Methods:
__init__
(raw_data)Attributes:
Get the numeric value of a Fluent input parameter. Returns ------- float Numeric value of the Fluent input parameter.
Get the unit label of a Fluent input parameter. Returns ------- str Unit label of the Fluent input parameter.
- __init__(raw_data)#
- property numeric_value#
Get the numeric value of a Fluent input parameter. Returns ——- float
Numeric value of the Fluent input parameter.