file_session#

Provides a module for file session.

Classes:

Batch(file_session, field_info)

Populates field data on surfaces.

BatchFieldData(data, field_info, ...)

Provides access to Fluent field data on surfaces collected via batches.

Fields(_session)

Container for field and solution variables.

FileFieldData(file_session, field_info)

File field data.

FileFieldInfo(file_session)

File field info.

FileSession([case_file_name, data_file_name])

File session to read case and data file.

Exceptions:

InvalidFieldName()

Raised when a field name is inappropriate.

InvalidMultiPhaseFieldName()

Raised when multi-phase field name is inappropriate.

class ansys.fluent.core.file_session.Batch(file_session, field_info)#

Bases: FieldBatch

Populates field data on surfaces.

Methods:

__init__(file_session, field_info)

__init__ method of Batch class.

add_pathlines_fields_request(field_name, ...)

Add request to get pathlines field on surfaces.

add_requests(obj, *args)

Add request to get surface, scalar, vector or path-lines field on surfaces.

add_scalar_fields_request(field_name, surfaces)

Add request to get scalar field data on surfaces.

add_surfaces_request(data_types, surfaces)

Add request to get surface data (vertices, face connectivity, centroids, and normals).

add_vector_fields_request(field_name, surfaces)

Add request to get vector field data on surfaces.

get_fields()

Get data for previously added requests.

get_response()

Get data for previously added requests.

get_surface_ids(surfaces)

Get a list of surface ids based on surfaces provided as inputs.

__init__(file_session, field_info)#

__init__ method of Batch class.

add_pathlines_fields_request(field_name, surfaces)#

Add request to get pathlines field on surfaces.

Parameters:
field_namestr

Name of the scalar field to color pathlines.

surfacesList[int | str]

List of surface IDS or surface names for the surface data.

Returns:
None

Deprecated since version v0.25.0: Function ‘add_pathlines_fields_request’ is deprecated since version v0.25.0. Use ‘add_requests’ instead.

Deprecated since version v0.25.0: Argument ‘surface_ids’ is deprecated; use ‘surfaces’ instead.

Deprecated since version v0.25.0: Argument ‘surface_names’ is deprecated; use ‘surfaces’ instead.

add_requests(obj, *args)#

Add request to get surface, scalar, vector or path-lines field on surfaces.

add_scalar_fields_request(field_name, surfaces, node_value=True, boundary_value=True)#

Add request to get scalar field data on surfaces.

Parameters:
field_namestr

Name of the scalar field.

surfacesList[int | str]

List of surface IDS or surface names for the surface data.

node_valuebool, optional

Whether to provide the nodal location. The default is True. If False, the element location is provided.

boundary_valuebool, optional

Whether to provide the slip velocity at the wall boundaries. The default is True. When True, no slip velocity is provided.

Returns:
None
Raises:
InvalidMultiPhaseFieldName

If field name does not have prefix phase- for multi-phase cases.

Deprecated since version v0.25.0: Function ‘add_scalar_fields_request’ is deprecated since version v0.25.0. Use ‘add_requests’ instead.

Deprecated since version v0.25.0: Argument ‘surface_ids’ is deprecated; use ‘surfaces’ instead.

Deprecated since version v0.25.0: Argument ‘surface_names’ is deprecated; use ‘surfaces’ instead.

add_surfaces_request(data_types, surfaces)#

Add request to get surface data (vertices, face connectivity, centroids, and normals).

Parameters:
data_typesList[SurfaceDataType] | List[str],

SurfaceDataType Enum members.

surfacesList[int | str]

List of surface IDS or surface names for the surface data.

Returns:
None

Deprecated since version v0.25.0: Function ‘add_surfaces_request’ is deprecated since version v0.25.0. Use ‘add_requests’ instead.

Deprecated since version v0.25.0: Arguments ‘provide_vertices’, ‘provide_faces’ are deprecated; use ‘data_types’ instead.

Deprecated since version v0.25.0: Argument ‘surface_ids’ is deprecated; use ‘surfaces’ instead.

Deprecated since version v0.25.0: Argument ‘surface_names’ is deprecated; use ‘surfaces’ instead.

add_vector_fields_request(field_name, surfaces)#

Add request to get vector field data on surfaces.

Parameters:
field_namestr

Name of the vector field.

surfacesList[int | str]

List of surface IDS or surface names for the surface data.

Returns:
None
Raises:
InvalidMultiPhaseFieldName

If field name does not have prefix phase- for multi-phase cases.

Deprecated since version v0.25.0: Function ‘add_vector_fields_request’ is deprecated since version v0.25.0. Use ‘add_requests’ instead.

Deprecated since version v0.25.0: Argument ‘surface_ids’ is deprecated; use ‘surfaces’ instead.

Deprecated since version v0.25.0: Argument ‘surface_names’ is deprecated; use ‘surfaces’ instead.

get_fields()#

Get data for previously added requests.

get_response()#

Get data for previously added requests.

