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. |
|
Provides access to variables defined in the case |
|
Represents an input parameter. |
|
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
Get the input parameters for this case.
Get the output parameters for this case.
Get the dimensionality associated with this case.
Get the precision associated with this case (single or double).
Get the number of iterations associated with this case.
rp_vars
()Get the rpvars associated with this case.
Access the rpvars associated with this case.
has_rp_var
(name)Find if this case has the given rpvar.
Get the config variables associated with this case.
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.
Get the config variables associated with this case.
has_config_var
(name)has_rp_var
(name)Find if this case has the given rpvar.
Get the input parameters for this case.
Get the number of iterations associated with this case.
Get the dimensionality associated with this case.
Get the output parameters for this case.
Get the precision associated with this case (single or double).
rp_vars
()Get the rpvars associated with this case.
Attributes:
Access the config variables associated with this case.
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.
- 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.
- 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.
- 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.
- class ansys.fluent.core.filereader.case_file.InputParameter(raw_data)#
Bases:
object
Represents an input parameter.
- Attributes:
- name
str
- value
The value of this input parameter, usually a string, qualified by units
- name
Methods:
__init__
(raw_data)Initialize InputParameter.
Attributes:
Get the numeric value of a Fluent input parameter.
Get the unit label of a Fluent input parameter.
- __init__(raw_data)#
Initialize InputParameter.