field_data#

Public APIs for retrieving Fluent field data and mesh data.

Use FieldData with request models such as ScalarFieldDataRequest. Response and mesh models are also available here for inspection and type annotations.

Classes:

AbstractFieldData()

Abstract base class for the field data service.

BaseDataRequest(surfaces)

Abstract base container for data requests sharing common fields and methods.

BaseFieldDataSource()

Abstract contract for a user-facing field-data source.

Batch(field_data, field_info, ...)

Collect field-data requests and retrieve them in one service call.

BatchFieldData(data, field_info, ...)

Read-only response container returned by Batch.

CellElementType(value[, names, module, ...])

Enumeration of cell element topologies supported by the Fluent mesh.

Element(_id, element_type[, node_indices, ...])

A single mesh cell containing topology and connectivity information.

Facet(node_indices)

A face of a polyhedral mesh element, defined by its node indices.

FieldBatch()

Abstract contract for collecting and executing field-data requests.

FieldData

alias of LiveFieldData

FieldDataBatch

alias of Batch

FieldDataSource()

Abstract contract for a field-data source that supports batching.

LiveFieldData(field_data, field_info, ...[, ...])

Primary user-facing wrapper over an AbstractFieldData service.

Mesh(nodes, elements)

Computational mesh for a Fluent zone, containing nodes and elements.

Node(_id, x, y, z)

A single mesh node with its spatial coordinates.

PathlinesData(pathlines_data_for_surface)

Class that enables object-style access to pathlines data structure.

PathlinesFieldDataRequest(surfaces, field_name)

Container storing parameters for path-lines field data request.

ScalarFieldDataRequest(surfaces, field_name)

Container storing parameters for scalar field data request.

SurfaceData(surf_data)

Class that enables object-style access to surface data structures.

SurfaceDataType(value[, names, module, ...])

Provides surface data types.

SurfaceFieldDataRequest(surfaces, data_types)

Container storing parameters for surface data request.

VectorFieldDataRequest(surfaces, field_name)

Container storing parameters for vector field data request.

ZoneInfo(_id, name, zone_type)

Metadata describing a mesh zone in the Fluent solver.

ZoneType(value[, names, module, qualname, ...])

Enumeration of zone types that classify mesh zones in the Fluent solver.

class ansys.fluent.core.fields.field_data.AbstractFieldData#

Bases: ABC

Abstract base class for the field data service.

Methods:

extract_fields(chunk_iterator)

Extract fields from the chunk iterator.

get_batched_fields()

Get the batched fields from the service.

get_scalar_field_range(field[, node_value, ...])

Get the range (minimum and maximum values) of the field.

get_scalar_fields_info()

Get fields information (field name, domain, and section).

get_solver_mesh_elements(domain_id, thread_id)

Get mesh elements.

get_solver_mesh_nodes_double(domain_id, ...)

Get mesh node -> double precision.

get_solver_mesh_nodes_float(domain_id, thread_id)

Get mesh node -> floating point precision.

get_surfaces_info()

Get surfaces information (surface name, ID, and type).

get_vector_fields_info()

Get vector fields information (vector components).

abstract extract_fields(chunk_iterator)#

Extract fields from the chunk iterator.

abstract get_batched_fields()#

Get the batched fields from the service.

abstract get_scalar_field_range(field, node_value=False, surface_ids=None)#

Get the range (minimum and maximum values) of the field.

Parameters:
field: str

Field name

node_value: bool
surface_idsList[int], optional

List of surface IDS for the surface data.

Returns:
List[float]
abstract get_scalar_fields_info()#

Get fields information (field name, domain, and section).

Returns:
Dict
abstract get_solver_mesh_elements(domain_id, thread_id)#

Get mesh elements.

Returns:
List[float]
abstract get_solver_mesh_nodes_double(domain_id, thread_id)#

Get mesh node -> double precision.

Returns:
List[float]
abstract get_solver_mesh_nodes_float(domain_id, thread_id)#

Get mesh node -> floating point precision.

Returns:
List[float]
abstract get_surfaces_info()#

Get surfaces information (surface name, ID, and type).

Returns:
Dict
abstract get_vector_fields_info()#

Get vector fields information (vector components).

Returns:
Dict
class ansys.fluent.core.fields.field_data.BaseDataRequest(surfaces)#

Bases: object

Abstract base container for data requests sharing common fields and methods.

Attributes:

surfaces: list[int | str | object]#
class ansys.fluent.core.fields.field_data.BaseFieldDataSource#

