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.

CaseVariable(variables[, path])

Provides access to variables defined in the case

InputParameter(raw_data)

Represents an input parameter.

OutputParameter(raw_data)

Represents 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 the input parameters for this case.

output_parameters()

Get the output parameters for this case.

num_dimensions()

Get the dimensionality associated with this case.

precision()

Get the precision associated with this case (single or double).

iter_count()

Get the number of iterations associated with this case.

rp_vars()

Get the rpvars associated with this case.

rp_var

Access the rpvars associated with this case.

has_rp_var(name)

Find if this case has the given rpvar.

config_vars()

Get the config variables associated with this case.

config_var

Access the config variables associated with this case.

has_config_var

Whether case has particular config var

Methods:

__init__([case_filepath, project_filepath])

Initialize a CaseFile object.

config_vars()

Get the config variables associated with this case.

has_config_var(name)

has_rp_var(name)

Find if this case has the given rpvar.

input_parameters()

Get the input parameters for this case.

iter_count()

Get the number of iterations associated with this case.

num_dimensions()

Get the dimensionality associated with this case.

output_parameters()

Get the output parameters for this case.

precision()

Get the precision associated with this case (single or double).

rp_vars()

Get the rpvars associated with this case.

Attributes:

config_var

Access the config variables associated with this case.

rp_var

Access the rpvars associated with this case.

__init__(case_filepath=None, project_filepath=None)#

Initialize a CaseFile object. Exactly one file path argument must be specified.

Parameters:
case_filepathOptional[str]

The path of a case file.

project_filepathOptional[str]

The path of a project file from which the case file is selected.

property config_var: CaseVariable#

Access the config variables associated with this case.

Returns:
CaseVariable

The config variables associated with this case.

config_vars()#

Get the config variables associated with this case.

Returns:
dict

The config variables associated with this case.

has_config_var(name)#
has_rp_var(name)#

Find if this case has the given rpvar.

Parameters:
namestr

Name of the rpvar.

Returns:
bool

Whether this case has the given rpvar.

input_parameters()#

Get the input parameters for this case.

Returns:
List[InputParameter]

The list of input parameters.

iter_count()#

Get the number of iterations associated with this case.

Returns:
int

The number of iterations associated with this case.

num_dimensions()#

Get the dimensionality associated with this case.

Returns:
int

The number of dimensions.

output_parameters()#

Get the output parameters for this case.

Returns:
List[OutputParameter]

The list of output parameters.

precision()#

Get the precision associated with this case (single or double).

Returns:
int

Either 1 or 2 to indicate single or double precision respectively.

property rp_var: CaseVariable#

Access the rpvars associated with this case.

Returns:
CaseVariable

The rpvars associated with this case.

rp_vars()#

Get the rpvars associated with this case.

Returns:
dict

The rpvars associated with this case.

class ansys.fluent.core.filereader.case_file.CaseVariable(variables, path='')#

Bases: object

Provides access to variables defined in the case

Methods:

__init__(variables[, path])

Initialize CaseVariable.

__init__(variables, path='')#

Initialize CaseVariable.

Parameters:
variablesdict

The variables dictionary.

pathOptional[str]

The path to the variables.

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

Bases: object

Represents an input parameter.

Attributes:
namestr
value

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

Methods:

__init__(raw_data)

Initialize InputParameter.

Attributes:

numeric_value

Get the numeric value of a Fluent input parameter.

units

Get the unit label of a Fluent input parameter.

__init__(raw_data)#

Initialize InputParameter.

Parameters:
raw_dataDict[str, str]

Input parameter data as a nested dictionary.

property numeric_value: float#

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

Represents an output parameter.

Attributes:
namestr

Methods:

__init__(raw_data)

Initialize OutputParameter.

__init__(raw_data)#

Initialize OutputParameter.

Parameters:
raw_datalist

Output parameter as a nested list.