Returns:
Dict[int, Dict[int, Dict[str, np.array]]]

Data is returned as dictionary of dictionaries in the following structure: tag int | Tuple-> surface_id [int] -> field_name [str] -> field_data[np.array]

Raises:
InvalidFieldName

If any field other than "velocity" is provided.

get_surface_ids(surfaces)#

Get a list of surface ids based on surfaces provided as inputs.

class ansys.fluent.core.file_session.BatchFieldData(data, field_info, allowed_surface_names, allowed_scalar_field_names)#

Bases: object

Provides access to Fluent field data on surfaces collected via batches.

Methods:

__init__(data, field_info, ...)

__init__ method of BatchFieldData class.

get_field_data(obj)

Get the surface, scalar, vector or path-lines field data on a surface.

get_surface_ids(surfaces)

Get a list of surface ids based on surfaces provided as inputs.

__init__(data, field_info, allowed_surface_names, allowed_scalar_field_names)#

__init__ method of BatchFieldData class.

get_field_data(obj)#

Get the surface, scalar, vector or path-lines field data on a surface.

Returns:
Dict[int | str, Dict | np.array]

Field data for the requested surface. If field data is unavailable for the surface, an empty array is returned and a warning is issued. Users should always check the array size before using the data.

Example:

data = get_field_data(field_data_request)[surface_id] if data.size == 0:

# Handle missing data

get_surface_ids(surfaces)#

Get a list of surface ids based on surfaces provided as inputs.

class ansys.fluent.core.file_session.Fields(_session)#

Bases: object

Container for field and solution variables.

Methods:

__init__(_session)

Initialize Fields.

__init__(_session)#

Initialize Fields.

class ansys.fluent.core.file_session.FileFieldData(file_session, field_info)#

Bases: FieldDataSource

File field data.

Methods:

__init__(file_session, field_info)

Initialize FileFieldData.

get_field_data(obj)

Get the surface, scalar, vector, or path-lines field data on a surface.

get_pathlines_field_data(field_name, surfaces)

Get the pathlines field data on a surface.

get_scalar_field_data(field_name, surfaces)

Get scalar field data on a surface.

get_surface_data(data_types, surfaces[, ...])

Get surface data (vertices and faces connectivity).

get_surface_ids(surfaces)

Get a list of surface ids based on surfaces provided as inputs.

get_vector_field_data(field_name, surfaces)

Get vector field data on a surface.

new_batch()

Create a new field batch.

new_transaction()

Create a new field transaction.

Attributes:

surface_ids

Get the surface ids.

__init__(file_session, field_info)#

Initialize FileFieldData.

get_field_data(obj)#

Get the surface, scalar, vector, or path-lines field data on a surface.

Parameters:
objSurfaceFieldDataRequest | ScalarFieldDataRequest | VectorFieldDataRequest | PathlinesFieldDataRequest

Request object describing the data to retrieve.

Returns:
Dict[int | str, SurfaceData | np.ndarray]

Dictionary mapping each surface name or ID to the requested data:

  • SurfaceFieldDataRequest – values are SurfaceData objects. Access retrieved data via attributes:

    • .verticesndarray of shape (N, 3), or None.

    • .connectivity – flat ndarray (when flatten_connectivity=True) or list of per-face ndarray objects, or None.

  • ScalarFieldDataRequest – values are ndarray of scalar field values per face/node.

  • VectorFieldDataRequest – values are ndarray of shape (N, 3) containing vector components.

Raises:
NotImplementedError

If a SurfaceFieldDataRequest includes unsupported SurfaceDataType entries (only Vertices and FacesConnectivity are supported by FileSession).

get_pathlines_field_data(field_name, surfaces)#

Get the pathlines field data on a surface.

Parameters:
field_namestr

Name of the scalar field to color pathlines.

surfacesList[int | str]

List of surface IDS or surface names for the surface data.

Returns:
Dict

Dictionary containing a map of surface IDs to the pathline data. For example, pathlines connectivity, vertices, and field.

Deprecated since version v0.25.0: Function ‘get_pathlines_field_data’ is deprecated since version v0.25.0. Use ‘get_field_data’ instead.

Deprecated since version v0.25.0: Argument ‘surface_ids’ is deprecated; use ‘surfaces’ instead.

Deprecated since version v0.25.0: Argument ‘surface_names’ is deprecated; use ‘surfaces’ instead.

get_scalar_field_data(field_name, surfaces, node_value=True, boundary_value=True)#

Get scalar field data on a surface.

Parameters:
field_namestr

Name of the scalar field.

surfacesList[int | str]

List of surface IDS or surface names for the surface data.

node_valuebool, optional

Whether to provide data for the nodal location. The default is True. When False, data is provided for the element location.

boundary_valuebool, optional

Whether to provide slip velocity at the wall boundaries. The default is True. When True, no slip velocity is provided.

Returns:
ScalarFieldData | Dict[int, ScalarFieldData]