Bases: ABC

Abstract contract for a user-facing field-data source.

This contract belongs to the wrapper layer, not to a transport service. It describes how callers resolve surfaces and retrieve data after a transport specific AbstractFieldData implementation has been connected.

LiveFieldData is the standard implementation.

Methods:

get_field_data(obj)

Retrieve the field data for a given request.

get_surface_ids(surfaces)

Retrieve a list of surface IDs based on input surface names or numerical identifiers.

abstract get_field_data(obj)#

Retrieve the field data for a given request.

This method processes the specified request and returns the corresponding field data in a structured format.

Returns:
Dict[int | str, SurfaceData | PathlinesData | np.ndarray]: A dictionary where keys represent surface
IDs or names, and values contain the corresponding field data.
abstract get_surface_ids(surfaces)#

Retrieve a list of surface IDs based on input surface names or numerical identifiers.

class ansys.fluent.core.fields.field_data.Batch(field_data, field_info, allowed_surface_ids, allowed_surface_names, allowed_scalar_field_names, allowed_vector_field_names)#

Bases: FieldBatch

Collect field-data requests and retrieve them in one service call.

Create this object with LiveFieldData.new_batch(). It delegates the transport operation to the AbstractFieldData implementation owned by the parent LiveFieldData, then returns a BatchFieldData from get_response().

Examples

>>> batch = field_data.new_batch()
>>> batch.add_requests(
...     ScalarFieldDataRequest(field_name="pressure", surfaces=["wall"]),
...     VectorFieldDataRequest(field_name="velocity", surfaces=["wall"]),
... )
>>> result = batch.get_response()

Methods:

__init__(field_data, field_info, ...)

Initialize a Batch instance.

add_requests(obj, *args)

Add one or more field data requests to the batch queue.

get_response()

Send all queued requests to Fluent and return the retrieved field data.

get_surface_ids(surfaces)

Resolve surface names or IDs to a list of integer surface IDs.

__init__(field_data, field_info, allowed_surface_ids, allowed_surface_names, allowed_scalar_field_names, allowed_vector_field_names)#

Initialize a Batch instance.

Parameters:
field_dataobject

Low-level field data service proxy connected to a running Fluent session.

field_info_FieldInfo

Object used to query metadata about available fields and surfaces.

allowed_surface_ids_AllowedSurfaceIDs

Validator for surface ID inputs.

allowed_surface_names_AllowedSurfaceNames

Validator for surface name inputs.

allowed_scalar_field_names_AllowedScalarFieldNames

Validator for scalar field name inputs.

allowed_vector_field_names_AllowedVectorFieldNames

Validator for vector field name inputs.

add_requests(obj, *args)#

Add one or more field data requests to the batch queue.

Accepts requests for surface geometry, scalar fields, vector fields, or pathlines. All requested surfaces are resolved to integer IDs. Duplicate requests are ignored with a warning. This method returns self to support method chaining.

Parameters:
objSurfaceFieldDataRequest | ScalarFieldDataRequest | VectorFieldDataRequest | PathlinesFieldDataRequest

The first (required) field data request.

*argsSurfaceFieldDataRequest | ScalarFieldDataRequest | VectorFieldDataRequest | PathlinesFieldDataRequest

Additional optional field data requests.

Returns:
Batch

Returns self to allow method chaining with get_response().

Raises:
ValueError

If two pathlines requests share the same field_name.

Examples

>>> result = (
...     field_data.new_batch()
...     .add_requests(
...         ScalarFieldDataRequest(field_name="pressure", surfaces=["wall"]),
...         VectorFieldDataRequest(field_name="velocity", surfaces=["wall"]),
...     )
...     .get_response()
... )
get_response()#

Send all queued requests to Fluent and return the retrieved field data.

Executes all requests added via add_requests() in a single server call. Returns a BatchFieldData object; use its get_field_data() method to access individual field arrays by surface.

Returns:
FieldDataSource

Abstract field-data source contract implemented by the returned response container.

Examples

>>> batch = field_data.new_batch()
>>> batch.add_requests(
...     ScalarFieldDataRequest(field_name="pressure", surfaces=["wall"])
... )
>>> result = batch.get_response()
>>> pressure = result.get_field_data(
...     ScalarFieldDataRequest(field_name="pressure", surfaces=["wall"])
... )
get_surface_ids(surfaces)#

Resolve surface names or IDs to a list of integer surface IDs.

Parameters:
surfaceslist[str | int]

