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 and config_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:

CaseFile([case_filepath, project_filepath])

Class to read a Fluent case file.

InputParameter(raw_data)

Class to represent an input parameter.

OutputParameter(raw_data)

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])

config_vars()

has_config_var(name)

has_rp_var(name)

input_parameters()

rtype:

List[InputParameter]

iter_count()

rtype:

int

num_dimensions()

rtype:

int

output_parameters()

rtype:

List[OutputParameter]

precision()

rtype:

int

rp_vars()

rtype:

dict

Attributes:

config_var

rp_var

__init__(case_filepath=None, project_filepath=None)#
property config_var#
config_vars()#
has_config_var(name)#
has_rp_var(name)#
input_parameters()#
Return type:

List[InputParameter]

iter_count()#
Return type:

int

num_dimensions()#
Return type:

int

output_parameters()#
Return type:

List[OutputParameter]

precision()#
Return type:

int

property rp_var#
rp_vars()#
Return type:

dict

class ansys.fluent.core.filereader.case_file.InputParameter(raw_data)#

Bases: object

Class to represent an input parameter.

Attributes:
namestr
value

The value of this input parameter, usually a string, qualified by units

Methods:

__init__(raw_data)

Attributes:

numeric_value

Get the numeric value of a Fluent input parameter. Returns ------- float Numeric value of the Fluent input parameter.

units

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.

property units: str#

Get the unit label of a Fluent input parameter. Returns ——- str

Unit label of the Fluent input parameter.

class ansys.fluent.core.filereader.case_file.OutputParameter(raw_data)#

Bases: object

Class to represent an output parameter.

Attributes:
namestr

Methods:

__init__(raw_data)

__init__(raw_data)#