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:
Abstract base class for the field data service. |
|
|
Abstract base container for data requests sharing common fields and methods. |
Abstract contract for a user-facing field-data source. |
|
|
Collect field-data requests and retrieve them in one service call. |
|
Read-only response container returned by |
|
Enumeration of cell element topologies supported by the Fluent mesh. |
|
A single mesh cell containing topology and connectivity information. |
|
A face of a polyhedral mesh element, defined by its node indices. |
Abstract contract for collecting and executing field-data requests. |
|
alias of |
|
alias of |
|
Abstract contract for a field-data source that supports batching. |
|
|
Primary user-facing wrapper over an |
|
Computational mesh for a Fluent zone, containing nodes and elements. |
|
A single mesh node with its spatial coordinates. |
|
Class that enables object-style access to pathlines data structure. |
|
Container storing parameters for path-lines field data request. |
|
Container storing parameters for scalar field data request. |
|
Class that enables object-style access to surface data structures. |
|
Provides surface data types. |
|
Container storing parameters for surface data request. |
|
Container storing parameters for vector field data request. |
|
Metadata describing a mesh zone in the Fluent solver. |
|
Enumeration of zone types that classify mesh zones in the Fluent solver. |
- class ansys.fluent.core.fields.field_data.AbstractFieldData#
Bases:
ABCAbstract base class for the field data service.
Methods:
extract_fields(chunk_iterator)Extract fields from the chunk iterator.
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 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 information (surface name, ID, and type).
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.
- abstract get_scalar_fields_info()#
Get fields information (field name, domain, and section).
- Returns:
Dict
- 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:
objectAbstract base container for data requests sharing common fields and methods.
Attributes:
- class ansys.fluent.core.fields.field_data.BaseFieldDataSource#
Bases:
ABCAbstract 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
AbstractFieldDataimplementation has been connected.LiveFieldDatais 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]:AdictionarywherekeysrepresentsurfaceIDsornames,andvaluescontainthecorrespondingfielddata.
- 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:
FieldBatchCollect field-data requests and retrieve them in one service call.
Create this object with
LiveFieldData.new_batch(). It delegates the transport operation to theAbstractFieldDataimplementation owned by the parentLiveFieldData, then returns aBatchFieldDatafromget_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.
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_data
object 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.
- field_data
- 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
selfto support method chaining.- Parameters:
- obj
SurfaceFieldDataRequest|ScalarFieldDataRequest|VectorFieldDataRequest|PathlinesFieldDataRequest The first (required) field data request.
- *args
SurfaceFieldDataRequest|ScalarFieldDataRequest|VectorFieldDataRequest|PathlinesFieldDataRequest Additional optional field data requests.
- obj
- Returns:
BatchReturns
selfto allow method chaining withget_response().
- Raises:
ValueErrorIf 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 aBatchFieldDataobject; use itsget_field_data()method to access individual field arrays by surface.- Returns:
FieldDataSourceAbstract 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.
- class ansys.fluent.core.fields.field_data.BatchFieldData(data, field_info, allowed_surface_names, allowed_scalar_field_names)#
Bases:
BaseFieldDataRead-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:
- data
dict 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.
- data
- class ansys.fluent.core.fields.field_data.CellElementType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
EnumEnumeration 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:
objectA 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 ofFacetobjects infacets.- Attributes:
- _id
int Integer element ID assigned by the Fluent solver.
- element_type
CellElementType Shape of the element; see
CellElementType.- node_indices
list[int] Zero-based indices into
Mesh.nodesfor standard elements. Empty for polyhedral elements.- facets
list[Facet] Faces of the element for
CellElementType.POLYHEDRONelements. Empty for standard elements.
- _id
Attributes:
-
element_type:
CellElementType#
- class ansys.fluent.core.fields.field_data.Facet(node_indices)#
Bases:
objectA face of a polyhedral mesh element, defined by its node indices.
Used only for
CellElementType.POLYHEDRONelements; standard element types store connectivity directly onElementvianode_indices.- Attributes:
- node_indices
list[int] Zero-based indices into the
Mesh.nodesarray for the nodes that form this facet.
- node_indices
Attributes:
- class ansys.fluent.core.fields.field_data.FieldBatch#
Bases:
ABCAbstract 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.Batchis the standard implementation andBatchFieldDatais its response container.Methods:
add_requests(obj, *args)Add field data requests for surfaces, scalars, vectors, or pathlines.
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
- class ansys.fluent.core.fields.field_data.FieldDataSource#
Bases:
BaseFieldDataSource,ABCAbstract contract for a field-data source that supports batching.
This extends
BaseFieldDataSourcewith the factory method needed to create aFieldBatch. The concrete source uses that batch to collect requests and return a batched response.LiveFieldDatafulfills this contract and returns aBatchfromnew_batch().Methods:
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,FieldDataSourcePrimary user-facing wrapper over an
AbstractFieldDataservice.The
field_dataargument is the transport-specific service adapter. It implementsAbstractFieldDataand 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 aBatchfor multiple requests. The batch returns aBatchFieldDataresponse whileBaseFieldDatasupplies 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").
- surfaces
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.
Create a new
Batchfor queuing multiple field data requests.- __init__(field_data, field_info, scheme_interpreter, get_zones_info=None)#
Initialize a LiveFieldData instance.
- Parameters:
- field_data
object Low-level field data service proxy connected to a running Fluent session.
- field_info
object Low-level field info service proxy for querying available fields and surfaces.
- scheme_interpreter
object Interface to the Fluent Scheme interpreter, used for evaluating expressions such as precision queries.
- get_zones_info
weakref.WeakMethod,optional Weak reference to a callable that returns a list of
ZoneInfoobjects. Required for mesh retrieval viaget_mesh().
- field_data
- 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
Meshobject. Only cell zones are currently supported; face zones raiseNotImplementedError.- Parameters:
- Returns:
- Raises:
ValueErrorIf zone does not match any known zone name or ID.
NotImplementedErrorIf 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
Batchfor 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().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:
objectComputational mesh for a Fluent zone, containing nodes and elements.
Returned by
LiveFieldData.get_mesh(). Thenodesarray provides spatial coordinates indexed from 0, and theelementsarray stores connectivity referencing those node indices.- Attributes:
Attributes:
- class ansys.fluent.core.fields.field_data.Node(_id, x, y, z)#
Bases:
objectA single mesh node with its spatial coordinates.
- Attributes:
Attributes:
- class ansys.fluent.core.fields.field_data.PathlinesData(pathlines_data_for_surface)#
Bases:
objectClass 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:
BaseDataRequestContainer 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:
BaseDataRequestContainer 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:
objectClass 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:
EnumProvides 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:
BaseDataRequestContainer storing parameters for surface data request.
Attributes:
-
data_types:
list[SurfaceDataType] |list[str]#
-
data_types:
- class ansys.fluent.core.fields.field_data.VectorFieldDataRequest(surfaces, field_name)#
Bases:
BaseDataRequestContainer 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:
objectMetadata describing a mesh zone in the Fluent solver.
- Attributes:
Attributes:
- class ansys.fluent.core.fields.field_data.ZoneType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
EnumEnumeration of zone types that classify mesh zones in the Fluent solver.
Attributes:
- CELL = 1#
- FACE = 2#