Surface names (str) or surface IDs (int) to resolve.

Returns:
list[int]

Corresponding list of integer surface IDs recognized by Fluent.

Raises:
DisallowedValuesError

If a surface name or ID is not found among the allowed surfaces.

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

Bases: BaseFieldData

Read-only response container returned by Batch.

The batch transport response is stored here and exposed through the shared BaseFieldData.get_field_data() implementation. This class adds only response-container behavior; it does not issue service calls.

Examples

>>> batch = field_data.new_batch()
>>> batch.add_requests(
...     ScalarFieldDataRequest(field_name="pressure", surfaces=["wall"])
... )
>>> result: FieldDataSource = batch.get_response()
>>> pressure = result.get_field_data(
...     ScalarFieldDataRequest(field_name="pressure", surfaces=["wall"])
... )

Methods:

__init__(data, field_info, ...)

Initialize a BatchFieldData container.

__init__(data, field_info, allowed_surface_names, allowed_scalar_field_names)#

Initialize a BatchFieldData container.

Parameters:
datadict

Extracted field data keyed by request descriptor tuples.

field_info_FieldInfo

Object used to query metadata about available fields and surfaces.

allowed_surface_names_AllowedSurfaceNames

Validator for surface name inputs.

allowed_scalar_field_names_AllowedScalarFieldNames

Validator for scalar field name inputs.

class ansys.fluent.core.fields.field_data.CellElementType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

Enumeration of cell element topologies supported by the Fluent mesh.

Each member corresponds to a standard finite-volume cell shape. The number of nodes and faces for each type is noted in the member comments.

Attributes:

GHOST = 8#
HEXAHEDRON = 4#
POLYHEDRON = 7#
PYRAMID = 5#
QUADRATIC_HEXAHEDRON = 10#
QUADRATIC_PYRAMID = 11#
QUADRATIC_TETRAHEDRON = 9#
QUADRATIC_WEDGE = 12#
QUADRILATERAL = 3#
TETRAHEDRON = 2#
TRIANGLE = 1#
WEDGE = 6#
class ansys.fluent.core.fields.field_data.Element(_id, element_type, node_indices=<factory>, facets=<factory>)#

Bases: object

A single mesh cell containing topology and connectivity information.

For standard element types (e.g. hexahedron, tetrahedron), connectivity is stored in node_indices. For polyhedral elements, connectivity is stored as a list of Facet objects in facets.

Attributes:
_idint

Integer element ID assigned by the Fluent solver.

element_typeCellElementType

Shape of the element; see CellElementType.

node_indiceslist[int]

Zero-based indices into Mesh.nodes for standard elements. Empty for polyhedral elements.

facetslist[Facet]

Faces of the element for CellElementType.POLYHEDRON elements. Empty for standard elements.

Attributes:

element_type: CellElementType#
facets: list[Facet]#
node_indices: list[int]#
class ansys.fluent.core.fields.field_data.Facet(node_indices)#

Bases: object

A face of a polyhedral mesh element, defined by its node indices.

Used only for CellElementType.POLYHEDRON elements; standard element types store connectivity directly on Element via node_indices.

Attributes:
node_indiceslist[int]

Zero-based indices into the Mesh.nodes array for the nodes that form this facet.

Attributes:

node_indices: list[int]#
class ansys.fluent.core.fields.field_data.FieldBatch#

Bases: ABC

Abstract contract for collecting and executing field-data requests.

A batch belongs to a FieldDataSource. It accepts request models, sends them through the source’s transport adapter, and returns a field-data source containing the response.

Batch is the standard implementation and BatchFieldData is its response container.

Methods:

add_requests(obj, *args)

Add field data requests for surfaces, scalars, vectors, or pathlines.

get_response()

Retrieve the response containing data for previously added field requests.

get_surface_ids(surfaces)

Retrieve a list of surface IDs based on input surface names or numerical identifiers.

abstract add_requests(obj, *args)#

Add field data requests for surfaces, scalars, vectors, or pathlines.

This method allows users to specify multiple field data requests, which will later be processed when retrieving responses.

abstract get_response()#

Retrieve the response containing data for previously added field requests.

This method processes all pending requests and returns the corresponding field data.

abstract get_surface_ids(surfaces)#

Retrieve a list of surface IDs based on input surface names or numerical identifiers.

ansys.fluent.core.fields.field_data.FieldData#

alias of LiveFieldData

ansys.fluent.core.fields.field_data.FieldDataBatch#

