Skip to content

fix: Unavaialble field data for some surfaces. #4345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/4345.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Unavaialble field data for some surfaces.
30 changes: 28 additions & 2 deletions src/ansys/fluent/core/file_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,20 @@ def get_field_data(
| PathlinesFieldDataRequest
),
) -> Dict[int | str, Dict | np.array]:
"""Get the surface, scalar, vector or path-lines field data on a surface."""
"""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
"""
if isinstance(obj, SurfaceFieldDataRequest):
return self._get_surface_data(**obj._asdict())
elif isinstance(obj, ScalarFieldDataRequest):
Expand Down Expand Up @@ -973,7 +986,20 @@ def get_field_data(
| PathlinesFieldDataRequest
),
) -> Dict[int | str, Dict | np.array]:
"""Get the surface, scalar, vector or path-lines field data on a surface."""
"""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
"""
if isinstance(obj, SurfaceFieldDataRequest):
return self._get_surface_data(**obj._asdict())
elif isinstance(obj, ScalarFieldDataRequest):
Expand Down
35 changes: 27 additions & 8 deletions src/ansys/fluent/core/services/field_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,20 @@ def get_field_data(
| PathlinesFieldDataRequest
),
) -> Dict[int | str, Dict | np.array]:
"""Get the surface, scalar, vector or path-lines field data on a surface."""
"""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
"""
if isinstance(obj, SurfaceFieldDataRequest):
return self._get_surface_data(**obj._asdict())
elif isinstance(obj, ScalarFieldDataRequest):
Expand Down Expand Up @@ -1185,13 +1198,19 @@ def _extract_field(field_datatype, field_size, chunk_iterator):
payload_tag_id = None
field = None
if payload_tag_id is not None:
field = _extract_field(
_FieldDataConstants.proto_field_type_to_np_data_type[
payload_info.fieldType
],
payload_info.fieldSize,
chunk_iterator,
)
if payload_info.fieldSize > 0:
field = _extract_field(
_FieldDataConstants.proto_field_type_to_np_data_type[
payload_info.fieldType
],
payload_info.fieldSize,
chunk_iterator,
)
else:
warnings.warn(
f"Field data is not available for surface: {surface_id}"
)
field = np.array([])

if self._callbacks_provider is not None:
for callback_data in self._callbacks_provider.callbacks():
Expand Down