If a surface name is provided as input, scalar field data is returned. If surface IDs are provided as input, a dictionary containing a map of surface IDs to scalar field data.

Raises:
InvalidMultiPhaseFieldName

If field name does not have prefix phase- for multi-phase cases.

Deprecated since version v0.25.0: Function ‘get_scalar_field_data’ is deprecated since version v0.25.0. Use ‘get_field_data’ instead.

Deprecated since version v0.25.0: Argument ‘surface_ids’ is deprecated; use ‘surfaces’ instead.

Deprecated since version v0.25.0: Argument ‘surface_names’ is deprecated; use ‘surfaces’ instead.

get_surface_data(data_types, surfaces, overset_mesh=False, flatten_connectivity=False)#

Get surface data (vertices and faces connectivity).

Only SurfaceDataType.Vertices and SurfaceDataType.FacesConnectivity are supported. Requesting any other type raises NotImplementedError.

Parameters:
data_typesList[SurfaceDataType] | List[str]

Surface data types to retrieve. Accepted values are SurfaceDataType.Vertices (or "vertices") and SurfaceDataType.FacesConnectivity (or "faces").

surfacesList[int | str]

List of surface IDs or surface names for the surface data.

overset_meshbool, optional

Whether to provide the overset method. The default is False.

flatten_connectivitybool, optional

When True, face connectivity is returned as a single flat ndarray. When False (default), it is returned as a list of per-face vertex-index arrays.

Returns:
Dict[int | str, SurfaceData]

Dictionary mapping each surface name or ID to a SurfaceData object. Requested data is available via its attributes:

  • SurfaceData.verticesndarray of shape (N, 3) containing vertex coordinates, or None if not requested.

  • SurfaceData.connectivity – flat ndarray (when flatten_connectivity=True) or list of per-face ndarray objects, or None if not requested.

Raises:
NotImplementedError

If any entry in data_types is not Vertices or FacesConnectivity.

Deprecated since version v0.25.0: Function ‘get_surface_data’ is deprecated since version v0.25.0. Use ‘get_field_data’ instead.

Deprecated since version v0.25.0: Argument ‘surface_ids’ is deprecated; use ‘surfaces’ instead.

Deprecated since version v0.25.0: Argument ‘surface_names’ is deprecated; use ‘surfaces’ instead.

get_surface_ids(surfaces)#

Get a list of surface ids based on surfaces provided as inputs.

get_vector_field_data(field_name, surfaces)#

Get vector field data on a surface.

Parameters:
field_namestr

Name of the vector field.

surfacesList[int | str]

List of surface IDS or surface names for the surface data.

Returns:
VectorFieldData | Dict[int, VectorFieldData]

If a surface name is provided as input, vector field data is returned. If surface IDs are provided as input, a dictionary containing a map of surface IDs to vector field data is returned.

Raises:
InvalidFieldName

If any field other than "velocity" is provided.

InvalidMultiPhaseFieldName

If field name does not have prefix phase- for multi-phase cases.

Deprecated since version v0.25.0: Function ‘get_vector_field_data’ is deprecated since version v0.25.0. Use ‘get_field_data’ instead.

Deprecated since version v0.25.0: Argument ‘surface_ids’ is deprecated; use ‘surfaces’ instead.

Deprecated since version v0.25.0: Argument ‘surface_names’ is deprecated; use ‘surfaces’ instead.

new_batch()#

Create a new field batch.

new_transaction()#

Create a new field transaction.

Deprecated since version 0.34: Use new_batch instead.

property surface_ids#

Get the surface ids.

class ansys.fluent.core.file_session.FileFieldInfo(file_session)#

Bases: _FileFieldInfo

File field info.

Methods:

__init__(file_session)

Initialize FileFieldInfo

__init__(file_session)#

Initialize FileFieldInfo

class ansys.fluent.core.file_session.FileSession(case_file_name=None, data_file_name=None)#

Bases: object

File session to read case and data file.

Methods:

__init__([case_file_name, data_file_name])

__init__ method of FileSession class.

read_case(case_file_name)

Read Case file.

read_data(data_file_name)

Read Data file.

Attributes:

field_data

Fluent field data on surfaces.

field_info

Provides access to Fluent field information.

__init__(case_file_name=None, data_file_name=None)#

__init__ method of FileSession class.

property field_data#

Fluent field data on surfaces.

property field_info#

Provides access to Fluent field information.

read_case(case_file_name)#

Read Case file.

read_data(data_file_name)#

Read Data file.

exception ansys.fluent.core.file_session.InvalidFieldName#

Bases: ValueError

Raised when a field name is inappropriate.

Methods:

__init__()

Initialize InvalidFieldName.

__init__()#

Initialize InvalidFieldName.

exception ansys.fluent.core.file_session.InvalidMultiPhaseFieldName#

Bases: ValueError

Raised when multi-phase field name is inappropriate.

Methods:

__init__()

Initialize InvalidMultiPhaseFieldName.

__init__()#

Initialize InvalidMultiPhaseFieldName.