alias of Batch

class ansys.fluent.core.fields.field_data.FieldDataSource#

Bases: BaseFieldDataSource, ABC

Abstract contract for a field-data source that supports batching.

This extends BaseFieldDataSource with the factory method needed to create a FieldBatch. The concrete source uses that batch to collect requests and return a batched response.

LiveFieldData fulfills this contract and returns a Batch from new_batch().

Methods:

new_batch()

Create a new field batch.

abstract new_batch()#

Create a new field batch.

class ansys.fluent.core.fields.field_data.LiveFieldData(field_data, field_info, scheme_interpreter, get_zones_info=None)#

Bases: BaseFieldData, FieldDataSource

Primary user-facing wrapper over an AbstractFieldData service.

The field_data argument is the transport-specific service adapter. It implements AbstractFieldData and can be backed by any kind of service, such as gRPC or REST. This wrapper adds validation, surface resolution, field metadata helpers, and conversion of transport results into user-facing objects.

Use new_batch() to create a Batch for multiple requests. The batch returns a BatchFieldData response while BaseFieldData supplies the shared response extraction logic.

Attributes:
surfaces_SurfaceNames

Lists all surface names available in the current Fluent session.

surface_ids_SurfaceIds

Lists all surface IDs available in the current Fluent session.

scalar_fields_ScalarFields

Lists available scalar field names (e.g., "pressure", "temperature").

vector_fields_VectorFields

Lists available vector field names (e.g., "velocity").

Examples

>>> field_data = solver.fields.field_data
>>> pressure = field_data.get_field_data(
...     ScalarFieldDataRequest(field_name="pressure", surfaces=["wall"])
... )

Methods:

__init__(field_data, field_info, ...[, ...])

Initialize a LiveFieldData instance.

get_mesh(zone)

Retrieve the computational mesh for a Fluent cell zone.

new_batch()

Create a new Batch for queuing multiple field data requests.

__init__(field_data, field_info, scheme_interpreter, get_zones_info=None)#

Initialize a LiveFieldData instance.

Parameters:
field_dataobject

Low-level field data service proxy connected to a running Fluent session.

field_infoobject

Low-level field info service proxy for querying available fields and surfaces.

scheme_interpreterobject

Interface to the Fluent Scheme interpreter, used for evaluating expressions such as precision queries.

get_zones_infoweakref.WeakMethod, optional

Weak reference to a callable that returns a list of ZoneInfo objects. Required for mesh retrieval via get_mesh().

get_mesh(zone)#

Retrieve the computational mesh for a Fluent cell zone.

Fetches node coordinates and element connectivity from the Fluent solver for the specified zone and returns them as a Mesh object. Only cell zones are currently supported; face zones raise NotImplementedError.

Parameters:
zonestr | int

Name or integer ID of the zone to retrieve. Must be a cell zone.

Returns:
Mesh

Mesh containing all Node coordinates and Element connectivity for the zone.

Raises:
ValueError

If zone does not match any known zone name or ID.

NotImplementedError

If zone refers to a face zone.

Examples

>>> mesh = field_data.get_mesh("fluid")
>>> print(f"Nodes: {len(mesh.nodes)}, Elements: {len(mesh.elements)}")
new_batch()#

Create a new Batch for queuing multiple field data requests.

Use a batch to accumulate several field data requests (scalar, vector, surface geometry, or pathlines) and retrieve them all from Fluent in a single efficient server call via Batch.get_response().

Returns:
Batch

A new Batch instance bound to this session.

Examples

>>> batch = field_data.new_batch()
>>> batch.add_requests(
...     ScalarFieldDataRequest(field_name="pressure", surfaces=["wall"]),
...     VectorFieldDataRequest(field_name="velocity", surfaces=["wall"]),
... )
>>> result = batch.get_response()
class ansys.fluent.core.fields.field_data.Mesh(nodes, elements)#

Bases: object

Computational mesh for a Fluent zone, containing nodes and elements.

Returned by LiveFieldData.get_mesh(). The nodes array provides spatial coordinates indexed from 0, and the elements array stores connectivity referencing those node indices.

Attributes:
nodeslist[Node]

Ordered list of Node objects; element connectivity uses zero-based indices into this list.

elementslist[Element]

List of Element objects describing cell topology and connectivity.

Attributes:

elements: list[Element]#
nodes: list[Node]#
class ansys.fluent.core.fields.field_data.Node(_id, x, y, z)#

Bases: object

A single mesh node with its spatial coordinates.

Attributes:
_idint

Integer node ID assigned by the Fluent solver.

xfloat

X-coordinate of the node in the solver’s length unit.

yfloat

Y-coordinate of the node in the solver’s length unit.

zfloat

Z-coordinate of the node in the solver’s length unit.

Attributes:

x

y

z

x: float#
y: float#
z: float#
class ansys.fluent.core.fields.field_data.PathlinesData(pathlines_data_for_surface)#

Bases: object

Class that enables object-style access to pathlines data structure.

Attributes:
scalar_field_name: str
vertices: npt.NDArray[np.float64] | None
lines: list[npt.NDArray[np.float64]] | None
scalar_field: npt.NDArray[np.float64] | None
pathlines_count: npt.NDArray[np.float64] | None
particle_time: npt.NDArray[np.float64] | None

Methods:

__init__(pathlines_data_for_surface)

__init__ method of PathlinesData class.

__init__(pathlines_data_for_surface)#

__init__ method of PathlinesData class.

class ansys.fluent.core.fields.field_data.PathlinesFieldDataRequest(surfaces, field_name, additional_field_name='', provide_particle_time_field=False, node_value=True, steps=500, step_size=500, skip=0, reverse=False, accuracy_control_on=False, tolerance=0.001, coarsen=1, velocity_domain='all-phases', zones=None, flatten_connectivity=False)#

Bases: BaseDataRequest

Container storing parameters for path-lines field data request.

Attributes:

accuracy_control_on: bool | None = False#
additional_field_name: str = ''#
coarsen: int | None = 1#
field_name: str | 'ScalarVariableDescriptor#
flatten_connectivity: bool = False#
node_value: bool | None = True#
provide_particle_time_field: bool | None = False#
reverse: bool | None = False#
skip: int | None = 0#
step_size: float | None = 500#
steps: int | None = 500#
surfaces: list[int | str | object]#
tolerance: float | None = 0.001#
velocity_domain: str | None = 'all-phases'#
zones: list | None = None#
class ansys.fluent.core.fields.field_data.ScalarFieldDataRequest(surfaces, field_name, node_value=True, boundary_value=True)#

Bases: BaseDataRequest

Container storing parameters for scalar field data request.

Attributes:

boundary_value: bool | None = True#
field_name: str | 'ScalarVariableDescriptor#
node_value: bool | None = True#
surfaces: list[int | str | object]#
class ansys.fluent.core.fields.field_data.SurfaceData(surf_data)#

Bases: object

Class that enables object-style access to surface data structures.

Attributes:
vertices: npt.NDArray[np.float64] | None
connectivity: list[npt.NDArray[np.float64]] | None
face_centroids: npt.NDArray[np.float64] | None
face_normals: npt.NDArray[np.float64] | None

Methods:

__init__(surf_data)

__init__ method of SurfaceData class.

__init__(surf_data)#

__init__ method of SurfaceData class.

class ansys.fluent.core.fields.field_data.SurfaceDataType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

Provides surface data types.

Attributes:

FacesCentroid = 'centroid'#
FacesConnectivity = 'faces'#
FacesNormal = 'face-normal'#
Vertices = 'vertices'#
class ansys.fluent.core.fields.field_data.SurfaceFieldDataRequest(surfaces, data_types, overset_mesh=False, flatten_connectivity=False)#

Bases: BaseDataRequest

Container storing parameters for surface data request.

Attributes:

data_types: list[SurfaceDataType] | list[str]#
flatten_connectivity: bool = False#
overset_mesh: bool | None = False#
surfaces: list[int | str | object]#
class ansys.fluent.core.fields.field_data.VectorFieldDataRequest(surfaces, field_name)#

Bases: BaseDataRequest

Container storing parameters for vector field data request.

Attributes:

field_name: str | 'VectorVariableDescriptor#
surfaces: list[int | str | object]#
class ansys.fluent.core.fields.field_data.ZoneInfo(_id, name, zone_type)#

Bases: object

Metadata describing a mesh zone in the Fluent solver.

Attributes:
_idint

Integer zone ID assigned by the Fluent solver.

namestr

Name of the zone as defined in the Fluent case.

zone_typeZoneType

Whether the zone is a cell zone or a face zone.

Attributes:

name: str#
zone_type: ZoneType#
class ansys.fluent.core.fields.field_data.ZoneType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

Enumeration of zone types that classify mesh zones in the Fluent solver.

Attributes:

CELL = 1#
FACE = 2#